Skip to content

Commit

Permalink
Add use_vis_params to add layer (#949)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom authored Oct 21, 2024
1 parent a332bfb commit 440c415
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit 440c415

Please sign in to comment.