@@ -42,20 +42,26 @@ def basemap_to_tiles(basemap, day=yesterday, **kwargs):
42
42
43
43
Parameters
44
44
----------
45
- basemap : class:`xyzservices.lib.TileProvider`
45
+ basemap : class:`xyzservices.lib.TileProvider` or Dict
46
46
Basemap description coming from ipyleaflet.basemaps.
47
47
day: string
48
48
If relevant for the chosen basemap, you can specify the day for
49
49
the tiles in the "%Y-%m-%d" format. Defaults to yesterday's date.
50
50
kwargs: key-word arguments
51
51
Extra key-word arguments to pass to the TileLayer constructor.
52
52
"""
53
- url = basemap .build_url (time = day , ** kwargs )
53
+ if isinstance (basemap , xyzservices .lib .TileProvider ):
54
+ url = basemap .build_url (time = day )
55
+ elif isinstance (basemap , dict ):
56
+ url = basemap .get ("url" , "" )
57
+ else :
58
+ raise ValueError ("Invalid basemap type" )
59
+
54
60
return TileLayer (
55
61
url = url ,
56
62
max_zoom = basemap .get ('max_zoom' , 19 ),
57
63
min_zoom = basemap .get ('min_zoom' , 1 ),
58
- attribution = basemap .get ('html_attribution' , '' ),
64
+ attribution = basemap .get ('html_attribution' , '' ) or basemap . get ( 'attribution' , '' ) ,
59
65
name = basemap .get ('name' , '' ),
60
66
** kwargs
61
67
)
0 commit comments