I have thousands of markers - I need to cache them and use show-hide tactics to only show like 100 markers at once but I have trouble with caching.

Adding all single markers/points to an array and if map is dragged or zoomed, then loop through the array to see it has already been loaded and then load all new markers that are not in that array is rather expensive.

How should I solve this caching issue?

How to load only markers/points/coordinates that haven't been loaded yet?

Could I benefit from grid system? A.k.a load all markers on that part of grid and cache grid - this would keep the array of already loaded areas/points much shorter.

  • what do you mean by 'caching'? are you using client side geometry? If you are, I would recommend that you use a server side tool to generate the view such as a KML, a Fusion Table or a WMS. – Hen Wagner Jan 16 '16 at 20:09
  • @HenWagner This problem is pretty much killing all my hard work: every time map is panned or zoomed, all markers in map viewport are reloaded every single time. I need to "cache" markers so that only these markers are loaded that haven't been loaded yet. Could you help me to figure this out? – N00b Jan 16 '16 at 21:04
  • @HenWagner Markers coordinates are sent to browser via ajax and is then placed on map via JS. All markers are also inside areas/polygons, maybe I could use them to check what markers have loaded and what not? – N00b Jan 16 '16 at 21:19
  • Can you use cookies to keep track of which markers the end user has already loaded? Or a session id or something? – user1462 Jan 17 '16 at 3:36
  • @barrycarter I need to "cache" markers only for "one page load" which means that everything should reset back to normal when page is refreshed because markers count and position is changing regulary. I could push and store them in array but how would I check if marker has already been loaded? Send the array of loaded markers to server, check there and send back only markers that haven't been loaded? This is the issue for me.. – N00b Jan 17 '16 at 3:43

Your Answer

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

Browse other questions tagged or ask your own question.