Just starting off with CesiumJS. I adapted some of the beginner code from the Google Cloud website to try and get a sense of how everything works, but all I see is the outline of Earth and the Moon… Any help would be greatly appreciated.
The reason is that there are no image layers in the scene, you need to add a default imageryProvider.
const viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider: new Cesium.ArcGisMapServerImageryProvider({
url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
}),
})
or after instantiating the viewer:
var layer = viewer.imageryLayers.addImageryProvider(
new Cesium.ArcGisMapServerImageryProvider({
url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
})
)
There are many types of image layers, you can refer to the API: ImageryProvider.
I didn’t look too carefully just now. In this example code, the Earth is hidden ( globe: false ), so everything on Earth cannot be displayed.
In addition, the request render mode is enabled in the code (requestRenderMode: true), and you must manually call the render method to render the scene, I suggest you don’t need to know about it for a while.
viewer.scene.requestRender();
Also, if you don’t know much about the API, I recommend giving the parameters default values in most cases.
const viewer = new Viewer('cesiumContainer', {
imageryProvider: new ArcGisMapServerImageryProvider({
url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
}),
});