Using Gmaps.map.replaceMarkers() I can replace entire marker set. But in my application I will use more than 3000 markers.
How to replace one marker or subset of markers?
This is definitely possible but because there is no rule, there is custom code to write.
Here is how I proceed generally:
I add some custom data in the marker's json, the id
of the active record's object generally
I sort my markers client side in javascript variables, say you have the ids of markers you want to remove in a js array called toClear
I remove useless markers:
Coffeescript:
for marker in Gmaps.map.markers
if marker.id in toClear
Gmaps.map.clearMarker marker
Gmaps.addMarkers new_markers_array