I can do it in Google Maps by using
polyline.map = nil
and
mapView.clear()
but I cannot find any relevant methods.
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 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];
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.