That didn't work either. The hullGraphic seems to be getting populated but the graphic never shows itself on the view. I can't seem to get a Codepen working correctly because the application currently uses a localized CSV file for an important step before this graphic gets generated. However, here is the relevant function:
Note that below the code, errr... below, I have copied the code that just puts the points on the map. It works fine. But if I swap it out for the convex hull it does not. Ideally I'd like to have both.
makePolicyExtentMap: function(LandUseCodes, countyCode){
console.log("Land Use Codes: "+LandUseCodes);
var queryTask = new QueryTask({
url: "https://services.wvgis.wvu.edu/arcgis/rest/services/Planning_Cadastre/WV_Parcels/MapServer/11"
});
var query = new Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "LandUseCode="+ LandUseCodes + " AND CountyCode="+ countyCode;
queryTask.execute(query).then(function(results){
//console.log(results.features);
var parcelIDResults = [];
for(let i=0;i<results.features.length;i++){
parcelIDResults.push(results.features[i].attributes["CleanParcelID"]);
}
console.log(parcelIDResults.length);
var parcelIDS = "";
for(let j=0;j<results.features.length;j++){
parcelIDS += "'"+parcelIDResults[j]+"',";
}
parcelIDS = parcelIDS.substring(0, parcelIDS.length - 1);
var queryTask = new QueryTask({
url: "https://services.wvgis.wvu.edu/arcgis/rest/services/Planning_Cadastre/WV_Parcels/MapServer/0"
});
var parcelsQuery = new Query();
parcelsQuery.returnGeometry = true;
parcelsQuery.outFields = ["*"];
parcelsQuery.where = "CleanParcelID IN ("+parcelIDS+")";
queryTask.execute(parcelsQuery).then(function(results){
const points = new Multipoint({
spatialReference: App.policyView.spatialReference,
points: results.features.map(feature => {
return [
feature.geometry.centroid.x,
feature.geometry.centroid.y
];
})
});
// CONVEXHULL //
const hullPolygon = geometryEngine.convexHull(points);
const hullGraphic = new Graphic({
geometry: hullPolygon,
symbol: {
type: 'simple-fill',
color: 'transparent',
outline: { color: 'red', width: 1.8 }
}
});
console.log(hullGraphic);
App.policyView.graphics.add(hullGraphic);
});
});
},
THIS IS THE WORKING POINT ONE
const simpleMarkerSymbol = {
type: "simple-marker",
//color: [ 20, 130, 200, 0.5 ],
color: [ 255, 99, 71, 0.85 ],
outline: {
color: "white",
width: 1
},
};
results.features.map((feature) => {
feature.symbol = simpleMarkerSymbol;
return feature;
});
App.policyView.graphics.removeAll();
// Add features to graphics layer
App.policyView.graphics.addMany(results.features);