enable integration with geocoder for mongo using reverse internal array format [lng,lat] #263

Closed
wants to merge 6 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

kristianmandrup commented Sep 7, 2012

Essential improvement for mongo geocoder integration! as requested in an issue... ;)

I appreciate your help on the gem but I don't understand why you make different modifications in one pull request.

Actually, your modifications on lib/gmaps4rails/helper/gmaps4rails_helper.rb seem to make it unusable (as far as I've read it, it's buggy) and I don't understand why you need this kind of functionnality.

I was playing around a bit. Just some ideas. I felt the partials were much more natural as simple view helpers (i.e avoid complex decision logic such as case + if/else in a view).

I had a use case where I needed the google map apis loaded for my gmaps-autocomplete gem. I felt it was easier to reuse/leverage the existing functionality you had created to load scripts for google apis, but I needed it without rendering the map.
I'm aware it was far from being an optimal pull request.

Contributor

kristianmandrup commented Oct 12, 2012

Some experimentations for loading options from a yaml file. Not yet tested

nengine commented Nov 2, 2012

I have the same problem when use with Geocoder. Array for lng, lat is reversed so map is not displaying properly. How can I fix this? thanks

Contributor

kristianmandrup commented Nov 2, 2012

Look at my fork and latest pull requests ;)

nengine commented Nov 2, 2012

Thanks @kristianmandrup, Please let me know anyway that I could do that functionality by overwriting methods + options in the code. I do not know how to make changes in the gem! Thanks a alot.

nengine commented Nov 2, 2012

In the original gem, I notice :lat_column => args[:lat] || "latitude", :lng_column => args[:lng] || "longitude", options. Is that something I could use to integrate with geocoder?

nengine commented Nov 2, 2012

I made the changes and passed the options but still getting in reverse order. In this case, lat is 40.7519846 and lng is -73.9697795 and this is how it is stored in location field. But when I do User.all.to_gmaps4rails they are still coming in reverse order.

  acts_as_gmappable :lat_lng_array => :location, :process_geocoding => false , :pos_order => [:lat, :lng ]
  field :location, :type => Array
  field :gmaps, :type => Boolean

  geocoded_by :address , :coordinates => :location
  after_validation :perform_geocoding

u.location
[-73.9697795, 40.7519846]

User.all.to_gmaps4rails
"[{"lat":-73.9697795,"lng":40.7519846},{"lat":-73.8477874,"lng":40.7209975}]"

Contributor

kristianmandrup commented Nov 3, 2012

If you use my fork you should be able to run a spec that at least demonstrates that the Array can be stored in either: [lat,lng] or [lng, lat] format. Not sure about the to_gmaps4rails method, but should be easy to use the same config option to customize that functionality as well to return in the format you want.

nengine commented Nov 3, 2012

Thanks for your reply. now I can call User.all.to_gmaps4rails and getting lat, lng in the order I wanted. But getting error when it is rendering the view.

NoMethodError in Home#index

Showing C:/Users/nash/crisis/app/views/home/index.html.erb where line #4 raised:

undefined method `config' for Gmaps4rails:Module
Extracted source (around line #4):

1:

Home#index


2:

Find me in app/views/home/index.html.erb


3:
4: <%= gmaps4rails(@json) %>

should be <%= gmaps(@json) %> I believe.

Contributor

kristianmandrup commented Jan 10, 2013

@neuralnw did you make a pull request with the changes to master? Would also be nice with a full example in the Wiki demonstrating how to configure this I think.

Owner

apneadiving commented Oct 22, 2013

Sorry guys I've completely changed the gem in v2.

No more geocoding!

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment