Hi, I tried to follow your suggestion but withou success. You can look the "infoWindowArray[this.id] is undefined" error at http://thebit.altervista.org/maps/testAddMarker5_web_new.php if you try to click over a marker.
I think I will utilise another solution I have found by searching in this group: I put loadedMarker.infoWindow = new google.maps.InfoWindow( intead of infoWindowArray[this.id] = new google.maps.InfoWindow( AND this.infoWindow.open(map,this); intead of infoWindowArray[this.id].open(map, this); and it works. So, I have another problem: when I open more markers, the previous which are opened does not closed. Why? Thanks. On 22 Mar, 21:39, chinhua kong <[email protected]> wrote: > Sorry that I couldn't spend time to test on page. Here is a few suggestions. > > 1. The var infowindowArray should be defined at global level (Same as where > you defines marker). Else event can't recognized it. > 2. The i value is not recognized when the event is fired. One of the > solution is let the marker remember it. You can add an id parameter in > marker and access it in the event listener such as following: > > var loadedMarker = new google.maps.Marker( > { > id: i, > position: new > google.maps.LatLng(loadCoordinates[i]['lat'], > loadCoordinates[i]['lng']), > map: map, > title: > loadCoordinates[i]['name'] > > }); > > Then edit the listener function as following > > google.maps.event.addListener(loadedMarker, 'click', function() > { > > infowindowArray[this.id].open(map,this); > > }); > > > I will suggest you to change you design. Let the marker hold the infowindow > and don't depend on the infowindowarray. If there is a request to remove an > marker, you can request the marker to clean its infowindow. > > > > On Tue, Mar 22, 2011 at 4:04 PM, thebit <[email protected]> wrote: > > I'm sorry but I don't understand your answer: > > >Are you try to manage it in future? > > Yes, because in the future I will give the possibility to delete each > > marker by click onto a button near each marker. > > > > Your solution is right for the above error but not really effiecient for > > the > > > infowindow[i]. You try to make infowindow as an array which I don't > > > understand your purpose. > > > What is a valid solution? > > I tried to create an array by writing: > > var infowindowArray = new Array(); > > > and in the "for" I put infowindowArray[i] but it appears an error (see > > the link > >http://www.google.com/url?sa=D&q=http://thebit.altervista.org/maps/te... > > ). > > I'm not sure to have understand what I must to do. > > > -- > > 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. > > -- > Best and Regards, > Chin Hua Kong -- 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.
