简体   繁体   中英

MKPolyline overlap

I have two trails(Blue and Red in color, say) (MKPolyline) overlays which I add to my MapView using the addOverlay method. Then, I have defined the viewForOverlay method and the trails get loaded fine onto the map. But the problem is I want the blue one to be on the top of the red one but the opposite happens.

How can I get my red trail to get on top of the blue trail when they overlap?

The method mapView:viewForOverlay: was deprecated as of iOS 7.0 see:

https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/MKMapViewDelegate/mapView:viewForOverlay :

The new method to use is mapView:rendererForOverlay: with MKPolylineRenderer objects.

To put your blue overlay on top of your red one, the following method can be used:

insertOverlay:aboveOverlay:

Apple's docs describe the adding and inserting of overlay methods in detail:

https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/index.html#//apple_ref/doc/uid/TP40008205-CH3-SW71

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM