azure-maps-control 2.2.2 → 2.3.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.
@@ -265,7 +265,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
265
265
  return Url;
266
266
  }());
267
267
 
268
- var version = "2.2.2";
268
+ var version = "2.3.0";
269
269
 
270
270
  /**
271
271
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -306,27 +306,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
306
306
  var tooltipContent = document.createElement("span");
307
307
  tooltipContent.innerText = name;
308
308
  tooltipContent.classList.add('tooltiptext');
309
- // mimics default edge tooltip theming
310
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
311
- tooltipContent.classList.add('dark');
312
- }
313
- var themeQuery = window.matchMedia('(prefers-color-scheme: dark)');
314
- var onThemeChange = function (e) {
315
- var isDark = e.matches;
316
- if (isDark && !tooltipContent.classList.contains('dark')) {
317
- tooltipContent.classList.add('dark');
318
- }
319
- else if (!isDark && tooltipContent.classList.contains('dark')) {
320
- tooltipContent.classList.remove('dark');
321
- }
322
- };
323
- // compensate for browsers where MediaQueryList is not derived from EventTarget (pre iOS13 Safari)
324
- if (typeof themeQuery.addEventListener === 'function') {
325
- themeQuery.addEventListener('change', function (e) { return onThemeChange(e); });
326
- }
327
- else if (typeof themeQuery.addListener === 'function') {
328
- themeQuery.addListener(function (e) { return onThemeChange(e); });
329
- }
330
309
  if (navigator.userAgent.indexOf('Edg') != -1) {
331
310
  tooltipContent.classList.add('edge');
332
311
  }
@@ -666,7 +645,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
666
645
  * Build the outermost container for the control, applies styling including any listeners for auto styling.
667
646
  */
668
647
  ControlBase.prototype.buildContainer = function (map, style, ariaLabel, tagName) {
669
- var _this = this;
670
648
  this._map = map;
671
649
  this._container = document.createElement(tagName || "div");
672
650
  this._container.classList.add("azure-maps-control-container");
@@ -675,11 +653,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
675
653
  }
676
654
  // Set the style or add the auto listener.
677
655
  if (style.toLowerCase() === exports.ControlStyle.auto) {
678
- this._map.styles.definitions().then(function (definitions) {
679
- if (_this._map) {
680
- _this._map.events.add("stylechanged", _this._onStyleChange);
681
- }
682
- });
656
+ if (this._map) {
657
+ this._map.events.add("stylechanged", this._onStyleChange);
658
+ }
683
659
  }
684
660
  else {
685
661
  this._container.classList.add(style);
@@ -4457,6 +4433,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4457
4433
  _this.hasFocus = false;
4458
4434
  _this.styleButtons = new Dictionary();
4459
4435
  _this.styleIcons = new Dictionary();
4436
+ // we need to rely on this to avoid potentially redundant thumbnail requests and .blob calls
4437
+ _this.thumbnailCache = {
4438
+ assumedConfiguration: undefined,
4439
+ response: new Dictionary(),
4440
+ blob: new Dictionary()
4441
+ };
4460
4442
  /**
4461
4443
  * Callback handler for the style changing.
4462
4444
  */
@@ -4470,6 +4452,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4470
4452
  if (!_this.styleOpsGrid) {
4471
4453
  return;
4472
4454
  }
4455
+ // do not recreate the styleOpsGrid if it is initialized and configuration object reference has not changed
4456
+ if (_this.styleOpsGrid.children.length > 0 && _this.thumbnailCache.assumedConfiguration === definitions) {
4457
+ return;
4458
+ }
4459
+ _this.thumbnailCache.assumedConfiguration = definitions;
4473
4460
  Array.from(_this.styleOpsGrid.children).forEach(function (element) { return element.remove(); });
4474
4461
  _this.styleButtons.clear();
4475
4462
  _this.populateOpsGridFromDefinitions(definitions);
@@ -4514,6 +4501,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4514
4501
  }
4515
4502
  });
4516
4503
  container.addEventListener("focusout", function (event) {
4504
+ if (event.target === currStyleButton) {
4505
+ // on focusout from reveal button -> reset the tabIndex on the styleOpsGrid elements that could have been set to -1 on esc key press
4506
+ Array.from(styleOpsGrid.children).forEach(function (e) { return e.removeAttribute('tabIndex'); });
4507
+ }
4517
4508
  if (!(event.relatedTarget instanceof Node && container.contains(event.relatedTarget))) {
4518
4509
  _this.hasFocus = false;
4519
4510
  if (!_this.hasMouse) {
@@ -4528,6 +4519,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4528
4519
  if (event.keyCode === 27) {
4529
4520
  event.stopPropagation();
4530
4521
  currStyleButton.focus();
4522
+ Array.from(styleOpsGrid.children).forEach(function (e) { return e.setAttribute('tabIndex', "-1"); });
4531
4523
  if (container.classList.contains(StyleControl.Css.inUse)) {
4532
4524
  container.classList.remove(StyleControl.Css.inUse);
4533
4525
  styleOpsGrid.classList.add("hidden-accessible-element");
@@ -4570,6 +4562,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4570
4562
  _super.prototype.onRemove.call(this);
4571
4563
  this.styleOpsGrid = null;
4572
4564
  this.styleButtons.clear();
4565
+ this.thumbnailCache.response.clear();
4566
+ this.thumbnailCache.blob.clear();
4567
+ this.thumbnailCache.assumedConfiguration = undefined;
4573
4568
  this.map.events.remove("stylechanged", this.onStyleChange);
4574
4569
  this.map.events.remove("mapconfigurationchanged", this.onMapConfigurationChange);
4575
4570
  };
@@ -4629,7 +4624,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4629
4624
  styleOptionButton.setAttribute("type", "button");
4630
4625
  var styleIconImage = new Image();
4631
4626
  fetchIconPromise
4632
- .then(function (response) { return response.blob(); })
4627
+ .then(function (response) {
4628
+ if (_this.thumbnailCache.blob.has(response.url)) {
4629
+ return _this.thumbnailCache.blob.get(response.url);
4630
+ }
4631
+ else {
4632
+ // we need the response.clone() to allow reading over body multiple times since response objects are cached
4633
+ // and can be reused across multiple invocations
4634
+ var blobPromise = response.clone().blob();
4635
+ _this.thumbnailCache.blob.set(response.url, blobPromise);
4636
+ return blobPromise;
4637
+ }
4638
+ })
4633
4639
  .then(function (blob) {
4634
4640
  var iconUrl = URL.createObjectURL(blob);
4635
4641
  styleIconImage.src = iconUrl;
@@ -4737,7 +4743,14 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4737
4743
  if (mapServiceOptions.transformRequest) {
4738
4744
  merge_1(requestParams, mapServiceOptions.transformRequest(requestParams.url, "Thumbnail"));
4739
4745
  }
4740
- var fetchThumbnailPromise = fetch(requestParams.url, { headers: requestParams.headers });
4746
+ var fetchThumbnailPromise;
4747
+ if (_this.thumbnailCache.response.has(requestParams.url)) {
4748
+ fetchThumbnailPromise = Promise.resolve(_this.thumbnailCache.response.get(requestParams.url));
4749
+ }
4750
+ else {
4751
+ fetchThumbnailPromise = fetch(requestParams.url, { headers: requestParams.headers });
4752
+ _this.thumbnailCache.response.set(requestParams.url, fetchThumbnailPromise);
4753
+ }
4741
4754
  // Add button for each style
4742
4755
  var styleOptionButton = _this.buildSelectStyleBtn(style.name, definitions, fetchThumbnailPromise);
4743
4756
  _this.styleOpsGrid.appendChild(styleOptionButton);
@@ -10015,7 +10028,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10015
10028
  };
10016
10029
  ZoomControl.prototype.updateZoomButtonsState = function () {
10017
10030
  var zoomInDisabled = this.map.getCamera().zoom >= this.map._getMap().getMaxZoom();
10018
- // small values need special handling, since depending on the height of the map view
10031
+ // small values need special handling, since depending on the height of the map view
10019
10032
  // the actual zoom we can zoom out to can be above or below 0 when the entire map fits the height into the view
10020
10033
  // use web mercator bounds to check if entire latitude range is visible
10021
10034
  var reachedLatitudeBoundaries = BoundingBox.getSouth(this.map.getCamera().bounds) <= -WEBMERCATOR_MAXLAT
@@ -10027,7 +10040,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10027
10040
  }
10028
10041
  if (this.zoomOutButton && this.zoomOutButton.disabled != zoomOutDisabled) {
10029
10042
  this.zoomOutButton.disabled = zoomOutDisabled;
10030
- this.zoomInButton.setAttribute("aria-label", zoomInDisabled ? "Zoom Out disabled" : "Zoom Out");
10043
+ this.zoomOutButton.setAttribute("aria-label", zoomInDisabled ? "Zoom Out disabled" : "Zoom Out");
10031
10044
  }
10032
10045
  };
10033
10046
  ZoomControl.prototype.constructZoomInButton = function (map) {
@@ -10120,6 +10133,72 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10120
10133
 
10121
10134
  var cloneDeepWith_1 = cloneDeepWith;
10122
10135
 
10136
+ /**
10137
+ * A hidden HTML element that is used to provide accessibility to shapes such as bubble.
10138
+ */
10139
+ var AccessibleIndicator = /** @class */ (function () {
10140
+ /**
10141
+ * Constructs an AccessibleIndicator object by initializing a hidden `div` element.
10142
+ * @internal
10143
+ */
10144
+ function AccessibleIndicator(options) {
10145
+ var _this = this;
10146
+ /**
10147
+ * Attaches the indicator to the HTML document in a hidden style.
10148
+ * @param map The map.
10149
+ */
10150
+ this.attach = function (map) {
10151
+ // If attaching to a different map, remove popup on current map
10152
+ if (_this.map !== map) {
10153
+ // If map was defined the indicator was attached to another map.
10154
+ if (_this.map) {
10155
+ _this.detachFromCurrentMap();
10156
+ }
10157
+ _this.map = map;
10158
+ _this.map.indicators._getCollectionDiv().appendChild(_this.element);
10159
+ _this.map.indicators.add(_this);
10160
+ }
10161
+ };
10162
+ /**
10163
+ * Removes the indicator from the map and the HTML document.
10164
+ */
10165
+ this.remove = function () {
10166
+ _this.detachFromCurrentMap();
10167
+ _this.element.remove();
10168
+ };
10169
+ /**
10170
+ * Get the DOM element of the indicator.
10171
+ * @returns The DOM element of the indicator.
10172
+ */
10173
+ this.getElement = function () {
10174
+ return _this.element;
10175
+ };
10176
+ this.detachFromCurrentMap = function () {
10177
+ if (_this.map) {
10178
+ _this.map.indicators.remove(_this);
10179
+ delete _this.map;
10180
+ }
10181
+ };
10182
+ this.element = document.createElement("div");
10183
+ // Set tabindex to 0 to make the element focusable.
10184
+ this.element.setAttribute("tabindex", "0");
10185
+ // Set the role to option, and it's container to listbox so the reader will read the listbox as a list.
10186
+ // For example, NVDA will read "data point, {posinset} of {setsize}" when the indicator is focused.
10187
+ this.element.setAttribute("role", "option");
10188
+ if (options === null || options === void 0 ? void 0 : options.setSize)
10189
+ this.element.setAttribute("aria-setsize", options.setSize.toString());
10190
+ if (options === null || options === void 0 ? void 0 : options.positionInSet)
10191
+ this.element.setAttribute("aria-posinset", options.positionInSet.toString());
10192
+ this.element.setAttribute("aria-label", "data point");
10193
+ this.element.classList.add(AccessibleIndicator.Css.hidden);
10194
+ }
10195
+ // CSS class names.
10196
+ AccessibleIndicator.Css = {
10197
+ hidden: "hidden-accessible-element"
10198
+ };
10199
+ return AccessibleIndicator;
10200
+ }());
10201
+
10123
10202
  var __extends$k = (window && window.__extends) || (function () {
10124
10203
  var extendStatics = function (d, b) {
10125
10204
  extendStatics = Object.setPrototypeOf ||
@@ -10233,19 +10312,24 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10233
10312
  * Get reference to Mapbox Map
10234
10313
  * @internal
10235
10314
  */
10236
- Source.prototype._setMap = function (map) {
10315
+ Source.prototype._setMap = function (map, shouldInvokeEvent) {
10316
+ if (shouldInvokeEvent === void 0) { shouldInvokeEvent = true; }
10237
10317
  if (map == null || map === undefined) {
10238
10318
  var temp = this.map;
10239
10319
  delete this.map;
10240
- this._invokeEvent("sourceremoved", this);
10241
- if (temp) {
10242
- temp.events.invoke("sourceremoved", this);
10320
+ if (shouldInvokeEvent) {
10321
+ this._invokeEvent("sourceremoved", this);
10322
+ if (temp) {
10323
+ temp.events.invoke("sourceremoved", this);
10324
+ }
10243
10325
  }
10244
10326
  }
10245
10327
  else {
10246
10328
  this.map = map;
10247
- this._invokeEvent("sourceadded", this);
10248
- this.map.events.invoke("sourceadded", this);
10329
+ if (shouldInvokeEvent) {
10330
+ this._invokeEvent("sourceadded", this);
10331
+ this.map.events.invoke("sourceadded", this);
10332
+ }
10249
10333
  }
10250
10334
  };
10251
10335
  return Source;
@@ -10566,6 +10650,27 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10566
10650
  }
10567
10651
  return geoJsonSource;
10568
10652
  };
10653
+ DataSource.prototype._isDeepEqual = function (other) {
10654
+ if (this.constructor !== other.constructor) {
10655
+ return false;
10656
+ }
10657
+ var source = this._buildSource();
10658
+ var otherSource = other._buildSource();
10659
+ return source.type === otherSource.type &&
10660
+ // no data comparison since it is costly and not needed. If geojson data is different, but other source properties are same, we treat it as an update.
10661
+ //source.data === otherSource.data &&
10662
+ source.maxzoom === otherSource.maxzoom &&
10663
+ source.cluster === otherSource.cluster &&
10664
+ source.clusterRadius === otherSource.clusterRadius &&
10665
+ source.tolerance === otherSource.tolerance &&
10666
+ source.lineMetrics === otherSource.lineMetrics &&
10667
+ JSON.stringify(source.clusterProperties) === JSON.stringify(otherSource.clusterProperties) &&
10668
+ source.buffer === otherSource.buffer &&
10669
+ source.clusterMinPoints === otherSource.clusterMinPoints &&
10670
+ source.generateId === otherSource.generateId &&
10671
+ source.promoteId === otherSource.promoteId &&
10672
+ source.filter === otherSource.filter;
10673
+ };
10569
10674
  /**
10570
10675
  * @internal
10571
10676
  */
@@ -10847,6 +10952,26 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10847
10952
  }
10848
10953
  return vectorSource;
10849
10954
  };
10955
+ /**
10956
+ * @internal
10957
+ */
10958
+ VectorTileSource.prototype._isDeepEqual = function (other) {
10959
+ if (this.constructor !== other.constructor) {
10960
+ return false;
10961
+ }
10962
+ var source = this._buildSource();
10963
+ var otherSource = other._buildSource();
10964
+ return source.type === otherSource.type &&
10965
+ source.url === otherSource.url &&
10966
+ ((source.tiles === undefined && otherSource.tiles === undefined) ||
10967
+ (source.tiles && otherSource.tiles && source.tiles.length === otherSource.tiles.length && source.tiles.every(function (value, idx) { return value === otherSource.tiles[idx]; }))) &&
10968
+ source.minzoom === otherSource.minzoom &&
10969
+ source.maxzoom === otherSource.maxzoom &&
10970
+ source.bounds === otherSource.bounds &&
10971
+ source.attribution === otherSource.attribution &&
10972
+ source.promoteId === otherSource.promoteId &&
10973
+ source.scheme === otherSource.scheme;
10974
+ };
10850
10975
  return VectorTileSource;
10851
10976
  }(Source));
10852
10977
 
@@ -10978,7 +11103,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
10978
11103
  // and can be used to determine which events are ours vs Mapbox's.
10979
11104
  Layer.LayerEvents = {
10980
11105
  layeradded: undefined,
10981
- layerremoved: undefined
11106
+ layerremoved: undefined,
11107
+ focusin: undefined,
11108
+ focusout: undefined,
10982
11109
  };
10983
11110
  return Layer;
10984
11111
  }(EventEmitter));
@@ -11133,6 +11260,44 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
11133
11260
  * @default 8
11134
11261
  */
11135
11262
  _this.radius = 8;
11263
+ /**
11264
+ * @internal
11265
+ * Specifies whether to create focusable indicators for the bubbles.
11266
+ * The default highlighting style is provided if the source is DataSource with Shape:
11267
+ * ```ts
11268
+ * const datasource = new DataSource('bubble-source');
11269
+ * datasource.setShapes([new Shape(new Point([-122.335, 47.62]))]);
11270
+ * this.map.sources.add(datasource);
11271
+ * const layer = new BubbleLayer(datasource, 'bubble', {
11272
+ * radius: 10,
11273
+ * color: 'cyan',
11274
+ * createIndicators: true,
11275
+ * });
11276
+ * ```
11277
+ *
11278
+ * For other sources, you can provide the accessibilityIdKey option to specify the property name of the feature to use as the accessibility id.
11279
+ * ```ts
11280
+ * const vtSource = new VectorTileSource("indoorTiles", { tiles, // provide your tile urls });
11281
+ * this.map.sources.add(vtSource);
11282
+ * const layer = new BubbleLayer(vtSource, 'bubble', {
11283
+ * createIndicators: true,
11284
+ * accessibilityIdKey: '{add your ID here}'
11285
+ * });
11286
+ * ```
11287
+ *
11288
+ * If you want to customize the highlighting style, you can use the focusin/focusout events to change the style of the bubble.
11289
+ * ```ts
11290
+ * this.map.events.add('focusin', 'bubble', (e) => { handle the style highlight });
11291
+ * ```
11292
+ *
11293
+ * Note: We treat this as an internal option for now because we hadn't fully decided the default styling for the indicators.
11294
+ * Once we decide, we will make this a public option or remove it.
11295
+ */
11296
+ _this.createIndicators = false;
11297
+ /**
11298
+ * @internal
11299
+ */
11300
+ _this.accessibilityIdKey = undefined;
11136
11301
  return _this;
11137
11302
  }
11138
11303
  return BubbleLayerOptions;
@@ -11153,6 +11318,63 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
11153
11318
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11154
11319
  };
11155
11320
  })();
11321
+ var __awaiter$1 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
11322
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11323
+ return new (P || (P = Promise))(function (resolve, reject) {
11324
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11325
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11326
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11327
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11328
+ });
11329
+ };
11330
+ var __generator$1 = (window && window.__generator) || function (thisArg, body) {
11331
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
11332
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
11333
+ function verb(n) { return function (v) { return step([n, v]); }; }
11334
+ function step(op) {
11335
+ if (f) throw new TypeError("Generator is already executing.");
11336
+ while (_) try {
11337
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
11338
+ if (y = 0, t) op = [op[0] & 2, t.value];
11339
+ switch (op[0]) {
11340
+ case 0: case 1: t = op; break;
11341
+ case 4: _.label++; return { value: op[1], done: false };
11342
+ case 5: _.label++; y = op[1]; op = [0]; continue;
11343
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
11344
+ default:
11345
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
11346
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
11347
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
11348
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
11349
+ if (t[2]) _.ops.pop();
11350
+ _.trys.pop(); continue;
11351
+ }
11352
+ op = body.call(thisArg, _);
11353
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
11354
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
11355
+ }
11356
+ };
11357
+ var __read$3 = (window && window.__read) || function (o, n) {
11358
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
11359
+ if (!m) return o;
11360
+ var i = m.call(o), r, ar = [], e;
11361
+ try {
11362
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11363
+ }
11364
+ catch (error) { e = { error: error }; }
11365
+ finally {
11366
+ try {
11367
+ if (r && !r.done && (m = i["return"])) m.call(i);
11368
+ }
11369
+ finally { if (e) throw e.error; }
11370
+ }
11371
+ return ar;
11372
+ };
11373
+ var __spreadArray = (window && window.__spreadArray) || function (to, from) {
11374
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
11375
+ to[j] = from[i];
11376
+ return to;
11377
+ };
11156
11378
  /**
11157
11379
  * Renders Point objects as scalable circles (bubbles).
11158
11380
  */
@@ -11166,6 +11388,93 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
11166
11388
  */
11167
11389
  function BubbleLayer(source, id, options) {
11168
11390
  var _this = _super.call(this, id) || this;
11391
+ _this.accessibleIndicator = [];
11392
+ /** @internal */
11393
+ _this._setAccessibleIndicator = function () { return __awaiter$1(_this, void 0, void 0, function () {
11394
+ var renderedShapes, accessibilityIdKey, createIndicator, insertHiddenBefore, insertHiddenInFront, attach;
11395
+ var _this = this;
11396
+ return __generator$1(this, function (_a) {
11397
+ this.accessibleIndicator.forEach(function (indicator) { return indicator.remove(); });
11398
+ this.accessibleIndicator = [];
11399
+ renderedShapes = this.map.layers.getRenderedShapes(this.map.getCamera().bounds, this);
11400
+ accessibilityIdKey = this.options.accessibilityIdKey || (this._getDataSource() ? Shape._shapeIdPropName : undefined);
11401
+ createIndicator = function (renderedShapes, idx) {
11402
+ var curRenderedShape = renderedShapes[idx];
11403
+ var bubbleFeature = curRenderedShape instanceof Shape ? curRenderedShape.toJson() : curRenderedShape;
11404
+ var indicator = new AccessibleIndicator({ positionInSet: idx + 1, setSize: renderedShapes.length });
11405
+ var element = indicator.getElement();
11406
+ var _a = __read$3(_this.map.positionsToPixels([_this.getFirstCoordinate(bubbleFeature.geometry.coordinates)]), 1), pixel = _a[0];
11407
+ element.addEventListener('focusin', function (event) {
11408
+ _this.accessibleIndicator.filter(function (i) { return i !== indicator; }).forEach(function (indicator) { return indicator.remove(); });
11409
+ // insert previous and next popups
11410
+ if (idx - 1 >= 0) {
11411
+ insertHiddenBefore(indicator, createIndicator(renderedShapes, idx - 1));
11412
+ }
11413
+ if (idx + 1 < renderedShapes.length) {
11414
+ attach(createIndicator(renderedShapes, idx + 1));
11415
+ }
11416
+ // if we are on boundaries: add the first / last indicator
11417
+ // to maintain indicators on full page navigation cycle
11418
+ if (idx >= 2 && idx == renderedShapes.length - 1) {
11419
+ insertHiddenInFront(createIndicator(renderedShapes, 0));
11420
+ }
11421
+ if (idx == 0 && renderedShapes.length >= 2) {
11422
+ attach(createIndicator(renderedShapes, renderedShapes.length - 1));
11423
+ }
11424
+ if (accessibilityIdKey !== undefined) {
11425
+ _this.map._getMap().setPaintProperty(_this.id, 'circle-stroke-color', ['case', ['==', ['get', accessibilityIdKey], bubbleFeature.properties[accessibilityIdKey]], '#000000', _this.options.strokeColor]);
11426
+ }
11427
+ var focusEvent = {
11428
+ target: element,
11429
+ type: 'focusin',
11430
+ map: _this.map,
11431
+ shape: curRenderedShape,
11432
+ originalEvent: event,
11433
+ pixel: pixel
11434
+ };
11435
+ _this._invokeEvent('focusin', focusEvent);
11436
+ });
11437
+ element.addEventListener('focusout', function (event) {
11438
+ if (accessibilityIdKey !== undefined) {
11439
+ _this.map._getMap().setPaintProperty(_this.id, 'circle-stroke-color', ['case', ['==', ['get', accessibilityIdKey], bubbleFeature.properties[accessibilityIdKey]], _this.options.strokeColor, _this.options.strokeColor]);
11440
+ }
11441
+ var focusEvent = {
11442
+ target: element,
11443
+ type: 'focusout',
11444
+ map: _this.map,
11445
+ shape: curRenderedShape,
11446
+ originalEvent: event,
11447
+ pixel: pixel
11448
+ };
11449
+ _this._invokeEvent('focusout', focusEvent);
11450
+ });
11451
+ _this.accessibleIndicator.push(indicator);
11452
+ return indicator;
11453
+ };
11454
+ insertHiddenBefore = function (base, toInsert) {
11455
+ toInsert.attach(_this.map);
11456
+ var elementToSwapIn = toInsert.getElement();
11457
+ var baseElement = base.getElement();
11458
+ baseElement.parentElement.insertBefore(elementToSwapIn, baseElement);
11459
+ };
11460
+ insertHiddenInFront = function (toInsert) {
11461
+ toInsert.attach(_this.map);
11462
+ var elementToSwapIn = toInsert.getElement();
11463
+ var parent = elementToSwapIn.parentElement;
11464
+ parent.insertBefore(elementToSwapIn, parent.firstElementChild);
11465
+ };
11466
+ attach = function (popup) {
11467
+ popup.attach(_this.map);
11468
+ };
11469
+ if (renderedShapes.length > 0) {
11470
+ attach(createIndicator(renderedShapes, 0));
11471
+ }
11472
+ if (renderedShapes.length > 1) {
11473
+ attach(createIndicator(renderedShapes, renderedShapes.length - 1));
11474
+ }
11475
+ return [2 /*return*/];
11476
+ });
11477
+ }); };
11169
11478
  _this.options = new BubbleLayerOptions().merge(cloneDeepWith_1(options, BubbleLayerOptions._cloneCustomizer));
11170
11479
  _this.options.source = source || _this.options.source;
11171
11480
  return _this;
@@ -11213,6 +11522,73 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
11213
11522
  }
11214
11523
  this.options = newOptions;
11215
11524
  };
11525
+ BubbleLayer.prototype.onAdd = function (map) {
11526
+ var _this = this;
11527
+ _super.prototype.onAdd.call(this, map);
11528
+ if (this.options.createIndicators) {
11529
+ // Wait for map idle for the first time to ensure `layer.getRenderedShapes` return correct shapes.
11530
+ map.events.addOnce('idle', this._setAccessibleIndicator);
11531
+ // The rendered shapes may be changed when map is moved. Update the indicators when map is moved.
11532
+ map.events.add('moveend', this._setAccessibleIndicator);
11533
+ var dataSource = this._getDataSource();
11534
+ if (dataSource) {
11535
+ // The rendered shapes may be changed when data is added. Update the indicators when data is added.
11536
+ map.events.add('dataadded', dataSource, function () {
11537
+ // Wait for map idle to ensure `layer.getRenderedShapes` return correct shapes.
11538
+ map.events.addOnce('idle', _this._setAccessibleIndicator);
11539
+ });
11540
+ }
11541
+ else {
11542
+ var sourceId_1 = typeof this.options.source === 'string' ? this.options.source : this.options.source.getId();
11543
+ map.events.add('sourcedata', function (mapDataEvent) {
11544
+ var _a;
11545
+ // There's chances that mapDataEvent.isSourceLoaded doesn't update correctly when using flyTo, thus we check by using map.isSourceLoaded.
11546
+ if (((_a = mapDataEvent.source) === null || _a === void 0 ? void 0 : _a.getId()) === sourceId_1 && map._getMap().isSourceLoaded(sourceId_1)) {
11547
+ // Source event will be fired multiple times, and we are only interested when the source is loaded.
11548
+ // Thus design a cache key that only changed when camera & style properties are changed.
11549
+ var curCacheKey = _this._getSourceDataEventCacheKey();
11550
+ if (curCacheKey !== _this.sourceDataEventCacheKey) {
11551
+ _this._setAccessibleIndicator();
11552
+ _this.sourceDataEventCacheKey = curCacheKey;
11553
+ }
11554
+ }
11555
+ });
11556
+ }
11557
+ }
11558
+ };
11559
+ BubbleLayer.prototype.onRemove = function () {
11560
+ if (this.options.createIndicators) {
11561
+ this.map.events.remove('idle', this._setAccessibleIndicator);
11562
+ this.map.events.remove('moveend', this._setAccessibleIndicator);
11563
+ var dataSource = this._getDataSource();
11564
+ if (dataSource) {
11565
+ this.map.events.remove('dataadded', dataSource, this._setAccessibleIndicator);
11566
+ }
11567
+ else {
11568
+ this.map.events.remove('sourcedata', this._setAccessibleIndicator);
11569
+ }
11570
+ }
11571
+ _super.prototype.onRemove.call(this);
11572
+ };
11573
+ BubbleLayer.prototype._getSourceDataEventCacheKey = function () {
11574
+ if (!this.map) {
11575
+ return undefined;
11576
+ }
11577
+ var mapConfiguration = this.map.getServiceOptions().mapConfiguration;
11578
+ return __spreadArray(__spreadArray([], __read$3(this.map.getCamera().bounds)), [
11579
+ this.map.getCamera().zoom,
11580
+ this.map.getCamera().pitch,
11581
+ this.map.getStyle().style,
11582
+ mapConfiguration instanceof Object ? mapConfiguration.id : mapConfiguration
11583
+ ]).join(',');
11584
+ };
11585
+ BubbleLayer.prototype._getDataSource = function () {
11586
+ var source = typeof this.options.source === 'string' ? this.map.sources.getById(this.options.source) : this.options.source;
11587
+ if (source instanceof DataSource) {
11588
+ return source;
11589
+ }
11590
+ return undefined;
11591
+ };
11216
11592
  /**
11217
11593
  * @internal
11218
11594
  */
@@ -11264,6 +11640,17 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
11264
11640
  ids.add(this.options.source);
11265
11641
  return ids;
11266
11642
  };
11643
+ /**
11644
+ * The coordinates can be nested, so we need to get the first coordinate.
11645
+ * @param coordinates The property from the Geometry. Can be Position, Position[], Position[][], etc.
11646
+ * @returns
11647
+ */
11648
+ BubbleLayer.prototype.getFirstCoordinate = function (coordinates) {
11649
+ if (!Array.isArray(coordinates[0])) {
11650
+ return coordinates;
11651
+ }
11652
+ return this.getFirstCoordinate(coordinates[0]);
11653
+ };
11267
11654
  return BubbleLayer;
11268
11655
  }(Layer));
11269
11656
 
@@ -12331,7 +12718,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
12331
12718
  };
12332
12719
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12333
12720
  };
12334
- var __read$3 = (window && window.__read) || function (o, n) {
12721
+ var __read$4 = (window && window.__read) || function (o, n) {
12335
12722
  var m = typeof Symbol === "function" && o[Symbol.iterator];
12336
12723
  if (!m) return o;
12337
12724
  var i = m.call(o), r, ar = [], e;
@@ -12347,7 +12734,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
12347
12734
  }
12348
12735
  return ar;
12349
12736
  };
12350
- var __spreadArray = (window && window.__spreadArray) || function (to, from) {
12737
+ var __spreadArray$1 = (window && window.__spreadArray) || function (to, from) {
12351
12738
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
12352
12739
  to[j] = from[i];
12353
12740
  return to;
@@ -12422,7 +12809,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
12422
12809
  finally { if (e_1) throw e_1.error; }
12423
12810
  }
12424
12811
  // Then execute the standard merge behavior.
12425
- var merged = _super.prototype.merge.apply(this, __spreadArray([], __read$3(valueList)));
12812
+ var merged = _super.prototype.merge.apply(this, __spreadArray$1([], __read$4(valueList)));
12426
12813
  if (isNewColorSet) {
12427
12814
  merged.fillPattern = undefined;
12428
12815
  }
@@ -13753,7 +14140,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13753
14140
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13754
14141
  };
13755
14142
  })();
13756
- var __read$4 = (window && window.__read) || function (o, n) {
14143
+ var __read$5 = (window && window.__read) || function (o, n) {
13757
14144
  var m = typeof Symbol === "function" && o[Symbol.iterator];
13758
14145
  if (!m) return o;
13759
14146
  var i = m.call(o), r, ar = [], e;
@@ -13865,7 +14252,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13865
14252
  */
13866
14253
  _this._onDown = function (event) {
13867
14254
  _this.map.popups._addDraggedPopup(_this);
13868
- var _a = __read$4(_this.map.positionsToPixels([_this.options.position]), 1), anchorPixel = _a[0];
14255
+ var _a = __read$5(_this.map.positionsToPixels([_this.options.position]), 1), anchorPixel = _a[0];
13869
14256
  if (event.type === "mousedown") {
13870
14257
  event = event;
13871
14258
  _this.dragOffset = [
@@ -14029,7 +14416,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14029
14416
  pixel[0] + this.dragOffset[0],
14030
14417
  pixel[1] + this.dragOffset[1]
14031
14418
  ];
14032
- var _a = __read$4(this.map.pixelsToPositions([anchorPixel]), 1), anchorPos = _a[0];
14419
+ var _a = __read$5(this.map.pixelsToPositions([anchorPixel]), 1), anchorPos = _a[0];
14033
14420
  this.options.position = anchorPos;
14034
14421
  this.marker.setLngLat(this.options.position);
14035
14422
  this._invokeEvent("drag", { type: "drag", target: this });
@@ -14183,7 +14570,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14183
14570
  posY = pt.y;
14184
14571
  }
14185
14572
  else {
14186
- var _a = __read$4(map.positionsToPixels([options.position]), 1), _b = __read$4(_a[0], 2), x = _b[0], y = _b[1];
14573
+ var _a = __read$5(map.positionsToPixels([options.position]), 1), _b = __read$5(_a[0], 2), x = _b[0], y = _b[1];
14187
14574
  posX = x;
14188
14575
  posY = y;
14189
14576
  }
@@ -14672,6 +15059,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14672
15059
  defaultRegion: {
14673
15060
  code: "NGT",
14674
15061
  strings: "en/resource.json"
15062
+ },
15063
+ latn: {
15064
+ code: "NGT-Latn",
15065
+ strings: "en/resource.json"
14675
15066
  }
14676
15067
  },
14677
15068
  ar: {
@@ -14718,6 +15109,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14718
15109
  us: {
14719
15110
  code: "en-US",
14720
15111
  strings: "en/resource.json"
15112
+ },
15113
+ au: {
15114
+ code: "en-AU",
15115
+ strings: "en/resource.json"
15116
+ },
15117
+ gb: {
15118
+ code: "en-GB",
15119
+ strings: "en/resource.json"
15120
+ },
15121
+ nz: {
15122
+ code: "en-NZ",
15123
+ strings: "en/resource.json"
14721
15124
  }
14722
15125
  },
14723
15126
  es: {
@@ -14843,14 +15246,31 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14843
15246
  }
14844
15247
  },
14845
15248
  zh: {
15249
+ // per https://microsoft.sharepoint.com/sites/globalreadiness/SitePages/Language-fallback.aspx
15250
+ // Chinese - Neutral (zh) fallbacks to en-US
14846
15251
  defaultRegion: {
14847
- code: "zh-Hant",
14848
- strings: "zh-tw/resource.json"
15252
+ code: "zh",
15253
+ strings: "en/resource.json"
15254
+ }
15255
+ },
15256
+ "zh-hans": {
15257
+ defaultRegion: {
15258
+ code: "zh-Hans",
15259
+ strings: "zh-cn/resource.json"
15260
+ },
15261
+ cn: {
15262
+ code: "zh-Hans-CN",
15263
+ strings: "zh-cn/resource.json"
14849
15264
  }
14850
15265
  },
14851
15266
  "zh-hant": {
15267
+ // per discussion with global readiness team, we were explicitly asked to not fallback zh-hant to zh-tw
14852
15268
  defaultRegion: {
14853
15269
  code: "zh-Hant",
15270
+ strings: "en/resource.json"
15271
+ },
15272
+ tw: {
15273
+ code: "zh-Hant-TW",
14854
15274
  strings: "zh-tw/resource.json"
14855
15275
  }
14856
15276
  }
@@ -15067,7 +15487,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15067
15487
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15068
15488
  };
15069
15489
  })();
15070
- var __read$5 = (window && window.__read) || function (o, n) {
15490
+ var __read$6 = (window && window.__read) || function (o, n) {
15071
15491
  var m = typeof Symbol === "function" && o[Symbol.iterator];
15072
15492
  if (!m) return o;
15073
15493
  var i = m.call(o), r, ar = [], e;
@@ -15083,7 +15503,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15083
15503
  }
15084
15504
  return ar;
15085
15505
  };
15086
- var __spreadArray$1 = (window && window.__spreadArray) || function (to, from) {
15506
+ var __spreadArray$2 = (window && window.__spreadArray) || function (to, from) {
15087
15507
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
15088
15508
  to[j] = from[i];
15089
15509
  return to;
@@ -15220,7 +15640,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15220
15640
  for (var _i = 0; _i < arguments.length; _i++) {
15221
15641
  valueList[_i] = arguments[_i];
15222
15642
  }
15223
- var merged = _super.prototype.merge.apply(this, __spreadArray$1([], __read$5(valueList)));
15643
+ var merged = _super.prototype.merge.apply(this, __spreadArray$2([], __read$6(valueList)));
15224
15644
  if (merged.authType === exports.AuthenticationType.subscriptionKey) {
15225
15645
  merged.authContext = merged.aadAppId = merged.getToken = undefined;
15226
15646
  }
@@ -15479,7 +15899,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15479
15899
  /**
15480
15900
  * Specifies which set of geopolitically disputed borders and labels are displayed on the map. The View parameter (also referred to as “user region parameter”) is a 2-letter ISO-3166 Country Code that will show the correct maps for that country/region. Country/Regions that are not on the View list or if unspecified will default to the “Unified” View.
15481
15901
  * Please see the supported [Views]{@link https://aka.ms/AzureMapsLocalizationViews }.
15482
- * It is your responsibility to determine the location of your users, and then set the View parameter correctly for that location. The View parameter in Azure Maps must be used in compliance with applicable laws, including those regarding mapping, of the country where maps, images and other data and third party content that You are authorized to access via Azure Maps is made available.
15902
+ * It is your responsibility to determine the location of your users, and then set the View parameter correctly for that location. The View parameter in Azure Maps must be used in compliance with applicable laws, including those regarding mapping, of the country/region where maps, images and other data and third party content that You are authorized to access via Azure Maps is made available.
15483
15903
  * @param view The new default view
15484
15904
  */
15485
15905
  function setView(view) {
@@ -15891,10 +16311,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15891
16311
  if (add) {
15892
16312
  this.logoAnchor = document.createElement("a");
15893
16313
  this.logoAnchor.className = "azure-map-logo";
15894
- this.logoAnchor.href = "https://microsoft.com";
16314
+ this.logoAnchor.href = "https://aka.ms/azuremaps";
15895
16315
  this.logoAnchor.setAttribute("aria-label", "Microsoft");
16316
+ this.logoAnchor.setAttribute("target", "_blank");
15896
16317
  this.container.appendChild(this.logoAnchor);
15897
- this.logoTooltip = buildAccessibleTooltip("Visit microsoft.com");
16318
+ this.logoTooltip = buildAccessibleTooltip("Visit azure.microsoft.com");
15898
16319
  this.container.appendChild(this.logoTooltip);
15899
16320
  positionTooltip(this.logoTooltip, this.logoAnchor);
15900
16321
  }
@@ -16076,11 +16497,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16076
16497
  // Translations for oceans: https://en.wikipedia.org/wiki/List_of_alternative_names_for_oceans
16077
16498
  this._preloadedCache.add(lang);
16078
16499
  var oceanConfig = {
16079
- source: ["Ocean label", "Ocean name"],
16500
+ source: [],
16080
16501
  labelType: "water",
16081
16502
  minZoom: 0,
16082
16503
  radius: 3950000,
16083
- polygonSources: ["Ocean", "Ocean or sea"]
16504
+ polygonSources: [] // doesn't affect the cache key
16084
16505
  };
16085
16506
  var shortLang = lang;
16086
16507
  var index = shortLang.indexOf("-");
@@ -16124,7 +16545,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16124
16545
  return MapLabelCache;
16125
16546
  }());
16126
16547
 
16127
- var __awaiter$1 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
16548
+ var __awaiter$2 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
16128
16549
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16129
16550
  return new (P || (P = Promise))(function (resolve, reject) {
16130
16551
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -16133,7 +16554,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16133
16554
  step((generator = generator.apply(thisArg, _arguments || [])).next());
16134
16555
  });
16135
16556
  };
16136
- var __generator$1 = (window && window.__generator) || function (thisArg, body) {
16557
+ var __generator$2 = (window && window.__generator) || function (thisArg, body) {
16137
16558
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
16138
16559
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16139
16560
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -16160,7 +16581,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16160
16581
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
16161
16582
  }
16162
16583
  };
16163
- var __read$6 = (window && window.__read) || function (o, n) {
16584
+ var __read$7 = (window && window.__read) || function (o, n) {
16164
16585
  var m = typeof Symbol === "function" && o[Symbol.iterator];
16165
16586
  if (!m) return o;
16166
16587
  var i = m.call(o), r, ar = [], e;
@@ -16176,6 +16597,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16176
16597
  }
16177
16598
  return ar;
16178
16599
  };
16600
+ var __spreadArray$3 = (window && window.__spreadArray) || function (to, from) {
16601
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
16602
+ to[j] = from[i];
16603
+ return to;
16604
+ };
16179
16605
  /**
16180
16606
  * This class analyizes the current view of a map and provides a description for use by accessibilty tools.
16181
16607
  * TODO: Use services when in GeoPol regions. (Kasmir) or when user region sensitive.
@@ -16212,8 +16638,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16212
16638
  this._minRoadDistance = 25;
16213
16639
  // Minium distance in pixels a second road must be in order to be considered an intersection.
16214
16640
  this._minIntersectionPixelDistance = 50;
16215
- // The vector tile source id for Azure Maps.
16216
- this._baseVectorTileSourceId = "microsoft.base";
16217
16641
  /*
16218
16642
  * Show details based on zoom level.
16219
16643
  *
@@ -16236,7 +16660,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16236
16660
  * Vector Tile source layers: https://developer.tomtom.com/maps-api/maps-api-documentation-vector/tile
16237
16661
  */
16238
16662
  // Configuration for label extraction.
16239
- this._lableConfig = [
16663
+ this._labelConfig = [
16240
16664
  // Water labels
16241
16665
  {
16242
16666
  source: ["Ocean label", "Ocean name"],
@@ -16370,10 +16794,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16370
16794
  polygonSources: ["Reservation"]
16371
16795
  }
16372
16796
  ];
16373
- // Name of all polygon layers in which we want to do an intersection test with.
16374
- this._polygonStyleLayer = ["National or state park", "National park", "Reservation", "Airport",
16375
- "Runway", "Stadium", "University", "Zoo", "Shopping", "Hospital", "Amusement park", "Ocean", "Sea",
16376
- "Ocean or sea"];
16377
16797
  // Name of all label types to cache.
16378
16798
  this._labelCache = new Set(["city", "state", "country", "water", "majorPoi"]);
16379
16799
  // Name of all road source layers.
@@ -16414,9 +16834,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16414
16834
  // Flag indicating if detailed descriptions which include zoom, lat/lon information should be returned.
16415
16835
  this._returnDetailedDescriptions = false;
16416
16836
  /** Event handler for shortcuts. */
16417
- this._shortcutListener = function (e) { return __awaiter$1(_this, void 0, void 0, function () {
16837
+ this._shortcutListener = function (e) { return __awaiter$2(_this, void 0, void 0, function () {
16418
16838
  var cam, styleOps, lang, style, camDesc;
16419
- return __generator$1(this, function (_a) {
16839
+ return __generator$2(this, function (_a) {
16420
16840
  switch (_a.label) {
16421
16841
  case 0:
16422
16842
  if (!(e.altKey && e.ctrlKey && e.keyCode === 68)) return [3 /*break*/, 2];
@@ -16484,9 +16904,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16484
16904
  /** Event handler for when the mouse or touch goes down */
16485
16905
  this._onPointerDown = function (event) {
16486
16906
  _this._lastPointerPos = _this._getEventPos(event);
16487
- _this._pointerTimeout = setTimeout(function () { return __awaiter$1(_this, void 0, void 0, function () {
16907
+ _this._pointerTimeout = setTimeout(function () { return __awaiter$2(_this, void 0, void 0, function () {
16488
16908
  var styleOps, lang, style, cam, loc;
16489
- return __generator$1(this, function (_a) {
16909
+ return __generator$2(this, function (_a) {
16490
16910
  switch (_a.label) {
16491
16911
  case 0:
16492
16912
  styleOps = this._map.getStyle();
@@ -16544,9 +16964,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16544
16964
  delete _this._rotateTimeout;
16545
16965
  };
16546
16966
  /** Called when the map has finished changing styles and is ready to create a new description */
16547
- this._updateStyle = function () { return __awaiter$1(_this, void 0, void 0, function () {
16967
+ this._updateStyle = function () { return __awaiter$2(_this, void 0, void 0, function () {
16548
16968
  var cam, styleOps, lang, style, camDesc;
16549
- return __generator$1(this, function (_a) {
16969
+ return __generator$2(this, function (_a) {
16550
16970
  switch (_a.label) {
16551
16971
  case 0:
16552
16972
  cam = this._map.getCamera();
@@ -16598,9 +17018,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16598
17018
  delete _this._moveTimeout;
16599
17019
  }
16600
17020
  // Send the new description to the map.
16601
- _this._moveTimeout = setTimeout(function () { return __awaiter$1(_this, void 0, void 0, function () {
17021
+ _this._moveTimeout = setTimeout(function () { return __awaiter$2(_this, void 0, void 0, function () {
16602
17022
  var loc;
16603
- return __generator$1(this, function (_a) {
17023
+ return __generator$2(this, function (_a) {
16604
17024
  switch (_a.label) {
16605
17025
  case 0:
16606
17026
  // Clear the rotate timeout as the move description will cover rotation.
@@ -16635,6 +17055,20 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16635
17055
  this._map.events.addOnce("idle", function () {
16636
17056
  if (!_this._disposed) {
16637
17057
  _this._updateCam(true);
17058
+ // Find the id of the vector tile source being used.
17059
+ _this._baseVectorTileSourceId = MapViewDescriptor._baseVectorTileSourceIds.find(function (id) { return _this._map.sources.getById(id); });
17060
+ // Set the label config based on the vector tile source.
17061
+ if (_this._baseVectorTileSourceId === "bing-mvt") {
17062
+ _this._labelConfig = MapViewDescriptor._labelConfigBing;
17063
+ _this._roadLayers = MapViewDescriptor._roadLayersBing;
17064
+ }
17065
+ // Derive polygon layers from the label config.
17066
+ _this._polygonStyleLayer = _this._labelConfig.reduce(function (acc, cur) {
17067
+ if (cur.polygonSources) {
17068
+ acc.push.apply(acc, __spreadArray$3([], __read$7(cur.polygonSources)));
17069
+ }
17070
+ return acc;
17071
+ }, []);
16638
17072
  // Add event listeners directly to mapbox because we will be using custom event data.
16639
17073
  // We don't automatically forward all properties of a mapbox event, so the custom data would be lost.
16640
17074
  var baseMap = _this._map._getMap();
@@ -16691,7 +17125,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16691
17125
  };
16692
17126
  /** Checks if the location has changed enough to justify a new description */
16693
17127
  MapViewDescriptor.prototype._checkLocThreshold = function (newCenter, lastCenter) {
16694
- var _a = __read$6(this._map.positionsToPixels([lastCenter, newCenter]), 2), lastPixel = _a[0], newPixel = _a[1];
17128
+ var _a = __read$7(this._map.positionsToPixels([lastCenter, newCenter]), 2), lastPixel = _a[0], newPixel = _a[1];
16695
17129
  return Pixel.getDistance(lastPixel, newPixel) >= this._moveThreshold;
16696
17130
  };
16697
17131
  /** Checks if the heading has changed enough to justify a new description */
@@ -16716,10 +17150,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16716
17150
  * @param cam The map camera informaiton.
16717
17151
  */
16718
17152
  MapViewDescriptor.prototype._getLocDesc = function (cam, lang, style) {
16719
- return __awaiter$1(this, void 0, void 0, function () {
17153
+ return __awaiter$2(this, void 0, void 0, function () {
16720
17154
  var info_1, cPx_1, intersects_1, intersectingPolygon, intersectingType_1, i, cnt, layerInfo, cl_1;
16721
17155
  var _this = this;
16722
- return __generator$1(this, function (_a) {
17156
+ return __generator$2(this, function (_a) {
16723
17157
  switch (_a.label) {
16724
17158
  case 0:
16725
17159
  if (!(style !== "blank")) return [3 /*break*/, 3];
@@ -16732,8 +17166,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16732
17166
  info_1 = {};
16733
17167
  cPx_1 = this._map.positionsToPixels([cam.center])[0];
16734
17168
  ErrorHandler.tryCatch(this._map, function () {
16735
- intersects_1 = _this._map._getMap().queryRenderedFeatures(cPx_1, {
16736
- layers: _this._polygonStyleLayer,
17169
+ var map = _this._map._getMap();
17170
+ intersects_1 = map.queryRenderedFeatures(cPx_1, {
17171
+ layers: _this._polygonStyleLayer.filter(function (layerId) { return map.getLayer(layerId); }),
16737
17172
  filter: ["==", ["geometry-type"], "Polygon"]
16738
17173
  });
16739
17174
  }, function () { });
@@ -16743,8 +17178,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16743
17178
  }
16744
17179
  intersectingType_1 = null;
16745
17180
  // Loop through each label config and try and retireve details about the map view.
16746
- for (i = 0, cnt = this._lableConfig.length; i < cnt; i++) {
16747
- layerInfo = this._lableConfig[i];
17181
+ for (i = 0, cnt = this._labelConfig.length; i < cnt; i++) {
17182
+ layerInfo = this._labelConfig[i];
16748
17183
  if (cam.zoom >= layerInfo.minZoom) {
16749
17184
  // If the layer info has polygons defined, do an intersection test for matching.
16750
17185
  if (layerInfo.polygonSources) {
@@ -16844,7 +17279,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16844
17279
  // Loop through the label sources.
16845
17280
  for (var i = 0, len = layerInfo.source.length; i < len; i++) {
16846
17281
  var params = {
16847
- sourceLayer: layerInfo.source[i]
17282
+ sourceLayer: layerInfo.source[i],
17283
+ filter: ["has", "name"]
16848
17284
  };
16849
17285
  var labels = this._map._getMap().querySourceFeatures(this._baseVectorTileSourceId, params);
16850
17286
  var closest = null;
@@ -16921,21 +17357,22 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16921
17357
  }
16922
17358
  if (closestRoad) {
16923
17359
  // Capture state and country codes from the closest road to ensure we have the most accurate values.
16924
- if (!info.country) {
17360
+ // Note: bing tiles do not have country_code and country_subdivision in road features.
17361
+ if (!info.country && closestRoad.properties.country_code) {
16925
17362
  info.country = closestRoad.properties.country_code;
16926
17363
  info.countryDis = 0;
16927
17364
  MapViewDescriptor._labelCache.cache(info.country, {
16928
- source: ["Country name"],
17365
+ source: [],
16929
17366
  labelType: "country",
16930
17367
  radius: 5000,
16931
17368
  minZoom: 0
16932
17369
  }, cPoint.geometry.coordinates, lang);
16933
17370
  }
16934
- if (!info.state) {
17371
+ if (!info.state && closestRoad.properties.country_subdivision) {
16935
17372
  info.state = closestRoad.properties.country_subdivision;
16936
17373
  info.stateDis = 0;
16937
17374
  MapViewDescriptor._labelCache.cache(info.state, {
16938
- source: ["State name"],
17375
+ source: [],
16939
17376
  labelType: "state",
16940
17377
  radius: 5000,
16941
17378
  minZoom: 4
@@ -17190,7 +17627,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17190
17627
  if (a.country) {
17191
17628
  info.country = a.country;
17192
17629
  MapViewDescriptor._labelCache.cache(info.country, {
17193
- source: ["Country name"],
17630
+ source: [],
17194
17631
  labelType: "country",
17195
17632
  radius: 5000,
17196
17633
  minZoom: 0
@@ -17199,7 +17636,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17199
17636
  if (a.countrySubdivision) {
17200
17637
  info.state = a.countrySubdivision;
17201
17638
  MapViewDescriptor._labelCache.cache(info.state, {
17202
- source: ["State name"],
17639
+ source: [],
17203
17640
  labelType: "state",
17204
17641
  radius: 5000,
17205
17642
  minZoom: 4
@@ -17208,7 +17645,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17208
17645
  if (a.municipality) {
17209
17646
  info.city = a.municipality;
17210
17647
  MapViewDescriptor._labelCache.cache(info.state, {
17211
- source: ["Small city"],
17648
+ source: [],
17212
17649
  labelType: "city",
17213
17650
  radius: 1000,
17214
17651
  minZoom: 10
@@ -17241,6 +17678,118 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17241
17678
  if (increment === void 0) { increment = 1; }
17242
17679
  return Math.round(val / increment) * increment;
17243
17680
  };
17681
+ // Ids of vector tile sources for different style APIs.
17682
+ MapViewDescriptor._baseVectorTileSourceIds = ["microsoft.base", "vectorTiles", "bing-mvt"];
17683
+ // Configuration for label extraction of Bing tiles.
17684
+ MapViewDescriptor._labelConfigBing = [
17685
+ // Water labels
17686
+ {
17687
+ source: ["water_feature"],
17688
+ labelType: "water",
17689
+ minZoom: 0,
17690
+ radius: 3950000,
17691
+ polygonSources: ["generic_water_fill"]
17692
+ },
17693
+ {
17694
+ source: ["water_feature"],
17695
+ labelType: "water",
17696
+ minZoom: 3,
17697
+ radius: 1000000,
17698
+ polygonSources: ["generic_water_fill"]
17699
+ },
17700
+ // Country labels
17701
+ {
17702
+ source: ["country_region"],
17703
+ labelType: "country",
17704
+ minZoom: 0,
17705
+ maxZoom: 5,
17706
+ radius: 300000
17707
+ },
17708
+ // State labels
17709
+ {
17710
+ source: ["admin_division1"],
17711
+ labelType: "state",
17712
+ minZoom: 4,
17713
+ maxZoom: 7,
17714
+ radius: 300000
17715
+ },
17716
+ // City labels
17717
+ {
17718
+ source: ["populated_place"],
17719
+ labelType: "city",
17720
+ minZoom: 8,
17721
+ radius: 40000
17722
+ },
17723
+ // Neighbourhood labels
17724
+ {
17725
+ source: ["neighborhood"],
17726
+ labelType: "neighbourhood",
17727
+ minZoom: 12,
17728
+ radius: 6000
17729
+ },
17730
+ // POI labels
17731
+ {
17732
+ source: ["amusement_park"],
17733
+ labelType: "poi",
17734
+ minZoom: 14,
17735
+ radius: 2000,
17736
+ polygonSources: ["amusement_park_fill"]
17737
+ },
17738
+ {
17739
+ source: ["hospital"],
17740
+ labelType: "poi",
17741
+ minZoom: 14,
17742
+ radius: 1000,
17743
+ polygonSources: ["hospital_fill"]
17744
+ },
17745
+ {
17746
+ source: ["shopping_center"],
17747
+ labelType: "poi",
17748
+ minZoom: 14,
17749
+ radius: 1000,
17750
+ polygonSources: ["shopping_center_fill"]
17751
+ },
17752
+ {
17753
+ source: ["stadium"],
17754
+ labelType: "poi",
17755
+ minZoom: 14,
17756
+ radius: 1000,
17757
+ polygonSources: ["stadium_fill"]
17758
+ },
17759
+ {
17760
+ source: ["higher_education_facility", "school"],
17761
+ labelType: "poi",
17762
+ minZoom: 14,
17763
+ radius: 1000,
17764
+ polygonSources: ["higher_education_facility_fill", "school_fill"]
17765
+ },
17766
+ {
17767
+ source: ["zoo"],
17768
+ labelType: "poi",
17769
+ minZoom: 14,
17770
+ radius: 1000,
17771
+ polygonSources: ["zoo_fill"]
17772
+ },
17773
+ // Major Poi labels
17774
+ {
17775
+ source: ["airport", "airport_terminal"],
17776
+ labelType: "majorPoi",
17777
+ minZoom: 11,
17778
+ radius: 3000,
17779
+ polygonSources: ["airport_terminal_fill", "airport_fill-merged7", "airport_runway_fill"]
17780
+ },
17781
+ {
17782
+ source: ["reserve"],
17783
+ labelType: "majorPoi",
17784
+ minZoom: 7,
17785
+ radius: 15000,
17786
+ polygonSources: ["generic_reserve_fill", "land_cover_forest_fill"]
17787
+ }
17788
+ ];
17789
+ // Name of all road source layers of Bing tiles.
17790
+ MapViewDescriptor._roadLayersBing = new Set([
17791
+ "road"
17792
+ ]);
17244
17793
  return MapViewDescriptor;
17245
17794
  }());
17246
17795
 
@@ -17388,14 +17937,17 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17388
17937
  var trafficOptions = _this.map.getTraffic();
17389
17938
  if (trafficOptions.flow !== "none") {
17390
17939
  var trafficFlowComponent = _this.map.layers.getLayerById("traffic_" + trafficOptions.flow);
17940
+ if (!trafficFlowComponent && ['absolute', 'relative-delay'].includes(trafficOptions.flow)) {
17941
+ // Fallback to relative if deprecated flow type is used
17942
+ trafficFlowComponent = _this.map.layers.getLayerById("traffic_relative");
17943
+ }
17391
17944
  if (trafficFlowComponent) {
17392
- _this.lastFlowMode = trafficOptions.flow;
17945
+ _this.lastFlowMode = trafficFlowComponent.getId().replace("traffic_", "");
17393
17946
  trafficFlowComponent._updateLayoutProperty("visibility", "visible", "none");
17394
17947
  }
17395
17948
  }
17396
17949
  };
17397
17950
  this.removeFromMap = function () {
17398
- var trafficOptions = _this.map.getTraffic();
17399
17951
  if (_this.lastFlowMode != "none") {
17400
17952
  var trafficFlowComponent = _this.map.layers.getLayerById("traffic_" + _this.lastFlowMode);
17401
17953
  if (trafficFlowComponent) {
@@ -17648,7 +18200,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17648
18200
  return IncidentPopupFactory;
17649
18201
  }());
17650
18202
 
17651
- var __awaiter$2 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
18203
+ var __awaiter$3 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
17652
18204
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17653
18205
  return new (P || (P = Promise))(function (resolve, reject) {
17654
18206
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -17657,7 +18209,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17657
18209
  step((generator = generator.apply(thisArg, _arguments || [])).next());
17658
18210
  });
17659
18211
  };
17660
- var __generator$2 = (window && window.__generator) || function (thisArg, body) {
18212
+ var __generator$3 = (window && window.__generator) || function (thisArg, body) {
17661
18213
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17662
18214
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
17663
18215
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -17711,10 +18263,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
17711
18263
  _this.map.events.add('moveend', _this.setAccessiblePopups);
17712
18264
  };
17713
18265
  this.accessiblePopups = [];
17714
- this.setAccessiblePopups = function () { return __awaiter$2(_this, void 0, void 0, function () {
18266
+ this.setAccessiblePopups = function () { return __awaiter$3(_this, void 0, void 0, function () {
17715
18267
  var features, localizedStrings, createPopup, insertHiddenBefore, insertHiddenInFront, addHidden;
17716
18268
  var _this = this;
17717
- return __generator$2(this, function (_a) {
18269
+ return __generator$3(this, function (_a) {
17718
18270
  switch (_a.label) {
17719
18271
  case 0:
17720
18272
  this.accessiblePopups.forEach(function (popup) { return popup.remove(); });
@@ -20982,7 +21534,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
20982
21534
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
20983
21535
  return c > 3 && r && Object.defineProperty(target, key, r), r;
20984
21536
  };
20985
- var __read$7 = (window && window.__read) || function (o, n) {
21537
+ var __read$8 = (window && window.__read) || function (o, n) {
20986
21538
  var m = typeof Symbol === "function" && o[Symbol.iterator];
20987
21539
  if (!m) return o;
20988
21540
  var i = m.call(o), r, ar = [], e;
@@ -20998,7 +21550,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
20998
21550
  }
20999
21551
  return ar;
21000
21552
  };
21001
- var __spreadArray$2 = (window && window.__spreadArray) || function (to, from) {
21553
+ var __spreadArray$4 = (window && window.__spreadArray) || function (to, from) {
21002
21554
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
21003
21555
  to[j] = from[i];
21004
21556
  return to;
@@ -21016,9 +21568,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21016
21568
  'data-azure-maps-attribution-order',
21017
21569
  'data-azure-maps-attribution-dynamic'
21018
21570
  ];
21019
- var allowedAttributionAttributes = __spreadArray$2([
21571
+ var allowedAttributionAttributes = __spreadArray$4([
21020
21572
  'href'
21021
- ], __read$7(attributionRuleAttributes));
21573
+ ], __read$8(attributionRuleAttributes));
21022
21574
  var AttributionRuleProxy = /** @class */ (function () {
21023
21575
  function AttributionRuleProxy(element, attributionChangeCallback) {
21024
21576
  var _this = this;
@@ -21241,7 +21793,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21241
21793
  };
21242
21794
  AttributionRuleProxy.prototype.applyAttributionResponse = function (attributions) {
21243
21795
  var _this = this;
21244
- var copyrights = attributions.map(function (resp) { return resp.copyrights || []; }).reduce(function (flat, copyrights) { return __spreadArray$2(__spreadArray$2([], __read$7(flat)), __read$7(copyrights)); }, []);
21796
+ var copyrights = attributions.map(function (resp) { return resp.copyrights || []; }).reduce(function (flat, copyrights) { return __spreadArray$4(__spreadArray$4([], __read$8(flat)), __read$8(copyrights)); }, []);
21245
21797
  if (copyrights.length == 0) {
21246
21798
  // no attribution for a provided tileset/bbox/z
21247
21799
  return;
@@ -21290,7 +21842,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21290
21842
  return AttributionRuleProxy;
21291
21843
  }());
21292
21844
 
21293
- var __read$8 = (window && window.__read) || function (o, n) {
21845
+ var __read$9 = (window && window.__read) || function (o, n) {
21294
21846
  var m = typeof Symbol === "function" && o[Symbol.iterator];
21295
21847
  if (!m) return o;
21296
21848
  var i = m.call(o), r, ar = [], e;
@@ -21306,7 +21858,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21306
21858
  }
21307
21859
  return ar;
21308
21860
  };
21309
- var __spreadArray$3 = (window && window.__spreadArray) || function (to, from) {
21861
+ var __spreadArray$5 = (window && window.__spreadArray) || function (to, from) {
21310
21862
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
21311
21863
  to[j] = from[i];
21312
21864
  return to;
@@ -21344,7 +21896,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21344
21896
  var style = map.getStyle();
21345
21897
  return Object.entries(style.sources)
21346
21898
  .filter(function (_a) {
21347
- var _b = __read$8(_a, 1), key = _b[0];
21899
+ var _b = __read$9(_a, 1), key = _b[0];
21348
21900
  return style.layers
21349
21901
  .filter(function (layer) { return layer && layer['source'] == key; })
21350
21902
  .reduce(function (isVisible, layer) {
@@ -21352,7 +21904,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21352
21904
  return !isLayerHidden || isVisible;
21353
21905
  }, false);
21354
21906
  }).map(function (_a) {
21355
- var _b = __read$8(_a, 1), key = _b[0];
21907
+ var _b = __read$9(_a, 1), key = _b[0];
21356
21908
  return map.getSource(key);
21357
21909
  });
21358
21910
  };
@@ -21363,8 +21915,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21363
21915
  resolve(source);
21364
21916
  }
21365
21917
  else {
21366
- // force source loading as same resolved source in different style will get cached and won't emit events
21367
- source.load();
21368
21918
  source.on('data', function sourceDataListener(event) {
21369
21919
  if (event.sourceDataType == 'metadata') {
21370
21920
  source.off('data', sourceDataListener);
@@ -21427,10 +21977,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21427
21977
  }, function () { return document.createElement('span'); });
21428
21978
  });
21429
21979
  var registeredRuleSet = new Set(Object.values(registeredRules));
21430
- var redundantRules = new Set(__spreadArray$3([], __read$8(allRules)).filter(function (rule) { return !registeredRuleSet.has(rule); }));
21431
- var redundantElements = new Set(__spreadArray$3([], __read$8(redundantRules)).map(function (rule) { return rule.getElement(); }));
21980
+ var redundantRules = new Set(__spreadArray$5([], __read$9(allRules)).filter(function (rule) { return !registeredRuleSet.has(rule); }));
21981
+ var redundantElements = new Set(__spreadArray$5([], __read$9(redundantRules)).map(function (rule) { return rule.getElement(); }));
21432
21982
  // eject redundant rules associated elements altogether
21433
- __spreadArray$3([], __read$8(redundantElements)).filter(function (elem) { return elem.parentElement !== null; })
21983
+ __spreadArray$5([], __read$9(redundantElements)).filter(function (elem) { return elem.parentElement !== null; })
21434
21984
  .forEach(function (elem) { return elem.parentElement.removeChild(elem); });
21435
21985
  _this.rules = Object.values(registeredRules);
21436
21986
  var attributionsToApply = attributions
@@ -21466,7 +22016,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21466
22016
  var visibleTextNodes = function (elem) {
21467
22017
  return Array.from(elem.style.display != 'none' ? elem.children : [])
21468
22018
  .map(function (elem) { return visibleTextNodes(elem); })
21469
- .reduce(function (flattened, nodes) { return __spreadArray$3(__spreadArray$3([], __read$8(flattened)), __read$8(nodes)); }, Array.from(elem.style.display != 'none' ? elem.childNodes : []).filter(function (node) { return node.nodeType == node.TEXT_NODE; }));
22019
+ .reduce(function (flattened, nodes) { return __spreadArray$5(__spreadArray$5([], __read$9(flattened)), __read$9(nodes)); }, Array.from(elem.style.display != 'none' ? elem.childNodes : []).filter(function (node) { return node.nodeType == node.TEXT_NODE; }));
21470
22020
  };
21471
22021
  var newRenderContext = _this.virtualContext.cloneNode(true);
21472
22022
  var visibleNodes = visibleTextNodes(newRenderContext);
@@ -21481,7 +22031,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21481
22031
  // }
21482
22032
  // });
21483
22033
  // strip all predefined keywords
21484
- visibleNodes.forEach(function (node) { return node.textContent = __spreadArray$3([], __read$8(attributionFilters)).reduce(function (target, filter) { return target.replace(filter, '').trim(); }, node.textContent); });
22034
+ visibleNodes.forEach(function (node) { return node.textContent = __spreadArray$5([], __read$9(attributionFilters)).reduce(function (target, filter) { return target.replace(filter, '').trim(); }, node.textContent); });
21485
22035
  // strip year from each node
21486
22036
  // visibleNodes.forEach(node => node.textContent = node.textContent.replace(copyrightYearPattern, '').trim());
21487
22037
  // deduplicate attribution text
@@ -23707,6 +24257,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23707
24257
  }
23708
24258
  return this.initPromise;
23709
24259
  };
24260
+ /**
24261
+ * Cleans up any resources used by the authentication manager.
24262
+ */
24263
+ AuthenticationManager.prototype.dispose = function () {
24264
+ if (this.tokenTimeOutHandle) {
24265
+ clearTimeout(this.tokenTimeOutHandle);
24266
+ this.tokenTimeOutHandle = null;
24267
+ }
24268
+ };
23710
24269
  /**
23711
24270
  * Gets the default auth context to be shared between maps without one specified to them.
23712
24271
  */
@@ -24437,7 +24996,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24437
24996
  };
24438
24997
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
24439
24998
  };
24440
- var __read$9 = (window && window.__read) || function (o, n) {
24999
+ var __read$a = (window && window.__read) || function (o, n) {
24441
25000
  var m = typeof Symbol === "function" && o[Symbol.iterator];
24442
25001
  if (!m) return o;
24443
25002
  var i = m.call(o), r, ar = [], e;
@@ -24635,7 +25194,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24635
25194
  var callbacks = new Dictionary(this.mapCallbackHandler.getEventCallbacks(eventType, layer));
24636
25195
  if (callbacks) {
24637
25196
  callbacks.forEach(function (_a, callback) {
24638
- var _b = __read$9(_a, 2), _ = _b[0], once = _b[1];
25197
+ var _b = __read$a(_a, 2), _ = _b[0], once = _b[1];
24639
25198
  // Invoking a listener this way circumvents the fire once logic in the modified callback.
24640
25199
  // So we check if the callback was added as a fire once and if so remove it here.
24641
25200
  if (once) {
@@ -24664,7 +25223,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24664
25223
  this._removeListener(eventType, target, callback);
24665
25224
  }
24666
25225
  else {
24667
- target._removeEventListener(eventType, callback);
25226
+ target === null || target === void 0 ? void 0 : target._removeEventListener(eventType, callback);
24668
25227
  }
24669
25228
  }
24670
25229
  }
@@ -24743,7 +25302,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24743
25302
  eventDict.forEach(function (callbackDict, eventType) {
24744
25303
  callbackDict.forEach(function (_a) {
24745
25304
  var e_6, _b;
24746
- var _c = __read$9(_a, 1), modifiedCallback = _c[0];
25305
+ var _c = __read$a(_a, 1), modifiedCallback = _c[0];
24747
25306
  try {
24748
25307
  for (var _d = __values$a(layer._getLayerIds()), _e = _d.next(); !_e.done; _e = _d.next()) {
24749
25308
  var mbLayerId = _e.value;
@@ -24776,7 +25335,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24776
25335
  eventDict.forEach(function (callbackDict, eventType) {
24777
25336
  callbackDict.forEach(function (_a) {
24778
25337
  var e_7, _b;
24779
- var _c = __read$9(_a, 1), modifiedCallback = _c[0];
25338
+ var _c = __read$a(_a, 1), modifiedCallback = _c[0];
24780
25339
  try {
24781
25340
  for (var _d = __values$a(layer._getLayerIds()), _e = _d.next(); !_e.done; _e = _d.next()) {
24782
25341
  var mbLayerId = _e.value;
@@ -25154,10 +25713,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25154
25713
  return ids;
25155
25714
  };
25156
25715
  FundamentalMapLayer.prototype._updateLayoutProperty = function (name, newValue, oldValue, subValue) {
25157
- var _this = this;
25716
+ if (isEqual_1(newValue, oldValue))
25717
+ return;
25718
+ var map = this.map._getMap();
25158
25719
  this.layers.forEach(function (layer) {
25159
- if (!(isEqual_1(newValue, oldValue))) {
25160
- _this.map._getMap().setLayoutProperty(layer.id, name, subValue || newValue);
25720
+ if (map.getLayer(layer.id)) {
25721
+ map.setLayoutProperty(layer.id, name, subValue || newValue);
25722
+ }
25723
+ else {
25724
+ console.warn("Could not update layout property " + name + " for layer " + layer.id + " to " + (subValue || newValue));
25161
25725
  }
25162
25726
  });
25163
25727
  };
@@ -25175,7 +25739,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25175
25739
  };
25176
25740
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
25177
25741
  };
25178
- var __read$a = (window && window.__read) || function (o, n) {
25742
+ var __read$b = (window && window.__read) || function (o, n) {
25179
25743
  var m = typeof Symbol === "function" && o[Symbol.iterator];
25180
25744
  if (!m) return o;
25181
25745
  var i = m.call(o), r, ar = [], e;
@@ -25191,7 +25755,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25191
25755
  }
25192
25756
  return ar;
25193
25757
  };
25194
- var __spreadArray$4 = (window && window.__spreadArray) || function (to, from) {
25758
+ var __spreadArray$6 = (window && window.__spreadArray) || function (to, from) {
25195
25759
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
25196
25760
  to[j] = from[i];
25197
25761
  return to;
@@ -25252,10 +25816,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25252
25816
  // Place the new layer behind the specified before layer.
25253
25817
  var layerIndex = this.layerIndex.findIndex(function (l) { return l.getId() === layer.getId(); });
25254
25818
  var userLayerIndex = this.userLayers.findIndex(function (ul) { return ul.layer.getId() === layer.getId(); });
25255
- var tempLayer = this.layerIndex[layerIndex];
25256
25819
  this._removeMapboxLayers(layer);
25257
25820
  this._addMapboxLayers(layer, before);
25258
- this.map.events._disableLayerEvents(tempLayer);
25821
+ var tempLayer = this.layerIndex[layerIndex];
25822
+ if (tempLayer) {
25823
+ this.map.events._disableLayerEvents(tempLayer);
25824
+ }
25259
25825
  this.map.events._enableLayerEvents(layer);
25260
25826
  this.layerIndex.splice(layerIndex, 1);
25261
25827
  var beforeIndex = this.layerIndex.findIndex(function (l) { return l.getId() === before; });
@@ -25263,7 +25829,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25263
25829
  if (!(layer instanceof FundamentalMapLayer)) {
25264
25830
  this.userLayers[userLayerIndex] = { layer: layer, before: before };
25265
25831
  }
25266
- tempLayer.onRemove();
25832
+ if (tempLayer) {
25833
+ tempLayer.onRemove();
25834
+ }
25267
25835
  layer.onAdd(this.map);
25268
25836
  }
25269
25837
  else {
@@ -25474,9 +26042,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25474
26042
  LayerManager.prototype.clear = function () {
25475
26043
  for (var layerIndexIndex = this.layerIndex.length - 1; layerIndexIndex >= 0; layerIndexIndex--) {
25476
26044
  var tempLayer = this.layerIndex[layerIndexIndex];
25477
- this._removeMapboxLayers(tempLayer, true);
25478
- this.layerIndex.splice(layerIndexIndex, 1);
25479
- tempLayer.onRemove();
26045
+ if (tempLayer) {
26046
+ this._removeMapboxLayers(tempLayer, true);
26047
+ this.layerIndex.splice(layerIndexIndex, 1);
26048
+ tempLayer.onRemove();
26049
+ }
25480
26050
  }
25481
26051
  this.userLayers = [];
25482
26052
  };
@@ -25627,7 +26197,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25627
26197
  // If a specified layer hasn't been added to the map throw an error.
25628
26198
  var index = this_1.layerIndex.findIndex(function (l) { return l.getId() === layerId; });
25629
26199
  if (index > -1) {
25630
- layerIds.push.apply(layerIds, __spreadArray$4([], __read$a(this_1.layerIndex[index]._getLayerIds()
26200
+ layerIds.push.apply(layerIds, __spreadArray$6([], __read$b(this_1.layerIndex[index]._getLayerIds()
25631
26201
  .filter(function (id) { return !!_this.map._getMap().getLayer(id); }))));
25632
26202
  }
25633
26203
  else {
@@ -25916,6 +26486,37 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25916
26486
  FundamentalMapSource.prototype._buildSource = function () {
25917
26487
  return this.source;
25918
26488
  };
26489
+ /**
26490
+ * @internal
26491
+ */
26492
+ FundamentalMapSource.prototype._isDeepEqual = function (other) {
26493
+ if (this.constructor !== other.constructor) {
26494
+ return false;
26495
+ }
26496
+ var source = this.source;
26497
+ var otherSource = other.source;
26498
+ var baseEqual = source.type === otherSource.type &&
26499
+ source.url === otherSource.url
26500
+ && ((source.tiles === undefined && otherSource.tiles === undefined) ||
26501
+ (source.tiles && otherSource.tiles && source.tiles.length === otherSource.tiles.length && source.tiles.every(function (value, idx) { return value === otherSource.tiles[idx]; })))
26502
+ && source.minzoom === otherSource.minzoom
26503
+ && source.maxzoom === otherSource.maxzoom
26504
+ && source.bounds === otherSource.bounds
26505
+ && source.attribution === otherSource.attribution;
26506
+ var rasterEqual = source.type !== "raster" || (source.type === "raster"
26507
+ && source.type === otherSource.type
26508
+ && source.tileSize === otherSource.tileSize
26509
+ && source.scheme === otherSource.scheme);
26510
+ var rasterDemEqual = source.type !== "raster-dem" || (source.type === "raster-dem"
26511
+ && source.type === otherSource.type
26512
+ && source.tileSize === otherSource.tileSize
26513
+ && source.encoding === otherSource.encoding);
26514
+ var vectorEqual = source.type !== "vector" || (source.type === "vector"
26515
+ && source.type === otherSource.type
26516
+ && source.promoteId === otherSource.promoteId
26517
+ && source.scheme === otherSource.scheme);
26518
+ return baseEqual && rasterEqual && rasterDemEqual && vectorEqual;
26519
+ };
25919
26520
  /**
25920
26521
  * Updates the source info to convert the tiles to url strings.
25921
26522
  * @param sourceDef The original source info.
@@ -26212,39 +26813,52 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26212
26813
  var _this = this;
26213
26814
  if (sources) {
26214
26815
  Object.keys(sources).forEach(function (sourceId) {
26816
+ var sourceToAdd = sources[sourceId];
26817
+ var newSource;
26818
+ if (sourceToAdd.type === "vector") {
26819
+ newSource = new FundamentalMapSource(sourceId, {
26820
+ name: sourceId,
26821
+ tiles: sourceToAdd.tiles,
26822
+ type: "vector",
26823
+ url: sourceToAdd.url
26824
+ });
26825
+ }
26826
+ else if (sourceToAdd.type === "raster") {
26827
+ newSource = new FundamentalMapSource(sourceId, {
26828
+ name: sourceId,
26829
+ tiles: sourceToAdd.tiles,
26830
+ type: "raster",
26831
+ url: sourceToAdd.url
26832
+ });
26833
+ }
26834
+ else {
26835
+ // Do not throw for the source of unknown type.
26836
+ // throw new Error(`Unable to construct source with ID ${sourceId}.`);
26837
+ // no other handling for the source we don't sync into the state here
26838
+ return;
26839
+ }
26215
26840
  if (!_this.sources.has(sourceId)) {
26216
- var sourceToAdd = sources[sourceId];
26217
- if (sourceToAdd.type === "vector") {
26218
- var newSource = new FundamentalMapSource(sourceId, {
26219
- name: sourceId,
26220
- tiles: sourceToAdd.tiles,
26221
- type: "vector",
26222
- url: sourceToAdd.url
26223
- });
26224
- _this.sources.set(sourceId, newSource);
26225
- newSource._setMap(_this.map);
26226
- }
26227
- else if (sourceToAdd.type === "raster") {
26228
- var newSource = new FundamentalMapSource(sourceId, {
26229
- name: sourceId,
26230
- tiles: sourceToAdd.tiles,
26231
- type: "raster",
26232
- url: sourceToAdd.url
26233
- });
26234
- _this.sources.set(sourceId, newSource);
26235
- newSource._setMap(_this.map);
26236
- }
26237
- else {
26238
- throw new Error("Unable to construct source with ID " + sourceId + ".");
26239
- }
26841
+ _this.sources.set(sourceId, newSource);
26842
+ newSource._setMap(_this.map);
26240
26843
  }
26241
- });
26242
- Object.keys(this.sources).forEach(function (sourceId) {
26243
- if (!sources.hasOwnProperty(sourceId)) {
26244
- _this.sources.get(sourceId)._setMap(null);
26245
- _this.sources.delete(sourceId);
26844
+ else if (_this.sources.has(sourceId) && !_this.sources.get(sourceId)._isDeepEqual(newSource)) {
26845
+ // source with same id but different properties: update
26846
+ _this.sources.set(sourceId, newSource);
26847
+ newSource._setMap(_this.map, false);
26246
26848
  }
26247
26849
  });
26850
+ // counter-intuitive: below is a bug and will do nothing since Object.keys(this.sources) will always return [], it should rather be:
26851
+ // Array.from(this.sources.keys()).forEach(sourceId => {
26852
+ // however, we have seen the first party users are compensating for this with their code containing explicit azm.sources.remove but not containing the check for existing
26853
+ // such removal will cause the exception, since the source would already be removed
26854
+ //
26855
+ // given this bug was here historically, we keep the removal unfixed here (already fixed in v3) to make sure we don't cause any unintented side effects for existing users
26856
+ // Object.keys(this.sources).forEach(sourceId => {
26857
+ // if (!sources.hasOwnProperty(sourceId)) {
26858
+ // this.sources.get(sourceId)._setMap(null);
26859
+ // this.sources.delete(sourceId);
26860
+ // }
26861
+ // });
26248
26862
  }
26249
26863
  };
26250
26864
  return SourceManager;
@@ -26370,7 +26984,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26370
26984
  };
26371
26985
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
26372
26986
  };
26373
- var __read$b = (window && window.__read) || function (o, n) {
26987
+ var __read$c = (window && window.__read) || function (o, n) {
26374
26988
  var m = typeof Symbol === "function" && o[Symbol.iterator];
26375
26989
  if (!m) return o;
26376
26990
  var i = m.call(o), r, ar = [], e;
@@ -26386,7 +27000,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26386
27000
  }
26387
27001
  return ar;
26388
27002
  };
26389
- var __spreadArray$5 = (window && window.__spreadArray) || function (to, from) {
27003
+ var __spreadArray$7 = (window && window.__spreadArray) || function (to, from) {
26390
27004
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
26391
27005
  to[j] = from[i];
26392
27006
  return to;
@@ -26461,7 +27075,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26461
27075
  }
26462
27076
  finally { if (e_1) throw e_1.error; }
26463
27077
  }
26464
- return _super.prototype.merge.apply(this, __spreadArray$5([], __read$b(valuesList)));
27078
+ return _super.prototype.merge.apply(this, __spreadArray$7([], __read$c(valuesList)));
26465
27079
  };
26466
27080
  return CameraBoundsOptions;
26467
27081
  }(Options));
@@ -26934,7 +27548,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26934
27548
  };
26935
27549
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
26936
27550
  };
26937
- var __read$c = (window && window.__read) || function (o, n) {
27551
+ var __read$d = (window && window.__read) || function (o, n) {
26938
27552
  var m = typeof Symbol === "function" && o[Symbol.iterator];
26939
27553
  if (!m) return o;
26940
27554
  var i = m.call(o), r, ar = [], e;
@@ -26950,7 +27564,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26950
27564
  }
26951
27565
  return ar;
26952
27566
  };
26953
- var __spreadArray$6 = (window && window.__spreadArray) || function (to, from) {
27567
+ var __spreadArray$8 = (window && window.__spreadArray) || function (to, from) {
26954
27568
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
26955
27569
  to[j] = from[i];
26956
27570
  return to;
@@ -27061,7 +27675,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27061
27675
  /**
27062
27676
  * Specifies which set of geopolitically disputed borders and labels are displayed on the map. The View parameter (also referred to as “user region parameter”) is a 2-letter ISO-3166 Country Code that will show the correct maps for that country/region. Country/Regions that are not on the View list or if unspecified will default to the “Unified” View.
27063
27677
  * Please see the supported [Views]{@link https://aka.ms/AzureMapsLocalizationViews}
27064
- * It is your responsibility to determine the location of your users, and then set the View parameter correctly for that location. The View parameter in Azure Maps must be used in compliance with applicable laws, including those regarding mapping, of the country where maps, images and other data and third party content that You are authorized to access via Azure Maps is made available.
27678
+ * It is your responsibility to determine the location of your users, and then set the View parameter correctly for that location. The View parameter in Azure Maps must be used in compliance with applicable laws, including those regarding mapping, of the country/region where maps, images and other data and third party content that You are authorized to access via Azure Maps is made available.
27065
27679
  * default: `undefined`
27066
27680
  * @default undefined
27067
27681
  */
@@ -27070,6 +27684,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27070
27684
  * @deprecated use `view` instead.
27071
27685
  */
27072
27686
  _this.userRegion = _this.view;
27687
+ /**
27688
+ * allows substituting a default MapControl's style transformer with custom one
27689
+ * Default style transformer is meant to update the incoming fetched style to desired state, as well as to synchronize the SDK state with style state
27690
+ * and move additional layers over
27691
+ * @internal
27692
+ */
27693
+ _this.customStyleTransform = undefined;
27073
27694
  return _this;
27074
27695
  }
27075
27696
  /**
@@ -27109,7 +27730,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27109
27730
  finally { if (e_1) throw e_1.error; }
27110
27731
  }
27111
27732
  // Then execute the standard merge behavior.
27112
- return _super.prototype.merge.apply(this, __spreadArray$6([], __read$c(valueList)));
27733
+ return _super.prototype.merge.apply(this, __spreadArray$8([], __read$d(valueList)));
27113
27734
  };
27114
27735
  return StyleOptions;
27115
27736
  }(Options));
@@ -27151,7 +27772,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27151
27772
  };
27152
27773
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
27153
27774
  };
27154
- var __read$d = (window && window.__read) || function (o, n) {
27775
+ var __read$e = (window && window.__read) || function (o, n) {
27155
27776
  var m = typeof Symbol === "function" && o[Symbol.iterator];
27156
27777
  if (!m) return o;
27157
27778
  var i = m.call(o), r, ar = [], e;
@@ -27167,7 +27788,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27167
27788
  }
27168
27789
  return ar;
27169
27790
  };
27170
- var __spreadArray$7 = (window && window.__spreadArray) || function (to, from) {
27791
+ var __spreadArray$9 = (window && window.__spreadArray) || function (to, from) {
27171
27792
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
27172
27793
  to[j] = from[i];
27173
27794
  return to;
@@ -27402,10 +28023,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27402
28023
  // won't change default behavior in Options as usually that's what desired
27403
28024
  // instead capture it here and reassign.
27404
28025
  var currentTransforms = this._transformers;
27405
- var transformersToMerge = valueList ? valueList.filter(function (value) { return value !== undefined; }).reduce(function (flattened, value) { return __spreadArray$7(__spreadArray$7([], __read$d(flattened)), __read$d(value._transformers || [])); }, []) : [];
28026
+ var transformersToMerge = valueList ? valueList.filter(function (value) { return value !== undefined; }).reduce(function (flattened, value) { return __spreadArray$9(__spreadArray$9([], __read$e(flattened)), __read$e(value._transformers || [])); }, []) : [];
27406
28027
  // Then execute the standard merge behavior.
27407
28028
  // If subscription key auth method isn't being used then the subscription key property should be undefined.
27408
- var merged = _super.prototype.merge.apply(this, __spreadArray$7([], __read$d(valueList)));
28029
+ var merged = _super.prototype.merge.apply(this, __spreadArray$9([], __read$e(valueList)));
27409
28030
  if (merged.authOptions.authType !== exports.AuthenticationType.subscriptionKey) {
27410
28031
  merged["subscription-key"] = merged.subscriptionKey = undefined;
27411
28032
  }
@@ -27417,7 +28038,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27417
28038
  if (merged.mapConfiguration && typeof merged.mapConfiguration !== 'string') {
27418
28039
  merged.mapConfiguration = __assign$7(__assign$7({}, merged.mapConfiguration), { defaultConfiguration: merged.mapConfiguration.defaultConfiguration || merged.mapConfiguration['defaultStyle'], configurations: merged.mapConfiguration.configurations || merged.mapConfiguration['styles'] });
27419
28040
  }
27420
- this._transformers = __spreadArray$7(__spreadArray$7([], __read$d(currentTransforms || [])), __read$d(transformersToMerge.filter(function (toMerge) { return !currentTransforms.includes(toMerge); })));
28041
+ this._transformers = __spreadArray$9(__spreadArray$9([], __read$e(currentTransforms || [])), __read$e(transformersToMerge.filter(function (toMerge) { return !currentTransforms.includes(toMerge); })));
27421
28042
  if (this.transformRequest && !this._transformers.includes(this.transformRequest)) {
27422
28043
  this._transformers.push(this.transformRequest);
27423
28044
  }
@@ -27613,7 +28234,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27613
28234
  };
27614
28235
  return __assign$8.apply(this, arguments);
27615
28236
  };
27616
- var __awaiter$3 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
28237
+ var __awaiter$4 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
27617
28238
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27618
28239
  return new (P || (P = Promise))(function (resolve, reject) {
27619
28240
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -27622,7 +28243,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27622
28243
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27623
28244
  });
27624
28245
  };
27625
- var __generator$3 = (window && window.__generator) || function (thisArg, body) {
28246
+ var __generator$4 = (window && window.__generator) || function (thisArg, body) {
27626
28247
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27627
28248
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27628
28249
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -27649,7 +28270,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27649
28270
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
27650
28271
  }
27651
28272
  };
27652
- var __read$e = (window && window.__read) || function (o, n) {
28273
+ var __read$f = (window && window.__read) || function (o, n) {
27653
28274
  var m = typeof Symbol === "function" && o[Symbol.iterator];
27654
28275
  if (!m) return o;
27655
28276
  var i = m.call(o), r, ar = [], e;
@@ -27665,7 +28286,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27665
28286
  }
27666
28287
  return ar;
27667
28288
  };
27668
- var __spreadArray$8 = (window && window.__spreadArray) || function (to, from) {
28289
+ var __spreadArray$a = (window && window.__spreadArray) || function (to, from) {
27669
28290
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
27670
28291
  to[j] = from[i];
27671
28292
  return to;
@@ -27692,6 +28313,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27692
28313
  * Preserve the map configuration that was used before the indoor map configuration was set
27693
28314
  */
27694
28315
  this.preservedPreindoorMapConfiguration = undefined;
28316
+ /**
28317
+ * The state of the progressive loading
28318
+ */
28319
+ this._progressiveLoadingState = {
28320
+ mapStyle: undefined,
28321
+ pendingVisibilityChange: undefined,
28322
+ };
27695
28323
  this._deferLayerGroupVisibilities = function (layerGroupLayers, initLayerGroups) {
27696
28324
  var validInitLayerGroups = initLayerGroups.filter(function (groupName) { return groupName in layerGroupLayers; });
27697
28325
  // If the initial layer groups are invalid, skip the progressive loading.
@@ -27699,11 +28327,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27699
28327
  return;
27700
28328
  var map = _this.map._getMap();
27701
28329
  var currentZoomLevel = map.getZoom();
27702
- // Select the layers to be deferred
28330
+ var currentMapStyle = _this.map.getStyle().style;
28331
+ // Cancel and release previous pending callback, if any.
28332
+ if (_this._progressiveLoadingState.pendingVisibilityChange) {
28333
+ _this.map.events.remove('load', _this._progressiveLoadingState.pendingVisibilityChange);
28334
+ _this._progressiveLoadingState.pendingVisibilityChange = null;
28335
+ }
28336
+ // Keep the current map style for future comparison.
28337
+ _this._progressiveLoadingState.mapStyle = currentMapStyle;
28338
+ // Select deferrable layers
27703
28339
  var deferredLayers = Object.entries(layerGroupLayers).reduce(function (deferred, _a) {
27704
- var _b = __read$e(_a, 2), groupName = _b[0], layers = _b[1];
28340
+ var _b = __read$f(_a, 2), groupName = _b[0], layers = _b[1];
27705
28341
  var isInInitialLayerGroup = validInitLayerGroups.includes(groupName);
27706
- return __spreadArray$8(__spreadArray$8([], __read$e(deferred)), __read$e(layers.filter(function (layer) {
28342
+ return __spreadArray$a(__spreadArray$a([], __read$f(deferred)), __read$f(layers.filter(function (layer) {
27707
28343
  var _a;
27708
28344
  // Exclude custom layers
27709
28345
  if (layer.type === 'custom')
@@ -27726,30 +28362,40 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27726
28362
  return false;
27727
28363
  }
27728
28364
  }
27729
- // Defer visible layers only.
28365
+ // Select visible layers only.
27730
28366
  return ((_a = layer.layout) === null || _a === void 0 ? void 0 : _a.visibility) !== 'none';
27731
28367
  })));
27732
28368
  }, []);
27733
- // Hide the deferred layers at initial load, therefore we can save the render time.
28369
+ // Hide the deferrable layers at initial load, therefore we can save the render time.
27734
28370
  deferredLayers.forEach(function (layer) {
28371
+ // Since this happens before sending style object into the map rendering,
28372
+ // we only need to update the style object, but not necessary to update maplibre's layout properties.
27735
28373
  layer.layout = layer.layout || {};
27736
28374
  layer.layout.visibility = 'none';
27737
28375
  });
27738
- // Make the deferred layers visible once the map instance is fully loaded
27739
- _this.map.events.addOnce('load', function () {
28376
+ // Make the deferred layers visible once the map instance is fully loaded.
28377
+ _this._progressiveLoadingState.pendingVisibilityChange = function () {
28378
+ // Release the callback.
28379
+ _this._progressiveLoadingState.pendingVisibilityChange = null;
28380
+ // Bail out the callback once map style has changed.
28381
+ var nextMapStyle = _this.map.getStyle().style;
28382
+ if (currentMapStyle !== nextMapStyle)
28383
+ return;
28384
+ // Make deferred layers visible
27740
28385
  deferredLayers.forEach(function (layer) {
28386
+ // This happens after the map rendering; Therefore, we need to update
28387
+ // both the style object and the maplibre's layout properties.
27741
28388
  layer.layout.visibility = 'visible';
27742
28389
  map.setLayoutProperty(layer.id, 'visibility', 'visible');
27743
28390
  });
27744
- });
28391
+ };
28392
+ _this.map.events.addOnce('load', _this._progressiveLoadingState.pendingVisibilityChange);
27745
28393
  };
27746
- this._onStyleData = function () {
27747
- _this._lookUpAsync(_this.map.getStyle()).then(function (style) {
27748
- _this.map.events.invoke("stylechanged", {
27749
- style: style.name,
27750
- map: _this.map,
27751
- type: "stylechanged"
27752
- });
28394
+ this._onStyleData = function (definition) {
28395
+ _this.map.events.invoke("stylechanged", {
28396
+ style: definition.name,
28397
+ map: _this.map,
28398
+ type: "stylechanged"
27753
28399
  });
27754
28400
  };
27755
28401
  /**
@@ -27772,9 +28418,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27772
28418
  || definitions.configurations[0];
27773
28419
  }
27774
28420
  };
27775
- this._lookUpAsync = function (options) { return __awaiter$3(_this, void 0, void 0, function () {
28421
+ this._lookUpAsync = function (options) { return __awaiter$4(_this, void 0, void 0, function () {
27776
28422
  var definitions, result;
27777
- return __generator$3(this, function (_a) {
28423
+ return __generator$4(this, function (_a) {
27778
28424
  switch (_a.label) {
27779
28425
  case 0: return [4 /*yield*/, this.definitions()];
27780
28426
  case 1:
@@ -27856,7 +28502,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27856
28502
  return baseName in styleNamesMap ? styleNamesMap[baseName] : baseName;
27857
28503
  };
27858
28504
  if (!this.serviceOptions.mapConfiguration) {
27859
- newPromise = new HijackablePromise(this._request(this.serviceOptions.staticAssetsDomain, constants.stylePath + "/" + constants.styleResourcePath, "StyleDefinitions", { version: this.serviceOptions.styleDefinitionsVersion }).then(function (definitions) { return ({
28505
+ var ensureAuthentication = this.map.authentication ? this.map.authentication.initialize() : Promise.resolve();
28506
+ newPromise = new HijackablePromise(ensureAuthentication.then(function () { return _this._request(_this.serviceOptions.staticAssetsDomain, constants.stylePath + "/" + constants.styleResourcePath, "StyleDefinitions", { version: _this.serviceOptions.styleDefinitionsVersion }).then(function (definitions) { return ({
27860
28507
  version: isNaN(definitions.version) ? 0 : parseFloat(definitions.version),
27861
28508
  defaultConfiguration: definitions.defaultStyle,
27862
28509
  configurations: definitions.styles
@@ -27883,19 +28530,25 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27883
28530
  domain: _this.serviceOptions.staticAssetsDomain,
27884
28531
  path: constants.stylePath + "/" + constants.styleResourcePath + "/" + style.name,
27885
28532
  queryParams: {
27886
- styleVersion: _this.serviceOptions.styleDefinitionsVersion,
28533
+ // Use the style version from the API response if it's available,
28534
+ // otherwise fallback to the version specified in the serviceOptions.
28535
+ // This is needed for flight testing the 2023-01-01 style version.
28536
+ styleVersion: definitions.version !== undefined && definitions.version !== null
28537
+ ? definitions.version
28538
+ : _this.serviceOptions.styleDefinitionsVersion
27887
28539
  // thus far we don't need to differentiate based on parameter here, as stylePatch will be called on cached styles as well
27888
28540
  //language: styleOptions.language
27889
28541
  },
27890
28542
  protocol: "https"
27891
28543
  }).toString(),
27892
28544
  }); })
27893
- }); }));
28545
+ }); }); }));
27894
28546
  }
27895
28547
  else if (typeof this.serviceOptions.mapConfiguration === 'string') {
27896
- newPromise = new HijackablePromise(this._request(this.serviceOptions.domain, constants.styleResourcePath + "/mapconfigurations/metadata/" + this.serviceOptions.mapConfiguration, "StyleDefinitions"
28548
+ var ensureAuthentication = this.map.authentication ? this.map.authentication.initialize() : Promise.resolve();
28549
+ newPromise = new HijackablePromise(ensureAuthentication.then(function () { return _this._request(_this.serviceOptions.domain, constants.styleResourcePath + "/mapconfigurations/metadata/" + _this.serviceOptions.mapConfiguration, "StyleDefinitions"
27897
28550
  // reassign properties from legacy mapConfiguration to new structure if needed
27898
- ).then(function (definitions) { return (__assign$8(__assign$8({}, definitions), { defaultConfiguration: definitions.defaultConfiguration || definitions['defaultStyle'], configurations: definitions.configurations || definitions['styles'] })); }));
28551
+ ).then(function (definitions) { return (__assign$8(__assign$8({}, definitions), { defaultConfiguration: definitions.defaultConfiguration || definitions['defaultStyle'], configurations: definitions.configurations || definitions['styles'] })); }); }));
27899
28552
  }
27900
28553
  else {
27901
28554
  newPromise = HijackablePromise.resolve(this.serviceOptions.mapConfiguration);
@@ -27926,23 +28579,183 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27926
28579
  if (styleDefinition.style) {
27927
28580
  return styleDefinition.style;
27928
28581
  }
27929
- throw Error("Style definition does not contain neither URL nor style object.");
28582
+ throw Error("Style definition neither contains URL nor style object.");
28583
+ };
28584
+ StyleManager.prototype.deriveNewStyleAndLayerGroups = function (previousStyle, nextStyle) {
28585
+ var _a, _b, _c, _d, _e, _f;
28586
+ // Layers in the next style with default properties that do not align with current StyleOptions
28587
+ // should be modified before they are applied to the map.
28588
+ var styleOptions = this.map.getStyle();
28589
+ var trafficOptions = this.map.getTraffic();
28590
+ var layersGroups = {};
28591
+ for (var i = 0; i < nextStyle.layers.length; i++) {
28592
+ var nextLayer = nextStyle.layers[i];
28593
+ var layerGroup = LayerGroupComparator.getLayerGroup(nextLayer);
28594
+ if (!layerGroup) {
28595
+ layersGroups[nextLayer.id] = [nextLayer];
28596
+ continue;
28597
+ }
28598
+ if (!layersGroups[layerGroup]) {
28599
+ layersGroups[layerGroup] = [];
28600
+ }
28601
+ var layerGroupLayers = layersGroups[layerGroup];
28602
+ layerGroupLayers.push(nextLayer);
28603
+ // 1. Set visiblity of fill-extrusion layers according to StyleOptions.showBuildingModels
28604
+ if (!styleOptions.showBuildingModels && nextLayer.type === "fill-extrusion") {
28605
+ nextLayer.layout = (_a = nextLayer.layout) !== null && _a !== void 0 ? _a : {};
28606
+ nextLayer.layout.visibility = "none";
28607
+ }
28608
+ else if (nextLayer.type === "fill-extrusion") {
28609
+ nextLayer.layout = (_b = nextLayer.layout) !== null && _b !== void 0 ? _b : {};
28610
+ nextLayer.layout.visibility = "visible";
28611
+ }
28612
+ // 2. Set visibility of traffic layers depending on traffic settings.
28613
+ if (trafficOptions.flow !== "none" && layerGroup) {
28614
+ if (layerGroup === "traffic_" + trafficOptions.flow && nextLayer.type == "line") {
28615
+ nextLayer.layout = (_c = nextLayer.layout) !== null && _c !== void 0 ? _c : {};
28616
+ nextLayer.layout.visibility = "visible";
28617
+ }
28618
+ }
28619
+ // 3. Set visibility of labels
28620
+ var isLabelLayerGroup = layerGroup === 'labels' || layerGroup === 'labels_places' || layerGroup === 'labels_indoor';
28621
+ if (isLabelLayerGroup && nextLayer.type === 'symbol') {
28622
+ if (styleOptions.showLabels && ((_d = nextLayer.layout) === null || _d === void 0 ? void 0 : _d.visibility) !== "none") {
28623
+ nextLayer.layout = (_e = nextLayer.layout) !== null && _e !== void 0 ? _e : {};
28624
+ nextLayer.layout.visibility = "visible";
28625
+ }
28626
+ else {
28627
+ nextLayer.layout = (_f = nextLayer.layout) !== null && _f !== void 0 ? _f : {};
28628
+ nextLayer.layout.visibility = "none";
28629
+ }
28630
+ }
28631
+ }
28632
+ return [nextStyle, layersGroups];
28633
+ };
28634
+ StyleManager.prototype.injectUserLayersIntoStyle = function (previousStyle, nextStyle, layerGroupLayers) {
28635
+ // Custom layers added to mapbox through this SDK should be carried over to the next style.
28636
+ return !previousStyle
28637
+ ? nextStyle
28638
+ : this.map.layers._getUserLayers().reduce(function (style, userLayer) {
28639
+ if (userLayer.layer instanceof WebGLLayer) {
28640
+ // mapbox custom layers cannot be serialized and preserved,
28641
+ // return to continue to the next user layer.
28642
+ return style;
28643
+ }
28644
+ var before = layerGroupLayers[userLayer.before] && layerGroupLayers[userLayer.before].length > 0
28645
+ ? layerGroupLayers[userLayer.before][0]
28646
+ : undefined;
28647
+ var layer = previousStyle.layers.find(function (layer) { return layer.id === userLayer.layer.getId(); });
28648
+ // when setStyle diff attempt is unsuccesful, _load will be called on the style that may have already injected user layers -> clean it up
28649
+ var existingLayerIdx = nextStyle.layers.findIndex(function (layer) { return layer.id === userLayer.layer.getId(); });
28650
+ if (existingLayerIdx > -1) {
28651
+ nextStyle.layers.splice(existingLayerIdx, 1);
28652
+ }
28653
+ if (layer) {
28654
+ var sourcesToCopy = new Set(Array.from(userLayer.layer._getSourceIds())
28655
+ .map(function (sourceId) { return previousStyle.sources[sourceId] ? { source: previousStyle.sources[sourceId], id: sourceId } : undefined; })
28656
+ .filter(function (source) { return source !== undefined; }));
28657
+ var insertIdx = before ? style.layers.findIndex(function (layer) { return layer.id === before.id; }) : -1;
28658
+ if (insertIdx > -1) {
28659
+ style.layers.splice(insertIdx, 0, layer);
28660
+ }
28661
+ else {
28662
+ style.layers.push(layer);
28663
+ }
28664
+ sourcesToCopy.forEach(function (_a) {
28665
+ var source = _a.source, id = _a.id;
28666
+ style.sources[id] = source;
28667
+ });
28668
+ }
28669
+ return style;
28670
+ }, __assign$8({}, nextStyle));
27930
28671
  };
27931
28672
  /**
27932
28673
  * @internal
27933
28674
  */
27934
28675
  StyleManager.prototype.setStyle = function (styleOptions, diff) {
28676
+ var _this = this;
27935
28677
  if (diff === void 0) { diff = true; }
27936
- try {
27937
- this.map._getMap().setStyle(this.getStyle(styleOptions), {
27938
- diff: diff,
27939
- stylePatch: this._stylePatch.bind(this),
27940
- validate: this.serviceOptions.validateStyle
27941
- });
28678
+ var transformStyleFunc;
28679
+ var targetDefinition = this._lookUp(styleOptions);
28680
+ if (!targetDefinition) {
28681
+ throw Error("Style definition " + styleOptions.style + " is not available.");
28682
+ }
28683
+ if (!targetDefinition.url && !targetDefinition.style) {
28684
+ throw Error("Style definition neither contains URL nor style object.");
28685
+ }
28686
+ var styleDataCallback = function () { return _this._onStyleData(targetDefinition); };
28687
+ var patchStyleEvent = function () {
28688
+ // FIXME: below diffing will be soon fixed on the maplibre side
28689
+ // If there was a previous styledata change event attached, remove it.
28690
+ // When the sprite url changes between style changes then maplibre can't perform the diff
28691
+ // In such cases it recalculate the style again. Removing previous attached
28692
+ // event listener makes sure that style changed event is not fired twice in these cases.
28693
+ _this.map.events.remove("styledata", styleDataCallback);
28694
+ _this.map.events.addOnce("styledata", styleDataCallback);
28695
+ };
28696
+ if (styleOptions && styleOptions.customStyleTransform) {
28697
+ transformStyleFunc = function (prev, next) {
28698
+ var target = styleOptions.customStyleTransform(prev, next);
28699
+ patchStyleEvent();
28700
+ return target;
28701
+ };
27942
28702
  }
27943
- catch (e) {
27944
- throw e;
28703
+ else {
28704
+ transformStyleFunc = function (previousStyle, style) {
28705
+ // make sure we always have a shallow clone to prevent mutating explicit json(rather then url) styles being set
28706
+ var nextStyle = __assign$8(__assign$8({}, style), { layers: __spreadArray$a([], __read$f(style.layers)), sources: __assign$8({}, style.sources) });
28707
+ var shouldProgressiveLoading = (styleOptions.progressiveLoading &&
28708
+ // The feature only effective at the initial load.
28709
+ !_this.map._isLoaded());
28710
+ // Shallow-clone the style object and duplicate layer.layout properties to avoid side-effects.
28711
+ if (shouldProgressiveLoading && Array.isArray(style === null || style === void 0 ? void 0 : style.layers)) {
28712
+ nextStyle = __assign$8({}, style);
28713
+ nextStyle.layers = nextStyle.layers.map(function (layer) {
28714
+ var nextLayer = __assign$8({}, layer);
28715
+ if (layer.layout) {
28716
+ nextLayer.layout = __assign$8({}, layer.layout);
28717
+ }
28718
+ return nextLayer;
28719
+ });
28720
+ }
28721
+ // 1. derive the base new style (without user layers) and layer groups
28722
+ var _a = __read$f(_this.deriveNewStyleAndLayerGroups(previousStyle, nextStyle), 2), targetStyle = _a[0], layerGroupLayers = _a[1];
28723
+ // 2. side effect: progressively render map layers to the canvas to shorten the time to the first meaningful render.
28724
+ if (shouldProgressiveLoading) {
28725
+ var initLayerGroups = styleOptions.progressiveLoadingInitialLayerGroups;
28726
+ if (Array.isArray(initLayerGroups) && initLayerGroups.length > 0) {
28727
+ _this._deferLayerGroupVisibilities(layerGroupLayers, initLayerGroups);
28728
+ }
28729
+ }
28730
+ // 3. copy user layers and sources from previous style into new one
28731
+ var targetStyleWithUserLayers = _this.injectUserLayersIntoStyle(previousStyle, targetStyle, layerGroupLayers);
28732
+ // 4. side effects: sync our control's LayerManager and SourceManager
28733
+ var nextFundamentalLayers = Object.entries(layerGroupLayers).map(function (_a) {
28734
+ var _b = __read$f(_a, 2), layerGroupId = _b[0], layers = _b[1];
28735
+ return _this._buildFundamentalLayerFrom(layers, layerGroupId);
28736
+ });
28737
+ var layerIndex = _this.map.layers._getUserLayers().reduce(function (layerIndex, userLayer) {
28738
+ var layerInsertIndex = userLayer.before ? layerIndex.findIndex(function (layer) { return layer.getId() === userLayer.before; }) : -1;
28739
+ if (layerInsertIndex > -1) {
28740
+ layerIndex.splice(layerInsertIndex, 0, userLayer.layer);
28741
+ }
28742
+ else {
28743
+ layerIndex.push(userLayer.layer);
28744
+ }
28745
+ return layerIndex;
28746
+ }, nextFundamentalLayers);
28747
+ _this.map.layers['layerIndex'] = layerIndex;
28748
+ _this.map.sources._syncSources(targetStyleWithUserLayers.sources);
28749
+ // 5. temporarily patch style data event
28750
+ patchStyleEvent();
28751
+ return targetStyleWithUserLayers;
28752
+ };
27945
28753
  }
28754
+ this.map._getMap().setStyle(targetDefinition.url || targetDefinition.style, {
28755
+ diff: diff,
28756
+ validate: this.serviceOptions.validateStyle,
28757
+ transformStyle: transformStyleFunc
28758
+ });
27946
28759
  };
27947
28760
  /**
27948
28761
  * Gets the color theme (light/dark) for the style type specified by the style options.
@@ -27955,8 +28768,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27955
28768
  return style.theme.toLowerCase();
27956
28769
  };
27957
28770
  StyleManager.prototype.getThemeAsync = function (styleOptions) {
27958
- return __awaiter$3(this, void 0, void 0, function () {
27959
- return __generator$3(this, function (_a) {
28771
+ return __awaiter$4(this, void 0, void 0, function () {
28772
+ return __generator$4(this, function (_a) {
27960
28773
  switch (_a.label) {
27961
28774
  case 0: return [4 /*yield*/, this._lookUpAsync(styleOptions)];
27962
28775
  case 1: return [2 /*return*/, (_a.sent()).theme];
@@ -28007,145 +28820,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28007
28820
  StyleManager.prototype.clearStyleSet = function () {
28008
28821
  this.unsetIndoorState();
28009
28822
  };
28010
- /**
28011
- * Function invoked by mapbox after a style is fetched but before it is committed to the map state.
28012
- *
28013
- * @param previousStyle The current style.
28014
- * @param nextStyle The next style which is to be applied.
28015
- * @param preserveLayer Preserve a layer from the previous style in the next style.
28016
- * @param updatePaintProperty Modify paint properties of a layer in the next style before the style is applied.
28017
- * @param updateLayoutProperty Modify layout properties of a layer in the next style before the style is applied.
28018
- * @param updateFilter Modify filter property of a layer in the next style before the style is applied.
28019
- */
28020
- StyleManager.prototype._stylePatch = function (previousStyle, nextStyle, preserveLayer, updatePaintProperty, updateLayoutProperty, updateFilter) {
28021
- var _this = this;
28022
- // Layers in the next style with default properties that do not align with current StyleOptions
28023
- // should be modified before they are applied to the map.
28024
- var styleOptions = this.map.getStyle();
28025
- var trafficOptions = this.map.getTraffic();
28026
- // force a replacement of language placeholder in the tileset url to avoid resolution to a same cache with placeholders on language change
28027
- nextStyle.sources = Object.entries(nextStyle.sources).reduce(function (newSources, _a) {
28028
- var _b = __read$e(_a, 2), sourceKey = _b[0], source = _b[1];
28029
- var newSource = __assign$8({}, source);
28030
- if ('url' in newSource && typeof newSource.url === 'string') {
28031
- if (newSource.url.includes(constants.languagePlaceHolder)) {
28032
- newSource.url = newSource.url.replace(constants.languagePlaceHolder, styleOptions.language);
28033
- }
28034
- }
28035
- newSources[sourceKey] = newSource;
28036
- return newSources;
28037
- }, {});
28038
- var shouldProgressiveLoading = (styleOptions.progressiveLoading &&
28039
- // The feature only effective at the initial load.
28040
- !this.map._isLoaded());
28041
- var setLayerVisibility = function (layer, visibility) {
28042
- var _a;
28043
- if (!shouldProgressiveLoading) {
28044
- // No need to apply the visibility change to maplibre while progressive loading is enabled.
28045
- // This can save a lot of CPU time.
28046
- updateLayoutProperty(layer.id, 'visibility', visibility);
28047
- }
28048
- layer.layout = (_a = layer.layout) !== null && _a !== void 0 ? _a : {};
28049
- layer.layout.visibility = visibility;
28050
- };
28051
- var layerGroupLayers = {};
28052
- nextStyle.layers.forEach(function (nextLayer) {
28053
- var _a;
28054
- var layerGroup = LayerGroupComparator.getLayerGroup(nextLayer);
28055
- if (layerGroup) {
28056
- // Set visibility of fill-extrusion layers according to StyleOptions.showBuildingModels
28057
- if (nextLayer.type === 'fill-extrusion') {
28058
- setLayerVisibility(nextLayer, styleOptions.showBuildingModels ? 'visible' : 'none');
28059
- }
28060
- // Set visibility of traffic layers depending on traffic settings.
28061
- if (trafficOptions.flow !== 'none' &&
28062
- layerGroup === "traffic_" + trafficOptions.flow &&
28063
- nextLayer.type == 'line') {
28064
- setLayerVisibility(nextLayer, 'visible');
28065
- }
28066
- // Set visibility of labels
28067
- var isLabelLayerGroup = layerGroup === 'labels' || layerGroup === 'labels_places' || layerGroup === 'labels_indoor';
28068
- if (isLabelLayerGroup && nextLayer.type === 'symbol') {
28069
- var isLayerVisible = ((_a = nextLayer.layout) === null || _a === void 0 ? void 0 : _a.visibility) !== 'none';
28070
- setLayerVisibility(nextLayer, isLayerVisible && styleOptions.showLabels ? 'visible' : 'none');
28071
- }
28072
- // Once this _stylePatch returns control to maplibre the next style will be applied immediately in the same context.
28073
- // To avoid potential data races update LayerManager with new a new set of FundamentalMapLayers from here instead of
28074
- // waiting for a styledata.load event to trigger a sync in a different context.
28075
- if (layerGroupLayers[layerGroup]) {
28076
- layerGroupLayers[layerGroup].push(nextLayer);
28077
- }
28078
- else {
28079
- layerGroupLayers[layerGroup] = [nextLayer];
28080
- }
28081
- }
28082
- });
28083
- if (shouldProgressiveLoading) {
28084
- var initLayerGroups = styleOptions.progressiveLoadingInitialLayerGroups;
28085
- if (Array.isArray(initLayerGroups) && initLayerGroups.length > 0) {
28086
- this._deferLayerGroupVisibilities(layerGroupLayers, initLayerGroups);
28087
- }
28088
- }
28089
- // A FundamentalMapLayer (grouped layer) representation of the next style must be built.
28090
- var previousLayers = this.map.layers.getLayers();
28091
- var nextLayers = Object.entries(layerGroupLayers).map(function (_a) {
28092
- var _b = __read$e(_a, 2), layerGroupName = _b[0], layerGroupMapboxLayers = _b[1];
28093
- return _this._buildFundamentalLayerFrom(layerGroupMapboxLayers, layerGroupName);
28094
- });
28095
- // Update FundamentalMapLayers in LayerManager
28096
- var userLayers = this.map.layers._getUserLayers();
28097
- var layersToRemove = previousLayers.filter(function (c) {
28098
- return (nextLayers.findIndex(function (n) { return c.getId() === n.getId(); }) < 0 &&
28099
- userLayers.findIndex(function (n) { return c.getId() === n.layer.getId(); }) < 0);
28100
- });
28101
- var prevNextIntersection = nextLayers.filter(function (n) { return previousLayers.find(function (c) { return c.getId() === n.getId(); }); });
28102
- var ePrevNextIntersection = prevNextIntersection.entries();
28103
- var replace = ePrevNextIntersection.next();
28104
- nextLayers.forEach(function (newFundamentalLayer) {
28105
- if (replace.value && replace.value[1].getId() === newFundamentalLayer.getId()) {
28106
- // Replace the existing layer with this ID with the new one.
28107
- var insertBefore = previousLayers.findIndex(function (l) { return l.getId() === newFundamentalLayer.getId(); });
28108
- _this.map.layers.remove(newFundamentalLayer.getId());
28109
- _this.map.layers.add(newFundamentalLayer, previousLayers[insertBefore].getId());
28110
- replace = ePrevNextIntersection.next();
28111
- }
28112
- else {
28113
- if (replace.value) {
28114
- // Insert new layer before the next common layer.
28115
- _this.map.layers.add(newFundamentalLayer, replace.value[1]);
28116
- }
28117
- else {
28118
- _this.map.layers.add(newFundamentalLayer);
28119
- }
28120
- }
28121
- });
28122
- layersToRemove.forEach(function (layer) {
28123
- _this.map.layers.remove(layer);
28124
- });
28125
- // Layers added to mapbox through this SDK since loading the last style should be
28126
- // carried over to the next style.
28127
- userLayers.forEach(function (userLayer) {
28128
- if (userLayer.layer instanceof WebGLLayer) {
28129
- // mapbox custom layers cannot be serialized and preserved,
28130
- // return to continue to the next user layer.
28131
- return;
28132
- }
28133
- var before = undefined;
28134
- if (_this.map.layers.getLayerById(userLayer.before)) {
28135
- var beforeCandidates = _this.map.layers.getLayerById(userLayer.before)._buildLayers();
28136
- before = (beforeCandidates.length > 0) ? beforeCandidates[0] : undefined;
28137
- }
28138
- preserveLayer(userLayer.layer.getId(), before === null || before === void 0 ? void 0 : before.id);
28139
- _this.map.layers.move(userLayer.layer, userLayer.before);
28140
- });
28141
- this.map.sources._syncSources(nextStyle.sources);
28142
- // If there was a previous styledata change event attached, remove it.
28143
- // When the sprite url changes between style changes then mapbox can't perform the diff
28144
- // In such cases it recalculate the style again. Removing previous attached
28145
- // event listener makes sure that style changed event is not fired twice in these cases.
28146
- this.map.events.remove("styledata", this._onStyleData);
28147
- this.map.events.addOnce("styledata", this._onStyleData);
28148
- };
28149
28823
  StyleManager.prototype._buildFundamentalLayerFrom = function (layers, id) {
28150
28824
  if (layers && layers.length > 0) {
28151
28825
  var newLayer = new FundamentalMapLayer(layers, id);
@@ -28186,27 +28860,30 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28186
28860
  * Fetches a json resource at the specified domain and path.
28187
28861
  */
28188
28862
  StyleManager.prototype._request = function (domain, path, resourceType, customQueryParams) {
28189
- var _a;
28863
+ var _a, _b;
28190
28864
  if (customQueryParams === void 0) { customQueryParams = {}; }
28191
- return __awaiter$3(this, void 0, void 0, function () {
28865
+ return __awaiter$4(this, void 0, void 0, function () {
28192
28866
  var requestParams, fetchOptions;
28193
- var _b;
28194
- return __generator$3(this, function (_c) {
28195
- switch (_c.label) {
28867
+ var _c;
28868
+ return __generator$4(this, function (_d) {
28869
+ switch (_d.label) {
28196
28870
  case 0:
28197
28871
  requestParams = {
28198
28872
  url: new Url({
28199
28873
  protocol: "https",
28200
28874
  domain: domain,
28201
28875
  path: path,
28202
- queryParams: __assign$8((_b = {}, _b[constants.apiVersionQueryParameter] = this.serviceOptions.styleAPIVersion, _b), customQueryParams)
28876
+ queryParams: __assign$8((_c = {}, _c[constants.apiVersionQueryParameter] = this.serviceOptions.styleAPIVersion,
28877
+ // Generate a hash code to avoid cache conflict
28878
+ // TODO: Remove this once style version 2023-01-01 is publicly available
28879
+ _c.hash = StyleManager._hashCode((_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.getToken()), _c), customQueryParams)
28203
28880
  }).toString()
28204
28881
  };
28205
28882
  if (typeof this.serviceOptions.transformRequest === "function" && resourceType) {
28206
28883
  // If a transformRequest(...) was specified use it.
28207
28884
  requestParams = this.serviceOptions.transformRequest(requestParams.url, resourceType);
28208
28885
  }
28209
- (_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.signRequest(requestParams);
28886
+ (_b = this.map.authentication) === null || _b === void 0 ? void 0 : _b.signRequest(requestParams);
28210
28887
  fetchOptions = {
28211
28888
  method: "GET",
28212
28889
  mode: "cors",
@@ -28223,11 +28900,26 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28223
28900
  throw new Error("HTTP " + response.status + ": " + response.statusText + " ");
28224
28901
  }
28225
28902
  })];
28226
- case 1: return [2 /*return*/, _c.sent()];
28903
+ case 1: return [2 /*return*/, _d.sent()];
28227
28904
  }
28228
28905
  });
28229
28906
  });
28230
28907
  };
28908
+ /**
28909
+ * A basic helper function to generate a hash from an input string.
28910
+ */
28911
+ StyleManager._hashCode = function (str) {
28912
+ if (str === void 0) { str = ""; }
28913
+ var chr, hash = 0;
28914
+ if (!str)
28915
+ return hash;
28916
+ for (var i = 0; i < str.length; i++) {
28917
+ chr = str.charCodeAt(i);
28918
+ hash = (hash << 5) - hash + chr;
28919
+ hash |= 0; // Convert to 32bit integer
28920
+ }
28921
+ return hash;
28922
+ };
28231
28923
  return StyleManager;
28232
28924
  }());
28233
28925
 
@@ -28236,6 +28928,123 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28236
28928
  */
28237
28929
  var isHMREnabled = function () { return 'ENVIRONMENT' in window && !!window['ENVIRONMENT']['hmr']; };
28238
28930
 
28931
+ var __values$j = (window && window.__values) || function(o) {
28932
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
28933
+ if (m) return m.call(o);
28934
+ if (o && typeof o.length === "number") return {
28935
+ next: function () {
28936
+ if (o && i >= o.length) o = void 0;
28937
+ return { value: o && o[i++], done: !o };
28938
+ }
28939
+ };
28940
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
28941
+ };
28942
+ /**
28943
+ * @internal
28944
+ * A manager for the map control's hidden indicators.
28945
+ * Exposed through the `indicators` property of the `atlas.Map` class.
28946
+ * Cannot be instantiated by the user.
28947
+ */
28948
+ var AccessibleIndicatorManager = /** @class */ (function () {
28949
+ /**
28950
+ * Constructs the indicator manager to be exposed only through the `indicators` property of the `Map` class.
28951
+ * @param map The map whose indicators are being managed by this.
28952
+ * @internal
28953
+ */
28954
+ function AccessibleIndicatorManager(map) {
28955
+ this.map = map;
28956
+ this.indicators = new Set();
28957
+ }
28958
+ /**
28959
+ * Adds an indicator to the map
28960
+ * @param indicator The indicator(s) to add.
28961
+ */
28962
+ AccessibleIndicatorManager.prototype.add = function (indicator) {
28963
+ var e_1, _a;
28964
+ indicator = Array.isArray(indicator) ? indicator : [indicator];
28965
+ try {
28966
+ for (var indicator_1 = __values$j(indicator), indicator_1_1 = indicator_1.next(); !indicator_1_1.done; indicator_1_1 = indicator_1.next()) {
28967
+ var i = indicator_1_1.value;
28968
+ if (!this.indicators.has(i)) {
28969
+ this.indicators.add(i);
28970
+ i.attach(this.map);
28971
+ }
28972
+ }
28973
+ }
28974
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
28975
+ finally {
28976
+ try {
28977
+ if (indicator_1_1 && !indicator_1_1.done && (_a = indicator_1.return)) _a.call(indicator_1);
28978
+ }
28979
+ finally { if (e_1) throw e_1.error; }
28980
+ }
28981
+ };
28982
+ /**
28983
+ * Removes all indicators from the map.
28984
+ */
28985
+ AccessibleIndicatorManager.prototype.clear = function () {
28986
+ var _this = this;
28987
+ this.indicators.forEach(function (indicator) {
28988
+ _this.indicators.delete(indicator);
28989
+ indicator.remove();
28990
+ });
28991
+ };
28992
+ /**
28993
+ * Removes an indicator from the map
28994
+ * @param indicator The indicator(s) to remove.
28995
+ */
28996
+ AccessibleIndicatorManager.prototype.remove = function (indicator) {
28997
+ var e_2, _a;
28998
+ indicator = Array.isArray(indicator) ? indicator : [indicator];
28999
+ try {
29000
+ for (var indicator_2 = __values$j(indicator), indicator_2_1 = indicator_2.next(); !indicator_2_1.done; indicator_2_1 = indicator_2.next()) {
29001
+ var i = indicator_2_1.value;
29002
+ if (this.indicators.has(i)) {
29003
+ this.indicators.delete(i);
29004
+ i.remove();
29005
+ }
29006
+ }
29007
+ }
29008
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
29009
+ finally {
29010
+ try {
29011
+ if (indicator_2_1 && !indicator_2_1.done && (_a = indicator_2.return)) _a.call(indicator_2);
29012
+ }
29013
+ finally { if (e_2) throw e_2.error; }
29014
+ }
29015
+ };
29016
+ /**
29017
+ * Returns the indicators currently attached to the map.
29018
+ */
29019
+ AccessibleIndicatorManager.prototype.getIndicators = function () {
29020
+ return Array.from(this.indicators);
29021
+ };
29022
+ /**
29023
+ * Returns the div element that should contain all the indicator containers.
29024
+ * Creates it if it doesn't already exist.
29025
+ * @internal
29026
+ */
29027
+ AccessibleIndicatorManager.prototype._getCollectionDiv = function () {
29028
+ var collection = this.map.getMapContainer()
29029
+ .querySelector("." + AccessibleIndicatorManager.Css.collection);
29030
+ if (!collection) {
29031
+ // If the collection div doesn't exist create it.
29032
+ collection = document.createElement("div");
29033
+ collection.setAttribute("aria-label", "map data");
29034
+ // Set the container role to listbox, and the descents' role to option, so the reader will read the listbox as a list.
29035
+ // For example, NVDA will read "data point, 1 of 1" when the indicator is focused.
29036
+ collection.setAttribute("role", "listbox");
29037
+ collection.classList.add(AccessibleIndicatorManager.Css.collection);
29038
+ this.map.getMapContainer().appendChild(collection);
29039
+ }
29040
+ return collection;
29041
+ };
29042
+ AccessibleIndicatorManager.Css = {
29043
+ collection: "accessible-indicator-collection-container"
29044
+ };
29045
+ return AccessibleIndicatorManager;
29046
+ }());
29047
+
28239
29048
  var __extends$19 = (window && window.__extends) || (function () {
28240
29049
  var extendStatics = function (d, b) {
28241
29050
  extendStatics = Object.setPrototypeOf ||
@@ -28262,7 +29071,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28262
29071
  };
28263
29072
  return __assign$9.apply(this, arguments);
28264
29073
  };
28265
- var __awaiter$4 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
29074
+ var __awaiter$5 = (window && window.__awaiter) || function (thisArg, _arguments, P, generator) {
28266
29075
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28267
29076
  return new (P || (P = Promise))(function (resolve, reject) {
28268
29077
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -28271,7 +29080,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28271
29080
  step((generator = generator.apply(thisArg, _arguments || [])).next());
28272
29081
  });
28273
29082
  };
28274
- var __generator$4 = (window && window.__generator) || function (thisArg, body) {
29083
+ var __generator$5 = (window && window.__generator) || function (thisArg, body) {
28275
29084
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28276
29085
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28277
29086
  function verb(n) { return function (v) { return step([n, v]); }; }
@@ -28298,7 +29107,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28298
29107
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
28299
29108
  }
28300
29109
  };
28301
- var __read$f = (window && window.__read) || function (o, n) {
29110
+ var __read$g = (window && window.__read) || function (o, n) {
28302
29111
  var m = typeof Symbol === "function" && o[Symbol.iterator];
28303
29112
  if (!m) return o;
28304
29113
  var i = m.call(o), r, ar = [], e;
@@ -28314,12 +29123,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28314
29123
  }
28315
29124
  return ar;
28316
29125
  };
28317
- var __spreadArray$9 = (window && window.__spreadArray) || function (to, from) {
29126
+ var __spreadArray$b = (window && window.__spreadArray) || function (to, from) {
28318
29127
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
28319
29128
  to[j] = from[i];
28320
29129
  return to;
28321
29130
  };
28322
- var __values$j = (window && window.__values) || function(o) {
29131
+ var __values$k = (window && window.__values) || function(o) {
28323
29132
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
28324
29133
  if (m) return m.call(o);
28325
29134
  if (o && typeof o.length === "number") return {
@@ -28429,6 +29238,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28429
29238
  _this.markers = new HtmlMarkerManager(_this);
28430
29239
  _this.sources = new SourceManager(_this);
28431
29240
  _this.popups = new PopupManager(_this);
29241
+ _this.indicators = new AccessibleIndicatorManager(_this);
28432
29242
  // Add CSS classes and set attributes for DOM elements.
28433
29243
  _this.map.getContainer().classList.add(Map.Css.container);
28434
29244
  _this.map.getCanvasContainer().classList.add(Map.Css.canvasContainer);
@@ -28469,9 +29279,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28469
29279
  _this._setAutoResize(_this.styleOptions.autoResize);
28470
29280
  _this.map.showTileBoundaries = _this.styleOptions.showTileBoundaries;
28471
29281
  _this.localizedStringsPromise = Localizer.getStrings(_this.styleOptions.language);
28472
- var stylesInit = _this.styles.initStyleset();
28473
- Promise.all([authManInit, stylesInit]).then(function (_a) {
28474
- var _b = __read$f(_a, 2), _ = _b[0], definitions = _b[1];
29282
+ authManInit
29283
+ // reuses this.styles.initPromise if initStyleset is already called
29284
+ .then(function () { return _this.styles.definitions(); })
29285
+ .then(function (definitions) {
28475
29286
  // Check that the map hasn't been removed for any reason.
28476
29287
  // If so no need to finish styling the map.
28477
29288
  if (_this.removed) {
@@ -28501,7 +29312,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28501
29312
  _this.events.invoke("error", errorData);
28502
29313
  });
28503
29314
  // --> Set initial camera state of map
28504
- _this.setCamera(__assign$9(__assign$9({}, options), { type: "jump", duration: 0 }));
29315
+ _this.setCamera(__assign$9(__assign$9({
29316
+ // Default minZoom to ensure the map doesn't zoom out to unsupported zoom levels.
29317
+ minZoom: 1 }, options), { type: "jump", duration: 0 }));
28505
29318
  // Add delegates to map
28506
29319
  {
28507
29320
  _this.incidentDelegate = new IncidentServiceDelegate(_this);
@@ -28534,6 +29347,16 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28534
29347
  }
28535
29348
  return _this;
28536
29349
  }
29350
+ Object.defineProperty(Map.prototype, "isDisposed", {
29351
+ /**
29352
+ * Returns true if the map has been disposed.
29353
+ */
29354
+ get: function () {
29355
+ return this.removed;
29356
+ },
29357
+ enumerable: false,
29358
+ configurable: true
29359
+ });
28537
29360
  /**
28538
29361
  * Returns the HTMLCanvasElement that the map is drawn to.
28539
29362
  */
@@ -28570,6 +29393,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28570
29393
  else {
28571
29394
  this.accessibleMapDelegate.removeFromMap();
28572
29395
  }
29396
+ var shouldReloadStyle = this.styles.serviceOptions.mapConfiguration !== this.serviceOptions.mapConfiguration
29397
+ || this.styles.serviceOptions.staticAssetsDomain !== this.serviceOptions.staticAssetsDomain
29398
+ || this.styles.serviceOptions.styleDefinitionsVersion !== this.serviceOptions.styleDefinitionsVersion
29399
+ || this.styles.serviceOptions.domain !== this.serviceOptions.domain
29400
+ || this.styles.serviceOptions.styleAPIVersion !== this.serviceOptions.styleAPIVersion;
29401
+ // NOTE: only perform a reload when the style dependent properties are changed
29402
+ //|| this.styles.serviceOptions.validateStyle !== this.serviceOptions.validateStyle
29403
+ //|| this.styles.serviceOptions.transformRequest !== this.serviceOptions.transformRequest
29404
+ this.styles.serviceOptions = this.serviceOptions;
29405
+ if (shouldReloadStyle) {
29406
+ this.styles.initPromise = null;
29407
+ this.setStyle({});
29408
+ }
28573
29409
  };
28574
29410
  /**
28575
29411
  * Adds request transformer
@@ -28598,6 +29434,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28598
29434
  if (!mapboxCameraOptions) {
28599
29435
  throw new Error("The map cannot be fit to the current canvas with the given CameraBoundsOptions.");
28600
29436
  }
29437
+ if ('pitch' in options) {
29438
+ mapboxCameraOptions.pitch = options.pitch;
29439
+ }
29440
+ if ('bearing' in options) {
29441
+ mapboxCameraOptions.bearing = options.bearing;
29442
+ }
28601
29443
  this.map.setMaxZoom(cameraBoundsOptions.maxZoom);
28602
29444
  this._invokeEvent("maxzoomchanged", this.map.getMaxZoom());
28603
29445
  maxBounds = this._generateSafeBounds(cameraBoundsOptions.maxBounds);
@@ -28720,8 +29562,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28720
29562
  // If this function is restructured such that a styledata event won't always trigger
28721
29563
  // if the language is changed, then either those delegates need changed
28722
29564
  // or the styledata event manually invoked.
29565
+ var noDiffOnLanguageViewChange = diff && (this.styleOptions.language === newOptions.language && this.styleOptions.view === newOptions.view);
28723
29566
  this.styleOptions = newOptions;
28724
- this._setStyleComponents(newOptions, diff);
29567
+ this._setStyleComponents(newOptions, noDiffOnLanguageViewChange);
28725
29568
  };
28726
29569
  /**
28727
29570
  * Returns the map control's current style settings.
@@ -29112,7 +29955,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29112
29955
  urls = layer.getOptions().subdomains || [];
29113
29956
  }
29114
29957
  // Add the tile urls to the layer, but don't update the map yet.
29115
- urls.push.apply(urls, __spreadArray$9([], __read$f(tileSources)));
29958
+ urls.push.apply(urls, __spreadArray$b([], __read$g(tileSources)));
29116
29959
  layer._setOptionsNoUpdate({
29117
29960
  subdomains: urls
29118
29961
  });
@@ -29134,7 +29977,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29134
29977
  Map.prototype.removeLayers = function (layerNames) {
29135
29978
  var e_1, _a;
29136
29979
  try {
29137
- for (var layerNames_1 = __values$j(layerNames), layerNames_1_1 = layerNames_1.next(); !layerNames_1_1.done; layerNames_1_1 = layerNames_1.next()) {
29980
+ for (var layerNames_1 = __values$k(layerNames), layerNames_1_1 = layerNames_1.next(); !layerNames_1_1.done; layerNames_1_1 = layerNames_1.next()) {
29138
29981
  var layerName = layerNames_1_1.value;
29139
29982
  // Previously calling removeLayers for layers that didn't exist in the map just did nothing.
29140
29983
  // Now, LayerManager will throw an error, so we need to check if the layer exists before calling remove.
@@ -29276,14 +30119,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29276
30119
  this.layers.clear();
29277
30120
  this.sources.clear();
29278
30121
  this.markers.clear();
30122
+ this.indicators.clear();
29279
30123
  };
29280
30124
  /**
29281
30125
  * Clean up the map's resources. Map will not function correctly after calling this method.
29282
30126
  */
29283
30127
  Map.prototype.dispose = function () {
30128
+ var _a;
29284
30129
  this.clear();
29285
30130
  this.map.remove();
30131
+ (_a = this.authentication) === null || _a === void 0 ? void 0 : _a.dispose();
29286
30132
  this.removed = true;
30133
+ // Remove event listeners
30134
+ window.removeEventListener("resize", this._windowResizeCallback);
29287
30135
  while (this.getMapContainer().firstChild) {
29288
30136
  var currChild = this.getMapContainer().firstChild;
29289
30137
  this.getMapContainer().removeChild(currChild);
@@ -29324,7 +30172,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29324
30172
  var e_2, _a;
29325
30173
  var positions = [];
29326
30174
  try {
29327
- for (var pixels_1 = __values$j(pixels), pixels_1_1 = pixels_1.next(); !pixels_1_1.done; pixels_1_1 = pixels_1.next()) {
30175
+ for (var pixels_1 = __values$k(pixels), pixels_1_1 = pixels_1.next(); !pixels_1_1.done; pixels_1_1 = pixels_1.next()) {
29328
30176
  var pixel = pixels_1_1.value;
29329
30177
  var lngLat = this.map.unproject(pixel);
29330
30178
  positions.push(new Position(lngLat.lng, lngLat.lat));
@@ -29347,7 +30195,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29347
30195
  var e_3, _a;
29348
30196
  var pixels = [];
29349
30197
  try {
29350
- for (var positions_1 = __values$j(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
30198
+ for (var positions_1 = __values$k(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
29351
30199
  var position = positions_1_1.value;
29352
30200
  var point = this.map.project(position);
29353
30201
  pixels.push(new Pixel(point.x, point.y));
@@ -29395,8 +30243,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29395
30243
  */
29396
30244
  Map.prototype._rebuildStyle = function (diff) {
29397
30245
  if (diff === void 0) { diff = true; }
29398
- return __awaiter$4(this, void 0, void 0, function () {
29399
- return __generator$4(this, function (_a) {
30246
+ return __awaiter$5(this, void 0, void 0, function () {
30247
+ return __generator$5(this, function (_a) {
29400
30248
  this.styles.setStyle(this.styleOptions, diff);
29401
30249
  this.imageSprite._restoreImages();
29402
30250
  return [2 /*return*/];
@@ -29612,7 +30460,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29612
30460
  return Map;
29613
30461
  }(EventEmitter));
29614
30462
 
29615
- var __read$g = (window && window.__read) || function (o, n) {
30463
+ var __read$h = (window && window.__read) || function (o, n) {
29616
30464
  var m = typeof Symbol === "function" && o[Symbol.iterator];
29617
30465
  if (!m) return o;
29618
30466
  var i = m.call(o), r, ar = [], e;
@@ -29628,7 +30476,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29628
30476
  }
29629
30477
  return ar;
29630
30478
  };
29631
- var __spreadArray$a = (window && window.__spreadArray) || function (to, from) {
30479
+ var __spreadArray$c = (window && window.__spreadArray) || function (to, from) {
29632
30480
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
29633
30481
  to[j] = from[i];
29634
30482
  return to;
@@ -29774,7 +30622,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
29774
30622
  lineLength = 50;
29775
30623
  }
29776
30624
  var lines = c.split(/<(tr|div|br|li|h[0-9]|p>)/);
29777
- longestStringLength = Math.max.apply(Math, __spreadArray$a([], __read$g((lines.map(function (el) { return el.replace(/<[a-zA-Z0-9\s=\/]+>/g, "").length; }))))) - 1;
30625
+ longestStringLength = Math.max.apply(Math, __spreadArray$c([], __read$h((lines.map(function (el) { return el.replace(/<[a-zA-Z0-9\s=\/]+>/g, "").length; }))))) - 1;
29778
30626
  var w = Math.ceil(longestStringLength * 3.5);
29779
30627
  if (w < width) {
29780
30628
  width = w;