简体   繁体   中英

Remove Poly line between two pints in MKMapView

I need to hide the poly line between the two points. In my project I Use the MKMap View with Transport Details (Like: car, Bike, Walking). The Main Functionality is "When the user click the car direction button the poly line is draw the car route between the two points and if the user click walking means draw the line between the two points and hide the poly line in car route". This is the condition.

I draw the poly line in all routes but, i don't know how to hide the poly line which is based on above functionality. I tried some of things to hide the poly line but it did.t work to me like "remove over lay".

Here is my drawing poly line functionality Code:

-(void)showRoute:(MKDirectionsResponse *)response
{
     for (MKRoute *route in response.routes)
     {
    [self.kioskDir_mapView
     addOverlay:route.polyline level:MKOverlayLevelAboveLabels];

    for (MKRouteStep *step in route.steps)
    {
        NSLog(@"%@", step.instructions);
    }
}
  }

 - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay
    {
     MKPolylineRenderer *renderer =
    [[MKPolylineRenderer alloc] initWithOverlay:overlay];
     renderer.strokeColor = [UIColor greenColor];
     renderer.lineWidth = 3.0;

      self.kioskDir_mapView.visibleMapRect = [self.kioskDir_mapView           mapRectThatFits:overlay.boundingMapRect];

return renderer;
      }

在这里,我附上了屏幕截图。显示的是两行汽车路线和步行路线。我想隐藏汽车路线。

Here i need to hide poly line if already draw line in map view. Can any one help me on this. Thanks.

Delete the Following line from the MKOverlayRenderer delegate.

" self.kioskDir_mapView.visibleMapRect = [self.kioskDir_mapView mapRectThatFits:overlay.boundingMapRect]; "

delete this line it works fine.

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