javascript - GeoJSON 源的 OpenLayers 过滤器
问题描述
我在一个简单的 html/javascript/jquery 项目上使用 OpenLayers (v6.3.1) 和ol-ext扩展(处理动画集群)。
我成功地显示了来自 geojson 的数据,并将矢量源传递给集群源,然后添加到图层中。我现在的目标是向地图上显示的 geojson 字段添加/删除过滤器(通过用户交互)。
矢量/簇源和簇层的代码:
const clusterSource = new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector({
url: `${URL_PATH}`,
format: new ol.format.GeoJSON(),
})
});
const clusterLayer = new ol.layer.AnimatedCluster({
name: 'Cluster',
source: clusterSource,
animationDuration: $("#animatecluster").prop('checked') ? 700 : 0,
// Cluster style
style: getStyle
});
我被困在过滤部分:我应该过滤特征数组并替换我的图层的源吗?或者有没有更简单的方法来使用 Openlayers?
谢谢你的帮助!
解决方案
推荐阅读
- java - 谁能解释一下为什么两个代码都按此顺序打印输出的原因(静态关键字执行优先级)
- c# - 不使用递归调用的 C# 中的复杂对象比较
- google-chrome - 在 chrome 开发工具 DOM 检查中搜索已解析的 href 值
- hangouts-chat - 如何查找 Google Hangouts Coversation ID
- amazon-web-services - 在集成 kinesis 消费者时无法初始化类 KinesisClientLibConfiguration
- salesforce - Mule4:用于跨父关系字段的 SFDC UPSERT 操作的 JSON/Java 有效负载结构
- fuzzing - 修改 AFL 以包含一个新变量供 Fuzzer 在种子选择中考虑
- javascript - 如何在 Ant Design 中为图标添加徽章?
- r - 当使用 \n 换行时,减少 geom_label() 和 geom_text() 中 R ggplot 中的行高
- java - 如何使用 protobuf-gradle-plugin 指定 Protobuf 路径