Reputation: 180
I have, for example, 10 markers on Google Map. But I zoomed and in visible area left only 2 markers.
Can Google Maps API somehow return me a number of markers in visible area (2 for my example)?
Upvotes: 3
Views: 1568
Reputation: 544
The above code is not working. There is no method as such getBounds(). Below is the updated code :
VisibleRegion visibleRegion = map.getProjection().getVisibleRegion();
LatLngBounds mapBound = visibleRegion.latLngBounds;
if(mapBound.contains(marker.getPosition()){
// do somethings i.e. such as changing marker icon and others.
}
Upvotes: 0
Reputation: 4855
You can evaluate map.getBounds().contains(marker.getPosition())
with each marker to see which ones are included in the current viewport.
Upvotes: 6