I use this script to display the popup in the arcgis-features.
I need to determine if the arcgis-features after it runs if it is empty or found features.
If i click on a featurelayer , then the console states that the component is not empty.
However, if i click on a mapimagelayer it states that the component is empty even though there is a feature inside the arcgis-features. Why?
const hitTestResult = await arcgisMap.view.hitTest(screenPoint);
const mapPoint = arcgisMap.view.toMap(screenPoint); await arcgisFeatures.open({
location: mapPoint,
features: results.map(r => r.graphic), // Include any client-side features found
fetchFeatures: true
}).then((response) => {
checkIfFeaturesEmpty()
})
function checkIfFeaturesEmpty() {
if (arcgisFeatures && arcgisFeatures.features) {
if (arcgisFeatures.features.length === 0) {
console.log('The <arcgis-features> component is empty.');
return true;
} else {
console.log('The <arcgis-features> component is not empty and contains ' + arcgisFeatures.features.length + ' features.');
return false;
}
} else {
console.log('The <arcgis-features> element or its features property is not available yet.');
return null;
}
}