mapbox / mapbox.js

Mapbox JavaScript API, a Leaflet Plugin
mapbox.com/mapbox.js/
Other
1.92k stars 386 forks source link

L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11') throws browser warning about loading "Studio Classic" styles scheduled for deprecation #1327

Closed george700dl closed 4 years ago

george700dl commented 4 years ago

Hello, we are getting our code ready for the 6/1/2020 deprecation of the Classic styles. We use MapboxGL, but we use MapboxJS (v 3.3.0 now) as a fallback for non-webGL supporting browsers. We've been using MapboxJS since 2013 and MapboxGL since last year.

This example itself: https://docs.mapbox.com/mapbox.js/example/v1.0.0/ throws:

  1. A warning about loading classic styles: "Warning: this implementation is loading a Mapbox Studio Classic style (mapbox.mapbox-streets-v8,mapbox.mapbox-terrain-v2). Studio Classic styles are scheduled for deprecation"

  2. A Leaflet error: Uncaught TypeError: t.getTileJSON is not a function at e._updateLayer (map.js:213) at e._onLayerReady (map.js:195) at e.fire (leaflet-src.js:593) at e. (style_layer.js:46) at XMLHttpRequest.r (request.js:28) at XMLHttpRequest.e (corslite.js:45)

Version prior to 3.3.0 do not throw these. My main concern is the style references. My understanding was that 'mapbox://styles/mapbox/streets-v11' was the way to go forward past 6/1/2020. Why the loading of mapbox.mapbox-streets-v8 and mapbox.mapbox-terrain-v2 ?

Thanks for your help. George

chelseadelgrande commented 4 years ago

I have this issue too when trying to create multiple choropleth maps. The documentation throws https://docs.mapbox.com/mapbox.js/example/v1.0.0/choropleth-joined-data-multiple-variables/ and many of the other examples for mapbox js seem to have the same issue.

Chelsea

riastrad commented 4 years ago

This is happening because the when the warning was added in #1317, it failed to account for the fact that L.mapbox.styleLayer objects set the tileJson value based on the Mapbox style object's sources field:

https://github.com/mapbox/mapbox.js/blob/6a6db371daa4ac49940948417ad2c09cf51cdcbb/src/style_layer.js#L32-L48

The good news is that, if you are using L.mapbox.styeLayer in your implementation and not directly adding Mapbox classic style as a L.mapbox.tileLayer, then these errors can safely be ignored.

chelseadelgrande commented 4 years ago

Hm ok do you know if the js doc examples will be updated/functioning properly, or migrated to be included in gl js docs? The sandbox saves me (and probably many of others) a lot of time

george700dl commented 4 years ago

Thanks for the explanation @riastrad . To add onto the above question, is there a plan to eliminate these errors? We would prefer to not be logging any browser errors in our customer-facing web products.

Also a follow-up to my original concerns - would there be any way to perform a "dry run" of the 6/1/2020 deprecation of the classic styles, before 6/1?

In our MapboxJS fallback wrapper, we are using: L.mapbox.map(element, options).addLayer(L.mapbox.styleLayer('mapbox://styles/ourcompany/blahblahblah');

and in our MapboxGL wrapper, we are using: new mapboxgl.Map({container: element, style: 'mapbox://styles/ourcompany/blahblahblah', ...});

We created 'mapbox://styles/ourcompany/blahblahblah' in Mapbox Studio and I received sufficient assurances from Mapbox that this will work after 6/1/2020. But I was wondering if there was any way to test this out beforehand somehow, to minimize the possibility of 75% of our website breaking on 6/1 :)

Thanks, George

rmrice commented 4 years ago

v3.3.1 has been published, which should resolve these console errors.

george700dl commented 4 years ago

v3.3.1 has been published, which should resolve these console errors.

Thank you! What is the new URL that I can reference in my code, for the JS and for stylesheet? https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js and https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css don't work at this time.

Thanks, George

rmrice commented 4 years ago

Hey @george700dl, apologies for the oversight. Just published to the CDN, so you should be able to use those urls now!

george700dl commented 4 years ago

Thank you Rebecca!