opengeos / leafmap

A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
https://leafmap.org
MIT License
3.22k stars 386 forks source link

add_cog_layer(zoom_to_layer=False) overrides zoom and location set in leafmap.Map #507

Closed Chris-airseed closed 1 year ago

Chris-airseed commented 1 year ago

Environment Information

Description

Using add_cog_layer overrides location and zoom level. add_cog_layer()

What I Did

m=leafmap.Map(google_map="HYBRID", location=[-31.562117, 147.194643], zoom=5, locate_control=False, latlon_control=True, draw_export=False, minimap_control=False)
m.add_cog_layer(url=url, zoom_to_layer=False)
m
giswqs commented 1 year ago

It works fine on my end. Please run leafmap.Report() and report the result here.

import leafmap
m = leafmap.Map()
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
m.add_cog_layer(url, name="Fire (pre-event)", zoom_to_layer=True)
m

image

Chris-airseed commented 1 year ago

Thanks giswqs The issue in the title was unclear. I've clarified it now.

giswqs commented 1 year ago

Again, it works as expected on my end. Setting zoom_to_layer=False does not change the map center/zoom level.

import leafmap
m = leafmap.Map(google_map="HYBRID", location=[-31.562117, 147.194643], zoom=5, locate_control=False, latlon_control=True, draw_export=False, minimap_control=False)
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
m.add_cog_layer(url, name="Fire (pre-event)", zoom_to_layer=False)
m

image

Chris-airseed commented 1 year ago

Thanks again! Okay so the issue was I had import leafmap.foliumap as leafmap rather than import leafmap

Chris-airseed commented 1 year ago

Actually the location issue still persists. It should centre on the East coast of Australia

giswqs commented 1 year ago

Use center rather than location for ipyleaflet.

import leafmap
m = leafmap.Map(center=[-31.562117, 147.194643], zoom=5)
m
giswqs commented 1 year ago

The folium bug has been fixed. Run leafmap.update_package() and restart the kernel to take effect.

Chris-airseed commented 1 year ago

Use center rather than location for ipyleaflet.

import leafmap
m = leafmap.Map(center=[-31.562117, 147.194643], zoom=5)
m

Yep. Just noticed that. Thank you