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_cog_layer(zoom_to_layer=False) overrides zoom and location set in leafmap.Map #507

Closed
Chris-airseed opened this issue Aug 18, 2023 · 8 comments · Fixed by #508
Closed
Labels
bug Something isn't working

Comments

@Chris-airseed
Copy link

Chris-airseed commented Aug 18, 2023

Environment Information

  • leafmap version: 0.23.1
  • Python version: 3.10.11
  • Operating System: Windows

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
@Chris-airseed Chris-airseed added the bug Something isn't working label Aug 18, 2023
@giswqs
Copy link
Member

giswqs commented Aug 18, 2023

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 Chris-airseed changed the title zoom_to_layer argument in add_cog_layer doesn't work add_cog_layer(zoom_to_layer=False) overrides zoom and location set in leafmap.Map Aug 18, 2023
@Chris-airseed
Copy link
Author

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

@giswqs
Copy link
Member

giswqs commented Aug 18, 2023

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
Copy link
Author

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

@Chris-airseed
Copy link
Author

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

@giswqs
Copy link
Member

giswqs commented Aug 18, 2023

Use center rather than location for ipyleaflet.

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

@giswqs
Copy link
Member

giswqs commented Aug 18, 2023

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

@Chris-airseed
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants