Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tile opacity #304

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ecoscope/mapping/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_ecomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading