如何在Google Maps V3上触发标记的onclick事件? [英] How to trigger the onclick event of a marker on a Google Maps V3?

查看:197
本文介绍了如何在Google Maps V3上触发标记的onclick事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从地图外触发Google地图上的标记的 onclick 事件?

我使用版本3 的API。我已经看到了许多第2版的教程,但是在第3版中找不到这个教程。



我有一个全局数组(名为 markers )包含地图的所有标记(google.maps.Marker)。现在我想做一些事情:

  markers [i] .click(); //我知道这行不通,但是你明白了...... 

//下一行似乎是v2中的方式,但v3中的等价物是什么?
GEvent.trigger(markers [i],'click');

感谢您的帮助,如果您需要更多信息,请告诉我!

解决方案

我找到了解决方案!感谢Firebug;)

  //markers是我声明的数组,其中包含地图$ b的所有标记$ b //i是我想要触发OnClick事件的数组中标记的索引

// V2版本是:
GEvent.trigger(markers [i] ,'点击');

// V3版本是:
google.maps.event.trigger(markers [i],'click');


How do I trigger the onclick event of a marker on a Google Maps from outside the map?

I use version 3 of the API. I've seen many tutorials for version 2, but can't find this for version 3.

I have a global array (named markers) containing all the marker of the map (google.maps.Marker). Now I want do do something like:

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');

Thanks for your help and if you need more info, let me know!

解决方案

I've found out the solution! Thanks to 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');

这篇关于如何在Google Maps V3上触发标记的onclick事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆