有没有更新MKPolyline坐标的方法?

see*_*eek 6 mkmapview ios mkpolyline swift

有没有更好的方法来更新MKPolyline坐标,而不是删除和添加新的叠加到mapView?

var a:[CLLocationCoordinate2D] = []  
var testline = MKPolyline()
var coords1 = CLLocationCoordinate2D(latitude: 52.167894, longitude: 17.077399)
var coords2 = CLLocationCoordinate2D(latitude: 52.168776, longitude: 17.081326)
var coords3 = CLLocationCoordinate2D(latitude: 52.167921, longitude: 17.083730)
var testcoords:[CLLocationCoordinate2D] = [coords1,coords2]
testline = MKPolyline(coordinates: &testcoords, count: testcoords.count)
self.mapView.addOverlay(testline)

self.mapView.removeOverlay(testline)
testcoords = [coords1,coords2,coords3]
testline = MKPolyline(coordinates: &testcoords, count: testcoords.count)
self.mapView.addOverlay(testline)
Run Code Online (Sandbox Code Playgroud)