I am trying to use the FeatureSet results, from a QueryTask, as the Source of a Feature Layer. No matter how I am doing it, I cannot seem to get the Feature Layer loaded. Please see my logic below and let me know what I am doing wrong.
1. var qTask = new QueryTask({
url: zipCodeUrl
});
2. var params = new Query({
returnGeometry: true,
outFields: ["*"]
});
3. params.where = "ID_ IN (" + blue.value + ")";
qTask.execute(params)
.then(getBlueResults)
.catch(promiseRejected);
4.
function getBlueResults(response) {
layer = new FeatureLayer({
source: response.features, // autocast as an array of esri/Graphic
// // create an instance of esri/layers/support/Field for each field object
fields: bluefields, // This is required when creating a layer from Graphics
objectIdField: "ObjectID"
});
map.add(layer);
}
Solved! Go to Solution.
David,
You are missing the required geometryType property (when using source). Do you see any errors in the browsers web console?
David,
You are missing the required geometryType property (when using source). Do you see any errors in the browsers web console?
That did it.
layer = new FeatureLayer({
spatialReference: { wkid: 4326 },
source: response.features, // autocast as an array of esri/Graphic
fields: bluefields,
renderer: blueRenderer,
geometryType: "polygon",
objectIdField: "ObjectID"
});
map.add(layer)