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

前端 未结 3 1405
忘掉有多难
忘掉有多难 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条回答
  •  旧时难觅i
    2020-12-21 15:40

    Solution:

    1. create polyline: teaching polyline by GoogleMapsAPIs
    2. create variable oldPolylineArr/oldPolyline type GMSPolyline/GMSPolyline_Array
    3. store the polyline to the oldPolyline
    4. remove the polyline

    Sample Coding:

    //Step 1:
    var mapView = GMSMapView()
    let path = GMSMutablePath()
    path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
    path.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0))
    path.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2))
    path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2))
    path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
    let rectangle = GMSPolyline(path: path)
    
    //Step 2:
    var oldPolylineArr = [GMSPolyline]()
    

    Array

    //Step 3:
    oldPolyline.append(rectangle)
    
    //Step 4:
    for p in (0 ..< oldPolylineArr.count) {
        oldPolylineArr[p].map = nil
    }
    

    is NOT Array

    //Step 3:
    oldPolyline = polyline
    
    //Step 4:
    oldPolyline.map = nil
    

提交回复
热议问题