在 MKMapView 上绘制指定尺寸(以米为单位)的元素
我试图在地图视图上的一个点周围画一个圆圈,我已经成功完成了这一点,但不完全是我想要的方式。 CG 方法总是相对于屏幕尺寸进行绘制,基本上我想以米为单位而不是像素来绘制东西。
有人有这样做的经验吗?
I'm attempting to draw a circle around a point on a mapview, which I have successfully done, but not quite the way I wanted to. The CG methods are always going to be drawing relative to the screen size, and basically I want to draw things in meters, not pixels.
Anyone have experience doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有任何执行您上面描述的操作的经验,但是 MKMapView 类有一组用于将像素与坐标协调一致的方法,反之亦然,您应该能够使用它们将圆映射到地图上的坐标:
http://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/occ/instm/MKMapView/convertCooperative:toPointToView:
此函数可能如果您有中心点、圆的半径(以米为单位)和方位角(以度为单位),那么在找到圆直径上的点以与上述功能一起使用时也很方便。
I don't have any experience doing what you describe above, but the MKMapView class has a set of methods for concerting Pixels to Coordinates and vice versa that you should be able to use to map your circle to Coordinates on the Map:
http://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/occ/instm/MKMapView/convertCoordinate:toPointToView:
This function may also come in handy for finding a point on the diamater of your circle to use with the above functions, providing you have your center point, the radius in meter of the circle, and the bearing in degrees.