1

I'm currently creating a new website based on geo-localised informations, which is quite new to me. I need to display my points of interest according to where the map is, and where the user make it move. I know I can use the Haversine formula to find POIs around the map's center for the first load.

Now, when the user moves the map to the side, how should I proceed? I though I could just trigger an AJAX load to fetch the POI around the new center, but this would not take into account the already loaded POI, so I'd need to clear the map before adding the new corresponding POI.

I think it'd be better if I can only load the missing POI, as it would probably be more efficient on zoom out.

What is considered best practice in GIS to load data on the fly? What is more memory-efficient?

Also, how can I load POI for the area covered by the screen, but load 20 by 20 to show progressively that informations are being fetched?

I'm using leaflet to display data on map, but I don't know if the number of information displayed as markers take more memory when they are grouped in a cluster.

  • 1
    Please take the tour here: gis.stackexchange.com/tour You have quite a few questions bundled into this one. What is your end goal, and what have you already tried to get there? What research have you already attempted in order to find an answer to your question, from this, what roadblocks did you hit? – MaryBeth Dec 14 '15 at 13:18
  • The question is basically "How should I load content to display it on the map". I just gave more details for the use cases, as I only know little about GIS. Since I don't want to load all data at once, I was wondering how to load only the missing data on the map by small amounts. – user2700551 Dec 14 '15 at 15:14
1

If you do have dozens of Mb of data (or more!) in total, then indeed it would be suitable to implement a dynamic loading of your data based on the current map view. You should look for RESTful services, or implement your own server with such service.

It is then up to you to program a caching mechanism to avoid requesting several times the same data when the user comes back to the same view.

Regarding progressive display, that would make sense mainly if each POI takes a long time to download, since you would probably have to send multiple requests (one per batch), which creates some extra overhead.

Now if your data is less than a few Mb, but you are still concerned with responsiveness of the map on client side (you can still have thousands of POI's, which slows down a lot web browsers), you could still load all data at once, but then use some clustering plugins to decrease the amount of POI's displayed simultaneously (most of these plugins also automatically hide POI's which are far away from the current view port). The most popular clustering plugin is Leaflet.markercluster. All data would be kept in memory, but display is lighter.

Using these clustering plugins significantly improves the usability of your map when you have hundreds to thousands of markers.

  • Each POI would be less than 1Mb, but the website should be public in the end so that anyone can add data to it (we don't have a fixed amount of POI, so it could be huge after some time of creating new POI). Thanks for clarifying how clustering works memory-wise. What is still difficult for me to see is how the request to the API would look like, given the map view and the POI already displayed (I don't think setting POI NOT LIKE poi_id1, poi_id2 etc. in SQL would be clean). – user2700551 Dec 17 '15 at 14:13
  • 1Mb per POI is really a lot (do you have images?). If a POI data is made up of only text, it would be probably below a few KB. – ghybs Dec 17 '15 at 16:03
  • Most go the POI contain a title and coordinates, it might happen that a few will have pictures, but my problem is not with the size here, it's how to load POI based on location. – user2700551 Dec 18 '15 at 8:59
  • If your POI's contain only title, coordinates and URL to a picture, there should be no reason the entire dataset cannot be downloaded at once, even with thousands of points. See Leaflet.markercluster example with 50,000 markers. – ghybs Dec 18 '15 at 10:07
  • I'm still interested in how I could load my POIs one after another as I need to do some treatments as well (unrelated to the current problem), if we ignore the fact that we can load them at once in some cases, how would you make the request to complete the data on the map? – user2700551 Dec 18 '15 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.