How to get visible overlays in MapKit? (i.e. MKOverlay / MKOverlayRender from Mapkit Ivew)

How to get a list (array) of the current visible overlay from MapkitView?

Background - for example, I want to show directional arrows in the center of certain Overlay types on my mapkitview, however how can I get visible? There seems to be no way to do this, I see? So I need to go through all the overlays (actually ~ 8000) and make my own check in order to see what will be displayed on the screen? It seems like a waste if MapKit could already do this as part of a decision about which labels should be displayed at a given time.

0
source share
1 answer

I dealt with some similar problems, and the most effective way I could find was to add overlays in the form of annotations, since MKOverlay implements MKAnnotation . You can then use annotationsInMapRect for the currently displayed mapRect. However, this will also return any normal MKAnnotations and will only use the calculated midpoint overlay. The only way (as I understand it) to get only overlays would be to iterate over each overlay and use:

 -(BOOL)intersectsMapRect:(MKMapRect)mapRect; 

on the current visible map. If you could find another way, I would be happy to hear!

+1
source

All Articles