I am try to remove travelled polyline from google maps but can't find any proper solution on internet. I've drawn polyline by this,
let origin = "\(24.96487181552221),\(67.06045475052892)" //add worker lat long here
let destination = "\(24.96485719),\(67.06699558)" //add job(customer) lat long here
let url = "https://maps.googleapis.com/maps/api/directions/json?origin=\(origin)&destination=\(destination)&mode=driving&key=[Google-API-Key]"
Alamofire.request(url).responseJSON { response in
do{
let json = try JSON(data: response.data!)
let routes = json["routes"].arrayValue
for route in routes
{
let routeOverviewPolyline = route["overview_polyline"].dictionary
let points = routeOverviewPolyline?["points"]?.stringValue
self.path = GMSPath.init(fromEncodedPath: points!)
self.polyline = GMSPolyline(path: self.path)
self.polyline?.strokeColor = UIColor(hexString: "19C90E")
self.polyline?.strokeWidth = 3.0
self.polyline?.map = self.mapView
}
}
catch let error {
print(error)
}
}
here polyline is a GMSPolyline which i want to remove as user travel through it's path.