On Aug 1, 7:25 am, dbrb2 <[email protected]> wrote: > Ok - I've sorted that problem. I was doing getElementByID, but unless > that ID was open, there was no ID to get - so the javascript was > throwing an error. For the moment I've stuck the getelementbyid into a > try/catch statement, so that the getelementbyid updates the window if > it is open, otherwise the event listner is changed as before. > > Query though: > > I have been changing the event listner by calling: > > google.maps.event.addListener(markerArray[id], 'click', function() > { ....} > > This would seem to mean that after a few itterations, every marker > will have many click listners. Is this the case, and if so, any > thoughts as to how I can replace the listner rather than add another?
Have you tried removeListener? http://code.google.com/apis/maps/documentation/javascript/reference.html#MapsEventListener -- Larry > > Cheers > > On Aug 1, 2:59 pm, dbrb2 <[email protected]> wrote: > > > Hello - seems to be working now. > > > The variable scope was not the problem. I replaced: > > > markerArray[id].setImage(testicon); > > > with > > > var temp = new google.maps.MarkerImage(testicon); > > markerArray[id].setIcon(temp); > > > And all seems to work :-) > > > My only issue now is the infowindow. I can update the markers onclick > > event listner in my ajax callback, so that the next time that marker > > is clicked the infowindow content changes. What would be nice is if I > > can update the infowindow if it is already being displayed at the time > > of the callback. > > > I tried this by putting a div inside the infowindow and using > > getElementByID and innerHTML in the callback, which failed. I'll keep > > trying :-) > > > On Aug 1, 2:23 pm, Rossko <[email protected]> wrote: > > > > > When the ajax call completes, I check the newly received data to see > > > > if the marker needs changing. If it does, I call: > > > > markerArray[id].setImage(testicon); > > > > This will be happening asynchronously, as you are using AJAX ; are you > > > sure 'id' is still in scope in your AJAX callback etc.? -- 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.
