it is pretty simple javascript. if you're going to be working with
arrays you should learn how to use the for loop - it does exactly what
both of your questions have asked (performs the same action/actions on
every member of the array). Your other question is a little trickier
because if you add the infowindow listener in a loop the variables get
overwritten (or that's how I understand it, anyway) but what I've
found easiest is to call a function from within the loop that adds a
listener to each marker, thus avoiding that problem:
var infowindow = new google.maps.InfoWindow();
for (var g = 0; g < flightPlanCoordinates.length; g++) {
var marker = new google.maps.Marker({
position: flightPlanCoordinates[g],
map: map,
});
addList(marker)
}
function addList(marker){
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
infowindow.setContent(marker.getPosition().lat()+","
+marker.getPosition().lng())
});
}
hope that helps
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.