I am working on google maps i am trying to add markers to a google map and then tried to remove it but now as i have done both adding and removing with the code below
The easier answer is that you don't remove the marker from the markers
array. All you do is identify the marker you want to remove from the map and then use setMap(null)
.
markers[indexOfMarker].setMap(null);
This way you can use the following if you want to add the marker back at some point:
markers[indexOfMarker].setMap(map);