-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
@tristen can you let me know if these query params ( |
Ahh thanks for the clarification on |
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😛
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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
@mollymerp one last thing too: The path should change from |
@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'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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())}`; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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}#/${ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
@tristen Added access_token param! |
Ported to iOS and macOS in mapbox/mapbox-gl-native#9078. |
@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? |
@tristen added it. with the most recent change the new feedback page and mapbox gl hashes should remain consistent. let me know if this is 👌 |
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}` : ''; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Line 50 in 78fc9c4
set: function(token) { config.ACCESS_TOKEN = token; } |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😊
We good to pull the trigger on this @tristen @anandthakker ? |
@mollymerp Looks good to merge from my end! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR does two things:
mapboxgl
prefix for thequeryselector
class that modifies the edit link it stopped getting updated, and the test didn't catch it bc we provide the TileJSON html inside the test.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