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