I'm using the ArcGIS API for JavaScript to create an interactive map in a web page. When I try to add a layer with an specific id, doesn't recognize the layer and I receive this error:
The code to add the layer is:
require([
"esri/Map",
"esri/views/MapView", // SceneView
"esri/layers/Layer",
"dojo/domReady!"
], function(Map, MapView, Layer) {
var map = new Map({
basemap: "gray" // streets, topo, satellite, gray
});
var view = new MapView({
container: "viewDiv", // Reference to the DOM node that will contain the view
map: map, // References the map object created in step 3
zoom: 4, // Sets the zoom level based on level of detail (LOD)
center: [-58, -15] // Sets the center point of view in lon/lat
});
// Add a layer in the map
Layer.fromPortalItem({
portalItem: { // autocast as esri/portal/PortalItem
id: "405b97de934143aebe4784e833258a0f"
}
}).then(addLayer).otherwise(rejection);
// Adds the layer to the map once it loads
function addLayer(lyr) {
map.add(lyr);
alert("Layer added");
}
function rejection(err) {
alert("Layer failed to load: " + err);
}
});
The layer is in the arcgis portal (layer) with the extension .lyr.
