Skip to content

Instantly share code, notes, and snippets.

@DavidQL
Created June 2, 2011 17:12
Show Gist options
  • Save DavidQL/1004836 to your computer and use it in GitHub Desktop.
Save DavidQL/1004836 to your computer and use it in GitHub Desktop.
googlemap.dropMarker = function($element) {
var myLatlng = new google.maps.LatLng($element.data('lat'),$element.data('long')),
marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: $element.data('name')
}),
infowindow = new google.maps.InfoWindow({
content: $element.data('name') + '<br/>' + $element.data('address')
});
// gather all info windows so you can close them when opening a new one.
googlemap.infowindows.push(infowindow);
google.maps.event.addListener(marker, 'click', function() {
_.each(googlemap.infowindows,function(infowindow) {
infowindow.close();
});
infowindow.open(map, marker);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment