@@ -20,13 +20,14 @@ class TileLayer(Layer):
2020
2121 Parameters
2222 ----------
23- tiles: str, default 'OpenStreetMap'
23+ tiles: str or :class:`xyzservices.TileProvider` , default 'OpenStreetMap'
2424 Map tileset to use. Can choose from this list of built-in tiles:
2525 - "OpenStreetMap"
2626 - "Stamen Terrain", "Stamen Toner", "Stamen Watercolor"
2727 - "CartoDB positron", "CartoDB dark_matter"
2828
29- You can pass a custom tileset to Folium by passing a Leaflet-style
29+ You can pass a custom tileset to Folium by passing a
30+ :class:`xyzservices.TileProvider` or a Leaflet-style
3031 URL to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``.
3132
3233 You can find a list of free tile providers here:
@@ -80,6 +81,14 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=0, max_zoom=18,
8081 control = True , show = True , no_wrap = False , subdomains = 'abc' ,
8182 tms = False , opacity = 1 , ** kwargs ):
8283
84+ # check for xyzservices.TileProvider without importing it
85+ if isinstance (tiles , dict ):
86+ attr = attr if attr else tiles .html_attribution
87+ min_zoom = tiles .get ("min_zoom" , min_zoom )
88+ max_zoom = tiles .get ("max_zoom" , max_zoom )
89+ subdomains = tiles .get ("subdomains" , subdomains )
90+ tiles = tiles .build_url (fill_subdomain = False , scale_factor = "{r}" )
91+
8392 self .tile_name = (name if name is not None else
8493 '' .join (tiles .lower ().strip ().split ()))
8594 super (TileLayer , self ).__init__ (name = self .tile_name , overlay = overlay ,
0 commit comments