1

我在 MKOverlayView 子类中画了一个圆圈。我有一个以米为单位的半径。我如何将所述米转换为点(在该缩放比例下)以在 drawMapRect:zoomScale:inContext: 中绘图?

4

1 回答 1

3

见标题:

帮手:

 // 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];
于 2013-04-05T14:40:10.927 回答