Unable to remove previous polyline from last search

Refresh

1 weeks ago

Views

9 time

0

I have a slight problem, I am unable to remove the previous polyline created from the previous search.

I have looked at google documentation​ but i am unable to find the right answers.

let routes = json["routes"].arrayValue   
for route in routes
        {

            let routeOverviewPolyline = route["overview_polyline"].dictionary
            print("routesOVER:",routeOverviewPolyline)
            let points = routeOverviewPolyline?["points"]?.stringValue


            let path = GMSPath.init(fromEncodedPath: points!)


            let polyline = GMSPolyline(path: path)
            if polyline != nil {
            print(polyline)
            polyline.strokeColor = .black
            polyline.strokeWidth = 10.0
            polyline.map = self.googleMaps
            }

        }
        }
        catch let error as NSError {
            print(error)
        }

in the google maps, 2 polylines are shown. 1 from the previous search and another from the current search

Google Maps Image

1 answers

0

Вы можете очистить MAPview перед нанесением на новую полилинию на карте.

self.googleMaps.clear()

Но выше код будет ясно штырьков на карте, а также. ваш придется перерисовывать свои контакты на карте, а также