我有一個半徑和位置。如何覆蓋iOS地圖上的圓形
這就是我想如何獲得圓的邊界矩形。
- (MKMapRect)boundingMapRect{
CLLocationCoordinate2D tmp;
MKCoordinateSpan radiusSpan = MKCoordinateRegionMakeWithDistance(self.coordinate, 0, self.radius).span;
tmp.latitude = self.coordinate.latitude - radiusSpan.longitudeDelta;
tmp.longitude = self.coordinate.longitude - radiusSpanSpan.longitudeDelta;
MKMapPoint upperLeft = MKMapPointForCoordinate(tmp);
MKMapRect bounds = MKMapRectMake(upperLeft.x, upperLeft.y, self.radius * 2, self.radius * 2);
return bounds;
}
MKMapRectMake(...)
似乎要在地圖點測量寬度和高度。我如何將半徑轉換爲?
最終,我呈現這樣的:
MKMapRect theMapRect = [self.overlay boundingMapRect];
CGRect theRect = [self rectForMapRect:theMapRect];
CGContextAddEllipseInRect(ctx, theRect);
CGContextFillPath(ctx);
半徑似乎並不等於米到底在地圖上,也似乎距離並沒有被正確地測量。如何做到這一點?
我會很感激每一個提示。
謝謝,正是我在找的:) – kadrian 2013-05-08 09:05:29
沒問題。樂於幫助! – 2013-05-08 18:12:03
謝謝。它的工作很好。 – Raja 2017-04-28 14:20:41