我想在地图视图中显示实时跟踪。我在单独的阵列中有纬度和经度列表...如何在地图中显示这一点..请任何人帮助这个问题。
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!)
{
let location = locations.last as! CLLocation
let location1 = locations.first as! CLLocation
// Have to get OldLocation And New Location From API
let oldCoordinates = location.coordinate
let newCoordinates = location1.coordinate
var area = [oldCoordinates, newCoordinates]
let polyline = MKPolyline(coordinates: &area, count: area.count)
mapView.add(polyline)
self.currentCLLocation = CLLocationCoordinate2D(latitude: newCoordinates.latitude, longitude: newCoordinates.longitude)
let region = MKCoordinateRegion(center: self.currentCLLocation, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
self.mapView.setRegion(region, animated: true)
print("Location Update Details")
print(location.coordinate.latitude)
print(location.coordinate.longitude)
self.mapView.delegate = self
let annotation = MKPointAnnotation()
annotation.coordinate = location1.coordinate
self.mapView.addAnnotation(annotation)
}
数组中的值:
Latitudes Array==>>
["12.988415", "12.988445", "12.988492", "12.988558", "12.988673", "12.988788", "12.988903", "12.989039"]
Longitudes Array==>>
["80.218386", "80.21839199999999", "80.218422", "80.218461", "80.218515", "80.218547", "80.21860100000001"]