First, (marker in markersArray) is incorrect, since in does not look for elements in the array.
He is looking for properties.
The way it worked for me was
for (var i=0; i<markersArray.length; i++) { if (markersArray[i].getPosition().equals(marker.getPosition())) { ...
This works as long as you only need to compare marker coordinates.
We use here the .lequals operator of the LatLng class.
source share