作者:漫路细雨中_575 | 来源:互联网 | 2023-05-25 11:55
Ivegotaradiusandalocation.我有一个半径和一个位置。ThisishowImtryingtogettheboundingrectangle
I've got a radius and a location.
我有一个半径和一个位置。
This is how I'm trying to get the bounding rectangle of the circle.
这就是我想要得到圆的边界矩形的方法。
- (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(...)
seems to want width and height measured in Map points. How do I convert the radius to that?
MKMapRectMake(…)似乎想要用映射点测量宽度和高度。如何把半径转换成这个?
In the end I'm rendering it like this:
最后我把它画成这样:
MKMapRect theMapRect = [self.overlay boundingMapRect];
CGRect theRect = [self rectForMapRect:theMapRect];
CGContextAddEllipseInRect(ctx, theRect);
CGContextFillPath(ctx);
The radius doesn't seem to equal meters on the map in the end and also the distance doesn't seem to be measured correctly. How to do it right?
在地图上,半径似乎不等于米,而且距离似乎也没有被正确测量。怎么做才对呢?
I would be really thankful for every hint.
我会感激每一个暗示。
2 个解决方案