Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix update edit link, add query parameters for map feedback #4685

Merged
merged 10 commits into from
May 31, 2017

Conversation

mollymerp
Copy link
Contributor

This PR does two things:

an alternative to this approach would be editing the tilejson in place to abide by our mapboxgl- prefix requirement.

closes #3558

cc @tristen

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@mollymerp
Copy link
Contributor Author

@tristen can you let me know if these query params (owner and id) are what you're looking for?
Scott confirmed that just the style id is not adequate to find the style associated bc ids are not globally unique, but owner+id pairs are.

@tristen
Copy link
Member

tristen commented May 6, 2017

Ahh thanks for the clarification on owner. What you are capturing looks great to me! 🎉

map.on('data', (e) => {
if (e.dataType === 'source' && e.sourceDataType === 'metadata') {
t.equal(attribution._editLink.href, 'https://www.mapbox.com/map-feedback/#/0/0/1', 'edit link contains map location data');
t.equal(attribution._editLink.href, 'https://www.mapbox.com/map-feedback/#/0/0/0?owner=mapbox&id=streets-v10', 'edit link contains map location data');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just omit these params if owner or id isn't set rather than passing defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these aren't defaults – I set them up at L17-18 😛

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg I'm reading through the test 😭 😭 😭 😭

map.setZoom(2);
t.equal(attribution._editLink.href, 'https://www.mapbox.com/map-feedback/#/0/0/3', 'edit link updates on mapmove');
t.equal(attribution._editLink.href, 'https://www.mapbox.com/map-feedback/#/0/0/2?owner=mapbox&id=streets-v10', 'edit link updates on mapmove');
Copy link
Member

@tristen tristen May 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that needs to change! hash should follow params. Structure should look like this:

https://www.mapbox.com/feedback/?owner=mapbox&id=streets-v10#/0/0/2

@tristen
Copy link
Member

tristen commented May 9, 2017

@mollymerp one last thing too: The path should change from map-feedback to feedback.

@mollymerp
Copy link
Contributor Author

@tristen I made the changes you requested. let us know when you need the release published by.

@@ -66,11 +66,12 @@ class AttributionControl {
}

_updateEditLink() {
if (!this._editLink) this._editLink = this._container.querySelector('.mapboxgl-improve-map');
if (!this._editLink) this._editLink = this._container.querySelector('.mapbox-improve-map');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I'm understanding this right, the change from .mapboxgl-improve-map to .mapbox-improve-map is in order to match against the CSS class used in our the TileJSON provided by Mapbox's vector tile sources?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct @anandthakker - I will ticket out changing that css class at the API level separately

center.lng}/${center.lat}/${Math.round(this._map.getZoom() + 1)}`;
const styleParams = (this.styleOwner && this.styleId) ? `?owner=${this.styleOwner}&id=${this.styleId}` : '';
this._editLink.href = `https://www.mapbox.com/feedback/${styleParams}#/${
Math.round(center.lng * 1000) / 1000}/${Math.round(center.lat * 1000) / 1000}/${Math.round(this._map.getZoom())}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we dropping the +1 from this._map.getZoom() + 1? Was it incorrect in the first place?

Copy link
Contributor Author

@mollymerp mollymerp May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anandthakker GL and raster zoom levels are off by one 😊. the old map-feedback link used Mapbox.js and therefore we had to add a zoom level to the hash for the link to open at the right spot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still necessary to round the zoom level?

this._editLink.href = `https://www.mapbox.com/map-feedback/#/${
center.lng}/${center.lat}/${Math.round(this._map.getZoom() + 1)}`;
const styleParams = (this.styleOwner && this.styleId) ? `?owner=${this.styleOwner}&id=${this.styleId}` : '';
this._editLink.href = `https://www.mapbox.com/feedback/${styleParams}#/${
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this map is using a custom style designed in Studio (as opposed to a default style), should the feedback tool display that style in its map? If so, we'll also need to pass in an access token or somehow make it so that the feedback tool can access any style.

/cc @tristen

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1ec5 yikes I think you brought up something pretty critical here. I assumed a token could be generated with the scope to include any custom style but that doesn't appear to be the case. It looks like an access token would need to be additionally passed for this to work.

@mollymerp client is encoded in the token so it might make sense to drop that parameter for token instead?

@mollymerp
Copy link
Contributor Author

@tristen Added access_token param!

@1ec5
Copy link
Contributor

1ec5 commented May 23, 2017

Ported to iOS and macOS in mapbox/mapbox-gl-native#9078.

@tristen
Copy link
Member

tristen commented May 23, 2017

@mollymerp I don't want to hold this PR much longer but we can we also capture bearing + pitch at the end of the hash?

@mollymerp
Copy link
Contributor Author

mollymerp commented May 23, 2017

@tristen added it. note that the previous order I was using in the hash was different and also had an extra / compared to what we use as the existing map hash option in gl-js. (#/lat/lng/zoom vs #zoom/lat/lng) 😬 I imagine this was due to how the original map-feedback page was implemented. reverted per tristen's request

with the most recent change the new feedback page and mapbox gl hashes should remain consistent. let me know if this is 👌

@mollymerp
Copy link
Contributor Author

I made some decent changes here so @anandthakker if you want to take another 👀 that would probably be a good idea 😊

@@ -69,7 +70,7 @@ class AttributionControl {
if (!this._editLink) this._editLink = this._container.querySelector('.mapbox-improve-map');
if (this._editLink) {
const center = this._map.getCenter();
const styleParams = (this.styleOwner && this.styleId) ? `?owner=${this.styleOwner}&id=${this.styleId}` : '';
const styleParams = (this.styleOwner && this.styleId) ? config.ACCESS_TOKEN ? `?owner=${this.styleOwner}&id=${this.styleId}&access_token=${config.ACCESS_TOKEN}` : `?owner=${this.styleOwner}&id=${this.styleId}` : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.ACCESS_TOKEN wouldn't pick up an access token that a user set using mapboxgl.accessToken = ... right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anandthakker I think it should

set: function(token) { config.ACCESS_TOKEN = token; }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

src/ui/map.js Outdated
@@ -192,9 +192,9 @@ class Map extends Camera {

bindHandlers(this, options);

this._hash = options.hash && (new Hash()).addTo(this);
this.hash = options.hash && (new Hash()).addTo(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should keep the _ to signal that this is a private member rather than a public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh good point – for some reason I was thinking the convention was no _ if its called from w/in another module but that is not correct 😊

@mollymerp
Copy link
Contributor Author

We good to pull the trigger on this @tristen @anandthakker ?

@tristen
Copy link
Member

tristen commented May 29, 2017

@mollymerp Looks good to merge from my end!

Copy link
Contributor

@anandthakker anandthakker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Including a username in map-feedback attribution link
4 participants