Using API 4.7
When my web map is loaded, I'm handling the loading of the feature layers and filtering the graphics displayed with the following:
webMapView.on("layerview-create", function(event) {
if (layerTitle === "Toxic Release")
{
layer.definitionExpression = "State_code = '" + state + "'";
}
else if (layerTitle === "Region 3 Boundary") {
layer.definitionExpression = "STUSPS = '" + state + "'";
}
else {
layer.definitionExpression = "STATE = '" + state + "'";
}
return function queryLayerData() {
var layerQuery = layer.createQuery();
return layer.queryFeatures(layerQuery).then(function (response) {
layerGeometries = response.features.map(function (feature) {
return feature.geometry;
});
return layerGeometries;
});
}
}
When an item is searched using the Search Widget, I want the feature layer to show the feature but there are cases when the feature is not show because of the filtering above.
How would I remove the filtering that takes place during the layerview-create process?
Mathew,
You would have to loop through the layerViews collection and get the layer property from the LayerView and set the definitionExpression to an empty string.