【问题标题】:Filter features by property which is a list of objects in Mapbox按属性过滤特征,这是 Mapbox 中的对象列表
【发布时间】:2019-11-11 09:08:48
【问题描述】:

我正在对我的 mapbox-gl-js 地图进行过滤。我有一个与此类似的功能:

[
    {
        "latitude": 1.0,
        "longitude": 1.0,
        "name": null,
        "description": null,
        "id": 3,
        "mappings": [
            {
                "type": "A",
                "mode": [
                    "1",
                    "2",
                    "3"
                ]
            },
            {
                "type": "B",
                "mode": [
                    "2",
                    "1",
                    "5"
                ]
            }
        ]
    }
]

现在,我想创建一个过滤器,它只显示一个特征,它的类型 = A AND 模式 = 1。这样复杂的过滤可能吗?我正在为这样的表达而苦苦挣扎:

this.map.setFilter('points2', ['==', ['get', 'type', ['object', ['get', 'mappings']]], 'A']));

但这似乎没有意义。

我还尝试从后端操作数据并创建以下 geoJson:

[
    {
        "latitude": 1.0,
        "longitude": 1.0,
        "name": null,
        "description": null,
        "id": 3,
        "mappings": {
            "A": [
                "1",
                "2",
                "3"
            ],
            "B": [
                "3",
                "2",
                "1"
            ]
        }
    }
]

它看起来比以前的 json 容易一些,但我无法编写适当的过滤器,因为据我所见,文档甚至没有说明此类情况。我还为这个问题添加了一个 Leafletjs 标记,因为可能在传单库中有一个很好的解决方案。

干杯

【问题讨论】:

    标签: leaflet mapbox mapbox-gl-js mapbox-gl


    【解决方案1】:

    一位 Mapbox 创建者回答了我的问题:https://github.com/mapbox/mapbox-gl-js/issues/8963

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 2015-11-28
      • 2013-06-01
      相关资源
      最近更新 更多