mapbox / mapbox.js

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

Document that `null` style URL is necessary when using a styleLayer and passing map options #1339

Open malwoodsantoro opened 3 years ago

malwoodsantoro commented 3 years ago

It's necessary to pass in null for the style URL when using map options. This isn't clear in the documentation. This is especially noticeable for users trying to migrate from Classic styles to the modern Static Tiles endpoint.

Map does not render with tile_layer.js:49 Uncaught TypeError: Cannot read property '0' of undefined error:

var map = L.mapbox.map('map', {maxZoom: 3})
    .setView([40, -74.50], 1)
    .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));

Map renders as expected:

var map = L.mapbox.map('map', null, {maxZoom: 3})
    .setView([40, -74.50], 1)
    .addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));