# Get lng and lat from Google maps

**URL:** <https://www.ruby-forum.com/t/get-lng-and-lat-from-google-maps/185271>\
**Category:** Rails\
**Created:** [March 17, 2010, 9:05am UTC](https://www.ruby-forum.com/t/get-lng-and-lat-from-google-maps/185271 "2010-03-17T09:05:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammed\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mohammed\_a](https://www.ruby-forum.com/u/mohammed_a)\
**Post date:** [March 17, 2010, 9:05am UTC](https://www.ruby-forum.com/t/get-lng-and-lat-from-google-maps/185271/1 "2010-03-17T09:05:26Z")

</div>

Hi

I am trying to have a google map where the user can click on the map  
and choose a location. After that, I need to save the lng and lat  
chosen by the user from the map into the database using rails. What  
would be the best way to approach that?

---

<div class="post-metadata">

**Author:** ![mohammed\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bcef8e/32.png) [@mohammed\_a](https://www.ruby-forum.com/u/mohammed_a)\
**Post date:** [March 17, 2010, 9:32am UTC](https://www.ruby-forum.com/t/get-lng-and-lat-from-google-maps/185271/2 "2010-03-17T09:32:50Z")

</div>

Use event\_id method

@map.event\_init(@map, :click,  
“function(marker,point) { alert(point);  
}”)

point will give u lat long information.

For information about google maps in rails:  
[http://blog.brijeshshah.com/google-maps-in-ruby-on-rails/](http://blog.brijeshshah.com/google-maps-in-ruby-on-rails/)

Thanks  
Brijesh S.
