The example I was using in the Google Playground was just to try and
figure out how to get the functionality to work correctly. I need to
trigger the event because in the actual code I have 3 maps and need to
trigger the click event on a different map than the one that has the
marker.

I just read briefly about function closures and I think I have an idea
of what is going on. If I create a function outside of the outer
function(addMarkers) is there any way to know which marker was clicked
on?

I thought that the click event for markers only sent a Event as a
parameter?

On Dec 22, 2:56 pm, Rossko <[email protected]> wrote:
> >           new google.maps.event.addListener( marker, 'click', function(e) {
> >             new google.maps.event.trigger( map, 'click' );
>
> Why try to trigger a map event ; just replace with code to do what you
> want directly (pan to the marker's location) ?
>
> > The problem with that is it will assign the last marker's position to every
> > event object an the result is no matter the marker you click on
>
> That will be due to not getting function closure on the 'marker'
> variable ; there are many threads about this usually manifesting as
> "all infowindows are the same"
> See this 
> examplehttp://code.google.com/apis/maps/documentation/javascript/examples/ev...
> the important feature is removing the listener creation to a seperate
> function, which allows for function closure on the content.  It's not
> an easy concept.

-- 
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