请帮助!!!!
我读过-How to get all visible markers on current zoom level,但我在地图上有超过2000个标记,我的应用程序运行非常缓慢。
还有别的办法吗????
代码-
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());
}
最佳答案
我不确定它是否真的更快,但这段代码绝对更干净:
public boolean isVisibleOnMap(LatLng latLng) {
VisibleRegion vr = mMap.getProjection().getVisibleRegion();
return vr.latLngBounds.contains(latLng);
}