-
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
Changes from 5 commits
973fe84
d18d408
ef0eb1f
ad82f4f
cbfe7b7
dc8664f
e2d0a3f
8601854
fc2afc1
192dfd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||
|
||||
const DOM = require('../../util/dom'); | ||||
const util = require('../../util/util'); | ||||
const config = require('../../util/config'); | ||||
|
||||
/** | ||||
* An `AttributionControl` control presents the map's [attribution information](https://www.mapbox.com/help/attribution/). | ||||
|
@@ -66,11 +67,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'); | ||||
if (this._editLink) { | ||||
const center = this._map.getCenter(); | ||||
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) ? 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. @anandthakker I think it should Line 50 in 78fc9c4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙈 |
||||
this._editLink.href = `https://www.mapbox.com/feedback/${styleParams}#/${ | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||||
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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Is it still necessary to round the zoom level? |
||||
} | ||||
} | ||||
|
||||
|
@@ -85,6 +87,12 @@ class AttributionControl { | |||
if (!this._map.style) return; | ||||
let attributions = []; | ||||
|
||||
if (this._map.style.stylesheet) { | ||||
const stylesheet = this._map.style.stylesheet; | ||||
this.styleOwner = stylesheet.owner; | ||||
this.styleId = stylesheet.id; | ||||
} | ||||
|
||||
const sourceCaches = this._map.style.sourceCaches; | ||||
for (const id in sourceCaches) { | ||||
const source = sourceCaches[id].getSource(); | ||||
|
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