Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseLayer parameter in CesiumWidget constructor doesn't seem to work as described #11375

Closed
astrengers opened this issue Jun 27, 2023 · 1 comment · Fixed by #11379
Closed

Comments

@astrengers
Copy link

astrengers commented Jun 27, 2023

The options.imageryProvider of the CesiumWidget constructor is deprecated since v1.104. The suggested replacement for this is to use the option.baseLayer. However, reading the documentation of the CesiumWidget it says that the constructor has a seperate baseLayer parameter you can provide to the CesiumWidget. Unfortunately when I provide this parameter with the value 'false' it doesn't work and it loads the default Cesium baselayer.

Looking at the actual constructor in the source code there only seems to be two parameters (container and options) and the baseLayer parameter is missing.

I tried using options.baseLayer in my TypeScript code, but this causes type errors saying that baseLayer isn't part of the options:
return new CesiumWidget(this.elementId, { terrainProvider, baseLayer: false, });

causes
TS2345: Argument of type '{ terrainProvider: CesiumTerrainProvider | undefined; baseLayer: boolean; }' is not assignable to parameter of type '{ clock?: Clock | undefined; imageryProvider?: false | ImageryProvider | undefined; terrainProvider?: TerrainProvider | undefined; terrain?: Terrain | undefined; ... 20 more ...; msaaSamples?: number | undefined; }'.   Object literal may only specify known properties, and 'baseLayer' does not exist in type '{ clock?: Clock | undefined; imageryProvider?: false | ImageryProvider | undefined; terrainProvider?: TerrainProvider | undefined; terrain?: Terrain | undefined; ... 20 more ...; msaaSamples?: number | undefined; }'.

Only when I provide the options.baseLayer as follows in my code it seems to work:

return new CesiumWidget(this.elementId, { terrainProvider, baseLayer: false, } as any);

Expected behaviour:
I can provide the baseLayer parameter as separately from the options parameter and the default Cesium baseLayer isn't loaded.

Actual behaviour:
I have to provide the baseLayer as part of the options (as options.baseLayer), which causes errors in the types and seems to be contrary to the documentation.

Sandcastles:
Expected to work

What actually works

Version used: "@cesium/engine": "^2.4.1",

@ggetz
Copy link
Contributor

ggetz commented Jun 28, 2023

Hi @astrengers, good catch. This is a documentation error. We'll get it fixed before the next release. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants