I have a code below that throws an error:
[esri.WebMap] #add() The item being added is not a Layer or a Promise that resolves to a Layer.
Both `console.log()` statements execute ok, and the properties in returned object look like expected. The layer actually loads, but I get the error as I am not able to actually add it to the map.
I am actually implementing a custom Experience Builder widget with React and JimuMapView.
const handleAdd = async (item) => {
const layerUrl = item.url;
const jimuMapView = state.jimuMapView;
if (jimuMapView && jimuMapView.view) {
const mapView = jimuMapView.view;
const tileLayer = new FeatureLayer({
url: layerUrl
});
console.log(tileLayer)
try {
await tileLayer.load();
console.log(tileLayer);
mapView.map.add(tileLayer);
} catch (error) {
console.error("Error loading FeatureLayer", error);
}
}
};
Is there anything obvious that I'm doing wrong? Can I add layer just as a reference/view layer instead?