Swift 3: How to remove the tracked polyline in Google map

前端 未结 3 1380
忘掉有多难
忘掉有多难 2020-12-21 15:33

I have draw the polylines, but I don\'t no that what coding can remove the tracked polyline in the google map. I\'m trying some coding in below.


this is no wor

3条回答
  •  有刺的猬
    2020-12-21 16:00

    Below is the approach to remove travelled polyline from google map iOS Swift:

    var oldPolyLines = [GMSPolyline]() /* Global Array Variable of your Class */
    

    Put below code where you are parsing routes and getting new polyline from direction API.

    if self.oldPolyLines.count > 0 {
        for polyline in self.oldPolyLines {
            polyline.map = nil
        }
    }
    self.oldPolyLines.append(yourNewPolyline)
    yourNewPolyLine.map = self.mapView
    

提交回复
热议问题