问题
I used this to be able to view one address at a time. Convert address to coordinates swift
However, I would like to view an array of addresses (131) and their respective coordinates
Here is my code:
func convertAddressToCoordinates() {
for address in addresses {
geocoder.geocodeAddressString(address) { placemarks, error in
let placemark = placemarks?.first
let lat = placemark?.location!.coordinate.latitude
let lon = placemark?.location!.coordinate.longitude
print("\(address): Lat: \(lat!), Lon: \(lon!)")
}
}
}
As you can see, it grabs the placemarks first coordinate; anyway to grab all placemarks?
来源:https://stackoverflow.com/questions/61846291/convert-multiple-addresses-to-coordinates-in-swift-ios