0

I am creating a Maui Map - currently only for Android - with the MapScan class:

MapSpan mapSpan = new(CenterLocation, MapScaleLat, MapScaleLng);

map.MoveToRegion(mapSpan);

If I create a circle of equidistant points from the center it looks like an elipse. The projection of the longitude appears much shorter. Therefore I tried to scale the axes differently but that doesn't seem to work. The code above scales the map equally in both directions. Any hints?

  • This might help: [Draw circle of certain radius on map view in Android](https://stackoverflow.com/questions/6029529/draw-circle-of-certain-radius-on-map-view-in-android) – Liqun Shen-MSFT Mar 20 '23 at 05:55

1 Answers1

1

To create a circle with equal distances from the centre in the MapScan class Maui Android, use the following code:

double radius = 100;
double lat = CenterLocation.Latitude;
double lng = CenterLocation.Longitude;
double d = radius / 3963.189;
for (double x = 0; x <= 360; x += 10) {
    double brng = Math.toRadians(x);
    double latRadians = Math.toRadians(lat);
    double lngRadians = Math.toRadians(lng);
    double lat2 = Math.asin(Math.sin(latRadians) * Math.cos(d) + Math.cos(latRadians) * Math.sin(d) * Math.cos(brng));
    double lng2 = lngRadians + Math.atan2(Math.sin(brng) * Math.sin(d) * Math.cos(latRadians), Math.cos(d) - Math.sin(latRadians) * Math.sin(lat2));
    lat2 = Math.toDegrees(lat2);
    lng2 = Math.toDegrees(lng2);
    // Add the point to the map
}

By using this code, a circle of equally spaced points will be generated from the map's centre. By altering the value of the radius variable, you can change the circle's radius. The centre of your map should be entered in place of the CenterLocation variable. Replace the MapScan class with the one that best fits your map.