Mapbox - 实现油漆不透明度的三种状态
我试图在以下情况下有 3 种不透明度状态:
- Clicked = Opacity: 0.8
- Hover = Opacity: 0.6
- Default = Opacity: 0.4
到目前为止我有这个代码:
'paint': {
'fill-color': '#627BC1',
'fill-opacity': [
'case',
['boolean', ['feature-state', 'hover'], false],
0.6,
0.4
]
}
但是鉴于它是布尔值,有人可以帮助我理解如何制作这是一个具有三个状态而不是两个状态的数组吗?
这是一个可用的示例:
https://codepen.io/hiven/pen/NWwBXJj
James
I am trying to have 3 states of opacity for the following situation:
- Clicked = Opacity: 0.8
- Hover = Opacity: 0.6
- Default = Opacity: 0.4
I have this code so far:
'paint': {
'fill-color': '#627BC1',
'fill-opacity': [
'case',
['boolean', ['feature-state', 'hover'], false],
0.6,
0.4
]
}
However given it's boolean, can someone help me understand how I can make this into an array with three states rather than 2?
Here is a useable example:
https://codepen.io/hiven/pen/NWwBXJj
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够执行类似以下操作
然后您只需根据需要设置“mystate”...
默认值为
0.4
这样您就可以支持任意数量的状态,每个状态都有自己的值- 而不是简单的布尔“真/假”
You should be able to do something like the following
Then you would just set "mystate" as required...
With the default being
0.4
This way you can support an arbitrary number states, each with their own value - rather than a simple Boolean "true/false"