MKCircle - 笔划宽度相当于米
我有一个 MKCircle。我希望能够将笔划宽度设置为等于米而不是点。这样我就可以绘制一个覆盖图,其半径以米为单位,笔画宽度以米为单位。
据我所知,每当地图缩放时,点与米的关系就会发生变化。我现在的注释计数非常低 (1),因此如果我能找到一种方法来计算给定地图状态下一米距离的所需笔划宽度(以点为单位),则在缩放时删除并读取它应该没问题。
I have a MKCircle. I would like to be able to set a stroke width equivilant to meters not points. So that I can draw an overlay with both radius in meters of a stroke width in meters.
I understand that the points to meters relationship changes whenever the map is zoomed. I have a very low annotation count (1) right now so removing and readding it on zoom should be OK if I can figure out a way to calculate the desired stroke width in points for a meter distance at a given map state.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先要考虑的是您是否真的想这样做:如果用户缩小,线条可能会变得看不见。
我能看到的唯一方法是使用
MKCooperativeRegionMakeWithDistance
然后使用 MKMapView 的convertRegion:toRectToView:
将其转换为 CGRect,从中可以读出宽度/高度以计算适当的线宽。The first thing to consider is whether you really want to do this: the line could wind up being invisibly thin if the user zooms out.
The only way I can see to do it is to create an appropriately-sized MKCoordinateRegion using
MKCoordinateRegionMakeWithDistance
and then use MKMapView'sconvertRegion:toRectToView:
to convert it to a CGRect, from which you can read out the width/height to calculate the appropriate line width.