rails-geocoder

Geocoder doesn't work on some of the Android phones

落爺英雄遲暮 提交于 2019-12-22 15:01:07
问题 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 {

Validating longitude / latitude with geocoder gem

淺唱寂寞╮ 提交于 2019-12-20 05:49:59
问题 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.

Geocoder: How get all results and order by distance?

北城余情 提交于 2019-12-19 21:54:32
问题 I know how to use the near method to get all results within a certain radius, but how do I get all results and order by distance? I know I could do something like this: Location.near(my_location, 999999, order: 'distance') However, I would rather skip the radius check altogether and simply get all results sorted by distance. 回答1: I have had the same issue, and I ended up adding this scope to my geocoded class: class A extend Geocoder::Model::ActiveRecord reverse_geocoded_by :latitude,

geocoding api not responding fast enough for IP address

℡╲_俬逩灬. 提交于 2019-12-18 09:25:55
问题 In my production server I've used the Geocoder gem. But, the following code not working in the server console. Geocoder.search("192.168.1.4") I've configured my geocoder.rb file with timeout 30 seconds. But still it gives the error geocoding api not responding fast enough Surprisingly, whenever i ran Geocoder.search("San Francisco, CA") it gives the result within seconds. What should i do? 回答1: I think it is an issue with freegeoip, try the following: Enter this in your rails console:

Method of getting current location from IP address in Rails (geocoder and gmaps4rails gems)

谁说胖子不能爱 提交于 2019-12-13 20:39:42
问题 I have an app which allows users to post Offers based on address they choose. I would like to add the option of saving the address based on the user's current location, determined by the IP address. I'm using the ruby Geocoder gem. This code will pass but it is not saving any address to the db. I'm not sure if it's an issue with my approach or if it is not working because of the development environment. I know that other features of Geocoder e.g. distance calculations don't work in

Google maps - setting it up to work with Rails 5 - geocoder not geocoding

别等时光非礼了梦想. 提交于 2019-12-13 17:27:32
问题 I have been trying for 4+ years to try and figure out a way to use google maps in my Rails app. I'm currently trying with Rails 5. I recently posted this cry for help. The suggestions I received haven't worked for me, so I'm trying again now to see if someone else might know something. Rails 5, Gmaps4Rails - setup I have models for organisation and address. The associations are: Organisation has_many :addresses, as: :addressable accepts_nested_attributes_for :addresses, reject_if: :all_blank,

Add distance to a particular latitude/longitude position

荒凉一梦 提交于 2019-12-12 09:22:08
问题 Rails 4 + Postgres. New to geospatial. Happy to accept solutions that involve RGeo, Geokit, Geocoder, or any other gem that helps solve this issue. Model contains two fields latitude and longitude . I have an offset attribute that contains a distance in meters and an orientation attribute that contains one of the 4 cardinal directions (N, E, W, S). Example: offset: 525.5 orientation: W What's a standard way of adding the offset distance to the lat-long position, to give me a new lat-long pair

Setting up Rails Geocoder with Personal API Key

不羁的心 提交于 2019-12-12 02:53:45
问题 Rails Geocoder says not to use Key for Free version, to instead only use the key for Premier. The site i'm maintaining seems to be going over the limit not, so I set up a new api key and enabled billing. I setup my initilizer like so Geocoder.configure( :timeout => 5, :lookup => :google, :api_key => "ENTERED MY KEY HERE", :units => :mi ) I Get a REQUEST DENIED in my logs. When I delete the file it uses geocoders default config and works. But my the morning it will stop working, assuming I'm

Ruby Geocoder nearbys is slow

放肆的年华 提交于 2019-12-11 13:10:35
问题 Using Rails 3.2, Ruby 1.9, geocoder gem. The following query I have in my controller: # 1500+ms to load nearby_shops = (current_shop.nearbys(10, :order => 'overall_rating DESC') .where(:shop_type => shop_type).includes(:photos, :active_property_list => :hotel_image_lists).limit(5)) # SQL Shop Load (4045.6ms) SELECT shops.*, 3958.755864232 * 2 * ASIN(SQRT(POWER( SIN((36.111927 - shops.lat) * PI() / 180 / 2), 2) + COS(36.111927 * PI() / 180) * COS(shops.lat * PI() / 180) * POWER(SIN((-115

Geocoder SQLite3::SQLException: no such column: lon:

时光怂恿深爱的人放手 提交于 2019-12-11 06:38:56
问题 I am trying to use Geocoder I am trying to get results for the following query (I have this in my controller): Event.near([params[:lat].to_f, params[:lng].to_f], params[:radius].to_f, unit: :km) In my model I have: geocoded_by :address, :latitude => :lat, :longitude => :lng after_validation :geocode but I get the following: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: lon: SELECT events.*, (69.09332411348201 * ABS(lat - -33.425329) * 0.7071067811865475) + (59