I have now resolved the problem: var cbFun = objTMref.openInfoBox.bind( objTMref ); google.maps.event.addListener(objTMref.marker, 'click', cbFun );
Thank you, On Sep 27, 2:37 pm, Sy <simonaplat...@googlemail.com> wrote: > Hi, > > I am trying to display a context sensitve infoBox when a marker is > clicked on and for some reason I am having problems getting it to > work. > > In my example I have two markers, each marker has a different icon and > I add a listener for the click with: > > google.maps.event.addListener(objTMref.marker, > 'click', > function() { > objTMref.openInfoBox(); > }); > > I think the problem is the objTMref is set to an instance of an > object, but it changes after the first call, so when the second > addListener occurs I think the reference changes and therefore all > listeners point to the same openInfoBox routine. > > How can I ensure that each callback remains intact? I could be > potentially adding hundreds of callbacks. > > Thank you, -- 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-v3@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.