reearth / resium

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

Setting imageryProvider=false doesn't disable the default layer #624

Open alaney opened 1 year ago

alaney commented 1 year ago

When I use the Viewer with imageryProvider=false and an ImageLayer I still see a request to the Cesium API (https://api.cesium.com/v1/assets/2/endpoint...). I would expect that disabling the default layer would prevent this request. Here is my component:

import { SceneMode } from 'cesium';
import { forwardRef } from 'react';
import { CesiumComponentRef, Viewer } from 'resium';
import { ViewerProps } from 'resium/dist/Viewer/Viewer';
import { Viewer as CesiumViewer } from 'cesium';

const MapViewer = forwardRef(
  (props: ViewerProps, ref: React.ForwardedRef<CesiumComponentRef<CesiumViewer>>): JSX.Element => {
    const { children, ...rest } = props;
    return (
      <Viewer
        ref={ref}
        className='mapView'
        imageryProvider={false}
        baseLayerPicker={false}
        geocoder={false}
        timeline={false}
        animation={false}
        fullscreenButton={false}
        infoBox={false}
        homeButton={false}
        sceneModePicker={false}
        sceneMode={SceneMode.SCENE2D}
        navigationHelpButton={false}
        selectionIndicator={false}
        {...rest}
      >
        <ImageryLayer imageryProvider={imageryProvider} />
      </Viewer>
    );
  }
);

MapViewer.displayName = 'MapViewer';
export default MapViewer;

Should disabling the default imagery provider prevent this request from being issued? Is there another way to prevent the request?

michfarmer commented 1 year ago

@alaney Try baseLayer={false} instead.