[request for help] getting lat/long bounds of visible map
See original GitHub issueHello,
I’m trying to develop a python web app (using Heroku and Flask) to displays data from a public API. The idea is to display the catalogued information of an organisation’s assets by plotting their locations on a map. The information is displayed as a pop-up when the user clicks on the icon.
I have done this successfully using a local copy of the data set so I know that the scheme is practical from an aesthetic/usability stand point with FastMarkerCluster. However, the ~400k records are updated semi-regularly so using a local copy is not optimal and I’d rather pull data as required from the organisation’s public API. I’ve tried to pull all the data from the API at once, but this maxes out the memory resources that Heroku assigns to my free account and the app crashes before it even loads.
To avoid this, I’m thinking to pull data from the API only after a zoom level threshold and only for the visible map area. The API appears to allow such queries, so I need to find a way to get the visible map bounds and update these on panning. Leaflet appears to have the functionality I need in getBounds()
. From the docs, it appears that get_bounds()
is the Folium version, but this example notebook shows that the function only returns the bounds of an object and not the whole map. Am I missing something here, or does the functionality I’d like not yet exist in Folium?
Thank you very much in advance and for all the work already done on Folium, Sorry if this isn’t the right place to ask, but I already tried StackOverflow but haven’t received a clear answer. -Rameses
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
Top GitHub Comments
@ramesesjd I created a repo with an example of what you had asked about. It have alot of room to improve but it does the job. The data is rendered in base of the map bounds. However when I tried to run the server with all your data points, it doesn’t works. (I took it from your repo to test it 😉 ) See it by yourself: https://github.com/fullonic/flask_folium Isn’t finished yet, but I don’t have too much free time for now. I will keep adding stuff to the repo to improved it. Let me know what do you think.
@Conengmo, thank you; I’m fine with the issue being closed at this time. If you don’t mind, I’d like to continue discussion with @fullonic in this thread and potentially re-open/submit a PR, depending on progress.