Elambaruthi
Elambaruthi

Reputation: 31

How to delete a polyline in Mapbox iOS SDK?

I can do it in Google Maps by using

polyline.map = nil 

and

mapView.clear() 

but I cannot find any relevant methods.

Upvotes: 3

Views: 1652

Answers (2)

Paras Gorasiya
Paras Gorasiya

Reputation: 1351

Here is a category extension method for MGLMapView that I am using. Its just like Google Maps SDK, so its easier to use anywhere in your project.

- (void)clear {
    if (self.annotations.count > 0) {
        NSArray *annotations = self.annotations;
        [self removeAnnotations:annotations];
    }
}

You can use it like

[self.mapView clear];

Upvotes: 0

Hayden
Hayden

Reputation: 1870

You can call mapView.removeAnnotation(polyline)

Where mapView is your MGLMapView and polyline is a MGLPolyline.

You will probably need to keep track of your polylines, how you do that is up to you (array, dictionary, etc)

Here is the documentation for MGLMapView if you need it

Upvotes: 5

Related Questions