ruby on rails - How to get information from the currently clicked marker in gmaps4rails? -
I am trying to find a way to get information from the currently clicked marker on a map. For example, I want to show the title and description of the currently clicked marker to show on a different page. Any help is appreciated thanks.
You must add the listener to the click:
var handler = Gmaps .build ('Google'); Handler .buildMap ({Provider: {}, Internal: {id: 'map'}}, function () {// I think you'll retrieve amrkers array var json_data = & lt;% = raw @ hash.to_json Are% & gt; marker = handler.edermakers (Jason_data); _Eich (Jason_data, function (jsone, index) {var marker = marker [index]; jsna marker = marker; google.maps.event.addListener ( Marker .getServiceObject (), 'Click', function () {console.log (json); // whatever you want here}};});});
Comments
Post a Comment