@deck.gl/carto 9.4.0-beta.4 → 9.4.1

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "9.4.0-beta.4",
6
+ "version": "9.4.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -53,8 +53,8 @@
53
53
  "@loaders.gl/mvt": "^4.4.3",
54
54
  "@loaders.gl/schema": "^4.4.3",
55
55
  "@loaders.gl/tiles": "^4.4.3",
56
- "@luma.gl/core": "^9.4.0-beta.7",
57
- "@luma.gl/shadertools": "^9.4.0-beta.7",
56
+ "@luma.gl/core": "^9.4.2",
57
+ "@luma.gl/shadertools": "^9.4.2",
58
58
  "@math.gl/web-mercator": "^4.1.0",
59
59
  "@types/d3-array": "^3.0.2",
60
60
  "@types/d3-color": "^3.1.3",
@@ -71,13 +71,13 @@
71
71
  "quadbin": "^0.4.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "@deck.gl/aggregation-layers": "~9.4.0-beta.3",
75
- "@deck.gl/core": "~9.4.0-beta.3",
76
- "@deck.gl/extensions": "~9.4.0-beta.3",
77
- "@deck.gl/geo-layers": "~9.4.0-beta.3",
78
- "@deck.gl/layers": "~9.4.0-beta.3",
74
+ "@deck.gl/aggregation-layers": "~9.4.0",
75
+ "@deck.gl/core": "~9.4.0",
76
+ "@deck.gl/extensions": "~9.4.0",
77
+ "@deck.gl/geo-layers": "~9.4.0",
78
+ "@deck.gl/layers": "~9.4.0",
79
79
  "@loaders.gl/core": "^4.4.3",
80
- "@luma.gl/core": "~9.4.0-beta.7"
80
+ "@luma.gl/core": "~9.4.0"
81
81
  },
82
- "gitHead": "510649703132adbd49cbfa7d25a49363aec03265"
82
+ "gitHead": "7de3aa41176da9d6dcc11562fb5fa8b9d0cb11a4"
83
83
  }
@@ -40,18 +40,43 @@ class EnhancedTextBackgroundLayer extends TextBackgroundLayer {
40
40
  }
41
41
  }
42
42
 
43
- // TextLayer which includes modified text-background-layer-vertex shader and only renders the
44
- // primary background layer in the collision pass
43
+ type EnhancedTextLayerProps = TextLayerProps & {
44
+ renderBackground?: boolean;
45
+ collisionBackgroundPadding?: TextLayerProps['backgroundPadding'];
46
+ };
47
+
48
+ // TextLayer which includes modified text-background-layer-vertex shader and uses a separate
49
+ // background layer for collision testing, while preserving TextLayer's visual background support.
45
50
  class EnhancedTextLayer extends TextLayer {
46
51
  static layerName = 'EnhancedTextLayer';
47
52
 
48
53
  filterSubLayer({layer, renderPass}) {
49
- const background = layer.id.includes('primary-background');
54
+ const collisionBackground = layer.id.endsWith('-collision-background');
50
55
  if (renderPass === 'collision') {
51
- return background; // Only draw primary background layer in collision pass
56
+ return collisionBackground; // Only draw collision background layer in collision pass
52
57
  }
53
58
 
54
- return !background; // Do not draw background layer in other passes
59
+ return !collisionBackground; // Do not draw collision background layer in other passes
60
+ }
61
+
62
+ renderLayers(): ReturnType<TextLayer['renderLayers']> {
63
+ const layers = super.renderLayers();
64
+ const backgroundLayer = layers[0] as TextBackgroundLayer | false;
65
+ const charactersLayer = layers[1];
66
+ const {renderBackground, collisionBackgroundPadding} = this.props as EnhancedTextLayerProps;
67
+
68
+ const collisionBackgroundLayer =
69
+ backgroundLayer &&
70
+ new EnhancedTextBackgroundLayer(backgroundLayer.props, {
71
+ id: `${this.id}-collision-background`,
72
+ padding: collisionBackgroundPadding
73
+ });
74
+
75
+ return [
76
+ Boolean(renderBackground) && backgroundLayer,
77
+ collisionBackgroundLayer,
78
+ charactersLayer
79
+ ];
55
80
  }
56
81
  }
57
82
 
@@ -154,13 +179,13 @@ export default class PointLabelLayer<
154
179
  ];
155
180
  }
156
181
 
157
- calculateBackgroundPadding() {
182
+ calculateBackgroundPadding(): [number, number, number, number] {
158
183
  const {getTextAnchor: anchor, getAlignmentBaseline: alignment, sizeScale} = this.props;
159
184
 
160
185
  // Heuristics to avoid label overlap
161
186
  const paddingX = 12 * sizeScale;
162
187
  const paddingY = 3 * sizeScale;
163
- const backgroundPadding = [0, 0, 0, 0];
188
+ const backgroundPadding: [number, number, number, number] = [0, 0, 0, 0];
164
189
  if (alignment === 'top') {
165
190
  backgroundPadding[TOP] = paddingY;
166
191
  } else if (alignment === 'bottom') {
@@ -192,6 +217,11 @@ export default class PointLabelLayer<
192
217
  outlineColor,
193
218
  outlineWidth,
194
219
  sizeScale,
220
+ getBackgroundColor,
221
+ getBorderColor,
222
+ getBorderWidth,
223
+ backgroundBorderRadius,
224
+ backgroundPadding,
195
225
  radiusScale,
196
226
 
197
227
  getAlignmentBaseline,
@@ -223,6 +253,11 @@ export default class PointLabelLayer<
223
253
  outlineColor,
224
254
  outlineWidth,
225
255
  sizeScale,
256
+ getBackgroundColor,
257
+ getBorderColor,
258
+ getBorderWidth,
259
+ backgroundBorderRadius,
260
+ backgroundPadding,
226
261
 
227
262
  getAlignmentBaseline,
228
263
  getColor,
@@ -242,8 +277,7 @@ export default class PointLabelLayer<
242
277
  }
243
278
  }),
244
279
  {
245
- getSize: 1,
246
- _subLayerProps: {background: {type: EnhancedTextBackgroundLayer}}
280
+ getSize: 1
247
281
  },
248
282
  props
249
283
  );
@@ -251,6 +285,7 @@ export default class PointLabelLayer<
251
285
 
252
286
  renderLayers(): Layer | null | LayersList {
253
287
  const {
288
+ background,
254
289
  getText,
255
290
  getSecondaryColor,
256
291
  getSecondaryText,
@@ -259,14 +294,15 @@ export default class PointLabelLayer<
259
294
  updateTriggers
260
295
  } = this.props;
261
296
  const getPixelOffset = this.calculatePixelOffset(false);
262
- const backgroundPadding = this.calculateBackgroundPadding();
297
+ const collisionBackgroundPadding = this.calculateBackgroundPadding();
263
298
  const out = [
264
299
  // Text doesn't update via updateTrigger for some reason
265
300
  this.renderTextLayer(`${updateTriggers.getText}-primary`, {
266
- backgroundPadding,
301
+ background: true,
302
+ renderBackground: background,
267
303
  getText,
268
304
  getPixelOffset,
269
- background: true // Only use background for primary label for faster collisions
305
+ collisionBackgroundPadding
270
306
  }),
271
307
  Boolean(getSecondaryText) &&
272
308
  this.renderTextLayer(`${updateTriggers.getSecondaryText}-secondary`, {