When you have a leaflet.js application, such as my experimental toy for xkcd GeoHashing (look at
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
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.
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?