-
Notifications
You must be signed in to change notification settings - Fork 385
update default tile/style endpoints for mapbox styles #1317
Conversation
c50a68c
to
a82b112
Compare
map.js tests appear to have been broken since a40d000
👋 @mapbox/gl-js @mapbox/static-apis this branch changes some pretty core functionality, so would appreciate a close review from one or both of you. |
👋 @asheemmamoowala @mourner any chance you'll be able to review this before the end of the week? |
@riastrad yes, will do! |
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.
👍 looks great to me apart from a few nits.
src/tile_layer.js
Outdated
return templated; | ||
var tileURL; | ||
if (L.Browser.retina && url.indexOf('/styles/v1') !== -1) { | ||
tileURL = [templated.slice(0, templated.indexOf('?')), '@2x', templated.slice(templated.indexOf('?'))].join(''); |
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.
Nit: this could probably be written in a simpler way, maybe templated.replace('?', '@2x?')
?
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.
Wow, yep - would make this much more readable. Switched to .replace
in bd3b7bc
if (typeof console === 'object' && | ||
typeof console.warn === 'function') { | ||
console.warn(_); | ||
} |
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.
The context this is being used may cause hundreds of duplicate warnings to be printed — maybe worth adopting something like warnOnce
from GL JS?
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.
Great point, implemented in 5a25f62
Resolves #1316
Up until now, Mapbox.js defaults have relied heavily on the Mapbox Legacy Static Tiles endpoints.
I'll mark this PR as ready for review when the following are implemented:
mapID
will automatically load the equivalent style from the modern Static Tiles API.riastrad.{class style id}
) is passed tomap
objects andtileLayer
objects.Logs a console warning about dropping support for the outdatedGiven that the url pattern for legacy & modern APIs is different, this appears to be unnecessary.tileLayer.setFormat()
method with defaultmapIDs
.If I identify any other usage of legacy APIs within the defaults, I will flag it and incorporate it within this PR before the review.
cc @mapbox/static-apis