0
votes

I am in the process of switching my map tiles provider from Google to MapBox in the hope that I will acquire more control over the appearance of the map. MapBox sounds like a good option because the documentation talks of being able to use designer styles from Mapbox Studio. However, I find the documentation horrendously confusing - or perhaps it is only because I am just starting off with Mapbox - so I am unable to figure out just how I go about the process of telling Leaflet/Mapbox to use a certain style. Can someone here tell me what needs to be done.

At present all I am doing is making the call

L.tileLayer(tileURL,
         {attribution:'Map data &copy;<a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
         maxZoom: 18,id:'mapbox.streets',
         accessToken: 'myAccessToken'}).addTo(_hold.lmap);

Where my tileURL is the basic one given in MapBox docs

https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}
1
What is your tileURL? Maybe this can help you gis.stackexchange.com/questions/182442/…MeltedPenguin
I have edited my post to include my tileURL. Based on the link above it looks like I need to modify it. Based on the information in that link I did a spot of googling and found that one can establish style urls from https://www.mapbox.com/help/define-style-url/. Perhaps I have answered my question but credit to you for pointing me the right direction. Write up an answer and I will accept it :-)DroidOS
Glad it helped. I'll let you answer your own question as you'll be able to provide more details of your final solution ;)MeltedPenguin

1 Answers

4
votes

Working example of tileURL is

https://api.mapbox.com/styles/v1/woldemarg/cjmd3mz8i679w2sp69nqb2dgi/tiles/{z}/{x}/{y}?access_token=...

where

woldemarg is my login at https://www.mapbox.com/studio/

cjmd3mz8i679w2sp69nqb2dgi is a style id.

Both you can get from your style URL in Studio - https://www.mapbox.com/help/define-style-url/

You can check that everything works correctly here - https://bl.ocks.org/danswick/raw/4c963d3facd6fcf96ac23f7fa36ccfea/