I am using Leaflet JS and MapBox to create a map. My browser displays as below:
The map does not show at all, my map tile is blank. The errors that I get in the dev tools console is:
GET https://api.tiles.mapbox.com/v4/mapbox.streets/9/123/183.png?access_token=pk.eyJ1IjoibXl2ZXJkaWN0IiwiYSI6ImNrZmoyYmpuNDB1eHYycG16bms0aHN2ZWwifQ.w0DRp5yDUHxa2RJa0aDRlQ 410 (Gone)
Image (async)
createTile @ TileLayer.js:158
_addTile @ GridLayer.js:812
_update @ GridLayer.js:709
_setView @ GridLayer.js:570
_resetView @ GridLayer.js:526
onAdd @ GridLayer.js:162
_layerAdd @ Layer.js:114
whenReady @ Map.js:1465
addLayer @ Layer.js:176
addTo @ Layer.js:52
(anonymous) @ maps.js:16
The maps.js:16
above references the last line .addTo(map)
in the maps.js
code snippet below:
let coordinates = [ 44.96, -93.2 ]
let zoomLevel = 9
let map = L.map("college-map").setView(coordinates, zoomLevel)
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox.streets',
accessToken: 'your-access-token'
}).addTo(map)
How do I fix this error and display the map successfully?
Mapbox changed the url schema from:
To:
The url
https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}
and the{id: 'mapbox/streets-v11'}
changed.Doc: Mapbox Leaflet Implementaton (On the right side is a switch with before and after(now)).
Url params: Static Tiles Style
Default Styles
The new default style Ids: