azure-maps-control 3.0.2 → 3.1.0

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.
@@ -91,10 +91,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
91
91
 
92
92
  var azuremapsMaplibreGlDev = {exports: {}};
93
93
 
94
- /* Build timestamp: Tue, 15 Aug 2023 00:27:33 GMT */
94
+ /* Build timestamp: Thu, 16 Nov 2023 20:40:59 GMT */
95
95
 
96
96
  (function (module, exports) {
97
- /* The Azure Maps fork of MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.3.0/LICENSE.txt */
97
+ /* The Azure Maps fork of MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v3.6.1/LICENSE.txt */
98
98
  (function (global, factory) {
99
99
  module.exports = factory() ;
100
100
  })(commonjsGlobal, (function () {
@@ -121,7 +121,22 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
121
121
  }
122
122
 
123
123
 
124
- define(['exports'], (function (exports) {
124
+ define(['exports'], (function (exports) {
125
+ function __awaiter(thisArg, _arguments, P, generator) {
126
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
127
+ return new (P || (P = Promise))(function (resolve, reject) {
128
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
129
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
130
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
131
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
132
+ });
133
+ }
134
+
135
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
136
+ var e = new Error(message);
137
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
138
+ };
139
+
125
140
  function getDefaultExportFromCjs (x) {
126
141
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
127
142
  }
@@ -518,6 +533,52 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
518
533
 
519
534
  var UnitBezier$1 = /*@__PURE__*/getDefaultExportFromCjs(unitbezier);
520
535
 
536
+ let supportsOffscreenCanvas;
537
+ function offscreenCanvasSupported() {
538
+ if (supportsOffscreenCanvas == null) {
539
+ supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&
540
+ new OffscreenCanvas(1, 1).getContext('2d') &&
541
+ typeof createImageBitmap === 'function';
542
+ }
543
+ return supportsOffscreenCanvas;
544
+ }
545
+
546
+ let offscreenCanvasDistorted;
547
+ /**
548
+ * Some browsers don't return the exact pixels from a canvas to prevent user fingerprinting (see #3185).
549
+ * This function writes pixels to an OffscreenCanvas and reads them back using getImageData, returning false
550
+ * if they don't match.
551
+ *
552
+ * @returns true if the browser supports OffscreenCanvas but it distorts getImageData results, false otherwise.
553
+ */
554
+ function isOffscreenCanvasDistorted() {
555
+ if (offscreenCanvasDistorted == null) {
556
+ offscreenCanvasDistorted = false;
557
+ if (offscreenCanvasSupported()) {
558
+ const size = 5;
559
+ const canvas = new OffscreenCanvas(size, size);
560
+ const context = canvas.getContext('2d', { willReadFrequently: true });
561
+ if (context) {
562
+ // fill each pixel with an RGB value that should make the byte at index i equal to i (except alpha channel):
563
+ // [0, 1, 2, 255, 4, 5, 6, 255, 8, 9, 10, 255, ...]
564
+ for (let i = 0; i < size * size; i++) {
565
+ const base = i * 4;
566
+ context.fillStyle = `rgb(${base},${base + 1},${base + 2})`;
567
+ context.fillRect(i % size, Math.floor(i / size), 1, 1);
568
+ }
569
+ const data = context.getImageData(0, 0, size, size).data;
570
+ for (let i = 0; i < size * size * 4; i++) {
571
+ if (i % 4 !== 3 && data[i] !== i) {
572
+ offscreenCanvasDistorted = true;
573
+ break;
574
+ }
575
+ }
576
+ }
577
+ }
578
+ }
579
+ return offscreenCanvasDistorted || false;
580
+ }
581
+
521
582
  /**
522
583
  * Given a value `t` that varies between 0 and 1, return
523
584
  * an interpolation function that eases between 0 and 1 in a pleasing
@@ -943,6 +1004,143 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
943
1004
  const blob = new Blob([new Uint8Array(data)], { type: 'image/png' });
944
1005
  img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;
945
1006
  }
1007
+ /**
1008
+ * Computes the webcodecs VideoFrame API options to select a rectangle out of
1009
+ * an image and write it into the destination rectangle.
1010
+ *
1011
+ * Rect (x/y/width/height) select the overlapping rectangle from the source image
1012
+ * and layout (offset/stride) write that overlapping rectangle to the correct place
1013
+ * in the destination image.
1014
+ *
1015
+ * Offset is the byte offset in the dest image that the first pixel appears at
1016
+ * and stride is the number of bytes to the start of the next row:
1017
+ * ┌───────────┐
1018
+ * │ dest │
1019
+ * │ ┌───┼───────┐
1020
+ * │offset→│▓▓▓│ source│
1021
+ * │ │▓▓▓│ │
1022
+ * │ └───┼───────┘
1023
+ * │stride ⇠╌╌╌│
1024
+ * │╌╌╌╌╌╌→ │
1025
+ * └───────────┘
1026
+ *
1027
+ * @param image - source image containing a width and height attribute
1028
+ * @param x - top-left x coordinate to read from the image
1029
+ * @param y - top-left y coordinate to read from the image
1030
+ * @param width - width of the rectangle to read from the image
1031
+ * @param height - height of the rectangle to read from the image
1032
+ * @returns the layout and rect options to pass into VideoFrame API
1033
+ */
1034
+ function computeVideoFrameParameters(image, x, y, width, height) {
1035
+ const destRowOffset = Math.max(-x, 0) * 4;
1036
+ const firstSourceRow = Math.max(0, y);
1037
+ const firstDestRow = firstSourceRow - y;
1038
+ const offset = firstDestRow * width * 4 + destRowOffset;
1039
+ const stride = width * 4;
1040
+ const sourceLeft = Math.max(0, x);
1041
+ const sourceTop = Math.max(0, y);
1042
+ const sourceRight = Math.min(image.width, x + width);
1043
+ const sourceBottom = Math.min(image.height, y + height);
1044
+ return {
1045
+ rect: {
1046
+ x: sourceLeft,
1047
+ y: sourceTop,
1048
+ width: sourceRight - sourceLeft,
1049
+ height: sourceBottom - sourceTop
1050
+ },
1051
+ layout: [{ offset, stride }]
1052
+ };
1053
+ }
1054
+ /**
1055
+ * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.
1056
+ *
1057
+ * @param data - image, imagebitmap, or canvas to parse
1058
+ * @param x - top-left x coordinate to read from the image
1059
+ * @param y - top-left y coordinate to read from the image
1060
+ * @param width - width of the rectangle to read from the image
1061
+ * @param height - height of the rectangle to read from the image
1062
+ * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred
1063
+ */
1064
+ function readImageUsingVideoFrame(image, x, y, width, height) {
1065
+ return __awaiter(this, void 0, void 0, function* () {
1066
+ if (typeof VideoFrame === 'undefined') {
1067
+ throw new Error('VideoFrame not supported');
1068
+ }
1069
+ const frame = new VideoFrame(image, { timestamp: 0 });
1070
+ try {
1071
+ const format = frame === null || frame === void 0 ? void 0 : frame.format;
1072
+ if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {
1073
+ throw new Error(`Unrecognized format ${format}`);
1074
+ }
1075
+ const swapBR = format.startsWith('BGR');
1076
+ const result = new Uint8ClampedArray(width * height * 4);
1077
+ yield frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));
1078
+ if (swapBR) {
1079
+ for (let i = 0; i < result.length; i += 4) {
1080
+ const tmp = result[i];
1081
+ result[i] = result[i + 2];
1082
+ result[i + 2] = tmp;
1083
+ }
1084
+ }
1085
+ return result;
1086
+ }
1087
+ finally {
1088
+ frame.close();
1089
+ }
1090
+ });
1091
+ }
1092
+ let offscreenCanvas;
1093
+ let offscreenCanvasContext;
1094
+ /**
1095
+ * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas
1096
+ *
1097
+ * @param data - image, imagebitmap, or canvas to parse
1098
+ * @param x - top-left x coordinate to read from the image
1099
+ * @param y - top-left y coordinate to read from the image
1100
+ * @param width - width of the rectangle to read from the image
1101
+ * @param height - height of the rectangle to read from the image
1102
+ * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred
1103
+ */
1104
+ function readImageDataUsingOffscreenCanvas(imgBitmap, x, y, width, height) {
1105
+ const origWidth = imgBitmap.width;
1106
+ const origHeight = imgBitmap.height;
1107
+ // Lazily initialize OffscreenCanvas
1108
+ if (!offscreenCanvas || !offscreenCanvasContext) {
1109
+ // Dem tiles are typically 256x256
1110
+ offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);
1111
+ offscreenCanvasContext = offscreenCanvas.getContext('2d', { willReadFrequently: true });
1112
+ }
1113
+ offscreenCanvas.width = origWidth;
1114
+ offscreenCanvas.height = origHeight;
1115
+ offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);
1116
+ const imgData = offscreenCanvasContext.getImageData(x, y, width, height);
1117
+ offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);
1118
+ return imgData.data;
1119
+ }
1120
+ /**
1121
+ * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and
1122
+ * the browser is mangling OffscreenCanvas getImageData results.
1123
+ *
1124
+ * @param data - image, imagebitmap, or canvas to parse
1125
+ * @param x - top-left x coordinate to read from the image
1126
+ * @param y - top-left y coordinate to read from the image
1127
+ * @param width - width of the rectangle to read from the image
1128
+ * @param height - height of the rectangle to read from the image
1129
+ * @returns a promise containing the parsed RGBA pixel values of the image
1130
+ */
1131
+ function getImageData(image, x, y, width, height) {
1132
+ return __awaiter(this, void 0, void 0, function* () {
1133
+ if (isOffscreenCanvasDistorted()) {
1134
+ try {
1135
+ return yield readImageUsingVideoFrame(image, x, y, width, height);
1136
+ }
1137
+ catch (e) {
1138
+ // fall back to OffscreenCanvas
1139
+ }
1140
+ }
1141
+ return readImageDataUsingOffscreenCanvas(image, x, y, width, height);
1142
+ });
1143
+ }
946
1144
 
947
1145
  const now = typeof performance !== 'undefined' && performance && performance.now ?
948
1146
  performance.now.bind(performance) :
@@ -1579,10 +1777,28 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
1579
1777
  terrarium: {
1580
1778
  },
1581
1779
  mapbox: {
1780
+ },
1781
+ custom: {
1582
1782
  }
1583
1783
  },
1584
1784
  "default": "mapbox"
1585
1785
  },
1786
+ redFactor: {
1787
+ type: "number",
1788
+ "default": 1
1789
+ },
1790
+ blueFactor: {
1791
+ type: "number",
1792
+ "default": 1
1793
+ },
1794
+ greenFactor: {
1795
+ type: "number",
1796
+ "default": 1
1797
+ },
1798
+ baseShift: {
1799
+ type: "number",
1800
+ "default": 0
1801
+ },
1586
1802
  volatile: {
1587
1803
  type: "boolean",
1588
1804
  "default": false
@@ -8856,6 +9072,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
8856
9072
  }
8857
9073
  }
8858
9074
  }
9075
+ function isZoomExpression(expression) {
9076
+ return expression._styleExpression !== undefined;
9077
+ }
8859
9078
  function createPropertyExpression(expressionInput, propertySpec) {
8860
9079
  const expression = createExpression(expressionInput, propertySpec);
8861
9080
  if (expression.result === 'error') {
@@ -9871,6 +10090,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9871
10090
  else if (sourceType === 'vector' && type === 'raster') {
9872
10091
  errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster source`));
9873
10092
  }
10093
+ else if (sourceType !== 'raster-dem' && type === 'hillshade') {
10094
+ errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a raster-dem source`));
10095
+ }
9874
10096
  else if (sourceType === 'raster' && type !== 'raster') {
9875
10097
  errors.push(new ValidationError(key, layer.source, `layer "${layer.id}" requires a vector source`));
9876
10098
  }
@@ -9957,6 +10179,47 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9957
10179
  return [];
9958
10180
  }
9959
10181
 
10182
+ function validateRasterDEMSource(options) {
10183
+ var _a;
10184
+ const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';
10185
+ const rasterDEM = options.value;
10186
+ const styleSpec = options.styleSpec;
10187
+ const rasterDEMSpec = styleSpec.source_raster_dem;
10188
+ const style = options.style;
10189
+ let errors = [];
10190
+ const rootType = getType(rasterDEM);
10191
+ if (rasterDEM === undefined) {
10192
+ return errors;
10193
+ }
10194
+ else if (rootType !== 'object') {
10195
+ errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));
10196
+ return errors;
10197
+ }
10198
+ const encoding = unbundle(rasterDEM.encoding);
10199
+ const isCustomEncoding = encoding === 'custom';
10200
+ const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];
10201
+ const encodingName = options.value.encoding ? `"${options.value.encoding}"` : 'Default';
10202
+ for (const key in rasterDEM) {
10203
+ if (!isCustomEncoding && customEncodingKeys.includes(key)) {
10204
+ errors.push(new ValidationError(key, rasterDEM[key], `In "${sourceName}": "${key}" is only valid when "encoding" is set to "custom". ${encodingName} encoding found`));
10205
+ }
10206
+ else if (rasterDEMSpec[key]) {
10207
+ errors = errors.concat(options.validateSpec({
10208
+ key,
10209
+ value: rasterDEM[key],
10210
+ valueSpec: rasterDEMSpec[key],
10211
+ validateSpec: options.validateSpec,
10212
+ style,
10213
+ styleSpec
10214
+ }));
10215
+ }
10216
+ else {
10217
+ errors.push(new ValidationError(key, rasterDEM[key], `unknown property "${key}"`));
10218
+ }
10219
+ }
10220
+ return errors;
10221
+ }
10222
+
9960
10223
  const objectElementValidators = {
9961
10224
  promoteId: validatePromoteId
9962
10225
  };
@@ -9974,7 +10237,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9974
10237
  switch (type) {
9975
10238
  case 'vector':
9976
10239
  case 'raster':
9977
- case 'raster-dem':
9978
10240
  errors = validateObject({
9979
10241
  key,
9980
10242
  value,
@@ -9985,6 +10247,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
9985
10247
  validateSpec,
9986
10248
  });
9987
10249
  return errors;
10250
+ case 'raster-dem':
10251
+ errors = validateRasterDEMSource({
10252
+ sourceName: key,
10253
+ value,
10254
+ style: options.style,
10255
+ styleSpec,
10256
+ validateSpec,
10257
+ });
10258
+ return errors;
9988
10259
  case 'geojson':
9989
10260
  errors = validateObject({
9990
10261
  key,
@@ -10698,7 +10969,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10698
10969
  klass.serialize(input, transferables) : {};
10699
10970
  if (!klass.serialize) {
10700
10971
  for (const key in input) {
10701
- // any cast due to https://github.com/facebook/flow/issues/5393
10702
10972
  if (!input.hasOwnProperty(key))
10703
10973
  continue; // eslint-disable-line no-prototype-builtins
10704
10974
  if (registry[name].omit.indexOf(key) >= 0)
@@ -18641,8 +18911,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
18641
18911
  }
18642
18912
  _handleSpecialPaintPropertyUpdate(name) {
18643
18913
  if (name === 'line-gradient') {
18644
- const expression = this._transitionablePaint._values['line-gradient'].value.expression;
18645
- this.stepInterpolant = expression._styleExpression.expression instanceof Step;
18914
+ const expression = this.gradientExpression();
18915
+ if (isZoomExpression(expression)) {
18916
+ this.stepInterpolant = expression._styleExpression.expression instanceof Step;
18917
+ }
18918
+ else {
18919
+ this.stepInterpolant = false;
18920
+ }
18646
18921
  this.gradientVersion = (this.gradientVersion + 1) % Number.MAX_SAFE_INTEGER;
18647
18922
  }
18648
18923
  }
@@ -20492,7 +20767,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
20492
20767
  /**
20493
20768
  * Called when shapedIcon.image.contentMatch is set.
20494
20769
  * Determines the dimensions of a content rectangle using the value in contentMatch.
20495
- * @param shapedIcon The icon that will be resized.
20770
+ *
20771
+ * @param shapedIcon - The icon that will be resized.
20496
20772
  * @returns Extents of the shapedIcon with contentMatch adjustments if necessary.
20497
20773
  */
20498
20774
  function applyContentMatch(shapedIcon) {
@@ -21275,7 +21551,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21275
21551
  */
21276
21552
  function resolveTokens(properties, text) {
21277
21553
  return text.replace(/{([^{}]+)}/g, (match, key) => {
21278
- return key in properties ? String(properties[key]) : '';
21554
+ return properties && key in properties ? String(properties[key]) : '';
21279
21555
  });
21280
21556
  }
21281
21557
 
@@ -21769,8 +22045,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21769
22045
  if (callback) {
21770
22046
  this.callbacks[id] = callback;
21771
22047
  }
21772
- const buffers = isSafari(this.globalScope) ? undefined : [];
21773
- this.target.postMessage({
22048
+ const buffers = [];
22049
+ const message = {
21774
22050
  id,
21775
22051
  type,
21776
22052
  hasCallback: !!callback,
@@ -21778,19 +22054,21 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21778
22054
  mustQueue,
21779
22055
  sourceMapId: this.mapId,
21780
22056
  data: serialize(data, buffers)
21781
- }, buffers);
22057
+ };
22058
+ this.target.postMessage(message, { transfer: buffers });
21782
22059
  return {
21783
22060
  cancel: () => {
21784
22061
  if (callback) {
21785
22062
  // Set the callback to null so that it never fires after the request is aborted.
21786
22063
  delete this.callbacks[id];
21787
22064
  }
21788
- this.target.postMessage({
22065
+ const cancelMessage = {
21789
22066
  id,
21790
22067
  type: '<cancel>',
21791
22068
  targetMapId,
21792
22069
  sourceMapId: this.mapId
21793
- });
22070
+ };
22071
+ this.target.postMessage(cancelMessage);
21794
22072
  }
21795
22073
  };
21796
22074
  }
@@ -21812,17 +22090,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21812
22090
  }
21813
22091
  else {
21814
22092
  let completed = false;
21815
- const buffers = isSafari(this.globalScope) ? undefined : [];
22093
+ const buffers = [];
21816
22094
  const done = task.hasCallback ? (err, data) => {
21817
22095
  completed = true;
21818
22096
  delete this.cancelCallbacks[id];
21819
- this.target.postMessage({
22097
+ const responseMessage = {
21820
22098
  id,
21821
22099
  type: '<response>',
21822
22100
  sourceMapId: this.mapId,
21823
22101
  error: err ? serialize(err) : null,
21824
22102
  data: serialize(data, buffers)
21825
- }, buffers);
22103
+ };
22104
+ this.target.postMessage(responseMessage, { transfer: buffers });
21826
22105
  } : (_) => {
21827
22106
  completed = true;
21828
22107
  };
@@ -21832,7 +22111,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21832
22111
  // task.type == 'loadTile', 'removeTile', etc.
21833
22112
  callback = this.parent[task.type](task.sourceMapId, params, done);
21834
22113
  }
21835
- else if (this.parent.getWorkerSource) {
22114
+ else if ('getWorkerSource' in this.parent) {
21836
22115
  // task.type == sourcetype.method
21837
22116
  const keys = task.type.split('.');
21838
22117
  const scope = this.parent.getWorkerSource(task.sourceMapId, keys[0], params.source);
@@ -22332,29 +22611,45 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22332
22611
  register('CanonicalTileID', CanonicalTileID);
22333
22612
  register('OverscaledTileID', OverscaledTileID, { omit: ['posMatrix'] });
22334
22613
 
22335
- // DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders
22336
- // data can be populated either from a pngraw image tile or from serliazed data sent back from a worker. When data is initially
22337
- // loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the
22338
- // elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of
22339
- // integer overflow when creating the texture used in the hillshadePrepare step.
22340
- // DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8
22341
- // surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a
22342
- // tile's edge without backfilling from neighboring tiles.
22343
22614
  class DEMData {
22344
22615
  // RGBAImage data has uniform 1px padding on all sides: square tile edge size defines stride
22345
22616
  // and dim is calculated as stride - 2.
22346
- constructor(uid, data, encoding) {
22617
+ constructor(uid, data, encoding, redFactor = 1.0, greenFactor = 1.0, blueFactor = 1.0, baseShift = 0.0) {
22347
22618
  this.uid = uid;
22348
22619
  if (data.height !== data.width)
22349
22620
  throw new RangeError('DEM tiles must be square');
22350
- if (encoding && encoding !== 'mapbox' && encoding !== 'terrarium') {
22351
- warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);
22621
+ if (encoding && !['mapbox', 'terrarium', 'custom'].includes(encoding)) {
22622
+ warnOnce(`"${encoding}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);
22352
22623
  return;
22353
22624
  }
22354
22625
  this.stride = data.height;
22355
22626
  const dim = this.dim = data.height - 2;
22356
22627
  this.data = new Uint32Array(data.data.buffer);
22357
- this.encoding = encoding || 'mapbox';
22628
+ switch (encoding) {
22629
+ case 'terrarium':
22630
+ // unpacking formula for mapzen terrarium:
22631
+ // https://aws.amazon.com/public-datasets/terrain/
22632
+ this.redFactor = 256.0;
22633
+ this.greenFactor = 1.0;
22634
+ this.blueFactor = 1.0 / 256.0;
22635
+ this.baseShift = 32768.0;
22636
+ break;
22637
+ case 'custom':
22638
+ this.redFactor = redFactor;
22639
+ this.greenFactor = greenFactor;
22640
+ this.blueFactor = blueFactor;
22641
+ this.baseShift = baseShift;
22642
+ break;
22643
+ case 'mapbox':
22644
+ default:
22645
+ // unpacking formula for mapbox.terrain-rgb:
22646
+ // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
22647
+ this.redFactor = 6553.6;
22648
+ this.greenFactor = 25.6;
22649
+ this.blueFactor = 0.1;
22650
+ this.baseShift = 10000.0;
22651
+ break;
22652
+ }
22358
22653
  // in order to avoid flashing seams between tiles, here we are initially populating a 1px border of pixels around the image
22359
22654
  // with the data of the nearest pixel from the image. this data is eventually replaced when the tile's neighboring
22360
22655
  // tiles are loaded and the accurate data can be backfilled using DEMData#backfillBorder
@@ -22389,26 +22684,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22389
22684
  get(x, y) {
22390
22685
  const pixels = new Uint8Array(this.data.buffer);
22391
22686
  const index = this._idx(x, y) * 4;
22392
- const unpack = this.encoding === 'terrarium' ? this._unpackTerrarium : this._unpackMapbox;
22393
- return unpack(pixels[index], pixels[index + 1], pixels[index + 2]);
22687
+ return this.unpack(pixels[index], pixels[index + 1], pixels[index + 2]);
22394
22688
  }
22395
22689
  getUnpackVector() {
22396
- return this.encoding === 'terrarium' ? [256.0, 1.0, 1.0 / 256.0, 32768.0] : [6553.6, 25.6, 0.1, 10000.0];
22690
+ return [this.redFactor, this.greenFactor, this.blueFactor, this.baseShift];
22397
22691
  }
22398
22692
  _idx(x, y) {
22399
22693
  if (x < -1 || x >= this.dim + 1 || y < -1 || y >= this.dim + 1)
22400
22694
  throw new RangeError('out of range source coordinates for DEM data');
22401
22695
  return (y + 1) * this.stride + (x + 1);
22402
22696
  }
22403
- _unpackMapbox(r, g, b) {
22404
- // unpacking formula for mapbox.terrain-rgb:
22405
- // https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
22406
- return ((r * 256 * 256 + g * 256.0 + b) / 10.0 - 10000.0);
22407
- }
22408
- _unpackTerrarium(r, g, b) {
22409
- // unpacking formula for mapzen terrarium:
22410
- // https://aws.amazon.com/public-datasets/terrain/
22411
- return ((r * 256 + g + b / 256) - 32768.0);
22697
+ unpack(r, g, b) {
22698
+ return (r * this.redFactor + g * this.greenFactor + b * this.blueFactor - this.baseShift);
22412
22699
  }
22413
22700
  getPixels() {
22414
22701
  return new RGBAImage({ width: this.stride, height: this.stride }, new Uint8Array(this.data.buffer));
@@ -23107,10 +23394,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23107
23394
  verticalizedLabelOffset = builtInOffset;
23108
23395
  builtInOffset = [0, 0];
23109
23396
  }
23397
+ const textureScale = positionedGlyph.metrics.isDoubleResolution ? 2 : 1;
23110
23398
  const x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];
23111
23399
  const y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset[1];
23112
- const x2 = x1 + textureRect.w * positionedGlyph.scale / pixelRatio;
23113
- const y2 = y1 + textureRect.h * positionedGlyph.scale / pixelRatio;
23400
+ const x2 = x1 + textureRect.w / textureScale * positionedGlyph.scale / pixelRatio;
23401
+ const y2 = y1 + textureRect.h / textureScale * positionedGlyph.scale / pixelRatio;
23114
23402
  const tl = new Point$2(x1, y1);
23115
23403
  const tr = new Point$2(x2, y1);
23116
23404
  const bl = new Point$2(x1, y2);
@@ -23454,7 +23742,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23454
23742
  if (radialOffset < 0)
23455
23743
  radialOffset = 0; // Ignore negative offset.
23456
23744
  // solve for r where r^2 + r^2 = radialOffset^2
23457
- const hypotenuse = radialOffset / Math.sqrt(2);
23745
+ const hypotenuse = radialOffset / Math.SQRT2;
23458
23746
  switch (anchor) {
23459
23747
  case 'top-right':
23460
23748
  case 'top-left':
@@ -24475,6 +24763,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24475
24763
  exports.UnwrappedTileID = UnwrappedTileID;
24476
24764
  exports.ValidationError = ValidationError;
24477
24765
  exports.ZoomHistory = ZoomHistory;
24766
+ exports.__awaiter = __awaiter;
24478
24767
  exports.add = add$4;
24479
24768
  exports.addDynamicAttributes = addDynamicAttributes;
24480
24769
  exports.arrayBufferToImage = arrayBufferToImage;
@@ -24520,6 +24809,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24520
24809
  exports.getAnchorJustification = getAnchorJustification;
24521
24810
  exports.getArrayBuffer = getArrayBuffer;
24522
24811
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
24812
+ exports.getImageData = getImageData;
24523
24813
  exports.getJSON = getJSON;
24524
24814
  exports.getOverlapMode = getOverlapMode;
24525
24815
  exports.getProtocolAction = getProtocolAction;
@@ -24531,6 +24821,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24531
24821
  exports.interpolate = interpolate;
24532
24822
  exports.invert = invert$2;
24533
24823
  exports.isImageBitmap = isImageBitmap;
24824
+ exports.isOffscreenCanvasDistorted = isOffscreenCanvasDistorted;
24534
24825
  exports.isSafari = isSafari;
24535
24826
  exports.isWorker = isWorker;
24536
24827
  exports.keysDifference = keysDifference;
@@ -24545,6 +24836,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24545
24836
  exports.multiply = multiply$5;
24546
24837
  exports.nextPowerOfTwo = nextPowerOfTwo;
24547
24838
  exports.normalize = normalize$4;
24839
+ exports.offscreenCanvasSupported = offscreenCanvasSupported;
24548
24840
  exports.operations = operations;
24549
24841
  exports.ortho = ortho;
24550
24842
  exports.parseCacheControl = parseCacheControl;
@@ -24557,6 +24849,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24557
24849
  exports.pointGeometry = pointGeometry;
24558
24850
  exports.polygonIntersectsPolygon = polygonIntersectsPolygon;
24559
24851
  exports.potpack = potpack;
24852
+ exports.readImageUsingVideoFrame = readImageUsingVideoFrame;
24560
24853
  exports.register = register;
24561
24854
  exports.registerForPluginStateChange = registerForPluginStateChange;
24562
24855
  exports.renderColorRamp = renderColorRamp;
@@ -24871,12 +25164,27 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24871
25164
  callback(err);
24872
25165
  }
24873
25166
  else if (data) {
24874
- callback(null, {
24875
- vectorTile: new performance.vectorTile.VectorTile(new performance.Protobuf(data)),
24876
- rawData: data,
24877
- cacheControl,
24878
- expires
24879
- });
25167
+ try {
25168
+ const vectorTile = new performance.vectorTile.VectorTile(new performance.Protobuf(data));
25169
+ callback(null, {
25170
+ vectorTile,
25171
+ rawData: data,
25172
+ cacheControl,
25173
+ expires
25174
+ });
25175
+ }
25176
+ catch (ex) {
25177
+ const bytes = new Uint8Array(data);
25178
+ const isGzipped = bytes[0] === 0x1f && bytes[1] === 0x8b;
25179
+ let errorMessage = `Unable to parse the tile at ${params.request.url}, `;
25180
+ if (isGzipped) {
25181
+ errorMessage += 'please make sure the data is not gzipped and that you have configured the relevant header in the server';
25182
+ }
25183
+ else {
25184
+ errorMessage += `got error: ${ex.messge}`;
25185
+ }
25186
+ callback(new Error(errorMessage));
25187
+ }
24880
25188
  }
24881
25189
  });
24882
25190
  return () => {
@@ -25025,28 +25333,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25025
25333
  this.loaded = {};
25026
25334
  }
25027
25335
  loadTile(params, callback) {
25028
- const { uid, encoding, rawImageData } = params;
25029
- // Main thread will transfer ImageBitmap if offscreen decode with OffscreenCanvas is supported, else it will transfer an already decoded image.
25030
- const imagePixels = performance.isImageBitmap(rawImageData) ? this.getImageData(rawImageData) : rawImageData;
25031
- const dem = new performance.DEMData(uid, imagePixels, encoding);
25032
- this.loaded = this.loaded || {};
25033
- this.loaded[uid] = dem;
25034
- callback(null, dem);
25035
- }
25036
- getImageData(imgBitmap) {
25037
- // Lazily initialize OffscreenCanvas
25038
- if (!this.offscreenCanvas || !this.offscreenCanvasContext) {
25039
- // Dem tiles are typically 256x256
25040
- this.offscreenCanvas = new OffscreenCanvas(imgBitmap.width, imgBitmap.height);
25041
- this.offscreenCanvasContext = this.offscreenCanvas.getContext('2d', { willReadFrequently: true });
25042
- }
25043
- this.offscreenCanvas.width = imgBitmap.width;
25044
- this.offscreenCanvas.height = imgBitmap.height;
25045
- this.offscreenCanvasContext.drawImage(imgBitmap, 0, 0, imgBitmap.width, imgBitmap.height);
25046
- // Insert an additional 1px padding around the image to allow backfilling for neighboring data.
25047
- const imgData = this.offscreenCanvasContext.getImageData(-1, -1, imgBitmap.width + 2, imgBitmap.height + 2);
25048
- this.offscreenCanvasContext.clearRect(0, 0, this.offscreenCanvas.width, this.offscreenCanvas.height);
25049
- return new performance.RGBAImage({ width: imgData.width, height: imgData.height }, imgData.data);
25336
+ return performance.__awaiter(this, void 0, void 0, function* () {
25337
+ const { uid, encoding, rawImageData, redFactor, greenFactor, blueFactor, baseShift } = params;
25338
+ const width = rawImageData.width + 2;
25339
+ const height = rawImageData.height + 2;
25340
+ const imagePixels = performance.isImageBitmap(rawImageData) ?
25341
+ new performance.RGBAImage({ width, height }, yield performance.getImageData(rawImageData, -1, -1, width, height)) :
25342
+ rawImageData;
25343
+ const dem = new performance.DEMData(uid, imagePixels, encoding, redFactor, greenFactor, blueFactor, baseShift);
25344
+ this.loaded = this.loaded || {};
25345
+ this.loaded[uid] = dem;
25346
+ callback(null, dem);
25347
+ });
25050
25348
  }
25051
25349
  removeTile(params) {
25052
25350
  const loaded = this.loaded, uid = params.uid;
@@ -26787,10 +27085,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26787
27085
  // note: removeAllProperties gives us a new properties object, so we can skip the clone step
26788
27086
  const cloneProperties = !update.removeAllProperties && (((_a = update.removeProperties) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = update.addOrUpdateProperties) === null || _b === void 0 ? void 0 : _b.length) > 0);
26789
27087
  if (cloneFeature || cloneProperties) {
26790
- feature = { ...feature };
27088
+ feature = Object.assign({}, feature);
26791
27089
  updateable.set(update.id, feature);
26792
27090
  if (cloneProperties) {
26793
- feature.properties = { ...feature.properties };
27091
+ feature.properties = Object.assign({}, feature.properties);
26794
27092
  }
26795
27093
  }
26796
27094
  if (update.newGeometry) {
@@ -26815,34 +27113,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26815
27113
  }
26816
27114
  }
26817
27115
 
26818
- function loadGeoJSONTile(params, callback) {
26819
- const canonical = params.tileID.canonical;
26820
- if (!this._geoJSONIndex) {
26821
- return callback(null, null); // we couldn't load the file
26822
- }
26823
- const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);
26824
- if (!geoJSONTile) {
26825
- return callback(null, null); // nothing in the given tile
26826
- }
26827
- const geojsonWrapper = new GeoJSONWrapper$2(geoJSONTile.features);
26828
- // Encode the geojson-vt tile into binary vector tile form. This
26829
- // is a convenience that allows `FeatureIndex` to operate the same way
26830
- // across `VectorTileSource` and `GeoJSONSource` data.
26831
- let pbf = vtpbf(geojsonWrapper);
26832
- if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {
26833
- // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)
26834
- pbf = new Uint8Array(pbf);
26835
- }
26836
- callback(null, {
26837
- vectorTile: geojsonWrapper,
26838
- rawData: pbf.buffer
26839
- });
26840
- }
26841
27116
  /**
26842
27117
  * The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.
26843
27118
  * This class is designed to be easily reused to support custom source types
26844
27119
  * for data formats that can be parsed/converted into an in-memory GeoJSON
26845
- * representation. To do so, create it with
27120
+ * representation. To do so, create it with
26846
27121
  * `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.
26847
27122
  * For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).
26848
27123
  */
@@ -26853,7 +27128,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26853
27128
  * See {@link GeoJSONWorkerSource#loadGeoJSON}.
26854
27129
  */
26855
27130
  constructor(actor, layerIndex, availableImages, loadGeoJSON) {
26856
- super(actor, layerIndex, availableImages, loadGeoJSONTile);
27131
+ super(actor, layerIndex, availableImages);
26857
27132
  this._dataUpdateable = new Map();
26858
27133
  /**
26859
27134
  * Fetch and parse GeoJSON according to the given params. Calls `callback`
@@ -26902,10 +27177,34 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26902
27177
  }
26903
27178
  return { cancel: () => { } };
26904
27179
  };
27180
+ this.loadVectorData = this.loadGeoJSONTile;
26905
27181
  if (loadGeoJSON) {
26906
27182
  this.loadGeoJSON = loadGeoJSON;
26907
27183
  }
26908
27184
  }
27185
+ loadGeoJSONTile(params, callback) {
27186
+ const canonical = params.tileID.canonical;
27187
+ if (!this._geoJSONIndex) {
27188
+ return callback(null, null); // we couldn't load the file
27189
+ }
27190
+ const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);
27191
+ if (!geoJSONTile) {
27192
+ return callback(null, null); // nothing in the given tile
27193
+ }
27194
+ const geojsonWrapper = new GeoJSONWrapper$2(geoJSONTile.features);
27195
+ // Encode the geojson-vt tile into binary vector tile form. This
27196
+ // is a convenience that allows `FeatureIndex` to operate the same way
27197
+ // across `VectorTileSource` and `GeoJSONSource` data.
27198
+ let pbf = vtpbf(geojsonWrapper);
27199
+ if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {
27200
+ // Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)
27201
+ pbf = new Uint8Array(pbf);
27202
+ }
27203
+ callback(null, {
27204
+ vectorTile: geojsonWrapper,
27205
+ rawData: pbf.buffer
27206
+ });
27207
+ }
26909
27208
  /**
26910
27209
  * Fetches (if appropriate), parses, and index geojson data into tiles. This
26911
27210
  * preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}
@@ -27187,12 +27486,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27187
27486
  }
27188
27487
  return layerIndexes;
27189
27488
  }
27190
- getWorkerSource(mapId, type, source) {
27489
+ getWorkerSource(mapId, sourceType, sourceName) {
27191
27490
  if (!this.workerSources[mapId])
27192
27491
  this.workerSources[mapId] = {};
27193
- if (!this.workerSources[mapId][type])
27194
- this.workerSources[mapId][type] = {};
27195
- if (!this.workerSources[mapId][type][source]) {
27492
+ if (!this.workerSources[mapId][sourceType])
27493
+ this.workerSources[mapId][sourceType] = {};
27494
+ if (!this.workerSources[mapId][sourceType][sourceName]) {
27196
27495
  // use a wrapped actor so that we can attach a target mapId param
27197
27496
  // to any messages invoked by the WorkerSource
27198
27497
  const actor = {
@@ -27200,9 +27499,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27200
27499
  this.actor.send(type, data, callback, mapId);
27201
27500
  }
27202
27501
  };
27203
- this.workerSources[mapId][type][source] = new this.workerSourceTypes[type](actor, this.getLayerIndex(mapId), this.getAvailableImages(mapId));
27502
+ this.workerSources[mapId][sourceType][sourceName] = new this.workerSourceTypes[sourceType](actor, this.getLayerIndex(mapId), this.getAvailableImages(mapId));
27204
27503
  }
27205
- return this.workerSources[mapId][type][source];
27504
+ return this.workerSources[mapId][sourceType][sourceName];
27206
27505
  }
27207
27506
  getDEMWorkerSource(mapId, source) {
27208
27507
  if (!this.demWorkerSources[mapId])
@@ -27224,7 +27523,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27224
27523
  define(['./shared'], (function (performance) {
27225
27524
  var name = "azuremaps-maplibre-gl";
27226
27525
  var description = "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library";
27227
- var version$2 = "3.3.0";
27526
+ var version$2 = "3.6.1";
27228
27527
  var main = "dist/azuremaps-maplibre-gl.js";
27229
27528
  var style = "dist/azuremaps-maplibre-gl.css";
27230
27529
  var license = "BSD-3-Clause";
@@ -27243,12 +27542,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27243
27542
  "@mapbox/unitbezier": "^0.0.1",
27244
27543
  "@mapbox/vector-tile": "^1.3.1",
27245
27544
  "@mapbox/whoots-js": "^3.1.0",
27246
- "@maplibre/maplibre-gl-style-spec": "^19.3.0",
27247
- "@types/geojson": "^7946.0.10",
27248
- "@types/mapbox__point-geometry": "^0.1.2",
27249
- "@types/mapbox__vector-tile": "^1.3.0",
27250
- "@types/pbf": "^3.0.2",
27251
- "@types/supercluster": "^7.1.0",
27545
+ "@maplibre/maplibre-gl-style-spec": "^19.3.3",
27546
+ "@types/geojson": "^7946.0.13",
27547
+ "@types/mapbox__point-geometry": "^0.1.4",
27548
+ "@types/mapbox__vector-tile": "^1.3.3",
27549
+ "@types/pbf": "^3.0.4",
27550
+ "@types/supercluster": "^7.1.3",
27252
27551
  earcut: "^2.2.4",
27253
27552
  "geojson-vt": "^3.2.1",
27254
27553
  "gl-matrix": "^3.4.3",
@@ -27265,94 +27564,94 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27265
27564
  var devDependencies = {
27266
27565
  "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
27267
27566
  "@mapbox/mvt-fixtures": "^3.10.0",
27268
- "@rollup/plugin-commonjs": "^25.0.3",
27269
- "@rollup/plugin-json": "^6.0.0",
27270
- "@rollup/plugin-node-resolve": "^15.1.0",
27271
- "@rollup/plugin-replace": "^5.0.2",
27272
- "@rollup/plugin-strip": "^3.0.2",
27273
- "@rollup/plugin-terser": "^0.4.3",
27274
- "@rollup/plugin-typescript": "^11.1.2",
27275
- "@types/benchmark": "^2.1.2",
27567
+ "@rollup/plugin-commonjs": "^25.0.7",
27568
+ "@rollup/plugin-json": "^6.0.1",
27569
+ "@rollup/plugin-node-resolve": "^15.2.3",
27570
+ "@rollup/plugin-replace": "^5.0.5",
27571
+ "@rollup/plugin-strip": "^3.0.4",
27572
+ "@rollup/plugin-terser": "^0.4.4",
27573
+ "@rollup/plugin-typescript": "^11.1.5",
27574
+ "@types/benchmark": "^2.1.5",
27276
27575
  "@types/cssnano": "^5.0.0",
27277
- "@types/d3": "^7.4.0",
27278
- "@types/diff": "^5.0.3",
27279
- "@types/earcut": "^2.1.1",
27280
- "@types/eslint": "^8.44.2",
27281
- "@types/gl": "^6.0.2",
27576
+ "@types/d3": "^7.4.2",
27577
+ "@types/diff": "^5.0.8",
27578
+ "@types/earcut": "^2.1.4",
27579
+ "@types/eslint": "^8.44.7",
27580
+ "@types/geojson-vt": "3.2.4",
27581
+ "@types/gl": "^6.0.4",
27282
27582
  "@types/glob": "^8.1.0",
27283
- "@types/jest": "^29.5.3",
27284
- "@types/jsdom": "^21.1.1",
27285
- "@types/minimist": "^1.2.2",
27286
- "@types/murmurhash-js": "^1.0.4",
27287
- "@types/nise": "^1.4.1",
27288
- "@types/node": "^20.4.8",
27289
- "@types/offscreencanvas": "^2019.7.0",
27290
- "@types/pixelmatch": "^5.2.4",
27291
- "@types/pngjs": "^6.0.1",
27292
- "@types/react": "^18.2.18",
27293
- "@types/react-dom": "^18.2.7",
27294
- "@types/request": "^2.48.8",
27295
- "@types/shuffle-seed": "^1.1.0",
27296
- "@types/window-or-global": "^1.0.4",
27297
- "@typescript-eslint/eslint-plugin": "^6.2.1",
27298
- "@typescript-eslint/parser": "^6.2.1",
27299
- address: "^1.2.2",
27583
+ "@types/jest": "^29.5.8",
27584
+ "@types/jsdom": "^21.1.5",
27585
+ "@types/minimist": "^1.2.5",
27586
+ "@types/murmurhash-js": "^1.0.5",
27587
+ "@types/nise": "^1.4.4",
27588
+ "@types/node": "^20.9.0",
27589
+ "@types/offscreencanvas": "^2019.7.3",
27590
+ "@types/pixelmatch": "^5.2.5",
27591
+ "@types/pngjs": "^6.0.4",
27592
+ "@types/react": "^18.2.35",
27593
+ "@types/react-dom": "^18.2.14",
27594
+ "@types/request": "^2.48.12",
27595
+ "@types/shuffle-seed": "^1.1.2",
27596
+ "@types/window-or-global": "^1.0.6",
27597
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
27598
+ "@typescript-eslint/parser": "^6.10.0",
27599
+ address: "^2.0.1",
27300
27600
  benchmark: "^2.1.4",
27301
27601
  canvas: "^2.11.2",
27302
27602
  cssnano: "^6.0.1",
27303
27603
  d3: "^7.8.5",
27304
27604
  "d3-queue": "^3.0.7",
27305
- "devtools-protocol": "^0.0.1179426",
27605
+ "devtools-protocol": "^0.0.1219864",
27306
27606
  diff: "^5.1.0",
27307
- "dts-bundle-generator": "^8.0.1",
27308
- eslint: "^8.46.0",
27607
+ "dts-bundle-generator": "^8.1.2",
27608
+ eslint: "^8.53.0",
27309
27609
  "eslint-config-mourner": "^3.0.0",
27310
27610
  "eslint-plugin-html": "^7.1.0",
27311
- "eslint-plugin-import": "^2.28.0",
27312
- "eslint-plugin-jest": "^27.2.3",
27313
- "eslint-plugin-react": "^7.33.1",
27611
+ "eslint-plugin-import": "^2.29.0",
27612
+ "eslint-plugin-jest": "^27.6.0",
27613
+ "eslint-plugin-react": "^7.33.2",
27314
27614
  "eslint-plugin-tsdoc": "0.2.17",
27315
- expect: "^29.6.2",
27615
+ expect: "^29.7.0",
27316
27616
  gl: "^6.0.2",
27317
- glob: "^10.3.3",
27617
+ glob: "^10.3.10",
27318
27618
  "is-builtin-module": "^3.2.1",
27319
- jest: "^29.6.2",
27619
+ jest: "^29.7.0",
27320
27620
  "jest-canvas-mock": "^2.5.2",
27321
- "jest-environment-jsdom": "^29.6.2",
27621
+ "jest-environment-jsdom": "^29.7.0",
27322
27622
  jsdom: "^22.1.0",
27323
27623
  "json-stringify-pretty-compact": "^4.0.0",
27324
27624
  minimist: "^1.2.8",
27325
27625
  "mock-geolocation": "^1.0.11",
27326
- nise: "^5.1.4",
27327
- "node-plantuml": "^0.9.0",
27626
+ nise: "^5.1.5",
27328
27627
  "npm-font-open-sans": "^1.1.0",
27329
27628
  "npm-run-all": "^4.1.5",
27330
27629
  "pdf-merger-js": "^4.3.0",
27331
27630
  pixelmatch: "^5.3.0",
27332
27631
  pngjs: "^7.0.0",
27333
- postcss: "^8.4.27",
27632
+ postcss: "^8.4.31",
27334
27633
  "postcss-cli": "^10.1.0",
27335
27634
  "postcss-inline-svg": "^6.0.0",
27336
27635
  "pretty-bytes": "^6.1.1",
27337
- puppeteer: "^21.0.1",
27636
+ puppeteer: "^21.5.1",
27338
27637
  react: "^18.2.0",
27339
27638
  "react-dom": "^18.2.0",
27340
- rollup: "^3.27.2",
27639
+ rollup: "^4.4.0",
27341
27640
  "rollup-plugin-sourcemaps": "^0.6.3",
27342
27641
  rw: "^1.3.3",
27343
27642
  semver: "^7.5.4",
27344
27643
  "shuffle-seed": "^1.1.6",
27345
27644
  "source-map-explorer": "^2.5.3",
27346
27645
  st: "^3.0.0",
27347
- stylelint: "^15.10.2",
27646
+ stylelint: "^15.11.0",
27348
27647
  "stylelint-config-standard": "^34.0.0",
27349
27648
  "ts-jest": "^29.1.1",
27350
27649
  "ts-node": "^10.9.1",
27351
- tslib: "^2.6.1",
27352
- typedoc: "^0.24.8",
27353
- "typedoc-plugin-markdown": "^3.15.4",
27354
- "typedoc-plugin-missing-exports": "^2.0.1",
27355
- typescript: "^5.1.6"
27650
+ tslib: "^2.6.2",
27651
+ typedoc: "^0.25.3",
27652
+ "typedoc-plugin-markdown": "^3.17.1",
27653
+ "typedoc-plugin-missing-exports": "^2.1.0",
27654
+ typescript: "^5.2.2"
27356
27655
  };
27357
27656
  var overrides = {
27358
27657
  "postcss-inline-svg": {
@@ -27378,11 +27677,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27378
27677
  "build-csp": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts",
27379
27678
  "build-csp-dev": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.csp.ts --environment BUILD:dev",
27380
27679
  "build-css": "postcss -o dist/azuremaps-maplibre-gl.css src/css/azuremaps-maplibre-gl.css",
27381
- "build-diagrams": "cd docs/diagrams; ls *.plantuml | xargs -I {} puml generate --svg {} -o {}.svg",
27382
27680
  "watch-css": "postcss --watch -o dist/azuremaps-maplibre-gl.css src/css/azuremaps-maplibre-gl.css",
27383
27681
  "build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts",
27384
27682
  "watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch",
27385
27683
  "start-server": "st --no-cache -H 0.0.0.0 --port 9966 .",
27684
+ "start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material",
27386
27685
  start: "run-p watch-css watch-dev start-server",
27387
27686
  "start-bench": "run-p watch-css watch-benchmarks start-server",
27388
27687
  lint: "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .",
@@ -28554,6 +28853,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28554
28853
  if (!this._doesCharSupportLocalGlyph(id)) {
28555
28854
  return;
28556
28855
  }
28856
+ // Client-generated glyphs are rendered at 2x texture scale,
28857
+ // because CJK glyphs are more detailed than others.
28858
+ const textureScale = 2;
28557
28859
  let tinySDF = entry.tinySDF;
28558
28860
  if (!tinySDF) {
28559
28861
  let fontWeight = '400';
@@ -28567,9 +28869,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28567
28869
  fontWeight = '200';
28568
28870
  }
28569
28871
  tinySDF = entry.tinySDF = new GlyphManager.TinySDF({
28570
- fontSize: 24,
28571
- buffer: 3,
28572
- radius: 8,
28872
+ fontSize: 24 * textureScale,
28873
+ buffer: 3 * textureScale,
28874
+ radius: 8 * textureScale,
28573
28875
  cutoff: 0.25,
28574
28876
  fontFamily,
28575
28877
  fontWeight
@@ -28589,16 +28891,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28589
28891
  * To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment
28590
28892
  * factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode)
28591
28893
  */
28592
- const topAdjustment = 27;
28894
+ const topAdjustment = 27.5;
28895
+ const leftAdjustment = 0.5;
28593
28896
  return {
28594
28897
  id,
28595
- bitmap: new performance.AlphaImage({ width: char.width || 30, height: char.height || 30 }, char.data),
28898
+ bitmap: new performance.AlphaImage({ width: char.width || 30 * textureScale, height: char.height || 30 * textureScale }, char.data),
28596
28899
  metrics: {
28597
- width: char.glyphWidth || 24,
28598
- height: char.glyphHeight || 24,
28599
- left: char.glyphLeft || 0,
28600
- top: char.glyphTop - topAdjustment || -8,
28601
- advance: char.glyphAdvance || 24
28900
+ width: char.glyphWidth / textureScale || 24,
28901
+ height: char.glyphHeight / textureScale || 24,
28902
+ left: (char.glyphLeft / textureScale + leftAdjustment) || 0,
28903
+ top: char.glyphTop / textureScale - topAdjustment || -8,
28904
+ advance: char.glyphAdvance / textureScale || 24,
28905
+ isDoubleResolution: true
28602
28906
  }
28603
28907
  };
28604
28908
  }
@@ -28856,7 +29160,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28856
29160
  const workers = this.workerPool.acquire(mapId);
28857
29161
  for (let i = 0; i < workers.length; i++) {
28858
29162
  const worker = workers[i];
28859
- const actor = new Dispatcher.Actor(worker, parent, mapId);
29163
+ const actor = new performance.Actor(worker, parent, mapId);
28860
29164
  actor.name = `Worker ${i}`;
28861
29165
  this.actors.push(actor);
28862
29166
  }
@@ -28887,7 +29191,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28887
29191
  this.workerPool.release(this.id);
28888
29192
  }
28889
29193
  }
28890
- Dispatcher.Actor = performance.Actor;
28891
29194
 
28892
29195
  function loadTileJson(options, requestManager, callback) {
28893
29196
  const loaded = function (err, tileJSON) {
@@ -29258,7 +29561,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29258
29561
  * map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);
29259
29562
  * ```
29260
29563
  * @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)
29261
- * @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
29262
29564
  */
29263
29565
  class VectorTileSource extends performance.Evented {
29264
29566
  constructor(id, options, dispatcher, eventedParent) {
@@ -29428,7 +29730,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29428
29730
  * ```ts
29429
29731
  * map.addSource('raster-source', {
29430
29732
  * 'type': 'raster',
29431
- * 'tiles': ['https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg'],
29733
+ * 'tiles': ['https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg'],
29432
29734
  * 'tileSize': 256,
29433
29735
  * });
29434
29736
  * ```
@@ -29498,6 +29800,25 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29498
29800
  this._tileJSONRequest = null;
29499
29801
  }
29500
29802
  }
29803
+ setSourceProperty(callback) {
29804
+ if (this._tileJSONRequest) {
29805
+ this._tileJSONRequest.cancel();
29806
+ }
29807
+ callback();
29808
+ this.load();
29809
+ }
29810
+ /**
29811
+ * Sets the source `tiles` property and re-renders the map.
29812
+ *
29813
+ * @param tiles - An array of one or more tile source URLs, as in the raster tiles spec (See the [Style Specification](https://maplibre.org/maplibre-style-spec/)
29814
+ * @returns `this`
29815
+ */
29816
+ setTiles(tiles) {
29817
+ this.setSourceProperty(() => {
29818
+ this._options.tiles = tiles;
29819
+ });
29820
+ return this;
29821
+ }
29501
29822
  serialize() {
29502
29823
  return performance.extend({}, this._options);
29503
29824
  }
@@ -29554,16 +29875,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29554
29875
  }
29555
29876
  }
29556
29877
 
29557
- let supportsOffscreenCanvas;
29558
- function offscreenCanvasSupported() {
29559
- if (supportsOffscreenCanvas == null) {
29560
- supportsOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' &&
29561
- new OffscreenCanvas(1, 1).getContext('2d') &&
29562
- typeof createImageBitmap === 'function';
29563
- }
29564
- return supportsOffscreenCanvas;
29565
- }
29566
-
29567
29878
  /**
29568
29879
  * A source containing raster DEM tiles (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)
29569
29880
  * This source can be used to show hillshading and 3D terrain
@@ -29587,12 +29898,16 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29587
29898
  this.maxzoom = 22;
29588
29899
  this._options = performance.extend({ type: 'raster-dem' }, options);
29589
29900
  this.encoding = options.encoding || 'mapbox';
29901
+ this.redFactor = options.redFactor;
29902
+ this.greenFactor = options.greenFactor;
29903
+ this.blueFactor = options.blueFactor;
29904
+ this.baseShift = options.baseShift;
29590
29905
  }
29591
29906
  loadTile(tile, callback) {
29592
29907
  const url = tile.tileID.canonical.url(this.tiles, this.map.getPixelRatio(), this.scheme);
29593
- tile.request = ImageRequest.getImage(this.map._requestManager.transformRequest(url, ResourceType.Tile), imageLoaded.bind(this), this.map._refreshExpiredTiles);
29908
+ const request = this.map._requestManager.transformRequest(url, ResourceType.Tile);
29594
29909
  tile.neighboringTiles = this._getNeighboringTiles(tile.tileID);
29595
- function imageLoaded(err, img) {
29910
+ tile.request = ImageRequest.getImage(request, (err, img, expiry) => performance.__awaiter(this, void 0, void 0, function* () {
29596
29911
  delete tile.request;
29597
29912
  if (tile.aborted) {
29598
29913
  tile.state = 'unloaded';
@@ -29604,23 +29919,40 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29604
29919
  }
29605
29920
  else if (img) {
29606
29921
  if (this.map._refreshExpiredTiles)
29607
- tile.setExpiryData(img);
29608
- delete img.cacheControl;
29609
- delete img.expires;
29610
- const transfer = performance.isImageBitmap(img) && offscreenCanvasSupported();
29611
- const rawImageData = transfer ? img : performance.browser.getImageData(img, 1);
29922
+ tile.setExpiryData(expiry);
29923
+ const transfer = performance.isImageBitmap(img) && performance.offscreenCanvasSupported();
29924
+ const rawImageData = transfer ? img : yield readImageNow(img);
29612
29925
  const params = {
29613
29926
  uid: tile.uid,
29614
29927
  coord: tile.tileID,
29615
29928
  source: this.id,
29616
29929
  rawImageData,
29617
- encoding: this.encoding
29930
+ encoding: this.encoding,
29931
+ redFactor: this.redFactor,
29932
+ greenFactor: this.greenFactor,
29933
+ blueFactor: this.blueFactor,
29934
+ baseShift: this.baseShift
29618
29935
  };
29619
29936
  if (!tile.actor || tile.state === 'expired') {
29620
29937
  tile.actor = this.dispatcher.getActor();
29621
- tile.actor.send('loadDEMTile', params, done.bind(this));
29938
+ tile.actor.send('loadDEMTile', params, done);
29622
29939
  }
29623
29940
  }
29941
+ }), this.map._refreshExpiredTiles);
29942
+ function readImageNow(img) {
29943
+ return performance.__awaiter(this, void 0, void 0, function* () {
29944
+ if (typeof VideoFrame !== 'undefined' && performance.isOffscreenCanvasDistorted()) {
29945
+ const width = img.width + 2;
29946
+ const height = img.height + 2;
29947
+ try {
29948
+ return new performance.RGBAImage({ width, height }, yield performance.readImageUsingVideoFrame(img, -1, -1, width, height));
29949
+ }
29950
+ catch (e) {
29951
+ // fall-back to browser canvas decoding
29952
+ }
29953
+ }
29954
+ return performance.browser.getImageData(img, 1);
29955
+ });
29624
29956
  }
29625
29957
  function done(err, data) {
29626
29958
  if (err) {
@@ -29954,8 +30286,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29954
30286
  performance.extend(data, { resourceTiming });
29955
30287
  // although GeoJSON sources contain no metadata, we fire this event to let the SourceCache
29956
30288
  // know its ok to start requesting tiles.
29957
- this.fire(new performance.Event('data', { ...data, sourceDataType: 'metadata' }));
29958
- this.fire(new performance.Event('data', { ...data, sourceDataType: 'content' }));
30289
+ this.fire(new performance.Event('data', Object.assign(Object.assign({}, data), { sourceDataType: 'metadata' })));
30290
+ this.fire(new performance.Event('data', Object.assign(Object.assign({}, data), { sourceDataType: 'content' })));
29959
30291
  });
29960
30292
  }
29961
30293
  loaded() {
@@ -30288,6 +30620,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
30288
30620
  * map.removeSource('some id'); // remove
30289
30621
  * ```
30290
30622
  * @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)
30623
+ *
30624
+ * Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.
30625
+ * This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,
30626
+ * set the layer's `raster-fade-duration` property to `0`.
30291
30627
  */
30292
30628
  class VideoSource extends ImageSource {
30293
30629
  constructor(id, options, dispatcher, eventedParent) {
@@ -34837,6 +35173,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
34837
35173
  this._load(empty, { validate: false });
34838
35174
  }
34839
35175
  _load(json, options, previousStyle) {
35176
+ var _a;
34840
35177
  const nextState = options.transformStyle ? options.transformStyle(previousStyle, json) : json;
34841
35178
  if (options.validate && emitValidationErrors(this, performance.validateStyle(nextState))) {
34842
35179
  return;
@@ -34855,7 +35192,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
34855
35192
  this.glyphManager.setURL(nextState.glyphs);
34856
35193
  this._createLayers();
34857
35194
  this.light = new Light(this.stylesheet.light);
34858
- this.map.setTerrain(this.stylesheet.terrain);
35195
+ this.map.setTerrain((_a = this.stylesheet.terrain) !== null && _a !== void 0 ? _a : null);
34859
35196
  this.fire(new performance.Event('data', { dataType: 'style' }));
34860
35197
  this.fire(new performance.Event('style.load'));
34861
35198
  }
@@ -35147,6 +35484,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35147
35484
  this[op.command].apply(this, op.args);
35148
35485
  }
35149
35486
  this.stylesheet = nextState;
35487
+ // reset serialization field, to be populated only when needed
35488
+ this._serializedLayers = null;
35150
35489
  return true;
35151
35490
  }
35152
35491
  addImage(id, image) {
@@ -35273,7 +35612,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35273
35612
  layer = performance.createStyleLayer(layerObject);
35274
35613
  }
35275
35614
  else {
35276
- if (typeof layerObject.source === 'object') {
35615
+ if ('source' in layerObject && typeof layerObject.source === 'object') {
35277
35616
  this.addSource(id, layerObject.source);
35278
35617
  layerObject = performance.clone$1(layerObject);
35279
35618
  layerObject = performance.extend(layerObject, { source: id });
@@ -35384,7 +35723,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35384
35723
  return this._layers[id];
35385
35724
  }
35386
35725
  /**
35387
- * checks if a specific layer is present within the style.
35726
+ * Return the ids of all layers currently in the style, including custom layers, in order.
35727
+ *
35728
+ * @returns ids of layers, in order
35729
+ */
35730
+ getLayersOrder() {
35731
+ return [...this._order];
35732
+ }
35733
+ /**
35734
+ * Checks if a specific layer is present within the style.
35388
35735
  *
35389
35736
  * @param id - the id of the desired layer
35390
35737
  * @returns a boolean specifying if the given layer is present
@@ -35557,6 +35904,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35557
35904
  return;
35558
35905
  const sources = performance.mapObject(this.sourceCaches, (source) => source.serialize());
35559
35906
  const layers = this._serializeByIds(this._order);
35907
+ const terrain = this.map.getTerrain() || undefined;
35560
35908
  const myStyleSheet = this.stylesheet;
35561
35909
  return performance.filterObject({
35562
35910
  version: myStyleSheet.version,
@@ -35571,7 +35919,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
35571
35919
  glyphs: myStyleSheet.glyphs,
35572
35920
  transition: myStyleSheet.transition,
35573
35921
  sources,
35574
- layers
35922
+ layers,
35923
+ terrain
35575
35924
  }, (value) => { return value !== undefined; });
35576
35925
  }
35577
35926
  _updateLayer(layer) {
@@ -36474,6 +36823,9 @@ uniform ${precision} ${type} u_${name};
36474
36823
  }
36475
36824
  gl.shaderSource(fragmentShader, fragmentSource);
36476
36825
  gl.compileShader(fragmentShader);
36826
+ if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
36827
+ throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);
36828
+ }
36477
36829
  gl.attachShader(this.program, fragmentShader);
36478
36830
  const vertexShader = gl.createShader(gl.VERTEX_SHADER);
36479
36831
  if (gl.isContextLost()) {
@@ -36482,6 +36834,9 @@ uniform ${precision} ${type} u_${name};
36482
36834
  }
36483
36835
  gl.shaderSource(vertexShader, vertexSource);
36484
36836
  gl.compileShader(vertexShader);
36837
+ if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
36838
+ throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);
36839
+ }
36485
36840
  gl.attachShader(this.program, vertexShader);
36486
36841
  this.attributes = {};
36487
36842
  const uniformLocations = {};
@@ -36493,6 +36848,9 @@ uniform ${precision} ${type} u_${name};
36493
36848
  }
36494
36849
  }
36495
36850
  gl.linkProgram(this.program);
36851
+ if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {
36852
+ throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);
36853
+ }
36496
36854
  gl.deleteShader(vertexShader);
36497
36855
  gl.deleteShader(fragmentShader);
36498
36856
  for (let it = 0; it < allUniformsInfo.length; it++) {
@@ -37296,11 +37654,12 @@ uniform ${precision} ${type} u_${name};
37296
37654
 
37297
37655
  const cache = new WeakMap();
37298
37656
  function isWebGL2(gl) {
37657
+ var _a;
37299
37658
  if (cache.has(gl)) {
37300
37659
  return cache.get(gl);
37301
37660
  }
37302
37661
  else {
37303
- const value = gl.getParameter(gl.VERSION).startsWith('WebGL 2.0');
37662
+ const value = (_a = gl.getParameter(gl.VERSION)) === null || _a === void 0 ? void 0 : _a.startsWith('WebGL 2.0');
37304
37663
  cache.set(gl, value);
37305
37664
  return value;
37306
37665
  }
@@ -40732,16 +41091,20 @@ uniform ${precision} ${type} u_${name};
40732
41091
  function throttle(fn, time) {
40733
41092
  let pending = false;
40734
41093
  let timerId = null;
41094
+ let lastCallContext = null;
41095
+ let lastCallArgs;
40735
41096
  const later = () => {
40736
41097
  timerId = null;
40737
41098
  if (pending) {
40738
- fn();
41099
+ fn.apply(lastCallContext, lastCallArgs);
40739
41100
  timerId = setTimeout(later, time);
40740
41101
  pending = false;
40741
41102
  }
40742
41103
  };
40743
- return () => {
41104
+ return (...args) => {
40744
41105
  pending = true;
41106
+ lastCallContext = this;
41107
+ lastCallArgs = args;
40745
41108
  if (!timerId) {
40746
41109
  later();
40747
41110
  }
@@ -42548,6 +42911,12 @@ uniform ${precision} ${type} u_${name};
42548
42911
  }
42549
42912
  reset() {
42550
42913
  this._active = false;
42914
+ this._zooming = false;
42915
+ delete this._targetZoom;
42916
+ if (this._finishTimeout) {
42917
+ clearTimeout(this._finishTimeout);
42918
+ delete this._finishTimeout;
42919
+ }
42551
42920
  }
42552
42921
  }
42553
42922
 
@@ -43327,7 +43696,7 @@ uniform ${precision} ${type} u_${name};
43327
43696
  this._updatingCamera = true;
43328
43697
  const inertialEase = this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions);
43329
43698
  const shouldSnapToNorth = bearing => bearing !== 0 && -this._bearingSnap < bearing && bearing < this._bearingSnap;
43330
- if (inertialEase) {
43699
+ if (inertialEase && (inertialEase.essential || !performance.browser.prefersReducedMotion)) {
43331
43700
  if (shouldSnapToNorth(inertialEase.bearing || this._map.getBearing())) {
43332
43701
  inertialEase.bearing = 0;
43333
43702
  }
@@ -43368,7 +43737,8 @@ uniform ${precision} ${type} u_${name};
43368
43737
  this._renderFrameCallback = () => {
43369
43738
  const t = Math.min((performance.browser.now() - this._easeStart) / this._easeOptions.duration, 1);
43370
43739
  this._onEaseFrame(this._easeOptions.easing(t));
43371
- if (t < 1) {
43740
+ // if _stop is called during _onEaseFrame from _fireMoveEvents we should avoid a new _requestRenderFrame, checking it by ensuring _easeFrameId was not deleted
43741
+ if (t < 1 && this._easeFrameId) {
43372
43742
  this._easeFrameId = this._requestRenderFrame(this._renderFrameCallback);
43373
43743
  }
43374
43744
  else {
@@ -45555,14 +45925,17 @@ uniform ${precision} ${type} u_${name};
45555
45925
  if (typeof window !== 'undefined') {
45556
45926
  addEventListener('online', this._onWindowOnline, false);
45557
45927
  let initialResizeEventCaptured = false;
45928
+ const throttledResizeCallback = throttle((entries) => {
45929
+ if (this._trackResize && !this._removed) {
45930
+ this.resize(entries)._update();
45931
+ }
45932
+ }, 50);
45558
45933
  this._resizeObserver = new ResizeObserver((entries) => {
45559
45934
  if (!initialResizeEventCaptured) {
45560
45935
  initialResizeEventCaptured = true;
45561
45936
  return;
45562
45937
  }
45563
- if (this._trackResize) {
45564
- this.resize(entries)._update();
45565
- }
45938
+ throttledResizeCallback(entries);
45566
45939
  });
45567
45940
  this._resizeObserver.observe(this._container);
45568
45941
  }
@@ -45764,7 +46137,6 @@ uniform ${precision} ${type} u_${name};
45764
46137
  * @internal
45765
46138
  * Return the map's pixel ratio eventually scaled down to respect maxCanvasSize.
45766
46139
  * Internally you should use this and not getPixelRatio().
45767
- * @hidden
45768
46140
  */
45769
46141
  _getClampedPixelRatio(width, height) {
45770
46142
  const { 0: maxCanvasWidth, 1: maxCanvasHeight } = this._maxCanvasSize;
@@ -46655,7 +47027,8 @@ uniform ${precision} ${type} u_${name};
46655
47027
  * ```
46656
47028
  */
46657
47029
  getTerrain() {
46658
- return this.terrain && this.terrain.options;
47030
+ var _a, _b;
47031
+ return (_b = (_a = this.terrain) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null;
46659
47032
  }
46660
47033
  /**
46661
47034
  * Returns a Boolean indicating whether all tiles in the viewport from all sources on
@@ -46945,7 +47318,7 @@ uniform ${precision} ${type} u_${name};
46945
47318
  *
46946
47319
  * @param layer - The layer to add,
46947
47320
  * conforming to either the MapLibre Style Specification's [layer definition](https://maplibre.org/maplibre-style-spec/layers) or,
46948
- * less commonly, the {@link CustomLayerInterface} specification.
47321
+ * less commonly, the {@link CustomLayerInterface} specification. Can also be a layer definition with an embedded source definition.
46949
47322
  * The MapLibre Style Specification's layer definition is appropriate for most layers.
46950
47323
  *
46951
47324
  * @param beforeId - The ID of an existing layer to insert the new layer before,
@@ -47074,6 +47447,19 @@ uniform ${precision} ${type} u_${name};
47074
47447
  getLayer(id) {
47075
47448
  return this.style.getLayer(id);
47076
47449
  }
47450
+ /**
47451
+ * Return the ids of all layers currently in the style, including custom layers, in order.
47452
+ *
47453
+ * @returns ids of layers, in order
47454
+ *
47455
+ * @example
47456
+ * ```ts
47457
+ * const orderedLayerIds = map.getLayersOrder();
47458
+ * ```
47459
+ */
47460
+ getLayersOrder() {
47461
+ return this.style.getLayersOrder();
47462
+ }
47077
47463
  /**
47078
47464
  * Sets the zoom extent for the specified style layer. The zoom extent includes the
47079
47465
  * [minimum zoom level](https://maplibre.org/maplibre-style-spec/layers/#minzoom)
@@ -47153,6 +47539,7 @@ uniform ${precision} ${type} u_${name};
47153
47539
  * @param name - The name of the paint property to set.
47154
47540
  * @param value - The value of the paint property to set.
47155
47541
  * Must be of a type appropriate for the property, as defined in the [MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/).
47542
+ * Pass `null` to unset the existing value.
47156
47543
  * @param options - Options object.
47157
47544
  * @returns `this`
47158
47545
  * @example
@@ -47949,7 +48336,6 @@ uniform ${precision} ${type} u_${name};
47949
48336
  * map.addControl(nav, 'top-left');
47950
48337
  * ```
47951
48338
  * @see [Display map navigation controls](https://maplibre.org/maplibre-gl-js/docs/examples/navigation/)
47952
- * @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
47953
48339
  */
47954
48340
  class NavigationControl {
47955
48341
  /**
@@ -48311,6 +48697,10 @@ uniform ${precision} ${type} u_${name};
48311
48697
  this._update = (e) => {
48312
48698
  if (!this._map)
48313
48699
  return;
48700
+ const isFullyLoaded = this._map.loaded() && !this._map.isMoving();
48701
+ if ((e === null || e === void 0 ? void 0 : e.type) === 'terrain' || ((e === null || e === void 0 ? void 0 : e.type) === 'render' && !isFullyLoaded)) {
48702
+ this._map.once('render', this._update);
48703
+ }
48314
48704
  if (this._map.transform.renderWorldCopies) {
48315
48705
  this._lngLat = smartWrap(this._lngLat, this._pos, this._map.transform);
48316
48706
  }
@@ -48534,6 +48924,7 @@ uniform ${precision} ${type} u_${name};
48534
48924
  map.getCanvasContainer().appendChild(this._element);
48535
48925
  map.on('move', this._update);
48536
48926
  map.on('moveend', this._update);
48927
+ map.on('terrain', this._update);
48537
48928
  this.setDraggable(this._draggable);
48538
48929
  this._update();
48539
48930
  // If we attached the `click` listener to the marker element, the popup
@@ -48649,7 +49040,7 @@ uniform ${precision} ${type} u_${name};
48649
49040
  if (!('offset' in popup.options)) {
48650
49041
  const markerHeight = 41 - (5.8 / 2);
48651
49042
  const markerRadius = 13.5;
48652
- const linearOffset = Math.sqrt(Math.pow(markerRadius, 2) / 2);
49043
+ const linearOffset = Math.abs(markerRadius) / Math.SQRT2;
48653
49044
  popup.options.offset = this._defaultMarker ? {
48654
49045
  'top': [0, 0],
48655
49046
  'top-left': [0, 0],
@@ -50222,7 +50613,7 @@ uniform ${precision} ${type} u_${name};
50222
50613
  }
50223
50614
  else if (typeof offset === 'number') {
50224
50615
  // input specifies a radius from which to calculate offsets at all positions
50225
- const cornerOffset = Math.round(Math.sqrt(0.5 * Math.pow(offset, 2)));
50616
+ const cornerOffset = Math.round(Math.abs(offset) / Math.SQRT2);
50226
50617
  return {
50227
50618
  'center': new performance.Point(0, 0),
50228
50619
  'top': new performance.Point(0, offset),
@@ -50531,7 +50922,7 @@ uniform ${precision} ${type} u_${name};
50531
50922
  sessionIdHeaderName: "Session-Id"
50532
50923
  };
50533
50924
 
50534
- var __values$l = (window && window.__values) || function(o) {
50925
+ var __values$k = (window && window.__values) || function(o) {
50535
50926
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
50536
50927
  if (m) return m.call(o);
50537
50928
  if (o && typeof o.length === "number") return {
@@ -50559,7 +50950,7 @@ uniform ${precision} ${type} u_${name};
50559
50950
  }
50560
50951
  var defaults;
50561
50952
  try {
50562
- for (var valuesList_1 = __values$l(valuesList), valuesList_1_1 = valuesList_1.next(); !valuesList_1_1.done; valuesList_1_1 = valuesList_1.next()) {
50953
+ for (var valuesList_1 = __values$k(valuesList), valuesList_1_1 = valuesList_1.next(); !valuesList_1_1.done; valuesList_1_1 = valuesList_1.next()) {
50563
50954
  var values = valuesList_1_1.value;
50564
50955
  if (!values) {
50565
50956
  continue;
@@ -50599,7 +50990,7 @@ uniform ${precision} ${type} u_${name};
50599
50990
  return Options;
50600
50991
  }());
50601
50992
 
50602
- var __extends$1f = (window && window.__extends) || (function () {
50993
+ var __extends$1g = (window && window.__extends) || (function () {
50603
50994
  var extendStatics = function (d, b) {
50604
50995
  extendStatics = Object.setPrototypeOf ||
50605
50996
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -50614,7 +51005,7 @@ uniform ${precision} ${type} u_${name};
50614
51005
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
50615
51006
  };
50616
51007
  })();
50617
- var __read$e = (window && window.__read) || function (o, n) {
51008
+ var __read$d = (window && window.__read) || function (o, n) {
50618
51009
  var m = typeof Symbol === "function" && o[Symbol.iterator];
50619
51010
  if (!m) return o;
50620
51011
  var i = m.call(o), r, ar = [], e;
@@ -50634,7 +51025,7 @@ uniform ${precision} ${type} u_${name};
50634
51025
  * @private
50635
51026
  */
50636
51027
  var UrlOptions = /** @class */ (function (_super) {
50637
- __extends$1f(UrlOptions, _super);
51028
+ __extends$1g(UrlOptions, _super);
50638
51029
  function UrlOptions() {
50639
51030
  var _this = _super !== null && _super.apply(this, arguments) || this;
50640
51031
  _this.domain = undefined;
@@ -50674,7 +51065,7 @@ uniform ${precision} ${type} u_${name};
50674
51065
  var self = this;
50675
51066
  var queryParamsString = Object.entries(self.options.queryParams)
50676
51067
  .map(function (_a) {
50677
- var _b = __read$e(_a, 2), key = _b[0], value = _b[1];
51068
+ var _b = __read$d(_a, 2), key = _b[0], value = _b[1];
50678
51069
  return "".concat(key, "=").concat(value);
50679
51070
  })
50680
51071
  .join("&");
@@ -50705,7 +51096,7 @@ uniform ${precision} ${type} u_${name};
50705
51096
  return Url;
50706
51097
  }());
50707
51098
 
50708
- var version = "3.0.2";
51099
+ var version = "3.1.0";
50709
51100
 
50710
51101
  /**
50711
51102
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -50815,7 +51206,7 @@ uniform ${precision} ${type} u_${name};
50815
51206
  eventTarget.addEventListener("keydown", dismissTooltip);
50816
51207
  };
50817
51208
 
50818
- var __extends$1e = (window && window.__extends) || (function () {
51209
+ var __extends$1f = (window && window.__extends) || (function () {
50819
51210
  var extendStatics = function (d, b) {
50820
51211
  extendStatics = Object.setPrototypeOf ||
50821
51212
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -50865,7 +51256,7 @@ uniform ${precision} ${type} u_${name};
50865
51256
  * The options for adding a control to the map.
50866
51257
  */
50867
51258
  var ControlOptions = /** @class */ (function (_super) {
50868
- __extends$1e(ControlOptions, _super);
51259
+ __extends$1f(ControlOptions, _super);
50869
51260
  function ControlOptions() {
50870
51261
  var _this = _super !== null && _super.apply(this, arguments) || this;
50871
51262
  /**
@@ -51009,7 +51400,7 @@ uniform ${precision} ${type} u_${name};
51009
51400
  EventEmitter: EventEmitter
51010
51401
  });
51011
51402
 
51012
- var __extends$1d = (window && window.__extends) || (function () {
51403
+ var __extends$1e = (window && window.__extends) || (function () {
51013
51404
  var extendStatics = function (d, b) {
51014
51405
  extendStatics = Object.setPrototypeOf ||
51015
51406
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -51029,7 +51420,7 @@ uniform ${precision} ${type} u_${name};
51029
51420
  * Implements control interface and provides support for automatic styling based on the map style.
51030
51421
  */
51031
51422
  var ControlBase = /** @class */ (function (_super) {
51032
- __extends$1d(ControlBase, _super);
51423
+ __extends$1e(ControlBase, _super);
51033
51424
  function ControlBase() {
51034
51425
  var _this = _super !== null && _super.apply(this, arguments) || this;
51035
51426
  /**
@@ -51131,7 +51522,7 @@ uniform ${precision} ${type} u_${name};
51131
51522
  return ControlBase;
51132
51523
  }(EventEmitter));
51133
51524
 
51134
- var __extends$1c = (window && window.__extends) || (function () {
51525
+ var __extends$1d = (window && window.__extends) || (function () {
51135
51526
  var extendStatics = function (d, b) {
51136
51527
  extendStatics = Object.setPrototypeOf ||
51137
51528
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -51150,7 +51541,7 @@ uniform ${precision} ${type} u_${name};
51150
51541
  * The options for a CompassControl object.
51151
51542
  */
51152
51543
  var CompassControlOptions = /** @class */ (function (_super) {
51153
- __extends$1c(CompassControlOptions, _super);
51544
+ __extends$1d(CompassControlOptions, _super);
51154
51545
  function CompassControlOptions() {
51155
51546
  var _this = _super !== null && _super.apply(this, arguments) || this;
51156
51547
  /**
@@ -51175,7 +51566,7 @@ uniform ${precision} ${type} u_${name};
51175
51566
  return CompassControlOptions;
51176
51567
  }(Options));
51177
51568
 
51178
- var __extends$1b = (window && window.__extends) || (function () {
51569
+ var __extends$1c = (window && window.__extends) || (function () {
51179
51570
  var extendStatics = function (d, b) {
51180
51571
  extendStatics = Object.setPrototypeOf ||
51181
51572
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -51194,7 +51585,7 @@ uniform ${precision} ${type} u_${name};
51194
51585
  * A control for changing the rotation of the map.
51195
51586
  */
51196
51587
  var CompassControl = /** @class */ (function (_super) {
51197
- __extends$1b(CompassControl, _super);
51588
+ __extends$1c(CompassControl, _super);
51198
51589
  /**
51199
51590
  * Constructs a CompassControl.
51200
51591
  * @param options The options for the control.
@@ -51257,6 +51648,16 @@ uniform ${precision} ${type} u_${name};
51257
51648
  grid.classList.add("hidden-accessible-element");
51258
51649
  }
51259
51650
  });
51651
+ // Dismiss the grid when esc key is pressed on the reset button and the tooltip is not visible
51652
+ rotationButton.addEventListener("keydown", function (event) {
51653
+ if ((event.key === "Escape" || event.key === "Esc") &&
51654
+ (container === null || container === void 0 ? void 0 : container.classList.contains("in-use")) &&
51655
+ (tooltip === null || tooltip === void 0 ? void 0 : tooltip.style.display) === "none") {
51656
+ event.stopPropagation();
51657
+ container.classList.remove("in-use");
51658
+ grid.classList.add("hidden-accessible-element");
51659
+ }
51660
+ });
51260
51661
  // If the control's position will require inverting the element order
51261
51662
  // add them in the opposite order to preserve tabindex.
51262
51663
  if (options && CompassControl.InvertOrderPositions.includes(options.position)) {
@@ -51362,7 +51763,7 @@ uniform ${precision} ${type} u_${name};
51362
51763
  return CompassControl;
51363
51764
  }(ControlBase));
51364
51765
 
51365
- var __extends$1a = (window && window.__extends) || (function () {
51766
+ var __extends$1b = (window && window.__extends) || (function () {
51366
51767
  var extendStatics = function (d, b) {
51367
51768
  extendStatics = Object.setPrototypeOf ||
51368
51769
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -51381,7 +51782,7 @@ uniform ${precision} ${type} u_${name};
51381
51782
  * The options for a PitchControl object.
51382
51783
  */
51383
51784
  var PitchControlOptions = /** @class */ (function (_super) {
51384
- __extends$1a(PitchControlOptions, _super);
51785
+ __extends$1b(PitchControlOptions, _super);
51385
51786
  function PitchControlOptions() {
51386
51787
  var _this = _super !== null && _super.apply(this, arguments) || this;
51387
51788
  /**
@@ -51406,7 +51807,7 @@ uniform ${precision} ${type} u_${name};
51406
51807
  return PitchControlOptions;
51407
51808
  }(Options));
51408
51809
 
51409
- var __extends$19 = (window && window.__extends) || (function () {
51810
+ var __extends$1a = (window && window.__extends) || (function () {
51410
51811
  var extendStatics = function (d, b) {
51411
51812
  extendStatics = Object.setPrototypeOf ||
51412
51813
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@@ -51425,7 +51826,7 @@ uniform ${precision} ${type} u_${name};
51425
51826
  * A control for changing the pitch of the map.
51426
51827
  */
51427
51828
  var PitchControl = /** @class */ (function (_super) {
51428
- __extends$19(PitchControl, _super);
51829
+ __extends$1a(PitchControl, _super);
51429
51830
  /**
51430
51831
  * Constructs a PitchControl.
51431
51832
  * @param options The options for the control.
@@ -51518,6 +51919,16 @@ uniform ${precision} ${type} u_${name};
51518
51919
  grid.classList.add("hidden-accessible-element");
51519
51920
  }
51520
51921
  });
51922
+ // Dismiss the grid when esc key is pressed on the reset button and the tooltip is not visible
51923
+ pitchButton.addEventListener("keydown", function (event) {
51924
+ if ((event.key === "Escape" || event.key === "Esc") &&
51925
+ (container === null || container === void 0 ? void 0 : container.classList.contains("in-use")) &&
51926
+ (tooltip === null || tooltip === void 0 ? void 0 : tooltip.style.display) === "none") {
51927
+ event.stopPropagation();
51928
+ container.classList.remove("in-use");
51929
+ grid.classList.add("hidden-accessible-element");
51930
+ }
51931
+ });
51521
51932
  // If the control's position will require inverting the element order
51522
51933
  // add them in the opposite order to preserve tabindex.
51523
51934
  if (options && PitchControl.INVERT_ORDER_POSITIONS.includes(options.position)) {
@@ -51636,6 +52047,74 @@ uniform ${precision} ${type} u_${name};
51636
52047
  return PitchControl;
51637
52048
  }(ControlBase));
51638
52049
 
52050
+ var __extends$19 = (window && window.__extends) || (function () {
52051
+ var extendStatics = function (d, b) {
52052
+ extendStatics = Object.setPrototypeOf ||
52053
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
52054
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
52055
+ return extendStatics(d, b);
52056
+ };
52057
+ return function (d, b) {
52058
+ if (typeof b !== "function" && b !== null)
52059
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
52060
+ extendStatics(d, b);
52061
+ function __() { this.constructor = d; }
52062
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
52063
+ };
52064
+ })();
52065
+ /**
52066
+ * A control to display a scale bar on the map.
52067
+ */
52068
+ var ScaleControl = /** @class */ (function (_super) {
52069
+ __extends$19(ScaleControl, _super);
52070
+ /**
52071
+ * A control to displays a scale bar relative to the pixel resolution at the center of the map.
52072
+ * @param options Options for defining how the control is rendered and functions.
52073
+ */
52074
+ function ScaleControl(options) {
52075
+ var _this = _super.call(this) || this;
52076
+ _this.map = null;
52077
+ _this.control = new maplibregl.ScaleControl({
52078
+ maxWidth: options === null || options === void 0 ? void 0 : options.maxWidth,
52079
+ unit: options === null || options === void 0 ? void 0 : options.unit
52080
+ });
52081
+ return _this;
52082
+ }
52083
+ /**
52084
+ * Initialization method for the control which is called when added to the map.
52085
+ * @param map The map that the control will be added to.
52086
+ * @param options The ControlOptions for this control.
52087
+ * @return An HTMLElement to be placed on the map for the control.
52088
+ */
52089
+ ScaleControl.prototype.onAdd = function (map, options) {
52090
+ var _a, _b, _c;
52091
+ this.map = map;
52092
+ (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a._getMap()) === null || _b === void 0 ? void 0 : _b.addControl(this.control);
52093
+ var container = this.buildContainer(map, exports.ControlStyle.auto, "Scale Bar");
52094
+ container.appendChild((_c = this.control) === null || _c === void 0 ? void 0 : _c._container);
52095
+ return container;
52096
+ };
52097
+ /**
52098
+ * Method that is called when the control is removed from the map. Should perform any necessary cleanup for the
52099
+ * control.
52100
+ */
52101
+ ScaleControl.prototype.onRemove = function () {
52102
+ var _a, _b;
52103
+ _super.prototype.onRemove.call(this);
52104
+ (_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a._getMap()) === null || _b === void 0 ? void 0 : _b.removeControl(this.control);
52105
+ this.map = null;
52106
+ };
52107
+ /**
52108
+ * Set the scale's unit of the distance
52109
+ * @param unit - Unit of the distance (`"imperial"`, `"metric"` or `"nautical"`).
52110
+ */
52111
+ ScaleControl.prototype.setUnit = function (unit) {
52112
+ var _a;
52113
+ (_a = this.control) === null || _a === void 0 ? void 0 : _a.setUnit(unit);
52114
+ };
52115
+ return ScaleControl;
52116
+ }(ControlBase));
52117
+
51639
52118
  /**
51640
52119
  * Removes all key-value entries from the list cache.
51641
52120
  *
@@ -55220,7 +55699,7 @@ uniform ${precision} ${type} u_${name};
55220
55699
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55221
55700
  }
55222
55701
  };
55223
- var __read$d = (window && window.__read) || function (o, n) {
55702
+ var __read$c = (window && window.__read) || function (o, n) {
55224
55703
  var m = typeof Symbol === "function" && o[Symbol.iterator];
55225
55704
  if (!m) return o;
55226
55705
  var i = m.call(o), r, ar = [], e;
@@ -55401,7 +55880,7 @@ uniform ${precision} ${type} u_${name};
55401
55880
  image_1.src = newSrc;
55402
55881
  }
55403
55882
  Object.entries(this.styleButtons).forEach(function (_a) {
55404
- var _b = __read$d(_a, 2), buttonStyleName = _b[0], button = _b[1];
55883
+ var _b = __read$c(_a, 2), buttonStyleName = _b[0], button = _b[1];
55405
55884
  return button.setAttribute('aria-current', buttonStyleName === styleName ? 'true' : 'false');
55406
55885
  });
55407
55886
  this.map.styles.definitions().then(function (mapConfiguration) {
@@ -55490,7 +55969,7 @@ uniform ${precision} ${type} u_${name};
55490
55969
  _this.map.setStyle({ style: name });
55491
55970
  }
55492
55971
  Object.entries(_this.styleButtons).forEach(function (_a) {
55493
- var _b = __read$d(_a, 2), styleName = _b[0], button = _b[1];
55972
+ var _b = __read$c(_a, 2), styleName = _b[0], button = _b[1];
55494
55973
  return button.setAttribute('aria-current', styleName === name ? 'true' : 'false');
55495
55974
  });
55496
55975
  }
@@ -55582,7 +56061,7 @@ uniform ${precision} ${type} u_${name};
55582
56061
  });
55583
56062
  var targetStyleName = this.map.getStyle().style;
55584
56063
  Object.entries(this.styleButtons).forEach(function (_a) {
55585
- var _b = __read$d(_a, 2), styleName = _b[0], button = _b[1];
56064
+ var _b = __read$c(_a, 2), styleName = _b[0], button = _b[1];
55586
56065
  return button.setAttribute('aria-current', styleName === targetStyleName ? 'true' : 'false');
55587
56066
  });
55588
56067
  };
@@ -55843,7 +56322,7 @@ uniform ${precision} ${type} u_${name};
55843
56322
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
55844
56323
  };
55845
56324
  })();
55846
- var __values$k = (window && window.__values) || function(o) {
56325
+ var __values$j = (window && window.__values) || function(o) {
55847
56326
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
55848
56327
  if (m) return m.call(o);
55849
56328
  if (o && typeof o.length === "number") return {
@@ -55914,7 +56393,7 @@ uniform ${precision} ${type} u_${name};
55914
56393
  // legend table contents
55915
56394
  var tr2 = document.createElement("tr");
55916
56395
  try {
55917
- for (var _c = __values$k(this.table), _d = _c.next(); !_d.done; _d = _c.next()) {
56396
+ for (var _c = __values$j(this.table), _d = _c.next(); !_d.done; _d = _c.next()) {
55918
56397
  var col = _d.value;
55919
56398
  var data = document.createElement("td");
55920
56399
  if (col === "Fast" || col === "Slow") {
@@ -55927,7 +56406,7 @@ uniform ${precision} ${type} u_${name};
55927
56406
  data.setAttribute("aria-label", "Traffic Legend");
55928
56407
  data.setAttribute("role", "img");
55929
56408
  try {
55930
- for (var col_1 = (e_2 = void 0, __values$k(col)), col_1_1 = col_1.next(); !col_1_1.done; col_1_1 = col_1.next()) {
56409
+ for (var col_1 = (e_2 = void 0, __values$j(col)), col_1_1 = col_1.next(); !col_1_1.done; col_1_1 = col_1.next()) {
55931
56410
  var color = col_1_1.value;
55932
56411
  var div = document.createElement("div");
55933
56412
  div.classList.add(color);
@@ -56863,7 +57342,7 @@ uniform ${precision} ${type} u_${name};
56863
57342
  return Point;
56864
57343
  }());
56865
57344
 
56866
- var __read$c = (window && window.__read) || function (o, n) {
57345
+ var __read$b = (window && window.__read) || function (o, n) {
56867
57346
  var m = typeof Symbol === "function" && o[Symbol.iterator];
56868
57347
  if (!m) return o;
56869
57348
  var i = m.call(o), r, ar = [], e;
@@ -56879,7 +57358,7 @@ uniform ${precision} ${type} u_${name};
56879
57358
  }
56880
57359
  return ar;
56881
57360
  };
56882
- var __values$j = (window && window.__values) || function(o) {
57361
+ var __values$i = (window && window.__values) || function(o) {
56883
57362
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56884
57363
  if (m) return m.call(o);
56885
57364
  if (o && typeof o.length === "number") return {
@@ -57854,8 +58333,8 @@ uniform ${precision} ${type} u_${name};
57854
58333
  if (k + 1 >= coords.length) {
57855
58334
  continue;
57856
58335
  }
57857
- var _a = __read$c(coords[k], 2), lon1 = _a[0], lat1 = _a[1];
57858
- var _b = __read$c(coords[k + 1], 2), lon2 = _b[0], lat2 = _b[1];
58336
+ var _a = __read$b(coords[k], 2), lon1 = _a[0], lat1 = _a[1];
58337
+ var _b = __read$b(coords[k + 1], 2), lon2 = _b[0], lat2 = _b[1];
57859
58338
  // split the line by antimeridian
57860
58339
  // and break geodesic into two line segments
57861
58340
  if (Math.abs(lon2 - lon1) > 180.0) {
@@ -57926,8 +58405,8 @@ uniform ${precision} ${type} u_${name};
57926
58405
  if (k + 1 >= geodesic.length) {
57927
58406
  continue;
57928
58407
  }
57929
- var _a = __read$c(geodesic[k], 2), lon1 = _a[0], lat1 = _a[1];
57930
- var _b = __read$c(geodesic[k + 1], 2), lon2 = _b[0], lat2 = _b[1];
58408
+ var _a = __read$b(geodesic[k], 2), lon1 = _a[0], lat1 = _a[1];
58409
+ var _b = __read$b(geodesic[k + 1], 2), lon2 = _b[0], lat2 = _b[1];
57931
58410
  // split the line by antimeridian
57932
58411
  // and break geodesic into two line segments
57933
58412
  if (Math.abs(lon2 - lon1) > 180.0) {
@@ -58138,7 +58617,7 @@ uniform ${precision} ${type} u_${name};
58138
58617
  function getPixelHeading(origin, destination) {
58139
58618
  origin = getPosition(origin);
58140
58619
  destination = getPosition(destination);
58141
- var _a = __read$c(mercatorPositionsToPixels([origin, destination], 21), 2), p1 = _a[0], p2 = _a[1];
58620
+ var _a = __read$b(mercatorPositionsToPixels([origin, destination], 21), 2), p1 = _a[0], p2 = _a[1];
58142
58621
  var dx = (p2[0] - p1[0]);
58143
58622
  var dy = (p1[1] - p2[1]);
58144
58623
  var alpha = ((5 / 2 * Math.PI) - Math.atan2(dy, dx)) * INV_PI_BY_180 % 360;
@@ -58685,7 +59164,7 @@ uniform ${precision} ${type} u_${name};
58685
59164
  });
58686
59165
  var lower = [];
58687
59166
  try {
58688
- for (var positions_1 = __values$j(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
59167
+ for (var positions_1 = __values$i(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
58689
59168
  var position = positions_1_1.value;
58690
59169
  while (lower.length >= 2 && _cross(lower[lower.length - 2], lower[lower.length - 1], position) <= 0) {
58691
59170
  lower.pop();
@@ -59194,7 +59673,7 @@ uniform ${precision} ${type} u_${name};
59194
59673
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
59195
59674
  };
59196
59675
  })();
59197
- var __values$i = (window && window.__values) || function(o) {
59676
+ var __values$h = (window && window.__values) || function(o) {
59198
59677
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
59199
59678
  if (m) return m.call(o);
59200
59679
  if (o && typeof o.length === "number") return {
@@ -59281,7 +59760,7 @@ uniform ${precision} ${type} u_${name};
59281
59760
  else if (geoType === "MultiLineString") {
59282
59761
  var pos = positions;
59283
59762
  try {
59284
- for (var pos_1 = __values$i(pos), pos_1_1 = pos_1.next(); !pos_1_1.done; pos_1_1 = pos_1.next()) {
59763
+ for (var pos_1 = __values$h(pos), pos_1_1 = pos_1.next(); !pos_1_1.done; pos_1_1 = pos_1.next()) {
59285
59764
  var p = pos_1_1.value;
59286
59765
  bbox = BoundingBox.merge(bbox, BoundingBox.fromPositions(p));
59287
59766
  }
@@ -59297,7 +59776,7 @@ uniform ${precision} ${type} u_${name};
59297
59776
  else if (geoType === "MultiPolygon") {
59298
59777
  var pos = positions;
59299
59778
  try {
59300
- for (var pos_2 = __values$i(pos), pos_2_1 = pos_2.next(); !pos_2_1.done; pos_2_1 = pos_2.next()) {
59779
+ for (var pos_2 = __values$h(pos), pos_2_1 = pos_2.next(); !pos_2_1.done; pos_2_1 = pos_2.next()) {
59301
59780
  var p1 = pos_2_1.value;
59302
59781
  // only need to check the exterior ring of Polygon
59303
59782
  bbox = BoundingBox.merge(bbox, BoundingBox.fromPositions(p1[0]));
@@ -59520,7 +59999,7 @@ uniform ${precision} ${type} u_${name};
59520
59999
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
59521
60000
  };
59522
60001
  })();
59523
- var __values$h = (window && window.__values) || function(o) {
60002
+ var __values$g = (window && window.__values) || function(o) {
59524
60003
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
59525
60004
  if (m) return m.call(o);
59526
60005
  if (o && typeof o.length === "number") return {
@@ -59944,7 +60423,7 @@ uniform ${precision} ${type} u_${name};
59944
60423
  var bounds = null;
59945
60424
  if (Array.isArray(data) && data.length > 0) {
59946
60425
  try {
59947
- for (var data_1 = __values$h(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
60426
+ for (var data_1 = __values$g(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
59948
60427
  var datum = data_1_1.value;
59949
60428
  tempBounds = BoundingBox.fromData(datum);
59950
60429
  if (tempBounds != null) {
@@ -60517,7 +60996,7 @@ uniform ${precision} ${type} u_${name};
60517
60996
  return SimplifyAP_1(points, tolerance, true);
60518
60997
  }
60519
60998
 
60520
- var __values$g = (window && window.__values) || function(o) {
60999
+ var __values$f = (window && window.__values) || function(o) {
60521
61000
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
60522
61001
  if (m) return m.call(o);
60523
61002
  if (o && typeof o.length === "number") return {
@@ -60577,7 +61056,7 @@ uniform ${precision} ${type} u_${name};
60577
61056
  if (points && Array.isArray(points) && Array.isArray(points[0])) {
60578
61057
  var pos = [];
60579
61058
  try {
60580
- for (var points_1 = __values$g(points), points_1_1 = points_1.next(); !points_1_1.done; points_1_1 = points_1.next()) {
61059
+ for (var points_1 = __values$f(points), points_1_1 = points_1.next(); !points_1_1.done; points_1_1 = points_1.next()) {
60581
61060
  var subPoints = points_1_1.value;
60582
61061
  pos.push(this.transform(subPoints, transformMatrix, decimals));
60583
61062
  }
@@ -60952,6 +61431,7 @@ uniform ${precision} ${type} u_${name};
60952
61431
  CompassControl: CompassControl,
60953
61432
  ControlBase: ControlBase,
60954
61433
  PitchControl: PitchControl,
61434
+ ScaleControl: ScaleControl,
60955
61435
  StyleControl: StyleControl,
60956
61436
  TrafficControl: TrafficControl,
60957
61437
  TrafficLegendControl: TrafficLegendControl,
@@ -61235,7 +61715,7 @@ uniform ${precision} ${type} u_${name};
61235
61715
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
61236
61716
  };
61237
61717
  })();
61238
- var __values$f = (window && window.__values) || function(o) {
61718
+ var __values$e = (window && window.__values) || function(o) {
61239
61719
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
61240
61720
  if (m) return m.call(o);
61241
61721
  if (o && typeof o.length === "number") return {
@@ -61434,7 +61914,7 @@ uniform ${precision} ${type} u_${name};
61434
61914
  var e_1, _a;
61435
61915
  var shapes = Array.isArray(shape) ? shape : [shape];
61436
61916
  try {
61437
- for (var shapes_1 = __values$f(shapes), shapes_1_1 = shapes_1.next(); !shapes_1_1.done; shapes_1_1 = shapes_1.next()) {
61917
+ for (var shapes_1 = __values$e(shapes), shapes_1_1 = shapes_1.next(); !shapes_1_1.done; shapes_1_1 = shapes_1.next()) {
61438
61918
  var s = shapes_1_1.value;
61439
61919
  if (typeof s === "number") {
61440
61920
  this._removeByIndex(s);
@@ -61461,7 +61941,7 @@ uniform ${precision} ${type} u_${name};
61461
61941
  var e_2, _a;
61462
61942
  var ids = Array.isArray(id) ? id : [id];
61463
61943
  try {
61464
- for (var ids_1 = __values$f(ids), ids_1_1 = ids_1.next(); !ids_1_1.done; ids_1_1 = ids_1.next()) {
61944
+ for (var ids_1 = __values$e(ids), ids_1_1 = ids_1.next(); !ids_1_1.done; ids_1_1 = ids_1.next()) {
61465
61945
  var i = ids_1_1.value;
61466
61946
  this._removeById(i);
61467
61947
  }
@@ -61625,7 +62105,7 @@ uniform ${precision} ${type} u_${name};
61625
62105
  data = Array.isArray(data) ? data : [data];
61626
62106
  if (typeof index !== "number") {
61627
62107
  try {
61628
- for (var data_1 = __values$f(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
62108
+ for (var data_1 = __values$e(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
61629
62109
  var d = data_1_1.value;
61630
62110
  this.shapes.push(d);
61631
62111
  this.shapesMap.set(d.getId(), this.shapes.length - 1);
@@ -61646,7 +62126,7 @@ uniform ${precision} ${type} u_${name};
61646
62126
  }
61647
62127
  }
61648
62128
  try {
61649
- for (var data_2 = __values$f(data), data_2_1 = data_2.next(); !data_2_1.done; data_2_1 = data_2.next()) {
62129
+ for (var data_2 = __values$e(data), data_2_1 = data_2.next(); !data_2_1.done; data_2_1 = data_2.next()) {
61650
62130
  var d = data_2_1.value;
61651
62131
  d._setDataSource(this);
61652
62132
  }
@@ -62589,7 +63069,7 @@ uniform ${precision} ${type} u_${name};
62589
63069
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62590
63070
  }
62591
63071
  };
62592
- var __read$b = (window && window.__read) || function (o, n) {
63072
+ var __read$a = (window && window.__read) || function (o, n) {
62593
63073
  var m = typeof Symbol === "function" && o[Symbol.iterator];
62594
63074
  if (!m) return o;
62595
63075
  var i = m.call(o), r, ar = [], e;
@@ -62605,7 +63085,7 @@ uniform ${precision} ${type} u_${name};
62605
63085
  }
62606
63086
  return ar;
62607
63087
  };
62608
- var __spreadArray$9 = (window && window.__spreadArray) || function (to, from, pack) {
63088
+ var __spreadArray$8 = (window && window.__spreadArray) || function (to, from, pack) {
62609
63089
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
62610
63090
  if (ar || !(i in from)) {
62611
63091
  if (!ar) ar = Array.prototype.slice.call(from, 0, i);
@@ -62642,7 +63122,7 @@ uniform ${precision} ${type} u_${name};
62642
63122
  var bubbleFeature = curRenderedShape instanceof Shape ? curRenderedShape.toJson() : curRenderedShape;
62643
63123
  var indicator = new AccessibleIndicator({ positionInSet: idx + 1, setSize: renderedShapes.length });
62644
63124
  var element = indicator.getElement();
62645
- var _a = __read$b(_this.map.positionsToPixels([_this.getFirstCoordinate(bubbleFeature.geometry.coordinates)]), 1), pixel = _a[0];
63125
+ var _a = __read$a(_this.map.positionsToPixels([_this.getFirstCoordinate(bubbleFeature.geometry.coordinates)]), 1), pixel = _a[0];
62646
63126
  element.addEventListener('focusin', function (event) {
62647
63127
  _this.accessibleIndicator.filter(function (i) { return i !== indicator; }).forEach(function (indicator) { return indicator.remove(); });
62648
63128
  // insert previous and next popups
@@ -62814,7 +63294,7 @@ uniform ${precision} ${type} u_${name};
62814
63294
  return undefined;
62815
63295
  }
62816
63296
  var mapConfiguration = this.map.getServiceOptions().mapConfiguration;
62817
- return __spreadArray$9(__spreadArray$9([], __read$b(this.map.getCamera().bounds), false), [
63297
+ return __spreadArray$8(__spreadArray$8([], __read$a(this.map.getCamera().bounds), false), [
62818
63298
  this.map.getCamera().zoom,
62819
63299
  this.map.getCamera().pitch,
62820
63300
  this.map.getStyle().style,
@@ -63954,42 +64434,6 @@ uniform ${precision} ${type} u_${name};
63954
64434
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
63955
64435
  };
63956
64436
  })();
63957
- var __values$e = (window && window.__values) || function(o) {
63958
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
63959
- if (m) return m.call(o);
63960
- if (o && typeof o.length === "number") return {
63961
- next: function () {
63962
- if (o && i >= o.length) o = void 0;
63963
- return { value: o && o[i++], done: !o };
63964
- }
63965
- };
63966
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
63967
- };
63968
- var __read$a = (window && window.__read) || function (o, n) {
63969
- var m = typeof Symbol === "function" && o[Symbol.iterator];
63970
- if (!m) return o;
63971
- var i = m.call(o), r, ar = [], e;
63972
- try {
63973
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
63974
- }
63975
- catch (error) { e = { error: error }; }
63976
- finally {
63977
- try {
63978
- if (r && !r.done && (m = i["return"])) m.call(i);
63979
- }
63980
- finally { if (e) throw e.error; }
63981
- }
63982
- return ar;
63983
- };
63984
- var __spreadArray$8 = (window && window.__spreadArray) || function (to, from, pack) {
63985
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
63986
- if (ar || !(i in from)) {
63987
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63988
- ar[i] = from[i];
63989
- }
63990
- }
63991
- return to.concat(ar || Array.prototype.slice.call(from));
63992
- };
63993
64437
  /**
63994
64438
  * Options used when rendering Polygon and MultiPolygon objects in a PolygonLayer.
63995
64439
  */
@@ -64025,50 +64469,6 @@ uniform ${precision} ${type} u_${name};
64025
64469
  _this.fillPattern = undefined;
64026
64470
  return _this;
64027
64471
  }
64028
- /**
64029
- * Override the standard merge behavior to set fillPattern and fillColor to be mutually exclusive
64030
- * @internal
64031
- */
64032
- PolygonLayerOptions.prototype.merge = function () {
64033
- var e_1, _a;
64034
- var valueList = [];
64035
- for (var _i = 0; _i < arguments.length; _i++) {
64036
- valueList[_i] = arguments[_i];
64037
- }
64038
- var isNewColorSet = false;
64039
- var isNewPatternSet = false;
64040
- try {
64041
- for (var valueList_1 = __values$e(valueList), valueList_1_1 = valueList_1.next(); !valueList_1_1.done; valueList_1_1 = valueList_1.next()) {
64042
- var value = valueList_1_1.value;
64043
- if (value) {
64044
- if (value.hasOwnProperty("fillColor")) {
64045
- isNewColorSet = true;
64046
- isNewPatternSet = false;
64047
- }
64048
- else if (value.hasOwnProperty("fillPattern")) {
64049
- isNewPatternSet = true;
64050
- isNewColorSet = false;
64051
- }
64052
- }
64053
- }
64054
- }
64055
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
64056
- finally {
64057
- try {
64058
- if (valueList_1_1 && !valueList_1_1.done && (_a = valueList_1.return)) _a.call(valueList_1);
64059
- }
64060
- finally { if (e_1) throw e_1.error; }
64061
- }
64062
- // Then execute the standard merge behavior.
64063
- var merged = _super.prototype.merge.apply(this, __spreadArray$8([], __read$a(valueList), false));
64064
- if (isNewColorSet) {
64065
- merged.fillPattern = undefined;
64066
- }
64067
- else if (isNewPatternSet) {
64068
- merged.fillColor = undefined;
64069
- }
64070
- return merged;
64071
- };
64072
64472
  return PolygonLayerOptions;
64073
64473
  }(LayerOptions$1));
64074
64474
 
@@ -64120,6 +64520,8 @@ uniform ${precision} ${type} u_${name};
64120
64520
  };
64121
64521
  /**
64122
64522
  * Sets the options of the polygon layer.
64523
+ * When `fillPattern` is set, `fillColor` will be ignored.
64524
+ * To set `fillColor`, make sure `fillPattern` is set to `undefined`.
64123
64525
  * @param newOptions The new options of the polygon layer.
64124
64526
  */
64125
64527
  PolygonLayer.prototype.setOptions = function (options) {
@@ -70392,59 +70794,59 @@ uniform ${precision} ${type} u_${name};
70392
70794
  var features = this.map._getMap().querySourceFeatures(sourceID, { sourceLayer: sourceLayer, filter: filter });
70393
70795
  return this.map.sources._mapFeaturesToShapes(features, true, this.sources.get(sourceID));
70394
70796
  };
70395
- // TODO: wait till the mapbox's bug is fixed
70396
- // /**
70397
- // * Gets the state of a feature
70398
- // * @param shape the ID of the shape
70399
- // * @param source the ID of the source
70400
- // * @param sourceLayer the ID of the layer
70401
- // */
70402
- // public getFeatureState(shape: string | Shape | Feature<Geometry, any>, source: string | Source, sourceLayer?: string): object {
70403
- // let featureID;
70404
- // if (typeof shape === "string") {
70405
- // featureID = shape;
70406
- // } else {
70407
- // featureID = shape instanceof Shape ? shape.getId() : shape.id;
70408
- // }
70409
- // const featureSource = typeof source === "string" ? source : source.getId();
70410
- // return this.map._getMap().getFeatureState({ id: featureID, source: featureSource, sourceLayer: sourceLayer });
70411
- // }
70412
- // /**
70413
- // * Removes the state or a single key value of the state of a feature.
70414
- // * @param shape the ID of the shape
70415
- // * @param source the ID of the source
70416
- // * @param sourceLayer the ID of the layer
70417
- // * @param key the key in the feature state to update
70418
- // */
70419
- // public removeFeatureState(shape: string | Shape | Feature<Geometry, any>, source: string | Source, sourceLayer?: string, key?: string) {
70420
- // let featureID;
70421
- // if (typeof shape === "string") {
70422
- // featureID = shape;
70423
- // } else {
70424
- // featureID = shape instanceof Shape ? shape.getId() : shape.id;
70425
- // }
70426
- // const featureSource = typeof source === "string" ? source : source.getId();
70427
- // // TODO: update the method when the mapbox typing file is updated
70428
- // (this.map._getMap() as any).removeFeatureState({ id: featureID, source: featureSource, sourceLayer: sourceLayer }, key);
70429
- // }
70430
- // /**
70431
- // * Sets the state of the feature by passing in a key value pair object.
70432
- // * @param shape the ID of the shape
70433
- // * @param source the ID of the source
70434
- // * @param sourceLayer the ID of the layer
70435
- // * @param key the key in the feature state to update
70436
- // */
70437
- // public setFeatureState(shape: string | Shape | Feature<Geometry, any>, source: string | Source, state: object, sourceLayer?: string) {
70438
- // let featureID;
70439
- // if (typeof shape === "string") {
70440
- // featureID = shape;
70441
- // } else {
70442
- // featureID = shape instanceof Shape ? shape.getId() : shape.id;
70443
- // }
70444
- // const featureSource = typeof source === "string" ? source : source.getId();
70445
- // // TODO: update the method when the mapbox typing file is updated
70446
- // this.map._getMap().setFeatureState({ id: featureID, source: featureSource, sourceLayer: sourceLayer }, state);
70447
- // }
70797
+ /**
70798
+ * Gets the state of a feature
70799
+ * @param feature the ID of the feature
70800
+ * @param source the ID of the source
70801
+ * @param sourceLayer the ID of the layer
70802
+ */
70803
+ SourceManager.prototype.getFeatureState = function (feature, source, sourceLayer) {
70804
+ var featureId;
70805
+ if (typeof feature === "string") {
70806
+ featureId = feature;
70807
+ }
70808
+ else {
70809
+ featureId = feature instanceof Shape ? feature.getId() : feature.id;
70810
+ }
70811
+ var featureSource = typeof source === "string" ? source : source.getId();
70812
+ return this.map._getMap().getFeatureState({ id: featureId, source: featureSource, sourceLayer: sourceLayer });
70813
+ };
70814
+ /**
70815
+ * Removes the state or a single key value of the state of a feature.
70816
+ * @param feature the ID of the feature
70817
+ * @param source the ID of the source
70818
+ * @param sourceLayer the ID of the layer
70819
+ * @param key the key in the feature state to update
70820
+ */
70821
+ SourceManager.prototype.removeFeatureState = function (feature, source, sourceLayer, key) {
70822
+ var featureId;
70823
+ if (typeof feature === "string") {
70824
+ featureId = feature;
70825
+ }
70826
+ else {
70827
+ featureId = feature instanceof Shape ? feature.getId() : feature.id;
70828
+ }
70829
+ var featureSource = typeof source === "string" ? source : source.getId();
70830
+ this.map._getMap().removeFeatureState({ id: featureId, source: featureSource, sourceLayer: sourceLayer }, key);
70831
+ };
70832
+ /**
70833
+ * Sets the state of the feature by passing in a key value pair object.
70834
+ * @param feature the ID of the feature
70835
+ * @param source the ID of the source
70836
+ * @param sourceLayer the ID of the layer
70837
+ * @param key the key in the feature state to update
70838
+ */
70839
+ SourceManager.prototype.setFeatureState = function (feature, source, state, sourceLayer) {
70840
+ var featureId;
70841
+ if (typeof feature === "string") {
70842
+ featureId = feature;
70843
+ }
70844
+ else {
70845
+ featureId = feature instanceof Shape ? feature.getId() : feature.id;
70846
+ }
70847
+ var featureSource = typeof source === "string" ? source : source.getId();
70848
+ this.map._getMap().setFeatureState({ id: featureId, source: featureSource, sourceLayer: sourceLayer }, state);
70849
+ };
70448
70850
  /**
70449
70851
  * @internal
70450
70852
  */
@@ -71709,8 +72111,8 @@ uniform ${precision} ${type} u_${name};
71709
72111
  */
71710
72112
  _this.styleSet = undefined;
71711
72113
  /**
71712
- * Enable accessibility
71713
- * default: true
72114
+ * Enable the accessibility feature to provide screen reader support for users who have difficulty visualizing the web application.
72115
+ * This property is set to true by default.
71714
72116
  * @default true
71715
72117
  */
71716
72118
  _this.enableAccessibility = true;
@@ -72548,14 +72950,13 @@ uniform ${precision} ${type} u_${name};
72548
72950
  return !previousStyle
72549
72951
  ? nextStyle
72550
72952
  : this.map.layers._getUserLayers().reduce(function (style, userLayer) {
72953
+ var _a, _b;
72551
72954
  if (userLayer.layer instanceof WebGLLayer) {
72552
72955
  // mapbox custom layers cannot be serialized and preserved,
72553
72956
  // return to continue to the next user layer.
72554
72957
  return style;
72555
72958
  }
72556
- var before = layerGroupLayers[userLayer.before] && layerGroupLayers[userLayer.before].length > 0
72557
- ? layerGroupLayers[userLayer.before][0]
72558
- : undefined;
72959
+ var beforeLayerId = ((_b = (_a = layerGroupLayers === null || layerGroupLayers === void 0 ? void 0 : layerGroupLayers[userLayer.before]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) || userLayer.before;
72559
72960
  var layer = previousStyle.layers.find(function (layer) { return layer.id === userLayer.layer.getId(); });
72560
72961
  // when setStyle diff attempt is unsuccesful, _load will be called on the style that may have already injected user layers -> clean it up
72561
72962
  var existingLayerIdx = nextStyle.layers.findIndex(function (layer) { return layer.id === userLayer.layer.getId(); });
@@ -72566,7 +72967,7 @@ uniform ${precision} ${type} u_${name};
72566
72967
  var sourcesToCopy = new Set(Array.from(userLayer.layer._getSourceIds())
72567
72968
  .map(function (sourceId) { return previousStyle.sources[sourceId] ? { source: previousStyle.sources[sourceId], id: sourceId } : undefined; })
72568
72969
  .filter(function (source) { return source !== undefined; }));
72569
- var insertIdx = before ? style.layers.findIndex(function (layer) { return layer.id === before.id; }) : -1;
72970
+ var insertIdx = beforeLayerId ? style.layers.findIndex(function (layer) { return layer.id === beforeLayerId; }) : -1;
72570
72971
  if (insertIdx > -1) {
72571
72972
  style.layers.splice(insertIdx, 0, layer);
72572
72973
  }