Search code examples
google-mapsgoogle-maps-api-2android-maps-v2

Android maps api v2 Circles


Not sure what is going on here, but I want it to make an additional circle every second as the device moves. All it does is make 1 circle. I want the circles to highlight the route I have taken. Recommendations? Thanks

LocationManager locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria cr = new Criteria();
String provider = locationmanager.getBestProvider(cr, true);
Location location = locationmanager.getLastKnownLocation(provider);

locationmanager.requestLocationUpdates(provider, 1000, 0, (LocationListener) this);




CircleOptions circleOptions = new CircleOptions()
.center(new LatLng(location.getLatitude(), location.getLongitude()));
circleOptions.radius(3.048); // In meters


mMap.addCircle(circleOptions);

Solution

  • Put:

    CircleOptions circleOptions = new CircleOptions()
            .center(new LatLng(location.getLatitude(), location.getLongitude()));
    circleOptions.radius(3.048); // In meters
    
    mMap.addCircle(circleOptions);
    

    inside onLocationChanged(Location location) callback.