Constructed FeatureCollection object not showing up on map (Esri 3.35)

222
0
02-18-2021 07:06 AM
asdfasdf45254
New Contributor

I'm in the process of trying to build a feature layer from the feature set resulting from a query, similar to this link: https://developers.arcgis.com/javascript/3/jssamples/fl_featureCollection.html

However, simply put, when I add the resulting feature layer to my map, it is not displayed anywhere, with no errors at all. It does show up in the LayerList widget however, just not in the map. Is there anything majorly wrong with how I'm creating the feature layer? I thought it might be an issue with my renderer JSON, but it is showing up in the LayerList widget.

Here is my code for building the FeatureCollection:

 whereStr = "USE='" + queryStr + "'";
            
            taskUrl = this.config.locations[this.siteSelection]["@url"] + "/" + this.layerId;
            console.log(taskUrl);
            queryTask = new QueryTask(taskUrl);
            query = new Query();
            query.where = whereStr;
            console.log(query.where);
            
            queryTask.execute(query, function(featureSet) {
              var resultFeatures = featureSet.features;

              var newFeatureCollection = {
                "layerDefinition": null,
                "featureSet": {
                  "features": featureSet.features,
                  "geometryType": "esriGeometryPolygon"
                }
              }

              newFeatureCollection.layerDefinition = {
                "geometryType": "esriGeometryPolygon",
                "objectIdField": "OBJECTID",
                "drawingInfo": {
                  "renderer": {
                    "type": "simple",
                    "symbol": {
                      "color": [
                        255,
                        255,
                        255,
                        0
                      ],
                      "outline": {
                        "color": [
                          115,
                          255,
                          223,
                          255
                        ],
                        "width": 3,
                        "type": "esriSLS",
                        "style": "esriSLSSolid"
                      },
                      "type": "esriSFS",
                      "style": "esriSFSSolid"
                    }
                  }
                }
              }

              console.log(newFeatureCollection);

              var featureLayer = new FeatureLayer(newFeatureCollection, {id: 'thing'});
              this.map.addLayer(featureLayer);
0 Kudos
0 Replies