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

Get zoom level #38

Closed
giswqs opened this issue Mar 14, 2022 · 5 comments · Fixed by #39
Closed

Get zoom level #38

giswqs opened this issue Mar 14, 2022 · 5 comments · Fixed by #39

Comments

@giswqs
Copy link

giswqs commented Mar 14, 2022

Is it possible to get the zoom level of a map object? I saw a similar question at python-visualization/folium#1352, but there is no solution.

@bartboogmans
Copy link

bartboogmans commented Aug 18, 2022

map1.getZoom() gives me nothing

The leaflet class itself (which I believe is the superclass) does however show it in its documentation:
https://leafletjs.com/reference-1.6.0.html#map

>>        self.map1 = folium.Map(
        	tiles='Stamen Terrain',
        	zoom_start=zoom0,
        	location=coordinate
        )
>> zoomlevel = self.map1.getZoom()

'Map' object has no attribute 'getZoom'

@blackary
Copy link
Collaborator

@bartboogmans

If you add your map to the streamlit app with output = st_folium(self.map1), then output becomes a dictionary that has, among other things, a "zoom" key, so output["zoom"] will give you the current zoom-level of the map.

@bartboogmans
Copy link

The st_folium function seems to be designed for Streamlit apps, that not everybody might use (including me).

Such a dictionary would do the job though, so thats a good idea.
Any idea if/how one could access this dictionary in non streamlit apps?

@randyzwitch
Copy link
Owner

This package is specifically designed to work in Streamlit, that's its complete scope. Broadening to make this available in other packages would require some sort of plugin specification between various web app projects, which does not currently exist.

@bartboogmans
Copy link

Whoops, I did not see that it was specifically for the combination with streamlit. I thought it was a general topic, so you're right to point this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants