Geocoding API's response was not valid JSON. and request.location = nil

前提是你 提交于 2019-12-05 04:16:15
neonmate

config/initalizers/geocoder.rb

Geocoder.configure(
 timeout: 10,
 ip_lookup: :telize   
)

Source: https://github.com/alexreisner/geocoder/issues/777

It seems that you just have no available action points to access to selected geo services. For me it was too small amount of available requests to Google geo services. I just increated it by registering on Google application serivces, and putting into config Google API key. For services, which determine Geo position by IP, it was recommended :telize since it does not have any request quotas currently by previous answerer. I also advice you to see into side of local IP storage to resovle them to Geo position, like :geoip2, and :maxmind_local. So your geoconfig will be like follows:

config/initalizers/geocoder.rb:

Geocoder.configure(                             
  lookup: :google,                                                 
  ip_lookup: :geoip2,                                                              
  maxmind_local: {
    package: :city                
  },                                                       
  geoip2: {
    file: File.join('vendor/share', 'GeoLite2-City.mmdb')
  },             
  google: {                        
    timeout: 20,
    use_https: true,                                                               
    api_key: ENV['GOOGLE_API_KEY']                                                 
  },       
}

NOTE: It seems that :telize service currently isn't properly working, returning: Geocoding API's response was not valid JSON.

Please refer to all options to configure goe services on geocoder's README.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!