一切看起来都很好。API 密钥隐藏在日志中。
请注意,使用reverseGeocoder(with: query)
方法您需要符合TTReverseGeocoderDelegate
协议才能获得结果。只需添加几行代码即可轻松完成:
import TomTomOnlineSDKSearch
import TomTomOnlineSDKRouting
class MainViewController: UIViewController, TTReverseGeocoderDelegate {
(...)
let tomtomRGeoAPI = TTReverseGeocoder()
func reverseGeocoder(_ reverseGeocoder: TTReverseGeocoder, completedWith response: TTReverseGeocoderResponse) {
NSLog("success")
}
func reverseGeocoder(_ reverseGeocoder: TTReverseGeocoder, failedWithError error: TTResponseError) {
NSLog("error")
}
override func viewDidLoad() {
super.viewDidLoad()
self.tomtomRevGeoAPI.delegate = self
var coordinate = CLLocationCoordinate2D()
coordinate.latitude = 54.966682
coordinate.longitude = -7.730234
let query = TTReverseGeocoderQueryBuilder.create(with: coordinate).withReturnSpeedLimit(true)
.build()
self.tomtomRevGeoAPI.reverseGeocoder(with: query)
}
(...)
问候, 马特乌斯