Python – How to Rename the Default Base Map Tile in Folium

foliumpython

I'm creating a map in the Folium library of Python. I'm also adding an additional terrain base map tile by using the following code:

import folium

m=folium.Map(location=[39.084916577250254,-94.5798510242038],
             tiles='Open Street Map',
             zoom_start=12,
             min_zoom=11)

folium.TileLayer(
          'Stamen Terrain', 
          name = 'Terrain'
          ).add_to(m)

folium.LayerControl().add_to(m)

m

The map renders without a problem, but I'm wondering if / how it's possible to rename the default base map on the dropdown control box here:

enter image description here

In this example, the 'Terrain' tile allows a name = argument to input a custom label on the map's control box, but I can't figure out how to do this for the default Open Street Map.

It bothers me that it's labelled 'openstreetmap' in all lowercase without any spaces. I'd prefer the control box to read 'Open Street Map' or something a bit nicer there. You would think I could input an argument in the initial folium.map() function, but I don't see such an argument.

Meta: let me know if this post is more appropriate for SO. I never know when it comes to questions like these.

Best Answer

You can add custom way after disabling the default option.

m = Map(tiles=None)

folium.raster_layers.TileLayer(tiles='openstreetmap', name='my name').add_to(m)

Source: https://github.com/python-visualization/folium/issues/1316