Search code examples
androidgoogle-mapsgpslocationfusedlocationproviderapi

FusedLocationProvider API. Transition Between GPS Locations


I have been working on retrieving GPS locations using Google's FusedLocationProvider API for about a week now. I have successfully gotten close to retrieving accurate gps data.

Currently the marker jumps around the map, instead I want it to smoothly animate like Google Maps, Waze, etc. I have searched the entire internet looking for a solution and have not found anything.


Solution

  • You could use animateCamera() method to set focus to new latlng.

    CameraPosition cameraPosition = new CameraPosition.Builder().target(
                    new LatLng(17.385044, 78.486671)).zoom(12).build();
    
    googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    

    This will result in smooth transition.

    PS:Play with the zoom to make it more realistic.

    You are looking for this