Issue
Let's say I have a point like lat:41.01522 and lon:28.95221. I need to calculate X latx and lonx so that these points create a circle (evenly distrubuted) around this point with a given radius.
any idea how?
Solution
This is how I'm doing it:
@Override
public void draw(Canvas canvas, MapView mapview, boolean shadow) {
super.draw(canvas, mapview, shadow);
if(location != null){
//---translate the GeoPoint with center to screen pixels---
screenPts = new Point();
mapview.getProjection().toPixels(new GeoPoint((int)(location.getLatitude()*1E6),(int)(location.getLongitude()*1E6)) , screenPts);
//Draw accuracy marker
GeoPoint g0 = mapview.getProjection().fromPixels(0, screenPts.y);
GeoPoint g1 = mapview.getProjection().fromPixels(width, screenPts.y);
l0.setLatitude(g0.getLatitudeE6()/1E6);
l0.setLongitude(g0.getLongitudeE6()/1E6);
l1.setLatitude(g1.getLatitudeE6()/1E6);
l1.setLongitude(g1.getLongitudeE6()/1E6);
float d01=l0.distanceTo(l1);
int size=(int)(location.getAccuracy() * width / d01);
canvas.drawCircle(screenPts.x, screenPts.y, size, paintAccuracyFill);
canvas.drawCircle(screenPts.x, screenPts.y, size, paintAccuracyStroke);
}
}
Good luck, Luis
Answered By - Luis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.