mapbox - How to color polygons based on different value ranges and null values in mapbox-gl-js?
问题描述
I'm trying to color polygons based on different value ranges. However, null values display as black. I'm not sure what would be the expression to explicitly say "use white colors for null values".
paint: {
"fill-color": [
"step",
["get", "value"],
"#f1eef6",
100,
"#bdc9e1",
200,
"#74a9cf",
300,
"#2b8cbe",
400,
"#045a8d"
],
"fill-opacity": 1
},
解决方案
一种简单的方法是使用["match"]
并将白色设置为默认颜色。这也捕获了您可能没有想到的任何其他值。
"fill-color": [
"match",
["get", "value"],
"#f1eef6",
100,
"#bdc9e1",
200,
"#74a9cf",
300,
"#2b8cbe",
400,
"#045a8d",
"white"
],
推荐阅读
- javascript - IOS上远离场景根(0,0,0)时的Three.js SkinnedMesh抖动
- sql - 如何按不同的列排序,然后在 SQL Server 中获取偏移行?
- ruby-on-rails - Ruby 出现未定义的方法错误,我不确定我是否完全理解方法是如何为我的插件工作的
- javascript - 在道具集的高阶组件内执行逻辑运算
- javascript - 生成彩票号码 - javascript
- java - 使用 Java Streams 按属性将对象列表组合在一起,并将它们减少为具有另一个属性平均值的新对象列表
- tableau-api - 如何根据维度进行选择性过滤?
- python - 如何在循环中移动到下一个线程之前等待线程完成而不冻结python中的gui
- cloud-foundry - 在 Cloud Foundary 的 ruby 项目中使用较新版本的 nodejs
- c# - 当我在设计器中将控件拖放到 TabPage 上时,它们会弹回原始位置