reearth / resium

React components for 🌏 Cesium
https://resium.reearth.io
MIT License
704 stars 130 forks source link

Viewer component baseLayer behavior is inconsistent with Cesium #663

Open mfarmer-ara opened 1 month ago

mfarmer-ara commented 1 month ago

On Cesium's Viewer doc, it expects baseLayer to be:

ImageryLayer | false or undefined.

In Resium's Viewer.ts, it is forcing baseLayer to be undefined when it is set to false.

This is causing the map to reach out https://api.cesium.com/v1/assets/2/endpoint to when you want to turn off baseLayerPicker and baseLayer in favor of the ImageryLayer component as Cesium falls back to the Ion behavior if baseLayer is not explicitly false.

mfarmer-ara commented 1 month ago
<Viewer
                id="LocationFromMap"
                ref={refViewer}
                full
                baseLayerPicker={false}
                timeline={false}
                homeButton={false}
                geocoder={false}
                fullscreenButton={false}
                vrButton={false}
                navigationHelpButton
                animation={false}
                selectionIndicator={false}
                baseLayer={false}
            >
           <ImageryLayer
                        imageryProvider={new UrlTemplateImageryProvider({
                           url: `${buildModuleUrl('Assets/Textures/NaturalEarthII')}/{z}/{x}/{reverseY}.jpg`,
                           tilingScheme: new GeographicTilingScheme(),
                           maximumLevel: 2,
                        });}
           />
    </Viewer>

The viewer code above (approximately) gives the following console errors due to baseLayer being forced to be undefined if it's false:

consoleErrors

If it's allowed to be false (not undefined) these don't happen. A token may also be appended to the first request if Cesium.Ion.defaultAccessToken is not set to undefined.

beaumcgee commented 1 month ago

Happy to see I'm not the only person experiencing this. I've been chasing this same error for the last couple days while trying to get Resium to work in an offline (aka no internet connection) environment. This issue doesn't prevent any functionality but does pollute the web console with Ion InvalidCredentials errors. This is after carefully following the Resium documentation and Cesium Offline Guide here: Guide.