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.

有帮助吗?

解决方案

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];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top