NOTE. I am using the v3 Google Maps API.
I am trying to add an info window to every marker that I put on the map. I am currently doing this with the following code:
for (var i in tracks[racer_id].data.points) { values = tracks[racer_id].data.points[i]; point = new google.maps.LatLng(values.lat, values.lng); if (values.qst) { var marker = new google.maps.Marker({map: map, position: point, clickable: true}); tracks[racer_id].markers[i] = marker; var info = new google.maps.InfoWindow({ content: '<b>Speed:</b> ' + values.inst + ' knots' }); tracks[racer_id].info[i] = info; google.maps.event.addListener(marker, 'click', function() { info.open(map, marker); }); } track_coordinates.push(point); bd.extend(point); }
The problem is that when I click on the marker, it just displays the info window for the last marker added. Also, to be clear, the info window appears next to the last marker, not the marker. I would suggest that my problem is in the addListener part, but I am not posting. Any ideas?
javascript google-maps google-maps-api-3
blcArmadillo Jul 01 '10 at 14:13 2010-07-01 14:13
source share