如何在MapKit中获得可见的叠加层? (即来自Mapkit Ivew的MKOverlay/MKOverlayRender) [英] how to get visible overlays in MapKit? (i.e. MKOverlay/MKOverlayRender from a Mapkit Ivew)

查看:83
本文介绍了如何在MapKit中获得可见的叠加层? (即来自Mapkit Ivew的MKOverlay/MKOverlayRender)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从MapkitView获取当前可见的叠加层列表(数组)?

How does one get a list (array) of currently visible overlay from a MapkitView?

背景-例如,我想在我的mapkitview上向某些叠加层类型的中心显示方向箭头,但是如何获得可见的?我看似乎没有办法做到这一点?那么,我是否需要遍历所有覆盖图(实际上是8000个左右),并自己检查一下屏幕上将显示的内容?如果MapKit在决定在给定时间需要显示哪些叠加层的过程中已经有效地做到了这一点,这似乎是一种浪费.

Background - for example I want to show direction arrows to the center of certain Overlay types on my mapkitview, however how do I get the visible ones? There seems to be no way to do this I can see? So do I need to got through all overlays (actually ~8000) and do my own check to see what would be showing on the screen? Seems a waste if MapKit would have already effectively done this as part of deciding what overlays need to be displayed at a given time.

推荐答案

我一直在修补一些类似的问题,由于MKOverlay实现了,所以我能想到的最有效的方法是也将叠加层添加为注释. MKAnnotation.这样您就可以对当前显示的mapRect使用annotationsInMapRect了.但是,这也将返回任何常规的MKAnnotations,并且仅使用覆盖层的计算中间值.仅据我所知,唯一获得覆盖的方法是在每个覆盖上进行迭代并使用:

I've been tinkering with some similar problems and the most efficient way I could figure out was to add the overlays as annotations as well, since MKOverlay implements MKAnnotation. Then you would be able to use annotationsInMapRect for the currently displayed mapRect. However this would also return any regular MKAnnotations, and only uses the calculated middle of the overlay. The only way (so far as I figured) to only get the overlays would be to iterate over each overlay and use:

-(BOOL)intersectsMapRect:(MKMapRect)mapRect;

当前可见的mapRect上的

. 如果您找到另一种方式,我很乐意听到!

on the currently visible mapRect. If you found another way I'd be happy to hear!

这篇关于如何在MapKit中获得可见的叠加层? (即来自Mapkit Ivew的MKOverlay/MKOverlayRender)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆