Skip to content

Commit

Permalink
Add zoom_to_layer param for folium add_cog_layer
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Aug 18, 2023
1 parent 17308b1 commit 0046597
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions leafmap/foliumap.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ def add_cog_layer(
shown: Optional[bool] = True,
bands: Optional[List] = None,
titiler_endpoint: Optional[str] = None,
zoom_to_layer=True,
**kwargs,
):
"""Adds a COG TileLayer to the map.
Expand All @@ -958,6 +959,7 @@ def add_cog_layer(
shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
bands (list, optional): A list of bands to use. Defaults to None.
titiler_endpoint (str, optional): TiTiler endpoint. Defaults to "https://titiler.xyz".
zoom_to_layer (bool, optional): Whether to zoom to the layer extent. Defaults to True.
**kwargs: Arbitrary keyword arguments, including bidx, expression, nodata, unscale, resampling, rescale,
color_formula, colormap, colormap_name, return_mask. See https://developmentseed.org/titiler/endpoints/cog/
and https://cogeotiff.github.io/rio-tiler/colormap/. To select a certain bands, use bidx=[1, 2, 3].
Expand All @@ -972,8 +974,9 @@ def add_cog_layer(
opacity=opacity,
shown=shown,
)
self.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
arc_zoom_to_extent(bounds[0], bounds[1], bounds[2], bounds[3])
if zoom_to_layer:
self.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
arc_zoom_to_extent(bounds[0], bounds[1], bounds[2], bounds[3])

def add_cog_mosaic(self, **kwargs):
raise NotImplementedError(
Expand Down

0 comments on commit 0046597

Please sign in to comment.