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

Add use_vis_params to add layer #949

Merged
merged 1 commit into from
Oct 21, 2024
Merged
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
12 changes: 11 additions & 1 deletion sepal_ui/mapping/sepal_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,22 @@ def zoom_bounds(self, bounds: Sequence[float], zoom_out: int = 1) -> Self:
bounds: coordinates corners as minx, miny, maxx, maxy in EPSG:4326
zoom_out: Zoom out the bounding zoom
"""
print("zooming")
# center the map
minx, miny, maxx, maxy = bounds
self.fit_bounds([[miny, minx], [maxy, maxx]])
print([[miny, minx], [maxy, maxx]])
print(self.zoom)

# adapt the zoom level
zoom_out = (self.zoom - 1) if zoom_out > self.zoom else zoom_out
print(zoom_out)
print(self.zoom)

self.zoom -= zoom_out

print(self.zoom)

return self

def add_raster(
Expand Down Expand Up @@ -452,6 +460,7 @@ def add_ee_layer(
opacity: float = 1.0,
viz_name: str = "",
key: str = "",
use_map_vis: bool = True,
) -> None:
"""Customized add_layer method designed for EE objects.

Expand All @@ -468,6 +477,7 @@ def add_ee_layer(
opacity: the opcity of the layer from 0 to 1, default to 1.
viz_name: the name of the vizaulization you want to use. default to the first one if existing
key: the unequivocal key of the layer. by default use a normalized str of the layer name
use_map_vis: whether or not to use the map visualization parameters. default to True
"""
# check the type of the ee object and raise an error if it's not recognized
if not isinstance(
Expand All @@ -494,7 +504,7 @@ def add_ee_layer(
viz_name = viz_name or viz[next(iter(viz))]["name"]

# apply it to vis_params
if not vis_params and viz:
if not vis_params and viz and use_map_vis:
# find the viz params in the list
try:
vis_params = next(i for p, i in viz.items() if i["name"] == viz_name)
Expand Down
Loading