简体   繁体   中英

can we enable Moving and Zooming google maps camera after first zoom android studio?

I'm using Google maps in a fragment. I'm facing some problem when I Zoom and move the google maps camera It's not moving, in every 1000 milliseconds it updating continuously. I searched for it "how to freely move and zoom google maps camera for the 2nd time". second time user should be able to zoom in zoom out and can move the Google maps camera. Below is my code I want this on MapReady() method If possible. Let me know your thoughts.

@Override
public void onLocationChanged(@NonNull Location location)
{
   lastLocation = location;
   LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
   mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
   mMap.animateCamera(CameraUpdateFactory.zoomTo(14));
}

try this, works fine for me

    @Override
    public void onLocationChanged(@NonNull Location location)
    {
        lastLocation = location;
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng ).zoom(14).build();
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM