根据图层指定字段进行条件过滤
require([
"esri/views/MapView",
"esri/Map",
"esri/layers/FeatureLayer",
"esri/widgets/Expand"
], (
MapView, Map, FeatureLayer, Expand
) => {
// flash flood warnings layer
const layer = new FeatureLayer({
portalItem: {
id: "f9e348953b3848ec8b69964d5bceae02"
},
outFields: ["SEASON"]
});
const selectedSeason = event.target.getAttribute("data-season");
floodLayerView.filter = {
where: "Season = '" + selectedSeason + "'"
};
view.whenLayerView(layer).then((layerView) => {
layerView.filter = {
where: "Season = '" + selectedSeason + "'"
};
//clear the filters when user closes the expand widget
seasonsExpand.watch("expanded", () => {
if (!seasonsExpand.expanded) {
floodLayerView.filter = null;
}
});
});
});