¿Cómo activar el evento onclick de un marcador en Google Maps V3?


¿Cómo disparo el evento onclick de un marcador en un Google Maps desde fuera del mapa?

Utilizo la versión 3 de la API. He visto muchos tutoriales para la versión 2, pero no puedo encontrar esto para la versión 3.

Tengo una matriz global (llamada marcadores ) que contiene todo el marcador del mapa (google.asignar.Marcador). Ahora quiero hacer algo como:

markers[i].click(); //I know it's not working, but you get the idea...

//Next line seems to be the way in v2, but what's the equivalent in v3?
GEvent.trigger(markers[i], 'click');

Gracias por su ayuda y si necesita más información, hágamelo saber!

Author: AlexV, 2010-04-28

2 answers

He encontrado la solución! Gracias a Firebug;)

//"markers" is an array that I declared which contains all the marker of the map
//"i" is the index of the marker in the array that I want to trigger the OnClick event

//V2 version is:
GEvent.trigger(markers[i], 'click');

//V3 version is:
google.maps.event.trigger(markers[i], 'click');
 318
Author: AlexV,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-09 15:33:45

Para futuros Googlers, Si obtiene un error similar a continuación después de activar, haga clic para un polígono

"Uncaught TypeError: Cannot read property 'vertex' of undefined"

Luego intente el siguiente código

google.maps.event.trigger(polygon, "click", {});
 5
Author: Ergec,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-03-29 13:42:47