Daniel wrote a good post describing how to address this problem. See
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/f40390e4a6ba89e9/25a246d92f93e9ea#25a246d92f93e9ea

Chad Killingsworth

On Mar 11, 3:09 pm, Thai Dang Vu <tdan...@gmail.com> wrote:
> I created 2 infoWindows and 2 markers like this:
>
> x = new google.maps.Marker({
>     clickable: true, draggable: false, map: map,
>     position: new google.maps.LatLng(40.81050, -74.38285), visible: true});
>
> x.setType('t');
> x.setAddress('130 State Route 10, East Hanover, NJ 07936');
> x.setPhone('973-887-3145');
> markers.push(x);
> x.setId(0);
> y = new google.maps.InfoWindow({
>     content: '<div style="float: left;">hic hic hic ' + x.getId() +
>              '</div>' +
>              '<div style="clear: both;"></div>'});
>
> google.maps.event.addListener(x, 'click', function() {
>     y.open(map,x);
>
> });
>
> x = new google.maps.Marker({
>     clickable: true, draggable: false, map: map,
>     position: new google.maps.LatLng(40.86159, -74.49681), visible: true});
>
> x.setType('k');
> x.setAddress('1711 State Route 10 East, Morris Plains, NJ 07950');
> x.setPhone('973-829-0197');
> markers.push(x);
> x.setId(1);
> y = new google.maps.InfoWindow({
>     content: '<div style="float: left;">hic hic hic ' + x.getId() +
>              '</div>' +
>              '<div style="clear: both;"></div>'});
>
> google.maps.event.addListener(x, 'click', function() {
>     y.open(map,x);
>
> });
>
> when I click on the first marker (the one with the id of 0), the infoWindow
> is popped-up, but it points to the 2nd marker and the content of that
> infoWindow is the content of the infoWindow for the 2nd marker.
>
> Did I do anything wrong? If the whole file is needed to see where I'm wrong,
> it's in the attachment.
>
>  index.html
> 7KViewDownload

-- 
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 google-maps-js-api...@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to