gpt4 book ai didi

ios - 如何在 swift 中从 zipCode 获取坐标

转载 作者:行者123 更新时间:2023-11-30 11:29:46 25 4
gpt4 key购买 nike

我试图从邮政编码获取坐标,但出现错误

{ "error_message" = "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 0.0.0.0., with empty referer"; results = ( ); status = "REQUEST_DENIED"; }

这是我的代码:

public func getLocationFromAddress(zipCode : String) -> CLLocationCoordinate2D {
let lat : Double = 0.0
let lon : Double = 0.0
let strUrl = "https://maps.googleapis.com/maps/api/geocode/json?address=\(zipCode)&key=\(Global.kGoogleApiKey.strPlaceAPIKey)&sensor=false"
let escapedString = strUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

AFAPIMaster.sharedAPIMaster.getLatLongCallApi_Completion(strGetURL:escapedString!,params: nil, showLoader: true, enableInteraction: false, viewObj:self.view, onSuccess: { (result) in
if let Dict = result as? NSDictionary {
print(Dict)
}
}, onFailure: { })
return CLLocationCoordinate2D(latitude: lat, longitude: lon)
}

最佳答案

您必须使用捆绑 ID 为您的移动应用程序创建 Api_key 才能使用该地理编码

关于ios - 如何在 swift 中从 zipCode 获取坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50368331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com