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

[Doc] TileLayer example uses deprecated properties and does not work with typescript #8467

Open
Kilowhisky opened this issue Feb 1, 2024 · 3 comments
Labels

Comments

@Kilowhisky
Copy link

Link

https://deck.gl/docs/api-reference/geo-layers/tile-layer

Description

The section for renderSubLayers() does not work with typescript, also it uses the bbox property that is marked as @Deprecated.

renderSubLayers: props => {
                const {
                  bbox: {west, south, east, north}
                } = props.tile as any;

                return new BitmapLayer(props, {
                  data: null,
                  image: props.data,
                  bounds: [west, south, east, north]
                });
}

In typescript you have to specify props.tile as any. Also the BitMapLayer argument props throws an error.

Argument of type 'LayerProps & { _subLayerProps?: { [subLayerId: string]: { [propName: string]: any; type?: ConstructorOf<Layer<{}>>; }; }; } & _TileLayerProps<any> & { ...; }' is not assignable to parameter of type 'Partial<{ id: string; data: any; dataComparator: <LayerDataT = LayerData<unknown>>(newData: LayerDataT, oldData?: LayerDataT) => boolean; _dataDiff: <LayerDataT = LayerData<unknown>>(newData: LayerDataT, oldData?: LayerDataT) => { ...; }[]; ... 50 more ...; tile: Tile2DHeader<...>; } & Required<...> & Required<...>>'.
  Types of property 'data' are incompatible.
    Type 'any' is not assignable to type 'never'.ts(2345)
@Kilowhisky Kilowhisky added the doc label Feb 1, 2024
@Kilowhisky
Copy link
Author

Actually this may be a straight up bug.

I have to do this to get the layer to render

const what = { ...props, data: undefined };

                return new BitmapLayer(what as any, {
                  image: props.data,
                  bounds: [west, south, east, north]
                });

or else i get this error

deck.js:59 deck: initialization of BitmapLayer({id: 'SurfaceTemperatureCurrent-6-10-5'}): count(): argument not a container Error: count(): argument not a container
    at count (count.js:24:1)
    at BitmapLayer.getNumInstances (layer.js:374:17)
    at BitmapLayer._updateAttributes (layer.js:590:31)
    at BitmapLayer._postUpdate (layer.js:1045:10)
    at BitmapLayer._update (layer.js:855:12)
    at BitmapLayer._initialize (layer.js:796:10)
    at LayerManager._initializeLayer (layer-manager.js:240:1)
    at LayerManager._updateSublayersRecursively (layer-manager.js:209:1)
    at LayerManager._updateSublayersRecursively (layer-manager.js:223:1)
    at LayerManager._updateLayers (layer-manager.js:174:1)

@Pessimistress
Copy link
Collaborator

props contains a data field that has to be passed to BitmapLayer's image prop instead of data, hence the overriding of data: null in the documentation's example. That is not a bug.

@nphias
Copy link

nphias commented Mar 11, 2024

hoping deck gl goes full typescript, this worked for me.

      renderSubLayers: props => {
        const {west, north, east, south} = props.tile.bbox as GeoBoundingBox;
        return [
          new BitmapLayer(props, {
            data: undefined,
            image: props.data,
            bounds: [west, south, east, north]
          }),
        ];
      }

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

No branches or pull requests

3 participants