@deck.gl-community/layers 0.0.0 → 9.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/index.cjs +493 -403
  2. package/dist/index.cjs.map +7 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.js +6 -5
  5. package/dist/path-marker-layer/arrow-2d-geometry.d.ts +4 -0
  6. package/dist/path-marker-layer/arrow-2d-geometry.js +58 -0
  7. package/dist/path-marker-layer/create-path-markers.d.ts +18 -0
  8. package/dist/path-marker-layer/create-path-markers.js +78 -0
  9. package/dist/path-marker-layer/path-marker-layer.d.ts +40 -0
  10. package/dist/path-marker-layer/path-marker-layer.js +124 -0
  11. package/dist/path-marker-layer/polyline.d.ts +18 -0
  12. package/dist/path-marker-layer/polyline.js +40 -0
  13. package/dist/path-outline-layer/outline.d.ts +8 -0
  14. package/dist/path-outline-layer/outline.js +100 -0
  15. package/dist/path-outline-layer/path-outline-layer.d.ts +34 -0
  16. package/dist/path-outline-layer/path-outline-layer.js +116 -0
  17. package/dist/tile-source-layer/tile-source-layer.d.ts +43 -0
  18. package/dist/tile-source-layer/tile-source-layer.js +109 -0
  19. package/package.json +33 -20
  20. package/src/index.ts +8 -5
  21. package/src/path-marker-layer/arrow-2d-geometry.ts +65 -0
  22. package/src/path-marker-layer/create-path-markers.ts +122 -0
  23. package/src/path-marker-layer/path-marker-layer.ts +183 -0
  24. package/src/path-marker-layer/polyline.ts +44 -0
  25. package/src/path-outline-layer/outline.ts +107 -0
  26. package/src/path-outline-layer/path-outline-layer.ts +159 -0
  27. package/src/{tile-source-layer.ts → tile-source-layer/tile-source-layer.ts} +34 -26
  28. package/dist/data-driven-tile-3d-layer/data-driven-tile-3d-layer.js +0 -193
  29. package/dist/data-driven-tile-3d-layer/data-driven-tile-3d-layer.js.map +0 -1
  30. package/dist/data-driven-tile-3d-layer/utils/colorize-tile.js +0 -31
  31. package/dist/data-driven-tile-3d-layer/utils/colorize-tile.js.map +0 -1
  32. package/dist/data-driven-tile-3d-layer/utils/filter-tile.js +0 -146
  33. package/dist/data-driven-tile-3d-layer/utils/filter-tile.js.map +0 -1
  34. package/dist/index.js.map +0 -1
  35. package/dist/tile-source-layer.js +0 -112
  36. package/dist/tile-source-layer.js.map +0 -1
  37. package/src/data-driven-tile-3d-layer/data-driven-tile-3d-layer.ts +0 -257
  38. package/src/data-driven-tile-3d-layer/utils/colorize-tile.ts +0 -49
  39. package/src/data-driven-tile-3d-layer/utils/filter-tile.ts +0 -175
@@ -0,0 +1,183 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {CompositeLayer, COORDINATE_SYSTEM, DefaultProps} from '@deck.gl/core';
6
+ import {ScatterplotLayer} from '@deck.gl/layers';
7
+ import {SimpleMeshLayer} from '@deck.gl/mesh-layers';
8
+ import {PathOutlineLayer, PathOutlineLayerProps} from '../path-outline-layer/path-outline-layer';
9
+ import {Arrow2DGeometry} from './arrow-2d-geometry';
10
+
11
+ import {createPathMarkers} from './create-path-markers';
12
+ import {getClosestPointOnPolyline} from './polyline';
13
+ import {Vector3} from '@math.gl/core';
14
+
15
+ const DISTANCE_FOR_MULTI_ARROWS = 0.1;
16
+ const ARROW_HEAD_SIZE = 0.2;
17
+ const ARROW_TAIL_WIDTH = 0.05;
18
+ // const ARROW_CENTER_ADJUST = -0.8;
19
+
20
+ const DEFAULT_MARKER_LAYER = SimpleMeshLayer;
21
+
22
+ export type PathMarkerLayerProps<DataT> = PathOutlineLayerProps<DataT> & {
23
+ getDirection?: (x) => any;
24
+ getMarkerColor?: (x) => number[];
25
+ getMarkerPercentages?: (x: any, info: any) => number[];
26
+ highlightPoint?: any;
27
+ highlightIndex?: number;
28
+ MarkerLayer?: any;
29
+ markerLayerProps?: any;
30
+ sizeScale?: number;
31
+ fp64?: boolean;
32
+ nebulaLayer?: any;
33
+ };
34
+
35
+ const DEFAULT_MARKER_LAYER_PROPS = {
36
+ mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH})
37
+ };
38
+
39
+ const defaultProps: DefaultProps<PathMarkerLayerProps<any>> = Object.assign(
40
+ {},
41
+ PathOutlineLayer.defaultProps,
42
+ {
43
+ MarkerLayer: DEFAULT_MARKER_LAYER,
44
+ markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,
45
+
46
+ sizeScale: 100,
47
+ fp64: false,
48
+
49
+ highlightIndex: -1,
50
+ highlightPoint: null,
51
+
52
+ getPath: (x) => x.path,
53
+ getColor: (x) => x.color,
54
+ getMarkerColor: (x) => [0, 0, 0, 255],
55
+ getDirection: (x) => x.direction,
56
+ getMarkerPercentages: (object, {lineLength}) =>
57
+ lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]
58
+ }
59
+ );
60
+
61
+ export class PathMarkerLayer<
62
+ DataT = any,
63
+ ExtraPropsT = Record<string, unknown>
64
+ > extends CompositeLayer<ExtraPropsT & Required<PathMarkerLayerProps<DataT>>> {
65
+ static layerName = 'PathMarkerLayer';
66
+ static defaultProps = defaultProps;
67
+
68
+ state: {
69
+ closestPoint: Vector3 | null;
70
+ closestPoints?: {position: Vector3}[];
71
+ markers: any[];
72
+ mesh: Arrow2DGeometry;
73
+ } = undefined!;
74
+
75
+ initializeState() {
76
+ this.state = {
77
+ markers: [],
78
+ mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH}),
79
+ closestPoint: null,
80
+ closestPoints: []
81
+ };
82
+ }
83
+
84
+ projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {
85
+ if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {
86
+ const [dx, dy] = viewport.metersToLngLatDelta(xyz);
87
+ const [x, y] = coordinateOrigin;
88
+ return viewport.projectFlat([x + dx, dy + y]);
89
+ } else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) {
90
+ const [dx, dy] = xyz;
91
+ const [x, y] = coordinateOrigin;
92
+ return viewport.projectFlat([x + dx, dy + y]);
93
+ }
94
+
95
+ return viewport.projectFlat(xyz);
96
+ }
97
+
98
+ updateState({props, oldProps, changeFlags}) {
99
+ if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {
100
+ const {
101
+ data,
102
+ getPath,
103
+ getDirection,
104
+ getMarkerColor,
105
+ getMarkerPercentages,
106
+ coordinateSystem,
107
+ coordinateOrigin
108
+ } = this.props;
109
+
110
+ const {viewport} = this.context;
111
+ const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);
112
+ this.state.markers = createPathMarkers({
113
+ data,
114
+ getPath,
115
+ getDirection,
116
+ getColor: getMarkerColor,
117
+ getMarkerPercentages,
118
+ projectFlat
119
+ });
120
+ this._recalculateClosestPoint();
121
+ }
122
+ if (changeFlags.propsChanged) {
123
+ if (props.point !== oldProps.point) {
124
+ this._recalculateClosestPoint();
125
+ }
126
+ }
127
+ }
128
+
129
+ _recalculateClosestPoint() {
130
+ const {highlightPoint, highlightIndex} = this.props;
131
+ if (highlightPoint && highlightIndex >= 0) {
132
+ const object = this.props.data[highlightIndex];
133
+ const points = this.props.getPath(object, null as any);
134
+ const {point} = getClosestPointOnPolyline({points, p: highlightPoint});
135
+ this.state.closestPoints = [{position: point}];
136
+ } else {
137
+ this.state.closestPoints = [];
138
+ }
139
+ }
140
+
141
+ getPickingInfo({info}) {
142
+ return Object.assign(info, {
143
+ // override object with picked feature
144
+ object: (info.object && info.object.path) || info.object
145
+ });
146
+ }
147
+
148
+ renderLayers() {
149
+ return [
150
+ new PathOutlineLayer(
151
+ this.props,
152
+ this.getSubLayerProps({
153
+ id: 'paths',
154
+ // Note: data has to be passed explicitly like this to avoid being empty
155
+ data: this.props.data
156
+ })
157
+ ),
158
+ new this.props.MarkerLayer(
159
+ this.getSubLayerProps(
160
+ Object.assign({}, this.props.markerLayerProps, {
161
+ id: 'markers',
162
+ data: this.state.markers,
163
+ getOrientation: (x) => [0, -x.angle, 0],
164
+ getColor: (x) => x.color,
165
+ sizeScale: this.props.sizeScale,
166
+ fp64: this.props.fp64,
167
+ pickable: false,
168
+ parameters: {
169
+ blend: false,
170
+ depthTest: false
171
+ }
172
+ })
173
+ )
174
+ ),
175
+ this.state.closestPoints &&
176
+ new ScatterplotLayer({
177
+ id: `${this.props.id}-highlight`,
178
+ data: this.state.closestPoints,
179
+ fp64: this.props.fp64
180
+ })
181
+ ];
182
+ }
183
+ }
@@ -0,0 +1,44 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {Vector3, clamp} from '@math.gl/core';
6
+
7
+ // Return the closest point on a line segment
8
+ export function getClosestPointOnLine({p, p1, p2, clampToLine = true}) {
9
+ const lineVector = new Vector3(p2).subtract(p1);
10
+ const pointVector = new Vector3(p).subtract(p1);
11
+ let dotProduct = lineVector.dot(pointVector);
12
+ if (clampToLine) {
13
+ dotProduct = clamp(dotProduct, 0, 1);
14
+ }
15
+
16
+ return lineVector.lerp(p1, p2, dotProduct);
17
+ }
18
+
19
+ // Return the closest point on a line segment
20
+ export function getClosestPointOnPolyline({p, points}) {
21
+ p = new Vector3(p);
22
+ let pClosest: Vector3 | null = null;
23
+ let distanceSquared = Infinity;
24
+ let index = -1;
25
+ for (let i = 0; i < points.length - 1; ++i) {
26
+ const p1 = points[i];
27
+ const p2 = points[i + 1];
28
+ const pClosestOnLine = getClosestPointOnLine({p, p1, p2});
29
+ const distanceToLineSquared = p.distanceSquared(pClosestOnLine);
30
+ if (distanceToLineSquared < distanceSquared) {
31
+ distanceSquared = distanceToLineSquared;
32
+ pClosest = pClosestOnLine;
33
+ index = i;
34
+ }
35
+ }
36
+ return {
37
+ point: pClosest,
38
+ index,
39
+ p1: points[index],
40
+ p2: points[index + 1],
41
+ distanceSquared,
42
+ distance: Math.sqrt(distanceSquared)
43
+ };
44
+ }
@@ -0,0 +1,107 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {ShaderModule} from '@luma.gl/shadertools';
6
+
7
+ /* eslint-disable camelcase */
8
+ const INITIAL_STATE: Record<string, any> = {
9
+ outlineEnabled: false,
10
+ outlineRenderShadowmap: false,
11
+ outlineShadowmap: null
12
+ };
13
+
14
+ function getUniforms({outlineEnabled, outlineRenderShadowmap, outlineShadowmap} = INITIAL_STATE) {
15
+ const uniforms: Record<string, any> = {};
16
+ if (outlineEnabled !== undefined) {
17
+ // ? 1.0 : 0.0;
18
+ uniforms.outline_uEnabled = outlineEnabled;
19
+ }
20
+ if (outlineRenderShadowmap !== undefined) {
21
+ // ? 1.0 : 0.0;
22
+ uniforms.outline_uRenderOutlines = outlineRenderShadowmap;
23
+ }
24
+ if (outlineShadowmap !== undefined) {
25
+ uniforms.outline_uShadowmap = outlineShadowmap;
26
+ }
27
+ return uniforms;
28
+ }
29
+
30
+ const vs = `\
31
+ #version 300 es
32
+ in float instanceZLevel;
33
+ out float outline_vzLevel;
34
+ out vec4 outline_vPosition;
35
+
36
+ // Set the z level for the outline shadowmap rendering
37
+ void outline_setZLevel(float zLevel) {
38
+ outline_vzLevel = zLevel;
39
+ }
40
+
41
+ // Store an adjusted position for texture2DProj
42
+ void outline_setUV(vec4 position) {
43
+ // mat4(
44
+ // 0.5, 0.0, 0.0, 0.0,
45
+ // 0.0, 0.5, 0.0, 0.0,
46
+ // 0.0, 0.0, 0.5, 0.0,
47
+ // 0.5, 0.5, 0.5, 1.0
48
+ // ) * position;
49
+ outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);
50
+ }
51
+ `;
52
+
53
+ const fs = `\
54
+ uniform bool outline_uEnabled;
55
+ uniform bool outline_uRenderOutlines;
56
+ uniform sampler2D outline_uShadowmap;
57
+
58
+ in float outline_vzLevel;
59
+ // in vec2 outline_vUV;
60
+ in vec4 outline_vPosition;
61
+
62
+ out vec4 fragColor;
63
+
64
+ const float OUTLINE_Z_LEVEL_ERROR = 0.01;
65
+
66
+ // Return a darker color in shadowmap
67
+ vec4 outline_filterShadowColor(vec4 color) {
68
+ return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);
69
+ }
70
+
71
+ // Return a darker color if in shadowmap
72
+ vec4 outline_filterDarkenColor(vec4 color) {
73
+ if (outline_uEnabled) {
74
+ float maxZLevel;
75
+ if (outline_vPosition.q > 0.0) {
76
+ maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;
77
+ } else {
78
+ discard;
79
+ }
80
+ if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {
81
+ vec4(color.rgb * 0.5, color.a);
82
+ } else {
83
+ discard;
84
+ }
85
+ }
86
+ return color;
87
+ }
88
+
89
+ // if enabled and rendering outlines - Render depth to shadowmap
90
+ // if enabled and rendering colors - Return a darker color if in shadowmap
91
+ // if disabled, just return color
92
+ vec4 outline_filterColor(vec4 color) {
93
+ if (outline_uEnabled) {
94
+ return outline_uRenderOutlines ?
95
+ outline_filterShadowColor(color) :
96
+ outline_filterDarkenColor(color);
97
+ }
98
+ return color;
99
+ }
100
+ `;
101
+
102
+ export const outline = {
103
+ name: 'outline',
104
+ vs,
105
+ fs,
106
+ getUniforms
107
+ } as const satisfies ShaderModule;
@@ -0,0 +1,159 @@
1
+ // deck.gl-community
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {PathLayer, PathLayerProps} from '@deck.gl/layers';
6
+ import type {DefaultProps, LayerContext} from '@deck.gl/core';
7
+ import {GL} from '@luma.gl/constants';
8
+ import {Framebuffer, Texture} from '@luma.gl/core';
9
+ import {outline} from './outline';
10
+
11
+ /**
12
+ * Unit literal to shader unit number conversion.
13
+ */
14
+ export const UNIT = {
15
+ common: 0,
16
+ meters: 1,
17
+ pixels: 2
18
+ };
19
+
20
+ // TODO - this should be built into assembleShaders
21
+ function injectShaderCode({source, code = ''}) {
22
+ const INJECT_CODE = /}[^{}]*$/;
23
+ return source.replace(INJECT_CODE, code.concat('\n}\n'));
24
+ }
25
+
26
+ const VS_CODE = `\
27
+ outline_setUV(gl_Position);
28
+ outline_setZLevel(instanceZLevel);
29
+ `;
30
+
31
+ const FS_CODE = `\
32
+ fragColor = outline_filterColor(fragColor);
33
+ `;
34
+
35
+ export type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {
36
+ dashJustified?: boolean;
37
+ getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);
38
+ getZLevel?: (d: DataT, index: number) => number;
39
+ };
40
+
41
+ const defaultProps: DefaultProps<PathOutlineLayerProps<any>> = {
42
+ getZLevel: () => 0
43
+ };
44
+
45
+ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends PathLayer<
46
+ DataT,
47
+ ExtraPropsT & Required<PathOutlineLayerProps<DataT>>
48
+ > {
49
+ static layerName = 'PathOutlineLayer';
50
+ static defaultProps = defaultProps;
51
+
52
+ state: {
53
+ model?: any;
54
+ pathTesselator: any;
55
+ outlineFramebuffer: Framebuffer;
56
+ dummyTexture: Texture;
57
+ } = undefined!;
58
+
59
+ // Override getShaders to inject the outline module
60
+ getShaders() {
61
+ const shaders = super.getShaders();
62
+ return Object.assign({}, shaders, {
63
+ modules: shaders.modules.concat([outline]),
64
+ vs: injectShaderCode({source: shaders.vs, code: VS_CODE}),
65
+ fs: injectShaderCode({source: shaders.fs, code: FS_CODE})
66
+ });
67
+ }
68
+
69
+ // @ts-expect-error PathLayer is missing LayerContext arg
70
+ initializeState(context: LayerContext) {
71
+ super.initializeState();
72
+
73
+ // Create an outline "shadow" map
74
+ // TODO - we should create a single outlineMap for all layers
75
+ this.setState({
76
+ outlineFramebuffer: context.device.createFramebuffer({}),
77
+ dummyTexture: context.device.createTexture({})
78
+ });
79
+
80
+ // Create an attribute manager
81
+ // @ts-expect-error check whether this.getAttributeManager works here
82
+ this.state.attributeManager.addInstanced({
83
+ instanceZLevel: {
84
+ size: 1,
85
+ type: GL.UNSIGNED_BYTE,
86
+ accessor: 'getZLevel'
87
+ }
88
+ });
89
+ }
90
+
91
+ // Override draw to add render module
92
+ draw({moduleParameters = {}, parameters, uniforms, context}) {
93
+ // Need to calculate same uniforms as base layer
94
+ const {
95
+ jointRounded,
96
+ capRounded,
97
+ billboard,
98
+ miterLimit,
99
+ widthUnits,
100
+ widthScale,
101
+ widthMinPixels,
102
+ widthMaxPixels
103
+ } = this.props;
104
+
105
+ uniforms = Object.assign({}, uniforms, {
106
+ jointType: Number(jointRounded),
107
+ capType: Number(capRounded),
108
+ billboard,
109
+ widthUnits: UNIT[widthUnits],
110
+ widthScale,
111
+ miterLimit,
112
+ widthMinPixels,
113
+ widthMaxPixels
114
+ });
115
+
116
+ // Render the outline shadowmap (based on segment z orders)
117
+ const {outlineFramebuffer, dummyTexture} = this.state;
118
+ // TODO(v9): resize, see 'sf' example.
119
+ // outlineFramebuffer.resize();
120
+ // TODO(v9) clear FBO
121
+ // outlineFramebuffer.clear({ color: true, depth: true, stencil: true });
122
+
123
+ this.state.model.updateModuleSettings({
124
+ outlineEnabled: true,
125
+ outlineRenderShadowmap: true,
126
+ outlineShadowmap: dummyTexture
127
+ });
128
+
129
+ this.state.model.draw({
130
+ uniforms: Object.assign({}, uniforms, {
131
+ jointType: 0,
132
+ widthScale: this.props.widthScale * 1.3
133
+ }),
134
+ parameters: {
135
+ depthTest: false,
136
+ // Biggest value needs to go into buffer
137
+ blendEquation: GL.MAX
138
+ },
139
+ framebuffer: outlineFramebuffer
140
+ });
141
+
142
+ // Now use the outline shadowmap to render the lines (with outlines)
143
+ this.state.model.updateModuleSettings({
144
+ outlineEnabled: true,
145
+ outlineRenderShadowmap: false,
146
+ outlineShadowmap: outlineFramebuffer
147
+ });
148
+ this.state.model.draw({
149
+ uniforms: Object.assign({}, uniforms, {
150
+ jointType: Number(jointRounded),
151
+ capType: Number(capRounded),
152
+ widthScale: this.props.widthScale
153
+ }),
154
+ parameters: {
155
+ depthTest: false
156
+ }
157
+ });
158
+ }
159
+ }
@@ -1,17 +1,17 @@
1
- //
1
+ // deck.gl-community
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {CompositeLayer, Layer} from '@deck.gl/core/typed';
6
- import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers/typed';
7
- import {BitmapLayer, GeoJsonLayer, PathLayer} from '@deck.gl/layers/typed';
5
+ import {CompositeLayer, Layer} from '@deck.gl/core';
6
+ import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers';
7
+ import {BitmapLayer, GeoJsonLayer, PathLayer} from '@deck.gl/layers';
8
8
  import type {TileSource} from '@loaders.gl/loader-utils';
9
9
 
10
10
  /* global window */
11
11
  const devicePixelRatio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;
12
12
 
13
13
  export type TileSourceLayerProps = TileLayerProps & {
14
- tileSource: TileSource;
14
+ tileSource: TileSource<any>;
15
15
  showTileBorders?: boolean;
16
16
  };
17
17
 
@@ -29,8 +29,8 @@ export class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {
29
29
  };
30
30
 
31
31
  state: {
32
- tileSource: TileSource | null;
33
- };
32
+ tileSource: TileSource<any> | null;
33
+ } = undefined!;
34
34
 
35
35
  initializeState() {
36
36
  this.setState({
@@ -45,7 +45,7 @@ export class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {
45
45
  }
46
46
 
47
47
  renderLayers() {
48
- const {tileSource, showTileBorders, metadata, onTilesLoad} = this.props;
48
+ const {tileSource, showTileBorders, metadata, onTilesLoad} = this.props as any;
49
49
  const minZoom = metadata?.minZoom || 0;
50
50
  const maxZoom = metadata?.maxZoom || 30;
51
51
 
@@ -56,7 +56,7 @@ export class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {
56
56
  getTileData: tileSource.getTileData,
57
57
  // Assume the pmtiles file support HTTP/2, so we aren't limited by the browser to a certain number per domain.
58
58
  maxRequests: 20,
59
-
59
+
60
60
  pickable: true,
61
61
  onViewportLoad: onTilesLoad,
62
62
  autoHighlight: showTileBorders,
@@ -66,25 +66,29 @@ export class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {
66
66
  tileSize: 256,
67
67
  // TOOD - why is this needed?
68
68
  zoomOffset: devicePixelRatio === 1 ? -1 : 0,
69
- renderSubLayers,
70
-
69
+ renderSubLayers: renderSubLayers as any,
70
+
71
71
  // Custom prop
72
72
  tileSource,
73
73
  showTileBorders
74
74
  })
75
75
  ];
76
- }
76
+ }
77
77
  }
78
78
 
79
- function renderSubLayers(props: TileSourceLayerProps & {tile: {index, bbox: {west, south, east, north}}}) {
79
+ function renderSubLayers(
80
+ props: TileSourceLayerProps & {tile: {index; bbox: {west; south; east; north}}}
81
+ ) {
80
82
  const {
81
- tileSource,
82
- showTileBorders,
83
+ tileSource,
84
+ showTileBorders,
83
85
  minZoom,
84
86
  maxZoom,
85
- tile: {index: {z: zoom},
86
- bbox: {west, south, east, north}}
87
- } = props;
87
+ tile: {
88
+ index: {z: zoom},
89
+ bbox: {west, south, east, north}
90
+ }
91
+ } = props as any;
88
92
 
89
93
  const layers: Layer[] = [];
90
94
 
@@ -95,7 +99,7 @@ function renderSubLayers(props: TileSourceLayerProps & {tile: {index, bbox: {wes
95
99
  layers.push(
96
100
  new GeoJsonLayer({
97
101
  id: `${props.id}-geojson`,
98
- data: props.data,
102
+ data: props.data as any,
99
103
  pickable: true,
100
104
  getFillColor: [0, 190, 80, 255],
101
105
  lineWidthScale: 500,
@@ -109,16 +113,20 @@ function renderSubLayers(props: TileSourceLayerProps & {tile: {index, bbox: {wes
109
113
  case 'image/webp':
110
114
  case 'image/avif':
111
115
  layers.push(
112
- new BitmapLayer(props, {
113
- data: null,
114
- image: props.data,
115
- bounds: [west, south, east, north],
116
- pickable: true
117
- })
116
+ new BitmapLayer(
117
+ props as any,
118
+ {
119
+ data: null,
120
+ image: props.data,
121
+ bounds: [west, south, east, north],
122
+ pickable: true
123
+ } as any
124
+ )
118
125
  );
119
126
  break;
120
127
 
121
128
  default:
129
+ // eslint-disable-next-line no-console
122
130
  console.error('Unknown tile mimeType', tileSource?.mimeType);
123
131
  }
124
132
 
@@ -137,7 +145,7 @@ function renderSubLayers(props: TileSourceLayerProps & {tile: {index, bbox: {wes
137
145
  ]
138
146
  ],
139
147
  getPath: (d) => d,
140
- getColor: borderColor,
148
+ getColor: borderColor as any,
141
149
  widthMinPixels: 4
142
150
  })
143
151
  );