Google 中的位置查询 android 中的地图

Location query in Google maps in android

我利用 Google 地图制作了一个应用程序。我在其中添加了我当前位置的标记。但是,一旦我打开应用程序,我希望它能放大到我的位置,而不是首先在 95302 23535919711008489 位置显示整个世界。我该如何实现?

      LatLng cameraLatLng = new LatLng(savedLat, savedLng);
                        googleMap = ((SupportMapFragment)   getSupportFragmentManager()
                                .findFragmentById(R.id.map)).getMap();
      googleMap.animateCamera(CameraUpdateFactory
                                .newLatLngZoom(cameraLatLng, 7))

savedLat、savedLng 您当前位置的经度和 latitude.You 可以更改缩放数字 ( 7 ) 以适合您。

使用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);
}

请阅读docs