-
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 1 commit
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 |
---|---|---|
|
@@ -66,11 +66,14 @@ 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)}`; | ||
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? |
||
if (this.styleOwner && this.styleId) { | ||
this._editLink.href += `?owner=${this.styleOwner}&id=${this.styleId}`; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -85,6 +88,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(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ function createMap() { | |
style: { | ||
version: 8, | ||
sources: {}, | ||
layers: [] | ||
layers: [], | ||
owner: 'mapbox', | ||
id: 'streets-v10' | ||
} | ||
}); | ||
} | ||
|
@@ -105,12 +107,12 @@ test('AttributionControl has the correct edit map link', (t) => { | |
map.addControl(attribution); | ||
|
||
map.on('load', () => { | ||
map.addSource('1', {type: 'vector', attribution: '<a class="mapboxgl-improve-map" href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>'}); | ||
map.addSource('1', {type: 'vector', attribution: '<a class="mapbox-improve-map" href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>'}); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I think we can just omit these params if 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. these aren't defaults – I set them up at L17-18 😛 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. 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 commentThe 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:
|
||
t.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.
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