答案 0 :(得分:1)
您可以创建List<Marker> markers
来存储您创建的标记:
private List<Marker> markers = new ArrayList<>();
并检查是否需要在每次相机更改时看到它们:
googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
for (Marker marker : markers) {
if (googleMap.getCameraPosition().zoom > 18) {
marker.setVisible(true);
} else {
marker.setVisible(false);
}
}
}
});
//Add some markers:
markers.add(googleMap.addMarker(new MarkerOptions().position(new LatLng(-1.052375, -78.128102))));
markers.add(googleMap.addMarker(new MarkerOptions().position(new LatLng(-1.054864, -78.153422))));
markers.add(googleMap.addMarker(new MarkerOptions().position(new LatLng(-1.072542, -78.102010))));