【问题标题】:Google Map nearby API is not working in iosGoogle Map附近的API在ios中不起作用
【发布时间】:2018-01-30 13:24:54
【问题描述】:

当我发布以下 API 时:

let str11 = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"

使用以下参数:

params = ["location":"-33.8670522,151.1957362",
          "radius":"500",
          "name":"harbour",
          "language" : "en-IN",
          "types":"food",
          "key":kMapsAPIKey,
           ]

我遇到了以下问题:

{
    "error_message" = "This service requires an API key.";
    "html_attributions" =     (
    );
    results =     (
    );
    status = "REQUEST_DENIED";
}

【问题讨论】:

    标签: ios swift google-maps google-maps-api-3


    【解决方案1】:

    您需要有一个 API 密钥才能使用此服务,这里有一个获取 API 密钥的链接

    https://developers.google.com/maps/documentation/javascript/get-api-key

    您在参数中使用的密钥不是有效密钥

    【讨论】:

      【解决方案2】:

      在swift 3.0中,试试这个功能找附近的地方

      func nearbysearchWithTypeApiCall(){
               key = "Your_Map_API_Key"
               location = "22.2082,70.3807"
               type = "food"
      
               url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=\(location)&radius=5000&key=\(key)&type=\(type)"
      
              Alamofire.request(url, method: .post, parameters: nil,encoding: JSONEncoding.default, headers: nil).responseJSON {
                  response in
                  switch response.result {
                  case .success:
                      let dicData  = response.result.value as! NSDictionary
                      self.arrData = dicData["results"] as! NSArray
                      print(self.arrData)
                      print(self.arrData.count)
                      break
                  case .failure(let error):
      
                      print(error)
                  }
              }
          }
      

      【讨论】:

        猜你喜欢
        • 2016-07-14
        • 1970-01-01
        • 1970-01-01
        • 2014-09-07
        • 1970-01-01
        • 2014-10-30
        • 2013-07-18
        • 1970-01-01
        • 2016-12-05
        相关资源
        最近更新 更多