Geocoder Gem Ruby

时间:2016-01-12 19:17:01

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

如果我插入一个coords到Geocoder,例如Lat:88,Lng:88,响应将为零。这是正确的

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 

有没有办法确定它是否真的与零地址或API /互联网问题有关?

1 个答案:

答案 0 :(得分:1)

查看Geocoder's github readme

错误处理部分
Geocoder.configure(:always_raise => :all)

是您正在寻找的。