Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting work with Geocoder gem #126

Open
epireve opened this issue May 22, 2014 · 1 comment
Open

Getting work with Geocoder gem #126

epireve opened this issue May 22, 2014 · 1 comment

Comments

@epireve
Copy link

epireve commented May 22, 2014

I am working on a geolocation app which consume data from Parse.com (which those data imported from JSON previously). Right now I am trying to geocode the address in parse database but couldn't find how to do it.

The issue is, the gem is worked with Mongo(Id/Mapper) and ActiveRecord. I am trying to hit with MongoID but the gem is not supported other than mentioned database driver.

Is there any way to flow the data from MongoId driver through 'ParseResource::Base'? Not sure this is the right question but my intention is get the geocoded recognised the mongoId driver.

Thanks in advanced,
-Fir

@epireve epireve changed the title Getting working with Geocoder gem Getting work with Geocoder gem May 22, 2014
@mafellows
Copy link

@epireve was able to find a simple solution using Geocoder.search("Address").

In the controller where necessary (creating, updating, etc.):

def geocode_address
  location = Geocoder.search("#{@object.address}")
  latitude = location.first.latitude
  longitude = location.first.longitude
  @object.geocode_coordinates(latitude, longitude) 
end

And in the model:

def geocode_coordinates(latitude, longitude)
  self.coordinates = ParseGeoPoint.new latitude: latitude, longitude: longitude
end

Should help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants