[英]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.