Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google Maps go to current location without animation

I know this might be a little silly and I must have missed something but how do I disable that animation that zooms in all the way to my marker and load up google maps and my current location immediately?

This is my current code

@Override
    public void onLocationChanged(Location location) {
        currentLocation = location;
        String curr_location = currentLocation.getLatitude()+ ","+currentLocation.getLongitude();
        LatLng coordinates = new LatLng(currentLocation.getLatitude(),currentLocation.getLongitude());
        CameraUpdate current = CameraUpdateFactory.newLatLngZoom(coordinates,15);
        googleMap.animateCamera(current);
        UpdateLocation(userid,email,curr_location);
    }

I'd like to remove the animate camera if possible. thanks!

like image 934
JianYA Avatar asked Jun 08 '16 02:06

JianYA


People also ask

How do I get Google Maps to use my current location?

Quick tip: In the iPhone and Android apps, tapping the Current Location button twice will turn on compass mode. The app will center on your location, but the map will rotate to match the direction you're currently facing in real life.

How do I hide the UI on Google Maps?

Disabling the UI Default Controls We can disable the default UI controls provided by Google Maps simply by making the disableDefaultUI value true in the map options.

How do I move my camera to my current location?

Without clicking any button, how to directly get the current location and move the camera to it. Also, I found that there is a button on the right top of the map. When click on it, it will go to current location.


1 Answers

Replace

googleMap.animateCamera(current);

with

googleMap.moveCamera(current);

(Reference)

like image 123
Juan Cruz Soler Avatar answered Oct 17 '22 17:10

Juan Cruz Soler