如何使用缩放状态重置Android中的Google地图
问题描述:
我在我的应用中使用Android版Google地图。我想重置我的谷歌地图,删除以前添加的标记和缩放级别。当我点击按钮时,之前添加的标记被重新设置并添加了新添加的内容。如何使用缩放状态重置Android中的Google地图
但我的问题是,我没有得到我的地图在默认状态(无变焦)。我是 得到更新地图放大状态,这我以前zoomed.I想要得到地图默认状态
我指的是Clear markers from Google Map in Android重置我的地图。
我的代码如下:
//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
}
}
}
你看看:https://developers.google.com/maps/documentation/android-api/map#configuring_initial_state –