这是我的代码。
let query = layer.createQuery();
query.geometry = geometry_here;
query.outFields = ["*"];
query.returnGeometry = true;
layer.queryFeatures(query).then((result) => {
console.log('result of principle transmission layer', result);
// i get filtered result here but i want to apply direct on layer
});
我只是通过这种方式获取过滤器数据,但是我想在层上应用过滤器。
答案 0 :(得分:1)
将FeatureLayer添加到地图时,您需要使用FeatureLayerView.filter,这将需要一些额外的接线。我假设您正在重新使用MapView,尽管场景中存在类似的功能。在定义过滤器的空间关系时,您有很多选择。请参阅FeatureFilter的spatialRelationship属性上的文档
const view = new MapView({
container: "sceneDiv",
map: map,
center: [-73.95, 40.702],
zoom: 13,
padding: {
right: 300
}
});
var layer = new FeatureLayer(url);
map.add(layer);
view.whenLayerView(layer)
.then(function(layerView) {
// The layerview for the layer is available here
featureLayerView.filter = new FeatureFilter({
geometry: geometry_here,
spatialRelationship: "contains"
});
})
.catch(function(error) {
// An error occurred during the layerview creation
});