@@ -78,6 +78,8 @@ class LegacyMap(MacroElement):
7878 * Simple : A simple CRS that maps longitude and latitude into x and y directly.
7979 May be used for maps of flat surfaces (e.g. game maps). Note that the y axis
8080 should still be inverted (going from bottom to top).
81+ control_scale : bool, default False
82+ Whether to add a control scale on the map.
8183
8284 Returns
8385 -------
@@ -100,7 +102,7 @@ def __init__(self, location=None, width='100%', height='100%',
100102 tiles = 'OpenStreetMap' , API_key = None , max_zoom = 18 , min_zoom = 1 ,
101103 zoom_start = 10 , attr = None , min_lat = - 90 , max_lat = 90 ,
102104 min_lon = - 180 , max_lon = 180 , detect_retina = False ,
103- crs = 'EPSG3857' ):
105+ crs = 'EPSG3857' , control_scale = False ):
104106 super (LegacyMap , self ).__init__ ()
105107 self ._name = 'Map'
106108
@@ -127,6 +129,7 @@ def __init__(self, location=None, width='100%', height='100%',
127129 self .max_lon = max_lon
128130
129131 self .crs = crs
132+ self .control_scale = control_scale
130133
131134 if tiles :
132135 self .add_tile_layer (tiles = tiles , min_zoom = min_zoom , max_zoom = max_zoom ,
@@ -161,6 +164,7 @@ def __init__(self, location=None, width='100%', height='100%',
161164 layers: [],
162165 crs: L.CRS.{{this.crs}}
163166 });
167+ {% if this.control_scale %}L.control.scale().addTo({{this.get_name()}});{% endif %}
164168 {% endmacro %}
165169 """ )
166170
0 commit comments