AnsweredAssumed Answered

Can the results of a query be placed in a FeatureLayer instead of a GraphicsLayer?

Question asked by john_richardson_1969 on Oct 12, 2018
Latest reply on Oct 15, 2018 by john_richardson_1969

I currently have a featurelayer being queried, and the results placed in a graphicslayer ... I am hoping that the results can be placed in a new featurelayer instead?

 

Here is current code:

 

$("#radio-4").click(function() {                       //shows only January crimes
      var sr = new SpatialReference(102100);

      janResults = new GraphicsLayer();
      janResults.title = "January";
      map.add(janResults);
      var janQuery = featurelayer.createQuery();
                                                                                   
      janQuery.where = "Month = 'January'";
      janQuery.outFields = ["Offense" , "Location"];
      janQuery.returnGeometry = true;
      janQuery.outSpatialReference = sr;

      featurelayer.queryFeatures(janQuery).then(displayGraphics);
     
      function displayGraphics(results) {

            janResults.removeAll();

            for (feature of results.features) {
                  var janGraphic = new Graphic ({
                        geometry: feature.geometry,
                        symbol: {
                              type: "simple-marker",
                              color: "blue",
                              size: "20px",
                              outline: {
                                    color:"black",
                                    width: 2,
                              },
                        },
                  });
                  janResults.add(janGraphic);
            }

      }
    
});  //end of January query

Outcomes