I am new to JavaScript and to JavaScript APIs as well,
I am trying to get all the attributes of a feature that is clicked on the webmap, and I don't want to use the default pop up so I disabled it, and wrote the function below. I get the geometry, but I want the actual feature.
How can I do this?
Here is the current code I have which always returns 0 features when I do the query based on the geometry or mappoint.
view.on("click", async function(event){
view.hitTest(event).then(
async function(response){
for(let j=0;j<=response.results.length-1;j++){
var graphic = response.results[j].graphic;
let featureLayer=graphic.layer;
let lyrType =featureLayer.operationalLayerType;
if(lyrType!='ArcGISFeatureLayer')
continue;
var query = featureLayer.createQuery();
query.geometry = graphic.geometry; // I also tried event.mapPoint
query.outFields= ["*"];
query.spatialRelationship = "intersects";
let rr= await featureLayer.queryFeatures(query);
let numberOfSelectedFeatures=rr.features.length; // this is 0, unless i remove the query then it gets every feature in the layer
}
});
});