我正在尝试寻找Xamarin.iOS像素转换的距离。我知道这是您本机执行的操作,但是如何在Xamarin / C#中执行此操作?

MKCoordinateRegion myRegion = MKCoordinateRegionMakeWithDistance(mapView.centerCoordinate,400,0);

CGRect myRect = [mapView convertRegion:myRegion toRectToView:nil];
NSLog(@“宽度为400m为%f”,myRect.size.width);

任何帮助或指导将不胜感激!谢谢!

最佳答案

对象:

MKCoordinateRegion myRegion = MKCoordinateRegionMakeWithDistance(mapView.centerCoordinate, 400, 0);
CGRect myRect = [mapView convertRegion: myRegion toRectToView: nil];
NSLog(@"width for 400m is %f", myRect.size.width);
Xamarin.iOS转换:
var myRegion = MKCoordinateRegion.FromDistance(mapView.CenterCoordinate, 400, 0);
var myRect = mapView.ConvertRegion(myRegion, null);
Console.WriteLine($"width for 400m is ${myRect.Size.Width}");

07-27 14:03