In my page, latitude, longitude and info window content are present in an array of objects named obj.
So if I need the latitude of property of the 1st object, I can
Should get you a long way.
function attachMarker( data ) {
var latLng = new google.maps.LatLng( data.latitude, data.longitude );
var marker = new google.maps.Marker({
position : latLng,
map : map, // global variable?
icon : prevIcon // global variable?
});
google.maps.event.addListener(marker, 'mouseover', function() {
infowindow.setContent( data.text );
infowindow.open(map, this);
});
// add marker here.
}
// afaik, you only need 1 instance of InfoWindow if you only change content.
var infowindow = new google.maps.InfoWindow();
var i = obj.length;
while ( i-- ) {
attachMarker( obj[ i ] );
}
BGerrissen's comment above helped a lot.
I managed to achieve function closure on the info variable.
The following Google Groups post explains how to.
https://groups.google.com/group/google-maps-api-for-flash/browse_thread/thread/befeb9bf2d1ebcc9
Thanks everyone :)