azure-maps-control 2.2.0 → 3.0.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,9 +56,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
56
56
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('azuremaps-maplibre-gl')) :
57
57
  typeof define === 'function' && define.amd ? define(['exports', 'azuremaps-maplibre-gl'], factory) :
58
58
  (global = global || self, factory(global.atlas = global.atlas || {}, global.maplibregl));
59
- }(this, (function (exports, mapboxgl) { 'use strict';
59
+ }(this, (function (exports, maplibregl) { 'use strict';
60
60
 
61
- var mapboxgl__default = 'default' in mapboxgl ? mapboxgl['default'] : mapboxgl;
61
+ maplibregl = maplibregl && Object.prototype.hasOwnProperty.call(maplibregl, 'default') ? maplibregl['default'] : maplibregl;
62
62
 
63
63
  var env = {
64
64
  domain: "atlas.microsoft.com",
@@ -343,7 +343,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
343
343
  return Url;
344
344
  }());
345
345
 
346
- var version = "2.2.0";
346
+ var version = "3.0.0-preview.1";
347
347
 
348
348
  /**
349
349
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -12574,9 +12574,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
12574
12574
  // Add this layer again if the layer was removed by mapbox after a style change.
12575
12575
  if (!_this.map._getMap().getLayer(_this.id)) {
12576
12576
  var map = _this.map;
12577
- var before_1 = (_a = _this.map.layers._getUserLayers().find(function (l) { return l.layer.getId() == _this.id; })) === null || _a === void 0 ? void 0 : _a.before;
12577
+ var before = (_a = _this.map.layers._getUserLayers().find(function (l) { return l.layer.getId() == _this.id; })) === null || _a === void 0 ? void 0 : _a.before;
12578
12578
  map.layers.remove(_this);
12579
- map.layers.add(_this, before_1);
12579
+ map.layers.add(_this, before);
12580
12580
  }
12581
12581
  };
12582
12582
  _this.options = new WebGLLayerOptions().merge(cloneDeepWith_1(options, WebGLLayerOptions._cloneCustomizer));
@@ -13243,7 +13243,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13243
13243
  if (options.anchor === "none") {
13244
13244
  this.autoAnchor = autoAnchor || "bottom";
13245
13245
  this.containerDiv.classList.add(this.autoAnchor);
13246
- marker = new mapboxgl.Marker({
13246
+ marker = new maplibregl.Marker({
13247
13247
  anchor: this.autoAnchor,
13248
13248
  element: this.containerDiv,
13249
13249
  offset: options.pixelOffset,
@@ -13251,7 +13251,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13251
13251
  }
13252
13252
  else {
13253
13253
  this.containerDiv.classList.add(options.anchor);
13254
- marker = new mapboxgl.Marker({
13254
+ marker = new maplibregl.Marker({
13255
13255
  anchor: options.anchor,
13256
13256
  element: this.containerDiv,
13257
13257
  offset: options.pixelOffset,
@@ -13617,7 +13617,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13617
13617
  if (!options.visible) {
13618
13618
  this.element.classList.add(HtmlMarker.hiddenClass);
13619
13619
  }
13620
- this.marker = new mapboxgl.Marker({
13620
+ this.marker = new maplibregl.Marker({
13621
13621
  element: this.element,
13622
13622
  offset: options.pixelOffset,
13623
13623
  draggable: options.draggable,
@@ -14326,13 +14326,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14326
14326
  * Gets the worker count that will get created.
14327
14327
  */
14328
14328
  function getWorkerCount() {
14329
- return mapboxgl__default.workerCount;
14329
+ return maplibregl.workerCount;
14330
14330
  }
14331
14331
  /**
14332
14332
  * Gets the Maximum number of images (raster tiles, sprites, icons) to load in parallel
14333
14333
  */
14334
14334
  function getMaxParallelImageRequests() {
14335
- return mapboxgl__default.maxParallelImageRequests;
14335
+ return maplibregl.maxParallelImageRequests;
14336
14336
  }
14337
14337
  /**
14338
14338
  * Gets the default language that was provided.
@@ -14385,7 +14385,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14385
14385
  if (UserAgent.isIE()) {
14386
14386
  return false;
14387
14387
  }
14388
- return mapboxgl__default.supported({
14388
+ return maplibregl.supported({
14389
14389
  failIfMajorPerformanceCaveat: failIfMajorPerformanceCaveat
14390
14390
  });
14391
14391
  }
@@ -14444,7 +14444,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14444
14444
  */
14445
14445
  function setWorkerCount(workerCount) {
14446
14446
  if (workerCount > 0) {
14447
- mapboxgl__default.workerCount = workerCount;
14447
+ maplibregl.workerCount = workerCount;
14448
14448
  hasWorkerCount = true;
14449
14449
  }
14450
14450
  }
@@ -14455,7 +14455,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14455
14455
  */
14456
14456
  function setMaxParallelImageRequests(maxParallelImageRequests) {
14457
14457
  if (maxParallelImageRequests > 0) {
14458
- mapboxgl__default.maxParallelImageRequests = maxParallelImageRequests;
14458
+ maplibregl.maxParallelImageRequests = maxParallelImageRequests;
14459
14459
  hasMaxParallelImageRequests = true;
14460
14460
  }
14461
14461
  }
@@ -14570,7 +14570,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14570
14570
  * created and destroyed.
14571
14571
  */
14572
14572
  function prewarm() {
14573
- mapboxgl__default.prewarm();
14573
+ maplibregl.prewarm();
14574
14574
  }
14575
14575
  /**
14576
14576
  * Clears up resources that have previously been created by `atlas.prewarm()`.
@@ -14579,7 +14579,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14579
14579
  * in your application.
14580
14580
  */
14581
14581
  function clearPrewarmedResources() {
14582
- mapboxgl__default.clearPrewarmedResources();
14582
+ maplibregl.clearPrewarmedResources();
14583
14583
  }
14584
14584
  /**
14585
14585
  * Returns if authentication options are set.
@@ -16257,6 +16257,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16257
16257
  40
16258
16258
  ];
16259
16259
  // accessibility recommendation: After using any of the map shortcut keys, NVDA should not read all the shortcut keys again.
16260
+ // // TODO: this should be this.map._getMap().getCanvas
16260
16261
  var mapCanvas = _this.map._getMap()._canvas;
16261
16262
  mapCanvas === null || mapCanvas === void 0 ? void 0 : mapCanvas.addEventListener('keyup', function (event) {
16262
16263
  if (baseShortcutKeyCodes.find(function (code) { return event.keyCode === code; })) {
@@ -23950,6 +23951,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23950
23951
  // Replace the existing layer with the new one.
23951
23952
  // Place the new layer behind the specified before layer.
23952
23953
  var layerIndex = this.layerIndex.findIndex(function (l) { return l.getId() === layer.getId(); });
23954
+ var userLayerIndex = this.userLayers.findIndex(function (ul) { return ul.layer.getId() === layer.getId(); });
23953
23955
  var tempLayer = this.layerIndex[layerIndex];
23954
23956
  this._removeMapboxLayers(layer);
23955
23957
  this._addMapboxLayers(layer, before);
@@ -23958,8 +23960,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23958
23960
  this.layerIndex.splice(layerIndex, 1);
23959
23961
  var beforeIndex = this.layerIndex.findIndex(function (l) { return l.getId() === before; });
23960
23962
  this.layerIndex.splice(beforeIndex, 0, layer);
23961
- if (!(layer instanceof FundamentalMapLayer))
23962
- this.userLayers.push({ layer: layer, before: before });
23963
+ if (!(layer instanceof FundamentalMapLayer)) {
23964
+ this.userLayers[userLayerIndex] = { layer: layer, before: before };
23965
+ }
23963
23966
  tempLayer.onRemove();
23964
23967
  layer.onAdd(this.map);
23965
23968
  }
@@ -23969,14 +23972,16 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23969
23972
  this.map.events._enableLayerEvents(layer);
23970
23973
  var beforeIndex = this.layerIndex.findIndex(function (l) { return l.getId() === before; });
23971
23974
  this.layerIndex.splice(beforeIndex, 0, layer);
23972
- if (!(layer instanceof FundamentalMapLayer))
23975
+ if (!(layer instanceof FundamentalMapLayer)) {
23973
23976
  this.userLayers.push({ layer: layer, before: before });
23977
+ }
23974
23978
  layer.onAdd(this.map);
23975
23979
  }
23976
23980
  }
23977
23981
  else {
23978
23982
  var layerIndex = this.layerIndex.findIndex(function (l) { return l.getId() === layer.getId(); });
23979
- if (layerIndex >= 0) {
23983
+ var userLayerIndex = this.userLayers.findIndex(function (ul) { return ul.layer.getId() === layer.getId(); });
23984
+ if (layerIndex >= 0 && userLayerIndex >= 0) {
23980
23985
  // Replace the existing layer with the new one.
23981
23986
  var tempLayer = this.layerIndex[layerIndex];
23982
23987
  this._removeMapboxLayers(tempLayer);
@@ -23984,6 +23989,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23984
23989
  this.map.events._disableLayerEvents(tempLayer);
23985
23990
  this.map.events._enableLayerEvents(layer);
23986
23991
  this.layerIndex[layerIndex] = layer;
23992
+ if (!(layer instanceof FundamentalMapLayer)) {
23993
+ this.userLayers[userLayerIndex] = { layer: layer, before: undefined };
23994
+ }
23987
23995
  tempLayer.onRemove();
23988
23996
  layer.onAdd(this.map);
23989
23997
  }
@@ -23992,8 +24000,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
23992
24000
  this._addMapboxLayers(layer);
23993
24001
  this.map.events._enableLayerEvents(layer);
23994
24002
  this.layerIndex.push(layer);
23995
- if (!(layer instanceof FundamentalMapLayer))
24003
+ if (!(layer instanceof FundamentalMapLayer)) {
23996
24004
  this.userLayers.push({ layer: layer, before: before });
24005
+ }
23997
24006
  layer.onAdd(this.map);
23998
24007
  }
23999
24008
  }
@@ -24239,6 +24248,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24239
24248
  else {
24240
24249
  this.layerIndex.push(layer);
24241
24250
  }
24251
+ // Update before property of the user layer
24252
+ var userLayer = this.userLayers.find(function (ul) { return ul.layer.getId() === layerId; });
24253
+ if (userLayer) {
24254
+ userLayer.before = beforeId;
24255
+ }
24242
24256
  };
24243
24257
  LayerManager.prototype._moveMapboxLayers = function (layer, before) {
24244
24258
  var e_7, _a;
@@ -25793,10 +25807,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25793
25807
  */
25794
25808
  LayerGroupComparator.getLayerGroup = function (layer) {
25795
25809
  var _a;
25796
- if ((layer === null || layer === void 0 ? void 0 : layer.metadata) && layer.metadata['microsoft.maps:layerGroup']) {
25797
- return layer.metadata['microsoft.maps:layerGroup'];
25810
+ var layerObject = layer;
25811
+ if ((layerObject === null || layerObject === void 0 ? void 0 : layerObject.metadata) && layerObject.metadata['microsoft.maps:layerGroup']) {
25812
+ return layerObject.metadata['microsoft.maps:layerGroup'];
25798
25813
  }
25799
- var layerId = (_a = layer === null || layer === void 0 ? void 0 : layer.id) !== null && _a !== void 0 ? _a : layer;
25814
+ var layerId = (_a = layerObject === null || layerObject === void 0 ? void 0 : layerObject.id) !== null && _a !== void 0 ? _a : layer;
25800
25815
  if (!layerId.startsWith("microsoft.")) {
25801
25816
  return undefined;
25802
25817
  }
@@ -26129,16 +26144,153 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26129
26144
  }
26130
26145
  throw Error("Style definition does not contain neither URL nor style object.");
26131
26146
  };
26147
+ StyleManager.prototype.deriveNewStyle = function (previousStyle, nextStyle) {
26148
+ // Layers in the next style with default properties that do not align with current StyleOptions
26149
+ // should be modified before they are applied to the map.
26150
+ var styleOptions = this.map.getStyle();
26151
+ var trafficOptions = this.map.getTraffic();
26152
+ return __assign(__assign({}, nextStyle), {
26153
+ // force a replacement of language placeholder in the tileset url to avoid resolution to a same cache with placeholders on language change
26154
+ sources: Object.entries(nextStyle.sources).reduce(function (newSources, _a) {
26155
+ var _b = __read(_a, 2), sourceKey = _b[0], source = _b[1];
26156
+ var newSource = __assign({}, source);
26157
+ if ('url' in newSource && typeof newSource.url === 'string') {
26158
+ if (newSource.url.includes(constants.languagePlaceHolder)) {
26159
+ newSource.url = newSource.url.replace(constants.languagePlaceHolder, styleOptions.language);
26160
+ }
26161
+ }
26162
+ newSources[sourceKey] = newSource;
26163
+ return newSources;
26164
+ }, {}), layers: nextStyle.layers.map(function (layer) {
26165
+ var _a, _b, _c, _d, _e;
26166
+ var nextLayer = __assign({}, layer);
26167
+ var layerGroup = LayerGroupComparator.getLayerGroup(nextLayer);
26168
+ if (!layerGroup) {
26169
+ return nextLayer;
26170
+ }
26171
+ // 1. Set visiblity of fill-extrusion layers according to StyleOptions.showBuildingModels
26172
+ if (!styleOptions.showBuildingModels && nextLayer.type === "fill-extrusion") {
26173
+ nextLayer.layout = (_a = nextLayer.layout) !== null && _a !== void 0 ? _a : {};
26174
+ nextLayer.layout.visibility = "none";
26175
+ }
26176
+ else if (nextLayer.type === "fill-extrusion") {
26177
+ nextLayer.layout = (_b = nextLayer.layout) !== null && _b !== void 0 ? _b : {};
26178
+ nextLayer.layout.visibility = "visible";
26179
+ }
26180
+ // 2. Set visibility of traffic layers depending on traffic settings.
26181
+ if (trafficOptions.flow !== "none" && layerGroup) {
26182
+ if (layerGroup === "traffic_" + trafficOptions.flow && nextLayer.type == "line") {
26183
+ nextLayer.layout = (_c = nextLayer.layout) !== null && _c !== void 0 ? _c : {};
26184
+ nextLayer.layout.visibility = "visible";
26185
+ }
26186
+ }
26187
+ // 3. Set visibility of labels
26188
+ var isLabelLayerGroup = layerGroup === 'labels' || layerGroup === 'labels_places' || layerGroup === 'labels_indoor';
26189
+ if (isLabelLayerGroup && nextLayer.type === 'symbol') {
26190
+ if (styleOptions.showLabels) {
26191
+ nextLayer.layout = (_d = nextLayer.layout) !== null && _d !== void 0 ? _d : {};
26192
+ nextLayer.layout.visibility = "visible";
26193
+ }
26194
+ else {
26195
+ nextLayer.layout = (_e = nextLayer.layout) !== null && _e !== void 0 ? _e : {};
26196
+ nextLayer.layout.visibility = "none";
26197
+ }
26198
+ }
26199
+ return nextLayer;
26200
+ }) });
26201
+ };
26202
+ StyleManager.prototype.injectUserLayersIntoStyle = function (previousStyle, nextStyle, layerGroupLayers) {
26203
+ // Custom layers added to mapbox through this SDK should be carried over to the next style.
26204
+ return !previousStyle
26205
+ ? nextStyle
26206
+ : this.map.layers._getUserLayers().reduce(function (style, userLayer) {
26207
+ if (userLayer.layer instanceof WebGLLayer) {
26208
+ // mapbox custom layers cannot be serialized and preserved,
26209
+ // return to continue to the next user layer.
26210
+ return style;
26211
+ }
26212
+ var before = layerGroupLayers[userLayer.before] && layerGroupLayers[userLayer.before].length > 0
26213
+ ? layerGroupLayers[userLayer.before][0]
26214
+ : undefined;
26215
+ var layer = previousStyle.layers.find(function (layer) { return layer.id === userLayer.layer.getId(); });
26216
+ // when setStyle diff attempt is unsuccesful, _load will be called on the style that may have already injected user layers -> clean it up
26217
+ var existingLayerIdx = nextStyle.layers.findIndex(function (layer) { return layer.id === userLayer.layer.getId(); });
26218
+ if (existingLayerIdx > -1) {
26219
+ nextStyle.layers.splice(existingLayerIdx, 1);
26220
+ }
26221
+ if (layer) {
26222
+ var sourcesToCopy = new Set(Array.from(userLayer.layer._getSourceIds())
26223
+ .map(function (sourceId) { return previousStyle.sources[sourceId] ? { source: previousStyle.sources[sourceId], id: sourceId } : undefined; })
26224
+ .filter(function (source) { return source !== undefined; }));
26225
+ var insertIdx = before ? style.layers.findIndex(function (layer) { return layer.id === before.id; }) : -1;
26226
+ if (insertIdx > -1) {
26227
+ style.layers.splice(insertIdx, 0, layer);
26228
+ }
26229
+ else {
26230
+ style.layers.push(layer);
26231
+ }
26232
+ sourcesToCopy.forEach(function (_a) {
26233
+ var source = _a.source, id = _a.id;
26234
+ style.sources[id] = source;
26235
+ });
26236
+ }
26237
+ return style;
26238
+ }, __assign({}, nextStyle));
26239
+ };
26132
26240
  /**
26133
26241
  * @internal
26134
26242
  */
26135
26243
  StyleManager.prototype.setStyle = function (styleOptions, diff) {
26244
+ var _this = this;
26136
26245
  if (diff === void 0) { diff = true; }
26137
26246
  try {
26138
26247
  this.map._getMap().setStyle(this.getStyle(styleOptions), {
26139
26248
  diff: diff,
26140
- stylePatch: this._stylePatch.bind(this),
26141
- validate: this.serviceOptions.validateStyle
26249
+ validate: this.serviceOptions.validateStyle,
26250
+ transformStyle: function (previousStyle, nextStyle) {
26251
+ // 1. derive the base new style (without user layers)
26252
+ var targetStyle = _this.deriveNewStyle(previousStyle, nextStyle);
26253
+ // 2. derive layer groups for the new style
26254
+ var layerGroupLayers = targetStyle.layers
26255
+ .map(function (nextLayer) { return ({ nextLayer: nextLayer, layerGroup: LayerGroupComparator.getLayerGroup(nextLayer) }); })
26256
+ .filter(function (_a) {
26257
+ var nextLayer = _a.nextLayer, layerGroup = _a.layerGroup;
26258
+ return layerGroup !== undefined;
26259
+ })
26260
+ .reduce(function (layerGroupLayers, _a) {
26261
+ var _b;
26262
+ var nextLayer = _a.nextLayer, layerGroup = _a.layerGroup;
26263
+ return (__assign(__assign({}, layerGroupLayers), (_b = {}, _b[layerGroup] = layerGroup in layerGroupLayers ? __spread(layerGroupLayers[layerGroup], [nextLayer]) : [nextLayer], _b)));
26264
+ }, {});
26265
+ // 3. copy user layers and sources from previous style into new one
26266
+ var targetStyleWithUserLayers = _this.injectUserLayersIntoStyle(previousStyle, nextStyle, layerGroupLayers);
26267
+ // 4. side effects: sync our control's LayerManager and SourceManager
26268
+ var nextFundamentalLayers = Object.entries(layerGroupLayers).map(function (_a) {
26269
+ var _b = __read(_a, 2), layerGroupId = _b[0], layers = _b[1];
26270
+ return _this._buildFundamentalLayerFrom(layers, layerGroupId);
26271
+ });
26272
+ var layerIndex = _this.map.layers._getUserLayers().reduce(function (layerIndex, userLayer) {
26273
+ var layerInsertIndex = userLayer.before ? layerIndex.findIndex(function (layer) { return layer.getId() === userLayer.before; }) : -1;
26274
+ if (layerInsertIndex > -1) {
26275
+ layerIndex.splice(layerInsertIndex, 0, userLayer.layer);
26276
+ }
26277
+ else {
26278
+ layerIndex.push(userLayer.layer);
26279
+ }
26280
+ return layerIndex;
26281
+ }, nextFundamentalLayers);
26282
+ _this.map.layers['layerIndex'] = layerIndex;
26283
+ _this.map.sources._syncSources(targetStyleWithUserLayers.sources);
26284
+ // 5. temporarily patch style data event
26285
+ // FIXME: below diffing will be soon fixed on the maplibre side
26286
+ // If there was a previous styledata change event attached, remove it.
26287
+ // When the sprite url changes between style changes then maplibre can't perform the diff
26288
+ // In such cases it recalculate the style again. Removing previous attached
26289
+ // event listener makes sure that style changed event is not fired twice in these cases.
26290
+ _this.map.events.remove("styledata", _this._onStyleData);
26291
+ _this.map.events.addOnce("styledata", _this._onStyleData);
26292
+ return targetStyleWithUserLayers;
26293
+ }
26142
26294
  });
26143
26295
  }
26144
26296
  catch (e) {
@@ -26208,145 +26360,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26208
26360
  StyleManager.prototype.clearStyleSet = function () {
26209
26361
  this.unsetIndoorState();
26210
26362
  };
26211
- /**
26212
- * Function invoked by mapbox after a style is fetched but before it is committed to the map state.
26213
- *
26214
- * @param previousStyle The current style.
26215
- * @param nextStyle The next style which is to be applied.
26216
- * @param preserveLayer Preserve a layer from the previous style in the next style.
26217
- * @param updatePaintProperty Modify paint properties of a layer in the next style before the style is applied.
26218
- * @param updateLayoutProperty Modify layout properties of a layer in the next style before the style is applied.
26219
- * @param updateFilter Modify filter property of a layer in the next style before the style is applied.
26220
- */
26221
- StyleManager.prototype._stylePatch = function (previousStyle, nextStyle, preserveLayer, updatePaintProperty, updateLayoutProperty, updateFilter) {
26222
- var _this = this;
26223
- // Layers in the next style with default properties that do not align with current StyleOptions
26224
- // should be modified before they are applied to the map.
26225
- var styleOptions = this.map.getStyle();
26226
- var trafficOptions = this.map.getTraffic();
26227
- // force a replacement of language placeholder in the tileset url to avoid resolution to a same cache with placeholders on language change
26228
- nextStyle.sources = Object.entries(nextStyle.sources).reduce(function (newSources, _a) {
26229
- var _b = __read(_a, 2), sourceKey = _b[0], source = _b[1];
26230
- var newSource = __assign({}, source);
26231
- if ('url' in newSource && typeof newSource.url === 'string') {
26232
- if (newSource.url.includes(constants.languagePlaceHolder)) {
26233
- newSource.url = newSource.url.replace(constants.languagePlaceHolder, styleOptions.language);
26234
- }
26235
- }
26236
- newSources[sourceKey] = newSource;
26237
- return newSources;
26238
- }, {});
26239
- // A FundamentalMapLayer (grouped layer) representation of the next style must be built.
26240
- var previousLayers = this.map.layers.getLayers();
26241
- var nextLayers = [];
26242
- var layerGroupLayers = {};
26243
- nextStyle.layers.forEach(function (nextLayer) {
26244
- var _a, _b, _c, _d, _e;
26245
- var layerGroup = LayerGroupComparator.getLayerGroup(nextLayer);
26246
- if (layerGroup) {
26247
- // Set visiblity of fill-extrusion layers according to StyleOptions.showBuildingModels
26248
- if (!styleOptions.showBuildingModels && nextLayer.type === "fill-extrusion") {
26249
- updateLayoutProperty(nextLayer.id, "visibility", "none");
26250
- nextLayer.layout = (_a = nextLayer.layout) !== null && _a !== void 0 ? _a : {};
26251
- nextLayer.layout.visibility = "none";
26252
- }
26253
- else if (nextLayer.type === "fill-extrusion") {
26254
- updateLayoutProperty(nextLayer.id, "visibility", "visible");
26255
- nextLayer.layout = (_b = nextLayer.layout) !== null && _b !== void 0 ? _b : {};
26256
- nextLayer.layout.visibility = "visible";
26257
- }
26258
- // Set visibility of traffic layers depending on traffic settings.
26259
- if (trafficOptions.flow !== "none" && layerGroup) {
26260
- if (layerGroup === "traffic_" + trafficOptions.flow && nextLayer.type == "line") {
26261
- updateLayoutProperty(nextLayer.id, "visibility", "visible");
26262
- nextLayer.layout = (_c = nextLayer.layout) !== null && _c !== void 0 ? _c : {};
26263
- nextLayer.layout.visibility = "visible";
26264
- }
26265
- }
26266
- // Set visibility of labels
26267
- var isLabelLayerGroup = layerGroup === 'labels' || layerGroup === 'labels_places' || layerGroup === 'labels_indoor';
26268
- if (isLabelLayerGroup && nextLayer.type === 'symbol') {
26269
- if (styleOptions.showLabels) {
26270
- updateLayoutProperty(nextLayer.id, "visibility", "visible");
26271
- nextLayer.layout = (_d = nextLayer.layout) !== null && _d !== void 0 ? _d : {};
26272
- nextLayer.layout.visibility = "visible";
26273
- }
26274
- else {
26275
- updateLayoutProperty(nextLayer.id, "visibility", "none");
26276
- nextLayer.layout = (_e = nextLayer.layout) !== null && _e !== void 0 ? _e : {};
26277
- nextLayer.layout.visibility = "none";
26278
- }
26279
- }
26280
- // Once this _stylePatch returns control to maplibre the next style will be applied immediately in the same context.
26281
- // To avoid potential data races update LayerManager with new a new set of FundamentalMapLayers from here instead of
26282
- // waiting for a styledata.load event to trigger a sync in a different context.
26283
- if (layerGroupLayers[layerGroup]) {
26284
- layerGroupLayers[layerGroup].push(nextLayer);
26285
- }
26286
- else {
26287
- layerGroupLayers[layerGroup] = [nextLayer];
26288
- }
26289
- }
26290
- });
26291
- Object.entries(layerGroupLayers).forEach(function (_a) {
26292
- var _b = __read(_a, 2), layerGroupId = _b[0], layerGroupMapboxLayers = _b[1];
26293
- nextLayers.push(_this._buildFundamentalLayerFrom(layerGroupMapboxLayers, layerGroupId));
26294
- });
26295
- // Update FundamentalMapLayers in LayerManager
26296
- var userLayers = this.map.layers._getUserLayers();
26297
- var firstUserLayer = userLayers[0];
26298
- var layersToRemove = previousLayers.filter(function (c) {
26299
- return (nextLayers.findIndex(function (n) { return c.getId() === n.getId(); }) < 0 &&
26300
- userLayers.findIndex(function (n) { return c.getId() === n.layer.getId(); }) < 0);
26301
- });
26302
- var prevNextIntersection = nextLayers.filter(function (n) { return previousLayers.find(function (c) { return c.getId() === n.getId(); }); });
26303
- var ePrevNextIntersection = prevNextIntersection.entries();
26304
- var replace = ePrevNextIntersection.next();
26305
- nextLayers.forEach(function (newFundamentalLayer) {
26306
- if (replace.value && replace.value[1].getId() === newFundamentalLayer.getId()) {
26307
- // Replace the existing layer with this ID with the new one.
26308
- var insertBefore = previousLayers.findIndex(function (l) { return l.getId() === newFundamentalLayer.getId(); });
26309
- _this.map.layers.remove(newFundamentalLayer.getId());
26310
- _this.map.layers.add(newFundamentalLayer, previousLayers[insertBefore].getId());
26311
- replace = ePrevNextIntersection.next();
26312
- }
26313
- else {
26314
- if (replace.value) {
26315
- // Insert new layer before the next common layer.
26316
- _this.map.layers.add(newFundamentalLayer, replace.value[1]);
26317
- }
26318
- else {
26319
- // Insert new layer underneath the first user layer, or the .
26320
- _this.map.layers.add(newFundamentalLayer, firstUserLayer === null || firstUserLayer === void 0 ? void 0 : firstUserLayer.layer);
26321
- }
26322
- }
26323
- });
26324
- layersToRemove.forEach(function (layer) {
26325
- _this.map.layers.remove(layer);
26326
- });
26327
- // Layers added to mapbox through this SDK since loading the last style should be
26328
- // carried over to the next style.
26329
- userLayers.forEach(function (userLayer) {
26330
- if (userLayer.layer instanceof WebGLLayer) {
26331
- // mapbox custom layers cannot be serialized and preserved,
26332
- // return to continue to the next user layer.
26333
- return;
26334
- }
26335
- var before = undefined;
26336
- if (_this.map.layers.getLayerById(userLayer.before)) {
26337
- var beforeCandidates = _this.map.layers.getLayerById(userLayer.before)._buildLayers();
26338
- before = (beforeCandidates.length > 0) ? beforeCandidates[0] : undefined;
26339
- }
26340
- preserveLayer(userLayer.layer.getId(), before === null || before === void 0 ? void 0 : before.id);
26341
- });
26342
- this.map.sources._syncSources(nextStyle.sources);
26343
- // If there was a previous styledata change event attached, remove it.
26344
- // When the sprite url changes between style changes then mapbox can't perform the diff
26345
- // In such cases it recalculate the style again. Removing previous attached
26346
- // event listener makes sure that style changed event is not fired twice in these cases.
26347
- this.map.events.remove("styledata", this._onStyleData);
26348
- this.map.events.addOnce("styledata", this._onStyleData);
26349
- };
26350
26363
  StyleManager.prototype._buildFundamentalLayerFrom = function (layers, id) {
26351
26364
  if (layers && layers.length > 0) {
26352
26365
  var newLayer = new FundamentalMapLayer(layers, id);
@@ -26518,10 +26531,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26518
26531
  if (_this.serviceOptions.transformRequest) {
26519
26532
  merge_1(requestParams, _this.serviceOptions.transformRequest(requestParams.url, resourceType));
26520
26533
  }
26534
+ // TODO: fix type variation
26521
26535
  return requestParams;
26522
26536
  }
26523
26537
  };
26524
- mapboxMap = new mapboxgl__default.Map(mapboxMapOptions);
26538
+ mapboxMap = new maplibregl.Map(mapboxMapOptions);
26525
26539
  }
26526
26540
  try {
26527
26541
  _this.map = mapboxMap;
@@ -26689,6 +26703,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26689
26703
  */
26690
26704
  Map.prototype.removeRequestTransformer = function (transformer) { this.serviceOptions.removeTransformer(transformer); };
26691
26705
  Map.prototype.setCamera = function (options, fromControl) {
26706
+ var _a;
26692
26707
  if (fromControl === void 0) { fromControl = false; }
26693
26708
  var mapboxCameraOptions;
26694
26709
  var maxBounds;
@@ -26697,13 +26712,22 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26697
26712
  var cameraBoundsOptions = new CameraBoundsOptions()
26698
26713
  .merge({ maxZoom: this.getCamera().maxZoom }, options);
26699
26714
  var bounds = this._generateSafeBounds(cameraBoundsOptions.bounds);
26700
- mapboxCameraOptions = this.map.cameraForBounds(bounds, {
26715
+ var cameraForBoundsOptions = {
26701
26716
  padding: cameraBoundsOptions.padding,
26702
26717
  offset: cameraBoundsOptions.offset,
26703
26718
  maxZoom: cameraBoundsOptions.maxZoom
26704
- });
26719
+ };
26720
+ mapboxCameraOptions = this.map.cameraForBounds(bounds, cameraForBoundsOptions);
26705
26721
  if (!mapboxCameraOptions) {
26706
- throw new Error("The map cannot be fit to the current canvas with the given CameraBoundsOptions.");
26722
+ var currentContainer = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getContainer();
26723
+ var errorDetails = {
26724
+ message: "The map cannot be fit to the current canvas with the given CameraBoundsOptions.",
26725
+ containerWidth: currentContainer === null || currentContainer === void 0 ? void 0 : currentContainer.clientWidth,
26726
+ containerHeight: currentContainer === null || currentContainer === void 0 ? void 0 : currentContainer.clientHeight,
26727
+ safeBounds: bounds,
26728
+ cameraForBoundsOptions: cameraForBoundsOptions
26729
+ };
26730
+ throw new Error(JSON.stringify(errorDetails));
26707
26731
  }
26708
26732
  this.map.setMaxZoom(cameraBoundsOptions.maxZoom);
26709
26733
  this._invokeEvent("maxzoomchanged", this.map.getMaxZoom());
@@ -28266,7 +28290,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
28266
28290
  domain: env.staticAssetsDomain,
28267
28291
  path: "sdk/javascript/mapcontrol/" + Version.getEndpointVersion() + "/mapbox-gl-rtl-text.min.js"
28268
28292
  });
28269
- mapboxgl.setRTLTextPlugin(rtlPluginUrl.toString(), function (error) {
28293
+ maplibregl.setRTLTextPlugin(rtlPluginUrl.toString(), function (error) {
28270
28294
  if (error) {
28271
28295
  console.warn(error);
28272
28296
  }