//Attempt nr 1
this.state.map.add(newMapImageLayer);
//Attempt nr 2
this.setState({
map: new Map({
basemap: "dark-gray-vector",
layers: [newMapImageLayer]
})
})
})
.catch((err) => console.error(err));
}
render() {
return null;
}
}
export default App;
`
I have tried many other ways but the two I am showing here are not adding the layer.
I also get this error:
[esri.support.LayersMixin] #add() The item being added is not a Layer or a Promise that resolves to a Layer.
I have been trying to add my own API layer on the map but I cant get it to work.
`import { Component } from "react"; import { Basemap, MapImageLayer, Map } from "react-arcgis"; import { loadModules } from "esri-loader";
class App extends Component { constructor(props) { super(props);
}
componentDidMount() { loadModules(["esri/layers/MapImageLayer"]) .then(([MapImageLayer]) => { const newMapImageLayer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer", title: "MapImageLayer" });
}
render() { return null; } }
export default App; `
I have tried many other ways but the two I am showing here are not adding the layer. I also get this error:
[esri.support.LayersMixin] #add() The item being added is not a Layer or a Promise that resolves to a Layer.
I have also tried to do it in codeSandBox: box