【发布时间】:2014-11-24 15:22:14
【问题描述】:
我已经能够通过代码打开世界地图并标记几个地方。但是,我总是必须缩小到城市,这需要一点时间。有没有办法直接打开特定城市的地图?
【问题讨论】:
-
这可能对你有帮助Changing the View
标签: android android-maps-v2 android-maps android-maps-extensions
我已经能够通过代码打开世界地图并标记几个地方。但是,我总是必须缩小到城市,这需要一点时间。有没有办法直接打开特定城市的地图?
【问题讨论】:
标签: android android-maps-v2 android-maps android-maps-extensions
例如,您可以将 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));
【讨论】:
您可以使用此示例代码将地图直接设置为您的城市坐标(lat、lng)并自动缩小到指定级别:
// 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);
【讨论】: