gpt4 book ai didi

filter - 传单.js : is it possible to filter geoJSON features by property?

转载 作者:行者123 更新时间:2023-12-02 06:43:18 26 4
gpt4 key购买 nike

我环顾四周,看到很多有关如何显示/隐藏图层的信息。这很酷,但由于我可以向 GeoJSON 功能添加任意属性,所以我希望能够相应地过滤它们。

例如,如果我的特征 1、2 和 3 具有以下属性:

  1. 小 |红色|甜甜的
  2. 大 |绿色|酸
  3. 小 |红色|热

我如何按大小过滤它们?还是按颜色或味道?

最佳答案

请参阅Using GeoJSON with Leaflet - Leaflet - a JavaScript library for interactive maps .

是的,您可以,只需添加一个过滤功能,例如:

L.geoJson(someFeatures, {
filter: function(feature, layer) {
return feature.properties.show_on_map;
}
}).addTo(map);

或者,如果您想要动态更新,那么另一个问题中有一个很好的答案: Leaflet: Update GeoJson filter?

关于filter - 传单.js : is it possible to filter geoJSON features by property?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21974597/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com