Hi all, I am trying to display a scene layer shared on ArcGIS online. I encountered a problem when I initiated the SceneView with camera property. The source code is as below,
const bSceneLayer = new BuildingSceneLayer({
url: my_url,
});
const basemap = new Basemap({
baseLayers: [bSceneLayer],
});
var map = new Map({
basemap: basemap,
});
const view = new SceneView({
container: "viewDiv",
map: map,
camera: {
heading: 90,
tilt: 45,
position: [ -122, 38, 20000 ]
}
});
Do you have a repro application in codepen or stackblitz? Using your camera properties in this Sample App works, so it could be something else, maybe an issue with the scene layer and basemap.
I just saw you have this other question here related to your scenelayer, so I'm going to guess it's probably related to that.
Hi. Thank you for the reply.
Due to security issue, I am not able to provide a repo with my current model(layer), and I can't find any similar layer public on the internet. But yes, I think the error is related to the basemap. Everything works fine if I render only the basemap with a default string value from the doc. I am struggling because there is no specification of this error in the doc.
If you create a new camera object like this, the position of the camera defaults to WGS84:
camera: {
heading: 90,
tilt: 45,
position: [ -122, 38, 20000 ]
}
This is most likely incompatible with the spatial reference of your building scene layer, which is why scene view throws an error. Granted, the error message could provide a bit more information.
You can create a valid camera object like this:
camera: {
position: {
x: -122, /* replace with projected coordinate */
y: 38, /* replace with projected coordinate */
z: 20000,
spatialReference: { wkid: 28992 /* Replace with wkid of your scene layer */ }
},
heading: 90,
tilt: 45
}
Also, instead of adding your building scene layer as a basemap, better add it as a layer to your map. This will make sure widgets like the layer list and legend work properly out-of-the-box:
const bSceneLayer = new BuildingSceneLayer({
url: my_url,
});
var map = new Map({
layers: [bSceneLayer],
});
Hope this helps! Otherwise as Rene already pointed out, it would be good to have a running sample app you can share.