@carto/api-client 0.5.27-alpha.dd7e837.114 → 0.5.28

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
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/CartoDB/carto-api-client#readme",
9
9
  "author": "Don McCurdy <donmccurdy@carto.com>",
10
10
  "packageManager": "yarn@4.3.1",
11
- "version": "0.5.27-alpha.dd7e837.114",
11
+ "version": "0.5.28",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -68,7 +68,7 @@
68
68
  "dependencies": {
69
69
  "@loaders.gl/schema": "^4.3.3",
70
70
  "@types/geojson": "^7946.0.16",
71
- "d3-format": "^3.1.0",
71
+ "d3-format": "^3.1.2",
72
72
  "d3-scale": "^4.0.2",
73
73
  "h3-js": "^4.1.0",
74
74
  "jsep": "^1.4.0",
@@ -124,7 +124,7 @@
124
124
  "tsup": "^8.3.6",
125
125
  "typescript": "~5.9.2",
126
126
  "typescript-eslint": "^8.26.1",
127
- "vite": "^7.0.0",
127
+ "vite": "^7.3.2",
128
128
  "vitest": "3.2.4"
129
129
  },
130
130
  "resolutions": {
@@ -514,10 +514,11 @@ export function getMaxMarkerSize(
514
514
  visConfig: VisConfig,
515
515
  visualChannels: VisualChannels
516
516
  ): number {
517
- const {radiusRange, radius} = visConfig;
517
+ const {radiusRange, radius, sizeMaxPixels} = visConfig;
518
518
  const {radiusField, sizeField} = visualChannels;
519
519
  const field = radiusField || sizeField;
520
- return Math.ceil(radiusRange && field ? radiusRange[1] : radius);
520
+ const baseSize = radiusRange && field ? radiusRange[1] : radius;
521
+ return Math.ceil(sizeMaxPixels ?? baseSize);
521
522
  }
522
523
 
523
524
  type Accessor = number | ((d: any, i: any) => number);
@@ -128,6 +128,7 @@ export function getLayerDescriptor({
128
128
  ...createInteractionProps(interactionConfig),
129
129
  ...styleProps,
130
130
  ...channelProps,
131
+ ...createZoomScaleProps(config, visualChannels),
131
132
  ...createParametersProp(layerBlending, styleProps.parameters || {}), // Must come after style
132
133
  ...createLoadOptions(data.accessToken),
133
134
  },
@@ -208,6 +209,38 @@ function createInteractionProps(interactionConfig: any) {
208
209
  };
209
210
  }
210
211
 
212
+ function createZoomScaleProps(
213
+ config: MapLayerConfig,
214
+ visualChannels: VisualChannels
215
+ ): Record<string, any> {
216
+ const {visConfig} = config;
217
+ if (
218
+ !visConfig.radiusScaleWithZoom ||
219
+ visualChannels.radiusField ||
220
+ visualChannels.sizeField
221
+ ) {
222
+ return {};
223
+ }
224
+ // When `radiusScaleWithZoom` is enabled, render the point in `common`
225
+ // coordinate space so it scales proportionally with zoom.
226
+ const scale = Math.pow(2, -(visConfig.radiusReferenceZoom as number));
227
+ const result: Record<string, any> = {
228
+ pointRadiusUnits: 'common',
229
+ pointRadiusScale: scale,
230
+ iconSizeUnits: 'common',
231
+ iconSizeScale: scale,
232
+ };
233
+ if (visConfig.sizeMinPixels !== undefined) {
234
+ result.pointRadiusMinPixels = visConfig.sizeMinPixels;
235
+ result.iconSizeMinPixels = visConfig.sizeMinPixels;
236
+ }
237
+ if (visConfig.sizeMaxPixels !== undefined) {
238
+ result.pointRadiusMaxPixels = visConfig.sizeMaxPixels;
239
+ result.iconSizeMaxPixels = visConfig.sizeMaxPixels;
240
+ }
241
+ return result;
242
+ }
243
+
211
244
  function mapProps(source: any, target: any, mapping: any) {
212
245
  for (const sourceKey in mapping) {
213
246
  const sourceValue = source[sourceKey];
@@ -667,7 +700,24 @@ function createChannelProps(
667
700
  const getSecondaryText =
668
701
  secondaryField && getTextAccessor(secondaryField, data);
669
702
 
670
- result.pointType = `${result.pointType}+text`;
703
+ // For line/polygon tileset layers, deck.gl's VectorTileLayer can synthesize
704
+ // point labels at line midpoints / polygon centroids via `autoLabels`. The
705
+ // optional `uniqueIdProperty` dedupes features that span multiple tiles so
706
+ // each feature gets one label instead of one-per-tile.
707
+ const geometry = data.tilestats?.layers?.[0]?.geometry;
708
+ const isLineOrPolygon =
709
+ geometry === 'Polygon' ||
710
+ geometry === 'MultiPolygon' ||
711
+ geometry === 'Line' ||
712
+ geometry === 'LineString' ||
713
+ geometry === 'MultiLineString';
714
+ if (isLineOrPolygon && (layerType === 'tileset' || layerType === 'mvt')) {
715
+ const uniqueIdProperty = visConfig.textLabelUniqueIdField;
716
+ result.autoLabels = uniqueIdProperty ? {uniqueIdProperty} : true;
717
+ result.pointType = 'text';
718
+ } else {
719
+ result.pointType = `${result.pointType}+text`;
720
+ }
671
721
  result.textCharacterSet = 'auto';
672
722
  result.textFontFamily = 'Inter, sans';
673
723
  result.textFontSettings = {sdf: true};
@@ -80,6 +80,11 @@ export type VisConfig = {
80
80
  radiusAggregationExp?: string;
81
81
  radiusAggregationDomain?: [number, number];
82
82
 
83
+ sizeMinPixels?: number;
84
+ sizeMaxPixels?: number;
85
+ radiusScaleWithZoom?: boolean;
86
+ radiusReferenceZoom?: number;
87
+
83
88
  sizeAggregation?: string;
84
89
  sizeAggregationExp?: string;
85
90
  sizeAggregationDomain?: [number, number];
@@ -108,6 +113,7 @@ export type VisConfig = {
108
113
  colorBands?: RasterLayerConfigColorBand[];
109
114
 
110
115
  uniqueValuesColorRange?: ColorRange;
116
+ textLabelUniqueIdField?: string | null;
111
117
  };
112
118
 
113
119
  export type TextLabel = {