我在android中使用谷歌地图api v2。我用经纬度做了一个标记。标记显示在正确的位置,但我希望地图只显示标记周围的区域。当地图显示时,我想放大到标记位置,这样它只显示标记附近的区域。如果有任何帮助,那就太好了。
传递您在此函数中放置标记的当前位置。
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);
}
提供标记位置
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));
}