c# in GMap.Net Unable to Amend Circle Method to Project Accurate Circle Polygon on Map

37 Views Asked by At

I would like to create a circle in GMap.Net drawing a polygon. The below method is from the first answer from this question link. To get something that looks like 100m (see image) I need to enter the radius parameter as 0.005. The circle also looks stretched. I think the issue is that the circle calculation is not very accurate due to the curvature of the earth coupled with not knowing the scale of the map. I would correct this but my math's is poor.

enter image description here

private void CreateCircle(PointF point, double radius, int segments)
{
    List<PointLatLng> gpollist = new List<PointLatLng>();

    double seg = Math.PI * 2 / segments;

    for (int i = 0; i < segments; i++)
    {
        double theta = seg * i;
        double a = point.X + Math.Cos(theta) * radius;
        double b = point.Y + Math.Sin(theta) * radius;

        PointLatLng gpoi = new PointLatLng(a, b);

        gpollist.Add(gpoi);
    }
    GMapPolygon gpol = new GMapPolygon(gpollist, "pol");
    GMapOverlay overlayOne = new GMapOverlay("circle");

    overlayOne.Polygons.Add(gpol);
    map.Overlays.Add(overlayOne);
}
0

There are 0 best solutions below