android - 如何在具有缩放状态的android中重置谷歌地图

标签 android google-maps supportmapfragment

我在我的应用程序中使用 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/

相关文章:

Android - 第二次打开时显示 Google map v2 或 SupportMapFragment 时出错

java - 将 12 个字符转换为长整型

java - 如何使用 TabLayout 在 ViewPager 的 Google Maps Fragment 中获取当前位置

安卓网址重定向

javascript - 在 data.feature 对象上添加工具提示,就像我们可以为标记做的那样

php - 确定并排序多个位置的距离

java - Mapview 顶部的另一个片段(SupportMapFragment)

android - SupportMapFragment 贴图在旋转时消失

android - 强制将您的应用程序添加到应用程序选择器中

android - 在 Android 上的 Unity3D 中将网站渲染为纹理