2013-05-09 101 views
12

我在android中使用Google maps api v2。我已经通过使用经度和纬度放置了一个标记。标记显示在正确的位置,但我想地图应该只显示标记周围的区域。我想缩放到标记位置,当地图显示时,它只显示标记的附近区域..任何帮助将大。谷歌地图api v2放大标记附近

回答

50

在您放置标记的位置传递您当前的位置。

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); 


} 
+0

非常感谢... – Ravi 2013-05-09 10:06:39

+0

@ Ravi-我很高兴你已经解决了。 – TheFlash 2013-05-09 10:08:28

+1

很好地完成。 +1:P – TheLittleNaruto 2014-02-11 10:25:56

13

提供标记位置。

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)); 
}