NicoTine
NicoTine

Reputation: 71

ArcGIS Web JS API "Invalid portal item type 'Map Service', expected 'Web Map'"

I wouldlike to display the map located at https://cartes.nicecotedazur.org/portal/apps/webappviewer/index.html?id=237a9574a4b34ffaba8754a61235e828 using the ArcGIS Web API.

I'm first trying to display it using ArcGIS Sandbox : https://developers.arcgis.com/javascript/latest/sample-code/sandbox/i

Here's the code sample :

  require(["esri/views/MapView", "esri/WebMap", "esri/config"], function (
    MapView,
    WebMap,
    esriConfig
  ) {
    esriConfig.portalUrl = "https://cartes.nicecotedazur.org/portal/";
    var webmap = new WebMap({
      portalItem: {
        id: "b79f6b55f4a0427b8c32ba805fa6e71a"
      }
    });

    var view = new MapView({
      map: webmap,
      container: "viewDiv"
    });
  });

But while loading this error message pops up in the console :

"Invalid portal item type 'Map Service', expected 'Web Map'"

I didn't find any article referencing this error

I tried with two different ids :

Upvotes: 0

Views: 848

Answers (1)

Seth Lutske
Seth Lutske

Reputation: 10686

Is this you actual code? First problem I see is that this:

var view = new WebMap({
  map: webmap,
  container: "viewDiv"
});

should be this

var view = new MapView({
  map: webmap,
  container: "viewDiv"
});

With that, I'm getting a CORS error to that resource. Here's a codesandbox. I'm not sure if that's because I'm using CSB. I can access the layer json directly, which means your setup is correct. But it makes me suspect that if you're getting CORS errors, you may need to set up a proxy.

Upvotes: 1

Related Questions