【问题标题】:Geocoder Gem Ruby地理编码器宝石红宝石
【发布时间】:2016-01-12 19:17:01
【问题描述】:

如果我将坐标插入地理编码器,例如 Lat:88, Lng:88,则响应将为 nil。这是正确的

2.2.3 :001 > Geocoder.address([88, 88])
Geocoder: HTTP request being made for https://maps.googleapis.com/maps/api/geocode/json?key=&language=en&latlng=88%2C88&sensor=false
 => nil 

但是,如果我超过了每日或每秒请求的查询限制,或者没有互联网连接,则响应也将为零,......让我们说像纽约这样的真实坐标(lat:40.7127, lng:-74.0059 )

2.2.3 :002 > Geocoder.address([40.7127, -74])
Geocoder: HTTP request being made for https://maps.googleapis.com/maps/api/geocode/json?key=&language=en&latlng=40.7127%2C-74&sensor=false
Geocoding API connection cannot be established.
 => nil 

有没有办法确定它是带有 nil 地址的真实坐标还是 API/Internet 问题?

【问题讨论】:

    标签: ruby google-maps reverse-geocoding rails-geocoder


    【解决方案1】:

    查看Geocoder's github readme错误处理部分

    Geocoder.configure(:always_raise => :all)
    

    就是你要找的。​​p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-14
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多