mapbox - Mapbox如何编写带有停止的图层绘制属性以便它可以支持特征状态?
问题描述
我正在使用 mapbox gl js 0.46.0。我利用了 setFeatureState API(>=0.46.0) 的优势,它对于像用例这样的“悬停在功能上”具有更好的性能。
我决定对具有两种状态的功能使用单层,一种是“无”,另一种是“选择”。不幸的是,由于文档和示例不足,我无法完全同步这两种状态的视觉效果。
例如,如果我想拥有一个基于缩放级别的带有停止的线宽属性,我该如何为相应的“选定”和“无”状态编写这种表达式?
"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
]
}
解决方案
推荐阅读
- r - 如何在 R 中存储具有当前日期/Sys.Date() 的文件?
- python - 如何使用 OpenCV 在视频上绘制 matplotlib 图
- mongodb - 执行文件删除操作的最佳位置在哪里?
- amazon-web-services - 将 asp.net 核心 API 部署到 AWS 导致环境不响应错误
- r - 是否可以用 dplyr 计算条件 cumsum
- javascript - 使用 Firebase 绘制 Python Django 的基于时间的图
- java - 然后在抽象类的具体方法中不使用注入模拟时的 Mockito
- javascript - AdaptiveCards 可扩展性
- c++ - Arduino 在通过 String 和 sprintf 将浮点数打印到字符串时非常随机地冻结
- javascript - 用 JavaScript 中的另一个嵌套数组数据更新嵌套数组值