0

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 :

  • b79f6b55f4a0427b8c32ba805fa6e71a which is the web map id
  • 237a9574a4b34ffaba8754a61235e828 which is the id found in the url

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

My bad, indeed it was a mistake. I actually use var view = new MapView(...). About the CORS error, I will look at it and update you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.