请帮忙!!! 我已阅读 - 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());
}
答案 0 :(得分:3)
我不确定它是否真的更快,但这段代码绝对更清晰:
public boolean isVisibleOnMap(LatLng latLng) {
VisibleRegion vr = mMap.getProjection().getVisibleRegion();
return vr.latLngBounds.contains(latLng);
}