list - Mapbox - 如何为属性设置多个值并独立过滤它们

标签 list api properties mapbox geojson

我正在使用 Mapbox API 上传包含公司数据的 Tileset。对于每家公司,我有 2 个字段(部门和标签),它们可能具有多个值,例如:

Company name: Acme
Sectors: IT, SmartTech
Tags: digital, smart, application

这些字段的值是我的 GeoJSON 字段中的一个数组,嵌套在 Properties 节点下,但是它们被导入为一个字符串而不是该属性的单个值,所以如果我想在我的 map 上设置一个过滤器基于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 样式过滤器的样子:

enter image description here

最佳答案

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
         }
      }
   ]
}

关于list - Mapbox - 如何为属性设置多个值并独立过滤它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52183518/

相关文章:

javascript - Jquery/Javascript 从具有最高属性值的数组中删除条目

java - Java 中的常量与属性

python - 我需要假设此代码中的 python 为空序列

python - 如何在 Python 中向左或向右移动列表中的所有元素?

api - 如何使用 Varnish 缓存 RESTful API,但仍然使用 HMAC 来签名/验证每个请求?

ios - 无需等待 API 响应即可更改图标状态。 (标记为最喜欢的功能)

api - 如何将OpenGL程序的uniform属性值重置为默认值?

C# 属性系统

java - 如何将 <String, List<Object>> 的 Map 转换为 <Object, List<String>> 的 Map?

python - 索引错误: list index out of range (In whoosh Search Engine library) error at