Can you tell me if I'm on the right track? (Will post full code if needed). It seems to be drawing correctly, but the query is returning undefined and I'm not quite sure where I'm going wrong. I suspect query.geometry = evt.geometry is wrong, but I might be way off.
map.on("load", initToolbar);
function initToolbar() {
tb = new Draw(map);
tb.on("draw-end", addGraphic);
// event delegation so a click handler is not
// needed for each individual button
on(dom.byId("doExtent"), "click", function(evt) {
if ( evt.target.id === "doExtent" ) {
return;
}
map.disableMapNavigation();
tb.activate(Draw.EXTENT);
});
}
var infoTemplate = new InfoTemplate("${PIN_DSP}","<b>${OWNER_NAME}</b>");
query = new Query();
query.returnGeometry = true;
query.outFields = ["PIN_DSP", "OWNER_NAME"];
queryTask = new esri.tasks.QueryTask("http://172.27.8.54/okaloosagis/rest/services/PropertyApp/ParcelService/MapServer/14");
function addGraphic(evt) {
//deactivate the toolbar and clear existing graphics
tb.deactivate();
map.enableMapNavigation();
var symbol;
if ( evt.geometry.type === "point" || evt.geometry.type === "multipoint") {
symbol = markerSymbol;
} else if ( evt.geometry.type === "line" || evt.geometry.type === "polyline") {
symbol = lineSymbol;
}
else {
symbol = fillSymbol;
}
map.graphics.add(new Graphic(evt.geometry, symbol));
query.geometry = evt.geometry;
queryTask.execute(query, function(fset) {
showFeatureSet(fset,evt);
})
}
function showFeatureSet(fset,evt) {
map.graphics.clear();
featureSet = fset;
var numFeatures = featureSet.features.length;
var content = "";
for (var i=0; i<numFeatures; i++) {
var graphic = featureSet.features;
content = content + graphic.attributes.FIELD_NAME;
}
map.infoWindow.setContent(content);
map.infoWindow.show(evt.screenPoint);
}
<div id="doExtent"><a><i class="far fa-square"></i></a></div>