我正在使用mapbox gl js 0.46.0。我利用了setFeatureState API(> = 0.46.0)的优势,该API对于“悬停在某项功能上”(如用例)具有更好的性能。
我已决定对具有两种状态的要素使用单层,一种是“无”,另一种是“已选择”。不幸的是,由于文档和示例不足,我无法完全同步这两种状态的视觉效果。
例如,如果我想具有一个基于缩放级别的线宽属性,并具有停止点,我该如何为相应的“选择”和“无”状态编写这种表达式?
"paint": {
"line-color": [
"match",[ "string", [ "feature-state", "line_color" ], "none" ],
"selected", "hsl(189, 87%, 37%)",
"none", "hsl(189, 87%, 37%)",
"hsl(189, 87%, 37%)"
],
"line-width": [
"match",[ "string", [ "feature-state", "line_width" ], "none" ],
"selected", 4,
"none", 3,
3
],
"line-opacity": [
"match",[ "string", [ "feature-state", "line_opacity" ], "none" ],
"selected", 0.68,
"none", 0.38,
0.38
]
}