Skip to content

Commit

Permalink
webiste: TypeScript example for DataFilterExtension (#9337)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer authored Jan 9, 2025
1 parent 47b62e0 commit 9cc2dd9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/api-reference/extensions/data-filter-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ The `DataFilterExtension` adds GPU-based data filtering functionalities to layer
</iframe>
</div>

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="language">
<TabItem value="js" label="JavaScript">
```js
import {GeoJsonLayer} from '@deck.gl/layers';
import {DataFilterExtension} from '@deck.gl/extensions';
Expand All @@ -35,6 +40,42 @@ const layer = new GeoJsonLayer({
});
```

</TabItem>
<TabItem value="ts" label="TypeScript">

```ts
import {GeoJsonLayer} from '@deck.gl/layers';
import {DataFilterExtension, DataFilterExtensionProps} from '@deck.gl/extensions';
import type {Feature, Geometry} from 'geojson';

type PropertiesType = {
timeOfDay: number;
};

const layer = new GeoJsonLayer<
PropertiesType,
DataFilterExtensionProps<Feature<Geometry, PropertiesType>>
>({
id: 'geojson-layer',
data: GEOJSON,

// props from GeoJsonLayer
getFillColor: [160, 160, 180],
getLineColor: [0, 0, 0],
getLineWidth: 10,

// props added by DataFilterExtension
getFilterValue: (f: Feature<Geometry, PropertiesType>) => f.properties.timeOfDay, // in seconds
filterRange: [43200, 46800], // 12:00 - 13:00

// Define extensions
extensions: [new DataFilterExtension({filterSize: 1})]
});
```

</TabItem>
</Tabs>

## Installation

To install the dependencies from NPM:
Expand Down

0 comments on commit 9cc2dd9

Please # to comment.