1

I have created a city engine web scene,and I am trying to display the 3d-visualisation view on sceneview by using the portal Item Id of my webscene. But I am getting

SyntaxError: Unexpected token ILLEGAL

How to solve this?

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Load a basic WebScene - 4.0beta3</title>

  <style>
    html,
    body {
      margin: 0;
      padding: 0;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.0beta3/esri/css/main.css">
  <script src="https://js.arcgis.com/4.0beta3/"></script>

  <script>
    require([
      "esri/views/SceneView",
      "esri/portal/PortalItem",
      "esri/WebScene",
      "dojo/domReady!"
    ], function(SceneView, PortalItem, WebScene) {
       var scene = new WebScene({
        portalItem: new PortalItem({
          id: "022290763bc243bbb5329c879e1dbd3a"
        })
      });
    var view = new SceneView({
        map: scene,
        container:"viewDiv"
      });
    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>

</html>
2

Your code is in fact correct. We can see this because changing the portal ID to the one from the sample code like so:

var scene = new WebScene({
        portalItem: new PortalItem({
          id: "51c67be4a5ea4da6948a40210ddfab1a"
          // use to be 022290763bc243bbb5329c879e1dbd3a
        })
      });

Works as expected. As such it must be something to do your portal item. Due to the fact that the ArcGIS JavaScript API is minified/obsfucated it is quite hard to deduce why this is happening. The common cause of ILLEGAL token is to do with rogue characters in JavaScript/JSON. The full explanation can be seen here. Some things to check:

  1. Is the item shared to publicly on your Portal/ArcGIS Online?
  2. What does your scene contain exactly? Is there anything unusual in there that may be causing the error?

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.