Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps iOS Remove Polylines

Is it possible to remove all Polylines without removing other objects?

[mapView clear]; removes everything including markers

I also tried the following but it didn't work either..

for (GMSPolyline __strong *polyline in self.mapView.subviews) {
    polyline = nil;
}

Thanks in advance

PS : I am using Google Maps SDK for iOS version: 1.7.2.7908

like image 208
Tim Tuffley Avatar asked May 01 '14 08:05

Tim Tuffley


2 Answers

When you add the polylines you should add them to your own collection. Then when you need to remove them, loop over your own collection and set each polyline's .map property to nil (which removes it from the map).

like image 114
Saxon Druce Avatar answered Sep 28 '22 08:09

Saxon Druce


You have to do

[self.polyline setMap:nil];

, that will remove the line from the map.

like image 35
Rajan Twanabashu Avatar answered Sep 28 '22 10:09

Rajan Twanabashu