How can I get the polygon object in google maps, when a path changed?

非 Y 不嫁゛ 提交于 2019-12-06 01:03:27

Meanwhile I came up with a simple solution. Define a global array for the polygons:

var polygonArray = [];

When creating the polygons, push them into that array:

polygonArray.push(polygon);

And add an event listener like this:

google.maps.event.addListener(path, "set_at", function(){
    for (i in polygonArray) {
        if (polygonArray[i].getPath() == this) {
            alert('Got it'); //polygonArray[i]
        }
    }
});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!