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:

enter image description here

The code to add the layer is:

          "esri/views/MapView", // SceneView
        ], 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
            portalItem: { // autocast as esri/portal/PortalItem
                id: "405b97de934143aebe4784e833258a0f"

          // Adds the layer to the map once it loads
          function addLayer(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.

  • We can't see the layer since it is in Portal. Maybe you need to be signed in for the web map to work? – timlohnes Jul 14 '16 at 16:11
  • How can I put the layer in the Portal? – Thiago Souza Jul 18 '16 at 11:17

It seems you are using the class Layer and not an object of the class. Take a look at the line:

function(Map, MapView, Layer) {

This is telling that you will use 3 classes: Map, MapView and Layer.

You already created 2 objects for Map and MapView:

var map = new Map({

var view = new MapView({

But you haven't created any object for Layer. Something like:

var lyr = new Layer({

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.