使用 Maps API 的 FusionTableLayer 的动态样式
我在设计 Fusion Layer 时遇到了一些麻烦,我真的会 感谢您的帮助。 我添加了一个默认样式定义为的图层,
layer.set('styles', [{
polygonOptions: {
fillColor: '#FFFFFF',
fillOpacity: 1,
strokeColor: '#000000',
strokeWeight: 1
}
}]);
效果很好。然后为该层设置一个点击监听器。这 故事是这样的:用户单击地图上的某个要素。如果它的 属性等于给定的值(例如在表单中),我想要这个 具有获得与其他颜色不同的填充颜色的功能。
google.maps.event.addListener(okresy,'click', function(ev) {
nazev = ev.row.NAZEV.value;
layer.set("styles", [{
polygonOptions: {
fillColor: '#FFFFFF',
fillOpacity: 1,
strokeColor: '#000000',
strokeWeight: 1
},
where: "'NAZEV' = '"+nazev+"'",
polygonOptions : {
fillColor : '#008C00',
fillOpacity : 1,
strokeColor : '#000000',
strokeWeight : 1
}
}]);
});
所以我所做的是将颜色 #008C00 设置为单击的功能并 我为所有其他功能指定了与开始时相同的样式。 然而,无论我做什么,我都无法使其发挥作用。其余功能 当某些功能处于默认状态时,获取默认的半透明红色 点击。我错过了什么吗? Opera Dragonfly 不会报告任何代码错误,所以我认为语法没问题。
I've run in some trouble styling Fusion Layer and I would really
appreciate your help.
I add a layer with default styling defined as
layer.set('styles', [{
polygonOptions: {
fillColor: '#FFFFFF',
fillOpacity: 1,
strokeColor: '#000000',
strokeWeight: 1
}
}]);
This works fine. Then a click listener is set for this layer. The
story goes like this: user clicks a feature on the map. If its
property equals to the value given (e. g. in the form), I want this
feature to get different fillColor than the rest.
google.maps.event.addListener(okresy,'click', function(ev) {
nazev = ev.row.NAZEV.value;
layer.set("styles", [{
polygonOptions: {
fillColor: '#FFFFFF',
fillOpacity: 1,
strokeColor: '#000000',
strokeWeight: 1
},
where: "'NAZEV' = '"+nazev+"'",
polygonOptions : {
fillColor : '#008C00',
fillOpacity : 1,
strokeColor : '#000000',
strokeWeight : 1
}
}]);
});
So what I do is setting color #008C00 to the feature clicked and to
every other feature I assign the same style as in the beginning.
However, whatever I do, I can't make it work. The rest of the features
gets that default half-transparent red color when some feature is
clicked. Am I missing something? Opera Dragonfly doesn't report any code mistakes, so I suppose the syntax is ok.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哈,问题解决了!我实际上需要更多类似这样的东西:
调试器没有报告任何错误,这就是让我困惑的地方。
Ha, problem solved! I actually needed something more like this:
Debugger didn't report any error though, that's what was confusing me.