【问题标题】:Google maps api v2 zooming near the marker谷歌地图 api v2 在标记附近缩放
【发布时间】:2013-05-09 09:48:07
【问题描述】:

我在 android 中使用 Google maps api v2。我使用 latitude 和 longitude 放置了一个标记。标记显示在正确的位置,但我希望地图应仅显示标记周围的区域。即我想在显示地图时缩放到标记位置,以便仅显示标记的附近区域。任何帮助都是很棒。

【问题讨论】:

    标签: android android-maps


    【解决方案1】:

    在此函数中传递您放置标记的当前位置。

    private void moveToCurrentLocation(LatLng currentLocation)
    {   
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation,15));
        // Zoom in, animating the camera.
        googleMap.animateCamera(CameraUpdateFactory.zoomIn());
        // Zoom out to zoom level 10, animating with a duration of 2 seconds.
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
    
    
    }
    

    【讨论】:

    • @Arsal Imam 我很高兴它有帮助..:)
    • 干得好兄弟......如果你能解释一下最后2个动画相机......
    【解决方案2】:

    提供标记位置。

    private void pointToPosition(LatLng position) {
        //Build camera position
        CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(position)
                .zoom(17).build();
        //Zoom in and animate the camera.
        mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 2012-11-29
      • 2016-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多