Out of interest, if I do add click event after click event without
ever using remove, what is actually happening? I still seem to get the
most recently defined infowindow displayed when I click a marker

On Aug 1, 7:32 pm, "[email protected]" <[email protected]>
wrote:
> On Aug 1, 11:16 am, dbrb2 <[email protected]> wrote:
>
> > I looked at that - but it seems that to use it I would need a
> > reference to every listner I added - rather than just saying "remove
> > the listener associated with this marker"
>
> Yes, it does.  How do you expect it to know what you mean?
>
>
>
> > I suppose I could keep a global array of all the listeners I've added
> > and use that to remove them again...
>
> Or you could add a property to the marker that includes a reference to
> the listener, or you could use function closure.
>
>   -- Larry
>
>
>
>
>
> > On Aug 1, 3:35 pm, "[email protected]" <[email protected]>
> > wrote:
>
> > > 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.h...
>
> > > -- 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.

Reply via email to