MKMapView overlay Polyline is drawn on top of road label
Asked Answered
D

1

5

I am making the navigation application by drawing a direction between 2 points. I successfully archive the functionality.

But the direction line is drawn on top of the road label and that label cannot be read as show in the picture below.

enter image description here

this is my code to draw overlay

- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
    MKPolylineView *overlayView = [[MKPolylineView alloc] initWithPolyline:overlay];
    overlayView.lineWidth = 10.0f;
    //overlayView.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.5f];
    overlayView.strokeColor = [UIColor redColor];
    return overlayView;
}

I can overcome this with a transparent line but it is not the efficient way.

The best way is to draw the line between the map layer and label layer of MKMapView but i don't know how can i archive that.

So any help please. Thanks.

Dunson answered 26/11, 2013 at 10:26 Comment(0)
A
9

Assuming you are writing this for iOS maps (not google maps as you tagged the question) and using iOS 7 then when you add the overlay to the map view you have the option of defining which level it is on addOverlay:level:. The levels are defined in the MKMapView class reference

[theMapView addOverlay:theOverlay level:MKOverlayLevelAboveRoads];
Aila answered 26/11, 2013 at 20:59 Comment(4)
do we have any way to specify the overlay level on ios6Dunson
No, that function was only added in iOS 7.Aila
@Aila Could you check out my overlay question too #20559091Colver
Sorry Gavin, I can't help with that one. I think Incanus is probably right.Aila

© 2022 - 2024 — McMap. All rights reserved.