2013-04-05 35 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