如何仅从 CLLocation 中获取纬度和经度值,而不是在 swift 中获取完整的位置详细信息
How to take only Latitude and Longitude values from CLLocation instead of taking full location details in swift
我正在尝试从 cllocation 中获取纬度和经度值。它即将提供完整的位置数据。因为我只需要纬度和经度数据来发送我的后端。我必须向服务器发送多个纬度和经度数据。
即使我尝试使用 CLLocationCoordinate2D,但是,它在发送到服务器时在数据中使用 CLLocationCoordinate。
I want to take in single array both latitude and longitude, not in two
arrays.
Can anyone suggest me, how to take only latitude and longitude values
to append to array in swift?
这是我的代码
var myLocations: [CLLocation] = []
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
myLocations.append(locations[0] as CLLocation)
}
output is
<+10.92088132,+77.56955708> +/- 1414.00m (speed -1.00 mps / course -1.00) @ 22/03/18, 1:17:30 PM India Standard Time
[<+10.92088132,+77.56955708> +/- 1414.00m (speed -1.00 mps / course -1.00) @ 22/03/18, 1:17:30 PM India Standard Time]
你可以试试
let loc = myLocations.last
let lat = currentLocation.coordinate.latitude
let lon = currentLocation.coordinate.longitude
然后像这样声明arr
var myLocations: [String] = []
let last = locations[0] as CLLocation
myLocations.append("\(last.coordinate.latitude),\(last.coordinate.longitude)")
var location = CLLocation()
location = myLocations.last! as CLLocation
let lat = location.coordinate.latitude
let longit = location.coordinate.longitude
我正在尝试从 cllocation 中获取纬度和经度值。它即将提供完整的位置数据。因为我只需要纬度和经度数据来发送我的后端。我必须向服务器发送多个纬度和经度数据。
即使我尝试使用 CLLocationCoordinate2D,但是,它在发送到服务器时在数据中使用 CLLocationCoordinate。
I want to take in single array both latitude and longitude, not in two arrays.
Can anyone suggest me, how to take only latitude and longitude values to append to array in swift?
这是我的代码
var myLocations: [CLLocation] = []
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
myLocations.append(locations[0] as CLLocation)
}
output is
<+10.92088132,+77.56955708> +/- 1414.00m (speed -1.00 mps / course -1.00) @ 22/03/18, 1:17:30 PM India Standard Time
[<+10.92088132,+77.56955708> +/- 1414.00m (speed -1.00 mps / course -1.00) @ 22/03/18, 1:17:30 PM India Standard Time]
你可以试试
let loc = myLocations.last
let lat = currentLocation.coordinate.latitude
let lon = currentLocation.coordinate.longitude
然后像这样声明arr
var myLocations: [String] = []
let last = locations[0] as CLLocation
myLocations.append("\(last.coordinate.latitude),\(last.coordinate.longitude)")
var location = CLLocation()
location = myLocations.last! as CLLocation
let lat = location.coordinate.latitude
let longit = location.coordinate.longitude