I need to get an CLLocation array with only the coordinates, like this:
var locations = [CLLocation(latitude: 38.5, longitude: -120.2),
CLLocation(latitude: 40.7000, longitude: -120.95000),
CLLocation(latitude: 43.25200, longitude: -126.453000)]
I am currently saving every location like so:
var locationArray: [CLLocation] = []
In the didUpdateLocations:
locationArray.append(locations[0] as CLLocation)
But what i am always getting is something like this:
[<-122.02684687,+37.32956209> +/- 0.00m (speed -1.00 mps / course -1.00) @ 10/9/14, 2:12:49 PM Central European Summer Time, <-122.02685248,+37.32959580> +/- 0.00m (speed -1.00 mps / course -1.00) @ 10/9/14, 2:12:49 PM Central European Summer Time, <-122.02685221,+37.32963096> +/- 0.00m (speed -1.00 mps / course -1.00) @ 10/9/14, 2:12:49 PM Central European Summer Time, <-122.02685460,+37.32966692> +/- 0.00m (speed -1.00 mps / course -1.00) @ 10/9/14, 2:12:49 PM Central European Summer Time
I tried converting it to an CLLocationCoordinate2D, but i always get the full location array and never the example above. I also tried something like this:
for (index,element) in enumerate(locationArray) {
var cllocation = CLLocation(latitude: element.coordinate.longitude, longitude: element.coordinate.latitude)
coordinatesArray.append(cllocation)
}
But that also returns the full location array. What i am doing wrong? How can i create a CLLocation array with only the coordinates? If you can point me in the right direction that would be fantastic.
How about:
var locationArray: [CLLocationCoordinate2D] = []
locationArray.append(CLLocationCoordinate2D(latitude: ..., longitude: ...))
CLLocation
contains all the other stuff like course
, altitude
, accuracy...
CLLocationCoordinate2D
just contains latitude and longitude.