处理多个多边形对象 [英] Handling Multiple Polygon Object
问题描述
示例代码:
for(var i = 0; i < multipleFlights.length; i ++)
{
google.maps.event.addListener(multipleFlights [i],'click',arrayfn); // $(multipleFlights [i])。click(function(){alert('x');});
}
如何获取中的当前多边形对象? arrayfn
函数。
预先感谢
这是一个常见的问题,至少有两种解决方案:
-
函数闭包(带有一个像createClickablePoly )将InfoWindow内容与Polygon相关联) - 示例
-
包含由click监听器函数访问的InfoWindow内容的成员变量。
Am trying to add/remove multiple polygon on the google map. On clicking each polygon, I have to show some info window for the corresponding polygon. On clicking the polygon, I couldn't maintain the polygon object.
Sample code:
for (var i = 0; i < multipleFlights.length; i++)
{
google.maps.event.addListener(multipleFlights[i], 'click', arrayfn); // $(multipleFlights[i]).click(function () { alert('x'); });
}
How can I get the current polygon object in the arrayfn
function .
Thanks in advance
This is a common problem, there are at least two solutions:
function closure (with a function like createClickablePoly() to associate the InfoWindow contents with the Polygon) - example
member variable containing the InfoWindow content accessed by the click listener function.
这篇关于处理多个多边形对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!