ruby on rails - Open & populate infowindow via ajax on "click" with Gmaps4Rails -
i trying populate google map infowindow content partial (via ajax) when map marker clicked.
apneadivings wiki post here has helped: https://github.com/apneadiving/google-maps-for-rails/wiki/adding-an-id-to-markers-and-access-them-later
i have id model instance want retrieve in marker (from source: "marker.json({ :id => user.id })"). cannot figure out how use attach listener markers click action, , put resulting html infowindow.
after create markers:
markers = handler.addmarkers(...); _.each(markers, function(marker){ google.maps.event.addlistener(marker.getserviceobject(), 'click', function(){ $.get(expectedurl) .done(function(data){ //only know how `data` structured var infowindow = new google.maps.infowindow({content: 'content' }); infowindow.open( handler.getmap(), marker.getserviceobject()); }) }) });
Comments
Post a Comment