将地址转换为坐标时的准确性

问题描述 投票:0回答:0

我正在使用一项功能来获取用户当前位置与商店位置之间的距离,如果距离大于特定范围,我需要显示一些警报。

为了获取商店位置的坐标,我正在传递商店地址,我担心的是传递地址时坐标是否准确。

如果坐标不准确,请建议任何其他获取坐标的方法。

我用来获取店铺坐标的代码:

var geocoder = CLGeocoder()
    geocoder.geocodeAddressString("shop address") { placemarks, error in
        let placemark = placemarks?.first
        let latitude = placemark?.location?.coordinate.latitude
        let longitude = placemark?.location?.coordinate.longitude
    }
swift core-location clgeocoder
© www.soinside.com 2019 - 2024. All rights reserved.