地理编码器 Gem Ruby

Geocoder Gem Ruby

如果我将坐标插入 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,液化天然气:-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/Internet 问题?

查看Geocoder's github readme

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

就是您要找的。