我在我的应用程序中使用 Android 版 Google map 。我想通过删除之前添加的标记和缩放级别来重置我的 Google map 。当我单击按钮时,之前添加的标记被重置并添加了我添加的新标记。
But My problem is that I am not getting my map in default state(without zoom).I am getting updated map with zoom-in state which i previously zoomed.I want to get map with default state
我是引用 Clear markers from Google Map in Android重置我的 map 。
我的代码如下:
//set zoom in and zoom out on map navigation button click
private void moveToCurrentLocation(LatLng currentLocation) {
if (map != null) {
if (forZoomInZoomOut) {//if true map will zoomin to currentlocation
map.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomIn());
// Zoom out to zoom level 10, animating with a duration of 2 seconds.
map.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
} else if (!forZoomInZoomOut){//if false map will reset
map.clear();//clear map to add new marker's
setMapMarker();//add markers here
}
}
}
最佳答案
没有缩放级别的 map 是不存在的。当您清除所有内容时,您必须将缩放设置为您想要的。
关于android - 如何在具有缩放状态的android中重置谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33499800/