This is more a question then an issue. How can I give to the main map layer a name to appear on layer control?
Because when we create the main layer using folium.Map() what appears on the layer control is the tiles name. Can it be change?
Thanks!
Yes, you can use a custom name. You will have to use foliums TileLayer class directly. The Map class normally creates a TileLayer object with some default settings. You can disable that by setting tiles=None.
m = folium.Map((0, 0), tiles=None)
folium.TileLayer('cartodbpositron', name='my tilelayer').add_to(m)
@Conengmo , thanks for explaining. Only to be more convenient I made this #1191 PR so we can pass the name more straightforward. What do you think?
I'd rather not overload the Map parameters even more. It's already quite crowded. We recently even removed some of the parameters, check out https://github.com/python-visualization/folium/pull/1127.
The current idea is that Map creates a TileLayer with some very common defaults and that for anything more complicated you have to call TileLayer yourself. Such as when you want to set a custom name.
Okay, I'm seeing it. I wasn't aware about all that map api pruning.
I thought that giving to the main map layer a name isn't something so complicated that should be necessary two lines of code to do it. However I'm okay with closing the PR. Thanks for your explanation :+1:
Most helpful comment
Yes, you can use a custom name. You will have to use foliums
TileLayerclass directly. TheMapclass normally creates aTileLayerobject with some default settings. You can disable that by settingtiles=None.