@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.
@@ -882,6 +882,10 @@ type VisConfig = {
882
882
  radiusAggregation?: string;
883
883
  radiusAggregationExp?: string;
884
884
  radiusAggregationDomain?: [number, number];
885
+ sizeMinPixels?: number;
886
+ sizeMaxPixels?: number;
887
+ radiusScaleWithZoom?: boolean;
888
+ radiusReferenceZoom?: number;
885
889
  sizeAggregation?: string;
886
890
  sizeAggregationExp?: string;
887
891
  sizeAggregationDomain?: [number, number];
@@ -903,6 +907,7 @@ type VisConfig = {
903
907
  rasterStyleType?: 'Rgb' | 'ColorRange' | 'UniqueValues';
904
908
  colorBands?: RasterLayerConfigColorBand[];
905
909
  uniqueValuesColorRange?: ColorRange;
910
+ textLabelUniqueIdField?: string | null;
906
911
  };
907
912
  type TextLabel = {
908
913
  field: VisualChannelField | null | undefined;
@@ -882,6 +882,10 @@ type VisConfig = {
882
882
  radiusAggregation?: string;
883
883
  radiusAggregationExp?: string;
884
884
  radiusAggregationDomain?: [number, number];
885
+ sizeMinPixels?: number;
886
+ sizeMaxPixels?: number;
887
+ radiusScaleWithZoom?: boolean;
888
+ radiusReferenceZoom?: number;
885
889
  sizeAggregation?: string;
886
890
  sizeAggregationExp?: string;
887
891
  sizeAggregationDomain?: [number, number];
@@ -903,6 +907,7 @@ type VisConfig = {
903
907
  rasterStyleType?: 'Rgb' | 'ColorRange' | 'UniqueValues';
904
908
  colorBands?: RasterLayerConfigColorBand[];
905
909
  uniqueValuesColorRange?: ColorRange;
910
+ textLabelUniqueIdField?: string | null;
906
911
  };
907
912
  type TextLabel = {
908
913
  field: VisualChannelField | null | undefined;
@@ -9699,10 +9699,11 @@ function getIconUrlAccessor(field, range, {
9699
9699
  return normalizeAccessor(accessor, data);
9700
9700
  }
9701
9701
  function getMaxMarkerSize(visConfig, visualChannels) {
9702
- const { radiusRange, radius } = visConfig;
9702
+ const { radiusRange, radius, sizeMaxPixels } = visConfig;
9703
9703
  const { radiusField, sizeField } = visualChannels;
9704
9704
  const field = radiusField || sizeField;
9705
- return Math.ceil(radiusRange && field ? radiusRange[1] : radius);
9705
+ const baseSize = radiusRange && field ? radiusRange[1] : radius;
9706
+ return Math.ceil(sizeMaxPixels ?? baseSize);
9706
9707
  }
9707
9708
  function negateAccessor(accessor) {
9708
9709
  if (typeof accessor === "function") {
@@ -10213,6 +10214,7 @@ function getLayerDescriptor({
10213
10214
  ...createInteractionProps(interactionConfig),
10214
10215
  ...styleProps,
10215
10216
  ...channelProps,
10217
+ ...createZoomScaleProps(config2, visualChannels),
10216
10218
  ...createParametersProp(layerBlending, styleProps.parameters || {}),
10217
10219
  // Must come after style
10218
10220
  ...createLoadOptions(data.accessToken)
@@ -10282,6 +10284,28 @@ function createInteractionProps(interactionConfig) {
10282
10284
  pickable
10283
10285
  };
10284
10286
  }
10287
+ function createZoomScaleProps(config2, visualChannels) {
10288
+ const { visConfig } = config2;
10289
+ if (!visConfig.radiusScaleWithZoom || visualChannels.radiusField || visualChannels.sizeField) {
10290
+ return {};
10291
+ }
10292
+ const scale2 = Math.pow(2, -visConfig.radiusReferenceZoom);
10293
+ const result = {
10294
+ pointRadiusUnits: "common",
10295
+ pointRadiusScale: scale2,
10296
+ iconSizeUnits: "common",
10297
+ iconSizeScale: scale2
10298
+ };
10299
+ if (visConfig.sizeMinPixels !== void 0) {
10300
+ result.pointRadiusMinPixels = visConfig.sizeMinPixels;
10301
+ result.iconSizeMinPixels = visConfig.sizeMinPixels;
10302
+ }
10303
+ if (visConfig.sizeMaxPixels !== void 0) {
10304
+ result.pointRadiusMaxPixels = visConfig.sizeMaxPixels;
10305
+ result.iconSizeMaxPixels = visConfig.sizeMaxPixels;
10306
+ }
10307
+ return result;
10308
+ }
10285
10309
  function mapProps(source, target, mapping) {
10286
10310
  for (const sourceKey in mapping) {
10287
10311
  const sourceValue = source[sourceKey];
@@ -10671,7 +10695,15 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10671
10695
  } = secondaryLabel || {};
10672
10696
  result.getText = mainLabel.field && getTextAccessor(mainLabel.field, data);
10673
10697
  const getSecondaryText = secondaryField && getTextAccessor(secondaryField, data);
10674
- result.pointType = `${result.pointType}+text`;
10698
+ const geometry = data.tilestats?.layers?.[0]?.geometry;
10699
+ const isLineOrPolygon = geometry === "Polygon" || geometry === "MultiPolygon" || geometry === "Line" || geometry === "LineString" || geometry === "MultiLineString";
10700
+ if (isLineOrPolygon && (layerType === "tileset" || layerType === "mvt")) {
10701
+ const uniqueIdProperty = visConfig.textLabelUniqueIdField;
10702
+ result.autoLabels = uniqueIdProperty ? { uniqueIdProperty } : true;
10703
+ result.pointType = "text";
10704
+ } else {
10705
+ result.pointType = `${result.pointType}+text`;
10706
+ }
10675
10707
  result.textCharacterSet = "auto";
10676
10708
  result.textFontFamily = "Inter, sans";
10677
10709
  result.textFontSettings = { sdf: true };