6

I want to add this map tile layer to my map – Stamen toner-background. As I read in documentation I need to simply give custom url in the tiles attribute of map

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='http://maps.stamen.com/toner-background/embed#6/{x}/{z}', attr="toner-bcg")

It loads but nothing is displayed.

I don't really know how this attribution thing works like and what should I do. I like the tile because it's like stamen toner but without country names and that makes my map a lot more beautiful.

ggegoge
  • 71
  • 1
  • 4

2 Answers2

4

This is your lucky day, Stamen designs are built-in in Folium. You should run the following code:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='Stamen Toner')

This should solve the issue.

The reason your code was not working is because you were not using the correct URL templates. The format is one specified here:

http://tile.stamen.com/toner/{z}/{x}/{y}.png
http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg
http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg

The code would look like this:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='http://tile.stamen.com/toner/{z}/{x}/{y}.png ')
1

To improve Fernando's answer, the below code works for me:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
    location=[52.5, 19], 
    tiles='http://tile.stamen.com/toner/{z}/{x}/{y}.png ', 
    attr="toner-bcg") # <-- note this
  • 1
    If you have an improvement to a previous answer, please edit or comment the answer instead of posing a new one. – Russ J Sep 22 '19 at 03:48