如何从地图外触发Google地图上标记的 onclick 事件?
我使用API的版本3 。我已经看过很多版本2的教程,但是在版本3中找不到这个。
我有一个全局数组(名为 markers ),其中包含地图的所有标记(google.maps.Marker)。现在我想做一些像:
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');
感谢您的帮助,如果您需要更多信息,请与我们联系!
答案 0 :(得分:324)
我找到了解决方案!感谢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');
答案 1 :(得分:5)
对于未来的Google员工, 如果在触发单击多边形
后出现类似下面的错误google.maps.event.trigger(polygon, "click", {});
然后尝试下面的代码
modeEmbarked = mode(df.Embarked.dropna())