0
我已经能够通过代码打开世界地图并标记几个地方。然而,我总是不得不缩小到城市,这需要一点时间。有没有办法直接打开某个特定城市的地图?如何在android中使用google APIs打开某个特定城市的地图
我已经能够通过代码打开世界地图并标记几个地方。然而,我总是不得不缩小到城市,这需要一点时间。有没有办法直接打开某个特定城市的地图?如何在android中使用google APIs打开某个特定城市的地图
例如,您可以使用moveCamera以及上次存储的位置(lat,lng或zoomLevel)。
final LatLng location = new LatLng(..., ...);// Loaded from SharedPreferences maybe.
// Move the camera to location with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 15));
您可以使用此示例代码的直接映射动画到你的城市坐标(纬度,经度),并自动缩小到指定级别:
// Set desired lat lng location, and zoom level (for example 10)
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(locationCity.getLatitude(), locationCity.getLongitude()), 10);
// Move the camera to location
gMap.animateCamera(cameraUpdate);
这可能会帮助你[更改视图] (https://developers.google.com/maps/documentation/android/views) – j4rey89 2014-11-23 07:24:52