title: How to get lat long position of any clicked point on a map? Gmaps4rails
body: <p>Hello i am looking for a way to get the lat,long of any clicked point on a map and have that information stored in an id tag. I am using gmaps4rails v2 and my current code is as follows:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    var handler2 = Gmaps.build('Google');
    handler2.buildMap({ provider: { }, internal: {id: 'map'}}, function(){
        // I assume this is the way you retrieve the amrkers array
        var json_data = &lt;%=raw @hash.to_json %&gt;;
        var markers = handler2.addMarkers(json_data);
  
        _.each(json_data, function(json, index){
            var marker  = markers[index];
            json.marker = marker;
            google.maps.event.addListener(handler2.map, 'click', function( event ){
                var latlong = document.getElementById("latlong");
                latlong.innerHTML =( "Latitude: "+event.latLng.lat()+" "+", longitude: "+event.latLng.lng() );
            });
  
        });
        handler2.bounds.extendWith(markers);
        handler2.getMap().setZoom(1);
  
    });
  &lt;/script&gt;
  
  &lt;div id="latlong"&gt;
  This is the lat long of the currently clicked point.
  &lt;/div&gt;
  </code></pre>
  
  <p>The issue is that no matter where i click on the map the listener is not responding and i am not getting any result in my id tag "latlong". any help is appreciated thank you.</p>