【发布时间】:2017-07-26 21:05:18
【问题描述】:
我有多边形、多多边形和带有孔的多边形。他们都工作正常。我们目前正在放置一个图钉(标记),然后当有人选择不同的多边形时移动标记。 [编辑:有数百个多边形,所以像下面的答案那样手动重新设置它们是不切实际的]
我们想要的是用填充颜色替换标记。当有人单击多边形时,我可以轻松更改 fillColor - 这不是问题。当有人单击不同的多边形时,我遇到的问题是试图清除该填充颜色。
这是一个包含许多文件的大型项目......但相关部分在这里:
//building is the polygon
building.addListener('click', function() {
// We've been using markers, can we can easily move them.
setMarker(map, this.center, true);
// Want to use this instead. This works fine to color the polygon but...
this.setOptions({
fillColor: 'orange'
});
// I need some function, likely to be called here that clears any other polygon that has been change to 'orange'.
// I was looking at map.data.revertStyle(); but this doesn't work at this level.
});
为了清楚起见,如果有人再次单击多边形,有很多示例如何重置多边形。这很容易做到。我想在单击不同的多边形时重置,就像移动标记功能的工作原理一样。
谢谢
【问题讨论】:
标签: javascript google-maps google-maps-api-3