question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[request for help] getting lat/long bounds of visible map

See original GitHub issue

Hello,

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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fulloniccommented, Apr 10, 2019

@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.

1reaction
ramesesjdcommented, Apr 7, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get the bounding box of the visible leaflet map?
If you just want to get the bounds you can call a map.getBounds() on dragend. map.on('dragend', myFunctionThatGetsMapBounds()) I would try ...
Read more >
Coordinates | Maps JavaScript API
LatLng class. google.maps.LatLng class. A LatLng is a point in geographical coordinates: latitude and longitude. Latitude ranges between -90 and 90 degrees, ...
Read more >
Specify Map Limits with Geographic Axes - MATLAB & ...
You can change the latitude and longitude limits of the map in a geographic axes or chart programmatically using the geolimits function.
Read more >
How to calculate a new bounding box that is 80 ...
Measure the horizontal and vertical dimensions of the bounds. · Multiply both of them by 0.1 thus you will get the 10% value...
Read more >
bounding box | Help
A bounding box is a mechanism for describing a particular area of a map. It is typically expressed as an array of coordinate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found