Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Google Maps V3上触发标记的onclick事件?_Javascript_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 如何在Google Maps V3上触发标记的onclick事件?

Javascript 如何在Google Maps V3上触发标记的onclick事件?,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,如何从地图外部触发Google地图上标记的onclick事件 我使用API的版本3。我看过很多关于版本2的教程,但在版本3中找不到 我有一个全局数组(命名标记),包含地图的所有标记(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

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

我使用API的版本3。我看过很多关于版本2的教程,但在版本3中找不到

我有一个全局数组(命名标记),包含地图的所有标记(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');

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

我找到了解决办法!感谢Firebug;)

对于未来的谷歌人来说, 如果触发后出现类似于下面的错误,请单击多边形

"Uncaught TypeError: Cannot read property 'vertex' of undefined"
然后尝试下面的代码

google.maps.event.trigger(polygon, "click", {});

单击正在触发,但在我的情况下,信息窗口没有调整到地图,它稍微减少了一点。@Saboor Awan尝试问一个关于这个问题的具体问题,因为注释不是解决这个问题的最佳方式。对v3执行此操作会给我
TypeError:a在main.js中没有定义(第16行,第894列)
这是什么原因?@invot在没有看到代码的情况下真的帮不上忙,但我在快速搜索时发现有人有同样的问题。。。尝试使用像素(px)而不是百分比(%)设置CSS中的“popupMapIn”宽度和高度。此解决方案在群集标记(组标记之一)情况下不起作用。请分享你的建议,如果你有。谢谢,你救了我一个晚上。我为此挣扎了3个小时!非常感谢。
google.maps.event.trigger(polygon, "click", {});