I am trying to create a featureLayer from an XML response where lat,lon are stored in a featureArray. Instead of creating this as point graphic, I would like to create them as a pointFeatureLayer. However, when I do that I get an error saying table feature layer cant be displayed. I am creating the featureLayer from featuresArray by loading it as FeatureLayerCollection containing lat,lon and id.
Here is the snapshot of the code, I have used.
fetch(url,{
method: 'GET',
mode:'cors',
}).then((response) => response.text())
.then(str => new window.DOMParser().parseFromString(str, 'text/xml'))
.then(async data => {
const nodes = data.getElementsByTagName('tower');
const featuresArray = [];
for (const node of nodes){
featuresArray.push({
longitude: node.getAttribute('lng'),
latitude: node.getAttribute('lat'),
id:node.getAttribute('id')
});
}
console.log(featuresArray);
const featureLayer = await this.esri.FeatureLayer({
source:featuresArray,
objectIdField:'id',
title:'TestLayer'
});
this.mvs.addToMap(featureLayer);