list - Mapbox - 如何为一个属性设置多个值并独立过滤它们
问题描述
我正在使用 Mapbox API 上传带有公司数据的 Tileset。对于每家公司,我都有 2 个可能具有多个值的字段(部门和标签),例如:
Company name: Acme
Sectors: IT, SmartTech
Tags: digital, smart, application
这些字段的值是我的 GeoJSON 字段中的一个数组,并嵌套在 Properties 节点下,但是它们作为一个字符串而不是该属性的单个值被导入,所以如果我想根据 Sectors 在我的地图上设置一个过滤器只显示 IT 公司,Acme 不会显示,因为它的 Sectors 属性是:["IT", "Engineering"]
这是我的 GeoJSON 结构:
{
"type":"FeatureCollection",
"features":[
{
"id":45543000000218192,
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
1.475,
52.796
]
},
"properties":{
"Company":"Acme",
"Website":"",
"Sectors":[
"SmartTech",
"IT"
],
"Tags":[
"digital",
"smart",
"application"
]
}
}
]
}
这就是我的 Mapbox 样式过滤器的样子:
解决方案
Glen,我最终不得不为我的每个属性创建每个扇区和标签的单独值,然后使用数字 (1) 和 (0) 标记它们,具体取决于该扇区/标签是否适用于该属性。这样我就可以在 Mapbox 中应用我需要的过滤器。
{
"type":"FeatureCollection",
"features":[
{
"id":45543000000218192,
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
1.475,
52.796
]
},
"properties":{
"Company":"Acme",
"Website":"",
"Sector - SmartTech": 0,
"Sector - IT": 1,
"Tag - Digital": 0,
"Tag - Smart": 1,
"Tag - Apps": 1
}
}
]
}
推荐阅读
- java - Jsonserialised 日期转换为 android 日期格式的问题
- javascript - 在 Google 自定义搜索栏仍然不可见时添加“正在加载...”消息,然后在该消息已经可见时将其删除
- java - 从 AEM DAM 下载资产
- php - 在 Woocommerce 产品小部件的特色产品价格下添加自定义文本
- asp.net-mvc - ASP.NET Core 中使用 Novell.Directory.Ldap.NETStandard2_0 的受限用户(登录工作站)的 LDAP 身份验证问题
- javascript - 使用ajax从coovachilli注销
- java - 如何在 Java 禁用字段上启用复制和剪切操作
- javascript - Vue.js - 为什么根元素不能有 v-for 并且需要 div 包装器
- widget - 如何从事件访问 appmaker 页面上的另一个小部件
- sql-server - 如何使模型字段在 sql server 2017 起始值 1990 中自动递增并使用存储过程递增 1