我目前正在使用Google地图上的Distance Matrix API,并具有以下代码来获取2个目的地之间的距离。但是,当我运行此代码时,出现错误。
func configureRoute(origin:String,destination:String){
let jsonURL = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=place_id:\(origin)&destinations=place_id:\(destination)&key=MYAPIKEY"
guard let url = URL(string: jsonURL ) else {return}
URLSession.shared.dataTask(with: url) { (data, response, err) in
guard let data = data else {return}
let dataAsString = String(data: data, encoding: .utf8)
print(dataAsString)
}.resume()
}
这是我的结果:
Optional("{\n \"destination_addresses\" : [],\n \"error_message\" : \"You have exceeded your daily request quota for this API.\",\n \"origin_addresses\" : [],\n \"rows\" : [],\n \"status\" : \"OVER_QUERY_LIMIT\"\n}\n")
尽管它告诉我我已经超出了API的限制,但我今天进行了3次调用,这是第一次调用的结果。为什么我无法使用API?