How can I check if a google map marker is already inside an array of markers?
Even after this markersArray.push(marker); the condition (marker in markersArray) is false.
How can I check if a google map marker is already inside an array
Share
First,
(marker in markersArray)is wrong sinceindoesn’t look for elements in the array.It looks for properties.
The way it worked for me was
This works as long as what you need compared is only the coordinates of the markers.
We use here the LatLng class’ .equals operator.