Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

update default tile/style endpoints for mapbox styles #1317

Merged
merged 16 commits into from
Mar 10, 2020

Conversation

riastrad
Copy link

@riastrad riastrad commented Jan 29, 2020

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:

  • Updates initialization code so that passing in a template mapID will automatically load the equivalent style from the modern Static Tiles API.
  • Set console warning when automatic support for classic style IDs (e.g. riastrad.{class style id}) is passed to map objects and tileLayer objects.
  • Logs a console warning about dropping support for the outdated tileLayer.setFormat() method with default mapIDs. Given that the url pattern for legacy & modern APIs is different, this appears to be unnecessary.
  • All previous tests are updated and passing
  • new tests for changes to default behavior

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

@riastrad riastrad added this to the v4.0.0 milestone Jan 29, 2020
@riastrad riastrad self-assigned this Jan 29, 2020
@riastrad riastrad force-pushed the riastrad-change-defaults branch from c50a68c to a82b112 Compare February 11, 2020 19:02
@riastrad riastrad changed the title [WIP] update default tile endpoints update default tile endpoints Feb 20, 2020
@riastrad riastrad changed the title update default tile endpoints update default tile/style endpoints for mapbox styles Feb 20, 2020
@riastrad riastrad marked this pull request as ready for review February 20, 2020 19:58
@riastrad riastrad requested review from a team February 20, 2020 20:02
@riastrad
Copy link
Author

👋 @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.

@riastrad
Copy link
Author

riastrad commented Mar 4, 2020

👋 @asheemmamoowala @mourner any chance you'll be able to review this before the end of the week?

@mourner
Copy link
Member

mourner commented Mar 4, 2020

@riastrad yes, will do!

Copy link
Member

@mourner mourner left a 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.

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('');
Copy link
Member

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?')?

Copy link
Author

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(_);
}
Copy link
Member

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?

Copy link
Author

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

@asheemmamoowala asheemmamoowala removed their request for review March 6, 2020 16:24
@riastrad riastrad requested a review from mourner March 9, 2020 17:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Point to modern Static Tiles API by default
3 participants