Convert Multiple Addresses to Coordinates in Swift - IOS

僤鯓⒐⒋嵵緔 提交于 2020-06-01 05:12:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!