When you have a leaflet.js application, such as my experimental toy for xkcd GeoHashing (look at geohashing.cgi
plus mirkarte.js
), you have to draw points all over the world. In the GeoHashing case, their coordinates can easily be calculated (the links and information I put into the popups isn’t, though); for e.g. a map of geocaches, each individual marker needs to be processed somehow.
What is the usual approach to do this on a world-wide scale?
I thought to register an event handler on moveend
… and zoomend
… and who knows which else, that take into account the left-, right-, top- and bottom-most parts that have already been prepared (initially all empty), and, if the map extends beyond that, add markers for the new areas to the layer then cache the new boundaries, and limit marker display to beyond a certain zoomlevel. The problem with this is, possibly, response time, and that a rectangular approach will mean generating extra data (say I start at N 0° E 0°, then move northwards to N 50° E 0°, then eastwards towards N 50° E 1°, then I will have to calculate everything down to N 0° E 1° as well. Merely annoying in the GeoHashing case, but possibly network intensive if I have to request additional data (popups for geohashing, marker positions too for geocaching, etc).
Storing a list of map bounds that have already been used gets slow very fast if the user pans the map around a lot, e.g. manually/visually following a route. So, if I were to do this, some kind of merging would be needed, which I cannot yet imagine.
I have not studied other maps, because they are not usually Open Source or well-written/well-commented… I’ve seen a bit of use of Google Maps API v1 and v2, and Leaflet, e.g. in the Opencaching Network, but that’s not well-structured or -commented source code. I don’t have any real grounding in GIS (slowly pushing myself in from the side, as techie and cacher, but getting interested), so I lack a good example how this could best be done (just as other things I may post questions on if I get over my shyness to do so). I do intend my map (linked above) to eventually be such well-readable source code (not the current draft though, I also learned practical JavaScript while writing it, and realise it’s a throw-away prototype, albeit a working one).
So, what are the “standard” ways (there’s probably more than one, depending on the scenario even) to handle this without massive network, CPU and RAM cost due to choice of stupid algorithms?