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 <
ros...@culzean.clara.co.uk> 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...