iOS MapKit - 每米点数

时间:2013-04-05 14:34:58

标签: cocoa mkmapview mapkit core-location

我在MKOverlayView子类中绘制一个圆圈。我的半径是米。我如何将所述米转换为点(以缩放比例)以便在drawMapRect中绘图:zoomScale:inContext:?

1 个答案:

答案 0 :(得分:2)

见标题:

助手:

 // Conversion between distances and projected coordinates
 MK_EXTERN CLLocationDistance MKMetersPerMapPointAtLatitude(CLLocationDegrees latitude) NS_AVAILABLE(NA, 4_0);
 MK_EXTERN double MKMapPointsPerMeterAtLatitude(CLLocationDegrees latitude) NS_AVAILABLE(NA, 4_0);

 MK_EXTERN CLLocationDistance MKMetersBetweenMapPoints(MKMapPoint a, MKMapPoint b) NS_AVAILABLE(NA, 4_0);

并从MKOverlayView

 // Convert screen points relative to this view to absolute MKMapPoints
 - (CGPoint)pointForMapPoint:(MKMapPoint)mapPoint;
 - (MKMapPoint)mapPointForPoint:(CGPoint)point;

所以

double ppm = MKMapPointsPerMeterAtLatitude(centerCoordinate.latitude);
MKMapPoint mkptLeftmost = ptCenter.x -= ppm;
CGPoint ptLeftmost  = [self pointForMapPoint:mkptLeftmost];