I am implementing an iphone app. i have a map and array of objects that contains the coordinates to be plotted on the map. And a polyline is drawn between these point. So i want to know how to remove this polyline. not Show/Hide, but remove.
here is my code of how i am drawing it
int pointCount = [routeLatitudes count] / 2; //routeLatitudes is the array that contains the coordinates latitude followed by 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 the polylines i created a reference MKOverlayView* overlayView = nil;
overlayView.hidden=false/true;
now i need to know how to remove/delete the drawn polylines.
Thank in advance.
try this
[mapView removeOverlays:mapView.overlays];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With