-5

I have implemented google map into my app. I have added a custom marker at my current location.I want to move the marker as the user moves, along with the map. I want to implement the functionality as in google maps navigation. While googling i found the following links but did not get the result. so can any one help me out ?

I have added this in onLocationChanged()

 LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        sourceLocation = latLng;
        startPoint = new GeoPoint(latLng.latitude,latLng.longitude);
        forNavigation = location;

       //  animation
        mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        // Zoom in the Google Map
        mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
       // mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mPositionMarker.getPosition(), 15));
        mMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(location
                .getLatitude(), location.getLongitude())));

These are the links which i found Google map: moving marker and map together smoothly along with user?

How to smoothly keep moving current location marker in Google Maps v2 android

Community
  • 1
  • 1
hasan_shaikh
  • 1,434
  • 1
  • 15
  • 38

1 Answers1

-1

here is two solution you have.

  1. Use onlocationtrue then it show you blue dot as your current location.

  2. Use fused api for current location and create you marker in locationchanged.

for fused api you can check from here.

thanks

Community
  • 1
  • 1
Saveen
  • 4,120
  • 14
  • 38
  • 41