首先,我将解释我要实现的目标。我正在基于JavaScript API运行arcgis应用程序。我正在像这样将CSVLayer渲染到我的SceneView中:
require(["esri/Map", "esri/layers/CSVLayer", "esri/views/SceneView", "esri/widgets/BasemapToggle", "esri/Graphic", "esri/tasks/support/Query", "esri/widgets/Legend", "esri/widgets/Expand"],
function (Map, CSVLayer, SceneView, BasemapToggle, Graphic, Query, Legend, Expand) {
var csvLayer = new CSVLayer({
url: numberLayers[0].Url,
popupTemplate: template,
featureReduction: {
type: "selection"
}
});
csvLayer.renderer = {
type: "simple",
symbol: {
type: "simple-marker",
style: "circle",
color: [255, 255, 255, 1],
outline: { color: [0, 0, 0, 0.4] },
size: 16,
},
label: "PurpleAir Sensors",
visualVariables: [colorVisual]
};
var map = new Map({ basemap: "streets-navigation-vector", layers: csvLayer });
var view = new SceneView({
container: "divSensorMapContainer",
camera: {
position: [
-119.289320,
35.216734,
2100000,
],
},
map: map,
center: centerPoint,
constraints: {
altitude: {
min: 0,
max: 9000000,
},
},
});
我要做的是根据CSVLayer中定义的属性过滤此数据。我尝试使用.whenLayerView函数来捕获图层视图,然后运行.filter属性来过滤数据集。
view.whenLayerView(csvLayer)
.then(function (layerView) {
sensorLayerView = layerView;
var newQuery = csvLayer.createQuery();
newQuery.where = "PM25 > '40'";
sensorLayerView.filter = newQuery;
csvLayer.queryFeatures(newQuery).then(function (result) {
if (highlight) {
highlight.remove();
}
highlight = sensorLayerView.highlight(result.features);
});
view.ui.move(["compass", "zoom", "navigation-toggle"], "bottom-right");
});
现在,在此.whenLayerView函数中,我们获取layerview,基于数据集定义查询,然后执行以下两项操作:
那么有人知道我在做什么错吗?我使用了参考教程来了解这一点,您可以在这里找到:
https://developers.arcgis.com/javascript//latest/sample-code/featurefilter-attributes/index.html
答案 0 :(得分:0)
过滤器的参数只是具有“ where”属性的对象,而不是ESRI查询对象。
所以应该是:
sensorLayerView.filter = {
where: "PM25 > '40'"
};
这将作为新的FeatureFilter
自动广播