我正在尝试从zipcode获取坐标,但收到错误
{ “error_message”=“此IP,站点或移动应用程序无权使用此API密钥。从IP地址收到请求 0.0.0.0。,空引用“; 结果=( ); 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)
}
答案 0 :(得分:0)
您必须为您的移动应用程序创建一个Api_key,其捆绑ID才能使用该地理编码