[英]Location query in Google maps in android
我已經利用Google Maps開發了一個應用程序。 我在其中添加了當前位置的標記。 但是,一旦我打開該應用程序,我希望它可以放大到我的位置,而不是首先在95302 23535919711008489
位置上顯示整個世界。 我該如何完成?
如下使用animateCamera()
@Override
public void onLocationChanged(Location location) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 10);
map.animateCamera(cameraUpdate);
locationManager.removeUpdates(this);
}
請閱讀文檔
LatLng cameraLatLng = new LatLng(savedLat, savedLng); googleMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap(); googleMap.animateCamera(CameraUpdateFactory .newLatLngZoom(cameraLatLng, 7))
savedLat,savedLng當前位置的經度和緯度。您可以將縮放數字(7)更改為適合的位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.