【问题标题】:Search via Geocoder gem with an existing google placeId for a location通过 Geocoder gem 使用现有的 google placeId 搜索位置
【发布时间】:2018-01-17 10:53:25
【问题描述】:

我正在尝试使用现有的 google PlaceId 搜索位置。

在文档中引用它来传递参数: google_place_id:真

require 'geocoder'

Geocoder.search("ChIJLU7jZClu5kcR4PcOOO6p3I0", params: {google_place_id: true})

https://github.com/alexreisner/geocoder#google-google

但是,搜索只返回空数组。

【问题讨论】:

标签: google-geocoding-api rails-geocoder


【解决方案1】:

尝试删除 params 关键字:

Geocoder.search("ChIJLU7jZClu5kcR4PcOOO6p3I0", { google_place_id: true })

【讨论】:

    【解决方案2】:

    Geocoder 使用了很多 api。谷歌不是它的默认值。此外,您还需要一个 API 密钥。 设置 API_KEY:

    Geocoder.configure api_key: your API_KEY
    

    现在可以搜索了

    Geocoder.search(some_places_id, lookup: :google_places_details)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多