diff --git a/ecoscope/mapping/map.py b/ecoscope/mapping/map.py index 3d54e03e..13565923 100644 --- a/ecoscope/mapping/map.py +++ b/ecoscope/mapping/map.py @@ -493,7 +493,7 @@ def pil_layer(image, bounds, opacity=1): return layer @staticmethod - def get_named_tile_layer(layer: str) -> BitmapTileLayer: + def get_named_tile_layer(layer: str, opacity: float = 1) -> BitmapTileLayer: # From Leafmap # https://github.com/opengeos/leafmap/blob/master/leafmap/basemaps.py xyz_tiles = { @@ -534,6 +534,7 @@ def get_named_tile_layer(layer: str) -> BitmapTileLayer: max_zoom=layer.get("max_zoom", None), min_zoom=layer.get("min_zoom", None), max_requests=layer.get("max_requests", None), + opacity=opacity, ) def to_html( diff --git a/tests/test_ecomap.py b/tests/test_ecomap.py index 36a8c5b8..0863634f 100644 --- a/tests/test_ecomap.py +++ b/tests/test_ecomap.py @@ -319,3 +319,12 @@ def test_add_polygon_with_color(poly_gdf): # validating zoom param by checking view state is non-default assert m.view_state.longitude != 10 assert m.view_state.latitude != 0 + + +def test_add_named_tile_layer(): + m = EcoMap() + m.add_layer(m.get_named_tile_layer("HYBRID", opacity=0.3)) + + assert len(m.layers) == 2 + assert isinstance(m.layers[1], BitmapTileLayer) + assert m.layers[1].opacity == 0.3