2013-04-05 89 views
0

我在MKOverlayView子类中绘制了一个圆。我有一个以米为单位的半径。如何将所述计量表转换为用于绘制drawMapRect的点(以该缩放比例):zoomScale:inContext:?iOS MapKit - 每米点数

回答

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]; 
+0

类型直列 - 没有保证......但多数民众赞成的方法 – 2013-04-05 14:46:21

+0

我会接受这个,因为这是一个好的答案。我认为我遇到的问题是无关紧要的。 – SeruK 2013-05-27 12:44:21