Moving (lowering/raising) WebMapTile...Provider in the ImageryLayerCollection

Hello, I have the current imagery layers in the image collection:

  1. _layers: Array(6)
  2. 0: ImageryLayer {_imageryProvider: UrlTemplateImageryProvider, alpha: 1, …}
  3. 1: WebMapTileServiceImageryProvider {_useKvp: true, _layer: “Coastlines”, …}
  4. 2: ImageryLayer {_imageryProvider: SingleTileImageryProvider, alpha: 1 …}
  5. 3: ImageryLayer {_imageryProvider: SingleTileImageryProvider, alpha: 1 …}
  6. 4: ImageryLayer {_imageryProvider: SingleTileImageryProvider, alpha: 1 …}
  7. 5: ImageryLayer {_imageryProvider: SingleTileImageryProvider, alpha: 1 …}

However, when I try to raise the WebMapTile…Provider to the top (since those are Coastline tiles, I need them on top) I get a Cesium Error:
image

I try to raise the layer to the top as usual:
viewer.imageryLayers.raiseToTop(myCoastlineImageryProvider)

I see, that in the Cesium documentation, it accepts an ImageryProvider as argument, and I pass in a WebMapTile…Provider, so that might be the reason it is not happy?
In that case, how do I still raise a WebMapTile…Provider?

Thanks

I think that should work. Can you share a Sandcastle example reproducing this issue? See: How to share custom Sandcastle examples

I have found a solution, not sure if intended, but I think the problem was exactly because it was treated as a type ‘WebMapTileServiceImageryProvider’ and not ‘ImageryProvider’.

So, a workaround was to get that layer by index from the viewer.ImageryLayers (using viewer.imageryLayers.get(viewer.imageryLayers._layers.length - 1) for the layer you just added)

which then gets that layer as an ‘ImageryProvider’ instead of WebMapTileServiceImageryProvider, and then it works.

I assume it just casts it to another type as a result of calling that .get() function