I am creating an ASP.NET MVC site where I want to have a Google Maps Javascript API map that displays markers loaded from my backend via AJAX.
Since I don't want the client to have memory problems, I want to lazily load tokens and apply them to Fluster2 to put them in clusters . I think the best way to lazily load markers is to add an event listener to the idleMap event that occurs after the map is expanded or enlarged.
Here is my current strategy:
- Add an event listener to the event
idle. - When an event is fired
idle, use jQuery to make an AJAX call HTTP POSTon my backend, providing the current viewport / map borders. - The backend returns all points inside the viewport.
- Points are created in markers and added to Fluster2, which adds them to the map. Old dots are NOT discarded.
- Repeat
However, this can create problems because old items are not discarded. I do not want to drop them, because I do not want to load them again, but with my current strategy I would load them a second time and create markers for them a second time.
While I think itβs not a good idea to tell the backend in an AJAX call somehow that I already have some of the tokens, it would be nice to implement some kind of hash table that does not allow duplication .
, , -: , , ; , .
? , -, ?