I would like to add Mapbox basemaps to Leaflet or OpenLayers, but I am missing the map IDs.
Before Mapbox Editor was deactivated, one could easily create and save a map, copy that map's ID and your personal API token and then include the map in Leaflet or OpenLayers by using the following URL, replacing my.map and your < access token here >:
http://a.tiles.mapbox.com/v4/my.map/{z}/{x}/{y}.png?access_token=<your access token here>
This still works. But only if you have existing maps from before Mapbox Editor was deactivated on January 31, 2017.
How do new users, who cannot save maps and therefore do not have a personal map ID, go about formatting the URL? New users get an API token but they cannot save maps anymore and thereby get a map ID.
So, how can the following Mapbox basemaps be accessed now:
- Classic
- Light
- Dark
- Satellite
- Satellite Streets
- Wheatpaste
- Streets Classic
- Comic
- Outdoors
- Run, Bike, Hike
- Pencil
- Pirates
- Emerald
- High Contrast
I found a post on Stack Overflow, which shows that the URL can be formatted this way:
https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}
So, you do not necessarily need a personal map ID as every public Mapbox basemap seems to have an ID.
I have tested this and it works, you just need to replace {id} with a map's name, such as streets-v9 but I am unable to find the IDs of the above maps.