I am unable to add a WMS from Geoserver

Hi,

I have the following code in Cesium Sandcastle and I am trying to add a WMS from Geoserver backend. I am getting the error TypeError: Cannot read properties of undefined (reading ‘addEventListener’) (on line 15) and TypeError: layers[i].queueReprojectionCommands is not a function

const viewer = new Cesium.Viewer(“cesiumContainer”);

const wmsShambamap={
url: ‘https://shambamap.org:8443/geoserver/Africa/wms’,
layers: ‘Africa:africa’,
parameters: {
service: ‘WMS’,
format: ‘image/png’,
transparent: true,
crossOrigin: null,
srs : ‘EPSG:4326’
},
};

var webMapServiceImageryProvider = new Cesium.WebMapServiceImageryProvider(wmsShambamap);
viewer.scene.imageryLayers.add(webMapServiceImageryProvider);

Hi there,

I think there may be a bit of confusion in between an ImageryProvider and an ImageryLayer.

WebMapServiceImageryProvider is an instance of an ImageryProvider. To create an imagery layer and add it to viewer.scene.imageryLayers, you can use ImageryLayerCollection.addImageryProvider. For example:

var webMapServiceImageryProvider = new Cesium.WebMapServiceImageryProvider(wmsShambamap);
viewer.scene.imageryLayers.addImageryProvider(webMapServiceImageryProvider);

Thanks,
Gabby