Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapView overlay Polyline is drawn on top of road label

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.

like image 818
SaintTail Avatar asked Nov 26 '13 10:11

SaintTail


1 Answers

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];
like image 110
Craig Avatar answered Oct 05 '22 09:10

Craig