>  google.maps.event.addListener(markers, 'click', function() {
>         infowindow.setContent(contentString);
>         infowindow.open(map,markers);
>         });
>   }
> Anyone have an Idea why it doesnt work.

"markers" is an array.

You need to work with individual marker objects, so this is needed:
  marker = new google.maps.Marker({...})
as you had before.

It should be "var marker" to ensure that it's a local variable. While
"var" is optional, leaving it out can have unforeseen consequences.

Once you have created your marker and have a reference to it (in the
variable "marker"), you can add your event listener to it and push it
on to the array:
  google.maps.event.addListener(marker, 'click', function() {...});
  markers.push(marker);

What you're doing at the moment is not retaining a reference to each
individual marker.

There are other ways to make it work, for example by adding the
listener to the marker in the array, but it's far easier to keep
dealing with identifiable individual markers and then push each one on
to the array by itself.

Please do bear in mind that although your code snippets seem to have
been enough in this case, that won't necessarily be so and a link to
your map page is always to be preferred. Which is why the posting
guidelines ask for one.

-- 
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.

Reply via email to