How to get the number of markers in the visible area on the map

Please, help!!! I read - How to get all visible markers at the current zoom level , but I have more than 2000 markers on the map, and my application is very slow.

Is there any other solution?

code -

public boolean isVisibleArea(final Marker marker) { final LatLngBounds.Builder bld = new LatLngBounds.Builder(); final VisibleRegion visibleRegion = mMap.getProjection().getVisibleRegion(); bld.include(visibleRegion.farLeft) .include(visibleRegion.farRight) .include(visibleRegion.nearLeft) .include(visibleRegion.nearRight); return bld.build().contains(marker.getPosition()); 

}

+4
source share
1 answer

I'm not sure if this is really faster, but this code is definitely clean:

 public boolean isVisibleOnMap(LatLng latLng) { VisibleRegion vr = mMap.getProjection().getVisibleRegion(); return vr.latLngBounds.contains(latLng); } 
+3
source

Source: https://habr.com/ru/post/1500666/


All Articles