to get the accuracy in fix meter just use
float accuracy = lm.getLastKnownLocation(best).getAccuracy();
* note: best is an Criteria object
and to draw the Radius, just use this Overlay class, which extend an Overlay Class, and then add it to a MapOverlay
package com.bopbi.component;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Paint.Style;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;
public class SourceOverlay extends Overlay {
private GeoPoint sourcePoint;
private float accuracy;
public SourceOverlay() {
super();
}
public void setSource(GeoPoint geoPoint, float accuracy) {
sourcePoint = geoPoint;
this.accuracy = accuracy;
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, false);
Projection projection = mapView.getProjection();
Point center = new Point();
int radius = (int) (projection.metersToEquatorPixels(accuracy));
projection.toPixels(sourcePoint, center);
Paint accuracyPaint = new Paint();
accuracyPaint.setAntiAlias(true);
accuracyPaint.setStrokeWidth(2.0f);
accuracyPaint.setColor(0xff6666ff);
accuracyPaint.setStyle(Style.STROKE);
canvas.drawCircle(center.x, center.y, radius, accuracyPaint);
accuracyPaint.setColor(0x186666ff);
accuracyPaint.setStyle(Style.FILL);
canvas.drawCircle(center.x, center.y, radius, accuracyPaint);
}
}
* note: dont forget to use the setSource() method, before add it to a MapOverlay
I have a question about this – doesn’t the default behavior of a GeoPoint already have a accuracy radius circle shown around the point?
The only issue is that if you use a custom marker, the accuracy circle does not appear. Is your tutorial for this case?
yes, that is why i create this tutorial
Ok, thanks! I have been using it and it works great.