Delete polylines on Xcode map

I am using iphone application. I have a map and an array of objects that contain the coordinates that should be mapped. A polyline is drawn between this point. So I want to know how to remove this polyline. Do not Show / Hide, but delete.

here is my code of how i draw it

int pointCount = [routeLatitudes count] / 2; // routeLatitudes is an array that contains the latitude of coordinates, and then the longitude.

MKMapPoint* pointArr = malloc(sizeof(MKMapPoint) * pointCount); int pointArrIndex = 0; for (int idx = 0; idx < [routeLatitudes count]; idx=idx+2) { CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude=[[routeLatitudes objectAtIndex:idx] doubleValue]; workingCoordinate.longitude=[[routeLatitudes objectAtIndex:idx+1] doubleValue]; MKMapPoint point = MKMapPointForCoordinate(workingCoordinate); pointArr[pointArrIndex] = point; pointArrIndex++; } // create the polyline based on the array of points. routeLine = [MKPolyline polylineWithPoints:pointArr count:pointCount]; [mapView addOverlay:routeLine]; free(pointArr); 

And to show / hide polylines, I created a link MKOverlayView * overlayView = nil;

overlayView.hidden = false / true;

Now I need to know how to remove / delete the drawn polylines.

Thanks in advance.

+4
source share
1 answer

try it

  [mapView removeOverlays:mapView.overlays]; 
+9
source

Source: https://habr.com/ru/post/1432869/


All Articles