Is there any method to update MKPolyline coordinates?
Asked Answered
J

0

7

Is there any better method to update MKPolyline coordinates than removing and adding new overlay to 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)
Journalize answered 22/9, 2014 at 11:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.