首页 > 解决方案 > 如何使用表达式过滤 Mapbox geoJSON?

问题描述

使用 mapbox 表达式并给出以下示例 geoJSON,如果许可证等于“娱乐”,我如何才能仅在地图上显示标记?在这种情况下,唯一要显示的两个位置应该是Store OneStore Three

我尝试过的一些表达方式:
1.) ['in', 'Recreational', ['get', 'license' ['get', 'products']]];
2.) ['in', ['Recreational', ['get', 'license', ['get', 'products']]]];
3.) ['in', ['==', 'Recreational', ['get', 'license', ['get', 'products']]]]

{
  "type": "Feature",
  "properties": {
      "name": "Store One",
      "products”: [
          {
            license: “Recreational”,
            product: “product name here”
          },
          {
            license: “Medical",
            product: “product name here”
          }
          {
            license: “Recreational”,
            product: “product name here”
          }
      ]
  },
  "geometry": {
      "type": "Point",
      "coordinates": [-104.99404, 39.75621]
  }
},
{
  "type": "Feature",
  "properties": {
      "name": "Store Two",
      "products”: [
          {
            license: “Medical",
            product: “product name here”
          },
          {
            license: “Medical,
            product: “product name here”
          }
          {
            license: “Medical,
            product: “product name here”
          }
      ]
  },
  "geometry": {
      "type": "Point",
      "coordinates": [-105.02163,39.77332]
  }
},
{
  "type": "Feature",
  "properties": {
      "name": "Store Three",
      "products”: [
          {
            license: “Medical”,
            product: “product name here”
          },
          {
            license: “Recreational”,
            product: “product name here”
          }
          {
            license: “Medical”,
            product: “product name here”
          }
      ]
  },
  "geometry": {
      "type": "Point",
      "coordinates": [-107.811071, 37.937463]
  }
}

标签: expressionmapboxgeojson

解决方案


推荐阅读