rails-geocoder

Problems implementing ruby geocoder using Sinatra

谁说胖子不能爱 提交于 2019-12-11 02:05:11
问题 According to the ruby geocoder documentation (rubygeocoder.com), it's possible to use the geocoder gem with a Sinatra app, but I'm running into issues getting it to work and haven't been able to find any working examples or related stackoverflow issues either. I think the problem is due to the fact that it's a Sinatra app and not a full rails app. My Gemfile: source "https://rubygems.org" ruby '2.1.2' gem 'dotenv', '~> 0.10.0' gem 'pg', '~> 0.17.1' gem 'rack-flash3' gem "sinatra" gem

Geocoder Gem not working in Production Environment

微笑、不失礼 提交于 2019-12-10 20:14:38
问题 So I am using Geocoder to pull in latitude and longitude coordinates based on an address provided by a user when submitting a form. I am doing this so that I can plot markers using the Google Maps API. This works perfectly in development - zero issues. When I push to production however, the latitude and longitude are not generated by Geocoder. I have checked my production logs and there are zero errors. I also checked to make sure that the gem is not just installed for development and I have

Geocoder Gem - getting “Reserved” for request.location.country (even in Local!)

让人想犯罪 __ 提交于 2019-12-09 01:01:36
I need to be able to see locally the output of geocoder countries and cities for a message like 'Hi, Yu are in {country detected}. To be able to use geocoder in local/dev mode,I have followed some SO advice and put: in config/environment/development.rb class ActionDispatch::Request def remote_ip "84.34.156.155" # fake ip for example end end and in application_controller def lookup_ip_location if Rails.env.development? Geocoder.search(request.remote_ip).first else request.location end end on my homepage if I put: You are in <%= request.location.country %> it displays locally "you are in

Geocoder Gem - getting “Reserved” for request.location.country (even in Local!)

点点圈 提交于 2019-12-08 04:32:44
问题 I need to be able to see locally the output of geocoder countries and cities for a message like 'Hi, Yu are in {country detected}. To be able to use geocoder in local/dev mode,I have followed some SO advice and put: in config/environment/development.rb class ActionDispatch::Request def remote_ip "84.34.156.155" # fake ip for example end end and in application_controller def lookup_ip_location if Rails.env.development? Geocoder.search(request.remote_ip).first else request.location end end on

Geocoder doesn't work on some of the Android phones

若如初见. 提交于 2019-12-06 05:29:45
I am working on Android application which allows user to enter the address and converts to latitude and longitude for further use. I am using following code to get lat and long addresses = geocoder.getFromLocationName("11381 zapata ave san diego", 1); if (addresses.size() > 0) { double latitude = addresses.get(0).getLatitude(); double longitude = addresses.get(0).getLongitude(); addGeoFence(latitude, longitude); tlFragmentMap.setLatLong(new LatLng(latitude, longitude)); return true; } else { return false; } This Geocoder works fine on some of the phones only. Can any one suggest me a way to

Can Ruby Geocoder return just the street name on reverse_geocode calls?

倖福魔咒の 提交于 2019-12-05 13:06:35
The geocoder gem will automatically reverse geocode on save if the line after_validation :reverse_geocode is included in the model. This results in a long string of text being saved as the address, though - the format is something like "Street Name, City Name, County Name, State Name, Zip Code, Country Name". I'm only interested in the street name for this particular project, so I'm wondering if there's a way to modify the after_validation call to only save that information. If I do the reverse geocoding manually, I can access the road value in the result: place = Place.first result = Geocoder

Ruby On Rails - Geocoder - Near with condition

落爺英雄遲暮 提交于 2019-12-04 14:10:32
问题 I'm using GeoCoder in my application. Now I need to search for objects in my database which are close to a position OR have specific attribute set. I would like to perform this action in one database query, because the database is realy huge. I would like to have something like Spot.near([lat,long],distance).where("visited = ?",true). The distance and the visited attribute should be combined with an OR, not with an AND. Does anyone have an idea how to do this? Thank you! 回答1: Based off of

error in request.location ruby geocoder

梦想的初衷 提交于 2019-12-04 12:12:15
In my sesions table I'm storing country and city name using the request method, now, in ubuntu server it works well but in redhat I am getting this error NoMethodError (undefined method `city' for nil:NilClass) I have tried this issue solution and I restarted my server but it doesn't work for me. In both servers I am using Passenger + Apache I have found the issue, it was that the search IP was taking too much time, so I created an initializer and changed the default timeout config/initializer/geocoder.rb Geocoder.configure( :timeout => 20 ) How I found I open the rails c and search my IP $

Does Geocoder gem work with google API key?

北城余情 提交于 2019-12-03 16:36:54
问题 I am using ruby geocoder gem for my project and as the project is growing I am starting to look into connecting to the Google API key. After adding this to the project: Geocoder.configure do |config| # geocoding service (see below for supported options): config.lookup = :google # to use an API key: config.api_key = 'my_key' # geocoding service request timeout, in seconds (default 3): config.timeout = 5 end I get Google Geocoding API error: request denied. when I start the application. From

Validating longitude / latitude with geocoder gem

半世苍凉 提交于 2019-12-02 08:52:29
I followed this Geocoder Railscast & I'm playing around with it to see if I can add validation to the longitude & latitude coordinates returned by the Geocoder Gem incase the user inputs a faulty address that does not return any longitude & latitude coordinates. I was able to get this working to a point with the code below but when I enter a correct address it gives the user a validation error the first time they submit the form, even though longitude & latitude coordinates where returned. The second time the user submits the form it works. I suspect this is happening as when the user submits