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>
1 Answer 1
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:
- Is the item shared to publicly on your Portal/ArcGIS Online?
- What does your scene contain exactly? Is there anything unusual in there that may be causing the error?
Explore related questions
See similar questions with these tags.