harhouf
harhouf

Reputation: 117

accuracy circle around the marker

I am working in android mapping application that’s used Osmdroid mapping API until now I am being able to show the map and the user location in the map , but how I can show the accuracy circle around the marker and is that can be testing in the emulator only.{I need some examples or tutorials on that }

Upvotes: 0

Views: 2226

Answers (2)

Ali Behzadian Nejad
Ali Behzadian Nejad

Reputation: 9044

Extend Overlay class and create a class and name it AccuracyIndicatorCircleOverlay (for example).

public class AccuracyIndicatorCircleOverlay extends Overlay {
}

Now override the draw method:

public void draw(Canvas canvas, MapView mapView, boolean shadow) {
   super.draw(canvas, mapView, shadow);
   // Now you can use getAccuracy() method of android.location.Location
   // to draw a circle based on your requirements.
}

Upvotes: 1

MikeIsrael
MikeIsrael

Reputation: 2889

I'm not familiar with osmdroid, but assuming you have access to the location data (specifically the accuracy) I would say just change out the image based on the accuracy. When you get a new location if the accuracy is different than previous then reset the image used for the user location. Seems to be the easiest solution assuming you get location updates.

If you are looking to add an overlay to a mapview here is a answer on SO where they used an overlay to create a radius according to accuracy.

Upvotes: 0

Related Questions