Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make 161 meter / 528ft circles on with OSMDROID?

I'm using OsmDroid on OpenStreetMaps and can make markers and polylines, but I can't find any examples on how I'd make 161m/528ft circles around a marker.

a) How do I make circles?
b) How do I make them 161m/528ft in size?

like image 946
Rocologo Avatar asked Jan 10 '23 17:01

Rocologo


1 Answers

Thanks to MKer, I got an idea on how to solve the problem and made this piece of code, which works:

oPolygon = new org.osmdroid.bonuspack.overlays.Polygon(this);
final double radius = 161;
ArrayList<GeoPoint> circlePoints = new ArrayList<GeoPoint>();
for (float f = 0; f < 360; f += 1){
    circlePoints.add(new GeoPoint(latitude , longitude ).destinationPoint(radius, f));
}
oPolygon.setPoints(circlePoints);
oMap.getOverlays().add(oPolygon);`

I know this can be optimized. I'm drawing 360 points, no matter what the zoom is!

Black 161meter circle made with Omsdroid on OpenStreetMap

like image 195
Rocologo Avatar answered Jan 28 '23 15:01

Rocologo