AnsweredAssumed Answered

Remove layer definitions expression after searchWidget.on("select-result") - API 4.7

Question asked by mmullan on Jun 5, 2018
Latest reply on Jun 5, 2018 by rscheitlin

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?

Outcomes