NOTE: I\'m using v3 of the Google Maps API
I\'m trying to add an info window to each marker I put on the map. Currently I\'m doing this with the following code:
The add_marker still has a closure issue, cause it uses the marker variable outside the google.maps.event.addListener scope.
A better implementation would be:
function add_marker(racer_id, point, note) {
var marker = new google.maps.Marker({map: map, position: point, clickable: true});
marker.note = note;
google.maps.event.addListener(marker, 'click', function() {
info_window.content = this.note;
info_window.open(this.getMap(), this);
});
return marker;
}
I also used the map from the marker, this way you don't need to pass the google map object, you probably want to use the map where the marker belongs to anyway.