I’ve had a look at the previous questions asked but i cannot quite seem to fit this in so here it is:
Basically, I have a Ruby on Rails project and i would like to have a page where the user pin points his location on a google map by adding a marker (only 1 should be permitted) and then store the longitude and latitude within the Ruby on Rails project i am working on.
I would like to know what would be the best approach to this (add map with Javascript?) but then how would i retrieve the latitude and longitude when the user hits a button within ruby on rails?
I would really appreciate any tips / links to relevant sites etc, as working in a ruby on rails environment is pretty new to me and i’m not sure how to go about doing the above.
Thanks a lot in advanced
I think the first step would be to get your views working without a map. Enter lat/long manually so you know your views and controllers are working. Once you reach that point, take a look at the Google Maps API documentation. Add a map to your view, figure out how to add a marker. When you add/remove a marker you can update your lat/long inputs with JavaScript (I would use jQuery personally). At this point you could make the lat/long inputs hidden or read-only – unless there’s a reason for your users to update the lat/long manually.
FYI – Google might suggest using V3 of the Maps API but when I tried using it there were too many missing pieces. I’d stick with V2.