azure-maps-control 2.1.16 → 2.1.17

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.
@@ -72,6 +72,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
72
72
  apiVersionQueryParameter: "api-version",
73
73
  authorizationHeaderName: "Authorization",
74
74
  authorizationTokenPrefix: "Bearer ",
75
+ jwtSasPrefix: "jwt-sas ",
75
76
  domainPlaceHolder: "{{azMapsDomain}}",
76
77
  legacyDomainPlaceHolder: "{azMapsDomain}",
77
78
  viewPlaceHolder: "{{azMapsView}}",
@@ -342,7 +343,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
342
343
  return Url;
343
344
  }());
344
345
 
345
- var version = "2.1.16";
346
+ var version = "2.1.17";
346
347
 
347
348
  /**
348
349
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -700,7 +701,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
700
701
  delete this._container;
701
702
  }
702
703
  if (this._map) {
703
- this._map.events.remove("styledata", this._onStyleChange);
704
+ this._map.events.remove("stylechanged", this._onStyleChange);
704
705
  delete this._map;
705
706
  }
706
707
  if (this._observer) {
@@ -724,7 +725,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
724
725
  if (style.toLowerCase() === exports.ControlStyle.auto) {
725
726
  this._map.styles.definitions().then(function (definitions) {
726
727
  if (_this._map) {
727
- _this._map.events.add("styledata", _this._onStyleChange);
728
+ _this._map.events.add("stylechanged", _this._onStyleChange);
728
729
  }
729
730
  });
730
731
  }
@@ -837,6 +838,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
837
838
  }
838
839
  }
839
840
  });
841
+ // Keep the focus on this control when esc key is pressed on the grid
842
+ grid.addEventListener("keydown", function (event) {
843
+ if (event.key === "Escape" || event.key === "Esc") {
844
+ event.stopPropagation();
845
+ rotationButton.focus();
846
+ container.classList.remove("in-use");
847
+ grid.classList.add("hidden-accessible-element");
848
+ }
849
+ });
840
850
  // If the control's position will require inverting the element order
841
851
  // add them in the opposite order to preserve tabindex.
842
852
  if (options && CompassControl.InvertOrderPositions.includes(options.position)) {
@@ -984,6 +994,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
984
994
  var _this = _super.call(this) || this;
985
995
  _this.container = null;
986
996
  _this.map = null;
997
+ _this.pitchButton = null;
987
998
  _this.pitchIncrementButton = null;
988
999
  _this.pitchDecrementButton = null;
989
1000
  _this.hasMouse = false;
@@ -992,6 +1003,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
992
1003
  _this.updatePitchButtonsState = function () {
993
1004
  var minPitchReached = _this.map.getCamera().pitch <= 0;
994
1005
  var maxPitchReached = _this.map.getCamera().pitch >= 60;
1006
+ // Keep the focus on this control when max/min pitch is reached
1007
+ if (_this.hasFocus && _this.pitchButton && (minPitchReached || maxPitchReached)) {
1008
+ _this.pitchButton.focus();
1009
+ }
995
1010
  if (_this.options.inverted) {
996
1011
  if (_this.pitchIncrementButton && _this.pitchIncrementButton.disabled != minPitchReached) {
997
1012
  _this.pitchIncrementButton.disabled = minPitchReached;
@@ -1054,6 +1069,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
1054
1069
  }
1055
1070
  }
1056
1071
  });
1072
+ // Keep the focus on this control when esc key is pressed on the grid
1073
+ grid.addEventListener("keydown", function (event) {
1074
+ if (event.key === "Escape" || event.key === "Esc") {
1075
+ event.stopPropagation();
1076
+ pitchButton.focus();
1077
+ container.classList.remove("in-use");
1078
+ grid.classList.add("hidden-accessible-element");
1079
+ }
1080
+ });
1057
1081
  // If the control's position will require inverting the element order
1058
1082
  // add them in the opposite order to preserve tabindex.
1059
1083
  if (options && PitchControl.INVERT_ORDER_POSITIONS.includes(options.position)) {
@@ -1070,6 +1094,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
1070
1094
  }
1071
1095
  this.map = map;
1072
1096
  this.container = container;
1097
+ this.pitchButton = pitchButton;
1073
1098
  map.events.add('pitch', this.pitchChanged);
1074
1099
  this.updatePitchButtonsState();
1075
1100
  return container;
@@ -1078,6 +1103,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
1078
1103
  if (this.container) {
1079
1104
  this.container.remove();
1080
1105
  this.container = null;
1106
+ this.pitchButton = null;
1081
1107
  this.pitchIncrementButton = null;
1082
1108
  this.pitchDecrementButton = null;
1083
1109
  }
@@ -4450,7 +4476,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4450
4476
  _super.prototype.onRemove.call(this);
4451
4477
  this.styleOpsGrid = null;
4452
4478
  this.styleButtons.clear();
4453
- this.map.events.remove("styledata", this.onStyleChange);
4479
+ this.map.events.remove("stylechanged", this.onStyleChange);
4454
4480
  this.map.events.remove("stylesetchanged", this.onStylesetChange);
4455
4481
  };
4456
4482
  /**
@@ -4505,7 +4531,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4505
4531
  var _this = this;
4506
4532
  var styleOptionButton = document.createElement("button");
4507
4533
  var friendlyName = this.mapToFriendlyStyleName(name, styleset);
4508
- styleOptionButton.setAttribute("alt", friendlyName);
4534
+ styleOptionButton.setAttribute("aria-label", friendlyName);
4509
4535
  styleOptionButton.setAttribute("type", "button");
4510
4536
  var styleIconImage = new Image();
4511
4537
  fetchIconPromise
@@ -4525,9 +4551,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4525
4551
  }
4526
4552
  _this.styleIcons.set(name, iconUrl);
4527
4553
  });
4528
- if (this.options.layout === "icons") {
4529
- styleIconImage.alt = friendlyName;
4530
- }
4554
+ styleIconImage.setAttribute("aria-hidden", "true");
4531
4555
  styleOptionButton.appendChild(styleIconImage);
4532
4556
  if (this.options.layout === "icons") {
4533
4557
  styleOptionButton.classList.add(StyleControl.Css.button);
@@ -4567,7 +4591,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4567
4591
  }
4568
4592
  selectCurrButton.classList.add(StyleControl.Css.currentStyle);
4569
4593
  selectCurrButton.setAttribute("aria-label", "Select Style");
4570
- selectCurrButton.setAttribute("alt", "Select Style");
4571
4594
  selectCurrButton.setAttribute("tabindex", "-1");
4572
4595
  this.currStyleImage = new Image();
4573
4596
  selectCurrButton.appendChild(this.currStyleImage);
@@ -4593,7 +4616,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4593
4616
  this.map.styles.definitions().then(function (definitions) { return __awaiter(_this, void 0, void 0, function () {
4594
4617
  return __generator(this, function (_a) {
4595
4618
  this.onStylesetChange(definitions);
4596
- this.map.events.add("styledata", this.onStyleChange);
4619
+ this.map.events.add("stylechanged", this.onStyleChange);
4597
4620
  return [2 /*return*/];
4598
4621
  });
4599
4622
  }); });
@@ -4843,6 +4866,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4843
4866
  _this.table = ["Fast",
4844
4867
  ["green", "yellow", "red", "dark-red"],
4845
4868
  "Slow"];
4869
+ _this.map = null;
4870
+ _this.syncHiddenState = null;
4846
4871
  return _this;
4847
4872
  }
4848
4873
  /**
@@ -4852,11 +4877,21 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4852
4877
  * @return An HTMLElement to be placed on the map for the control.
4853
4878
  */
4854
4879
  TrafficLegendControl.prototype.onAdd = function (map) {
4880
+ this.map = map;
4855
4881
  var container = this.buildContainer(map, exports.ControlStyle.auto, "Traffic Legend");
4856
4882
  var TrafficLegendDiv = this.buildTrafficLegendDiv(map);
4883
+ container.setAttribute("role", "definition");
4857
4884
  container.appendChild(TrafficLegendDiv);
4858
4885
  return container;
4859
4886
  };
4887
+ TrafficLegendControl.prototype.onRemove = function () {
4888
+ _super.prototype.onRemove.call(this);
4889
+ if (this.syncHiddenState) {
4890
+ this.map.events.remove('styledata', this.syncHiddenState);
4891
+ this.syncHiddenState = null;
4892
+ }
4893
+ this.map = null;
4894
+ };
4860
4895
  TrafficLegendControl.prototype.buildTrafficLegendDiv = function (map) {
4861
4896
  var e_1, _a, e_2, _b;
4862
4897
  var trafficLegend = document.createElement("div");
@@ -4921,8 +4956,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4921
4956
  }
4922
4957
  trafficLegendTable.appendChild(tr2);
4923
4958
  trafficLegend.appendChild(trafficLegendTable);
4924
- // display legend when the traffic flow is shown, hide it otherwise
4925
- map.events.add("styledata", function (eventData) {
4959
+ this.syncHiddenState = function (eventData) {
4926
4960
  if (eventData.dataType === "style") {
4927
4961
  var trafficOptions = map.getTraffic();
4928
4962
  if (trafficOptions.flow && trafficOptions.flow !== "none") {
@@ -4932,7 +4966,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4932
4966
  trafficLegend.classList.add("hidden");
4933
4967
  }
4934
4968
  }
4935
- });
4969
+ };
4970
+ // display legend when the traffic flow is shown, hide it otherwise
4971
+ this.syncHiddenState({ dataType: 'style' });
4972
+ map.events.add("styledata", this.syncHiddenState);
4936
4973
  return trafficLegend;
4937
4974
  };
4938
4975
  return TrafficLegendControl;
@@ -12763,6 +12800,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
12763
12800
  // They must use setOptions(...).
12764
12801
  return cloneDeepWith_1(this.options, PopupOptions._cloneCustomizer);
12765
12802
  };
12803
+ /**
12804
+ * Returns popup container element.
12805
+ */
12806
+ Popup.prototype.getPopupContainer = function () {
12807
+ return this.containerDiv;
12808
+ };
12766
12809
  /**
12767
12810
  * Drags the popup to the specified pixel.
12768
12811
  * Accounts for the pixel offset when dragging started.
@@ -13792,6 +13835,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13792
13835
  * Literal value `"anonymous"`
13793
13836
  */
13794
13837
  AuthenticationType["anonymous"] = "anonymous";
13838
+ /**
13839
+ * The shared access signature authentication mechanism. Allows a callback responsible for acquiring a token to be provided on requests.
13840
+ * Literal value `"sas"`.
13841
+ */
13842
+ AuthenticationType["sas"] = "sas";
13795
13843
  })(exports.AuthenticationType || (exports.AuthenticationType = {}));
13796
13844
  /**
13797
13845
  * Options for specifying how the map control should authenticate with the Azure Maps services.
@@ -13831,11 +13879,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13831
13879
  */
13832
13880
  _this.aadInstance = undefined;
13833
13881
  /**
13834
- * A callback to use with the anonymous authentication mechanism.
13882
+ * A callback to use with the anonymous/sas authentication mechanism.
13835
13883
  * This callback will be responsible for resolving to a authentication token.
13836
13884
  * E.g. fetching a CORS protected token from an endpoint.
13837
13885
  */
13838
13886
  _this.getToken = undefined;
13887
+ /**
13888
+ * Optionally provide an initial token for sas authentication.
13889
+ */
13890
+ _this.sasToken = undefined;
13839
13891
  /**
13840
13892
  * Optionally provide an existing `AuthenticationContext` from the ADAL.js library.
13841
13893
  * This authentication context will be used to acquire the AAD token.
@@ -13878,6 +13930,14 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13878
13930
  this.authType = exports.AuthenticationType.anonymous;
13879
13931
  this.getToken = getTokenCallback;
13880
13932
  };
13933
+ /**
13934
+ * Sets the required options to configure the sas authentication method.
13935
+ * @param getTokenCallback Callback function responsible for resolving to an authentication token.
13936
+ */
13937
+ AuthenticationOptions.prototype.setSasCallbackFunction = function (getTokenCallback) {
13938
+ this.authType = exports.AuthenticationType.sas;
13939
+ this.getToken = getTokenCallback;
13940
+ };
13881
13941
  /**
13882
13942
  * Override the standard merge behavior to handle mutually exclusive options.
13883
13943
  * @internal
@@ -13897,6 +13957,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
13897
13957
  else if (merged.authType === exports.AuthenticationType.anonymous) {
13898
13958
  merged.subscriptionKey = merged.authContext = merged.aadAppId = undefined;
13899
13959
  }
13960
+ else if (merged.authType === exports.AuthenticationType.sas) {
13961
+ merged.authContext = merged.subscriptionKey = merged.aadAppId = undefined;
13962
+ }
13900
13963
  return merged;
13901
13964
  };
13902
13965
  return AuthenticationOptions;
@@ -14623,7 +14686,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
14623
14686
  path: "search/address/reverse/json",
14624
14687
  queryParams: __assign({ "api-version": "1.0", "language": options.style.language, "limit": 1, "query": normalizeLatitude(options.position[1]) + "," + normalizeLongitude(options.position[0]) }, (options.style.view && { view: options.style.view }))
14625
14688
  };
14626
- return new Url((_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.signRequest(urlOptions)).get();
14689
+ return new Url(((_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.signRequest(urlOptions)) || urlOptions).get();
14627
14690
  };
14628
14691
  return NearbyGeographySearchService;
14629
14692
  }());
@@ -15827,8 +15890,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15827
15890
  _this.createMapKeyBindingInfo();
15828
15891
  _this.map.getMapContainer().setAttribute("role", "application");
15829
15892
  _this.map.getMapContainer().setAttribute("aria-label", "Map Application");
15893
+ _this.map.getCanvasContainer().setAttribute("aria-live", "polite");
15894
+ _this.map.getCanvasContainer().setAttribute("aria-describedby", "atlas-map-state atlas-map-style");
15830
15895
  _this.map.getCanvas().setAttribute("aria-label", "Interactive Map");
15831
- _this.map.getCanvas().setAttribute("aria-describedby", "atlas-map-state atlas-map-style atlas-map-shortcuts");
15896
+ _this.map.getCanvas().setAttribute("aria-describedby", "atlas-map-shortcuts");
15832
15897
  _this.map.getCanvas().setAttribute("alt", "Interactive Map");
15833
15898
  };
15834
15899
  this.removeFromMap = function () {
@@ -15850,10 +15915,12 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15850
15915
  delete _this.atlasMapStyleInfo;
15851
15916
  _this.map.getMapContainer().removeAttribute("role");
15852
15917
  _this.map.getMapContainer().removeAttribute("aria-label");
15918
+ _this.map.getCanvasContainer().removeAttribute("aria-live");
15919
+ _this.map.getCanvasContainer().removeAttribute("aria-describedby");
15853
15920
  _this.map.getCanvas().removeAttribute("aria-label");
15854
15921
  _this.map.getCanvas().removeAttribute("aria-describedby");
15855
15922
  _this.map.getCanvas().removeAttribute("alt");
15856
- _this.map.events.remove("styledata", _this.updateMapStyle);
15923
+ _this.map.events.remove("stylechanged", _this.updateMapStyle);
15857
15924
  };
15858
15925
  this.createMapKeyBindingInfo = function () {
15859
15926
  _this.atlasMapKeyBindings = document.createElement("div");
@@ -15878,7 +15945,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15878
15945
  "Jump focus to the map: Escape."
15879
15946
  ].join("\n");
15880
15947
  _this.map.getCanvasContainer().appendChild(_this.atlasMapKeyBindings);
15881
- _this.atlasMapKeyBindings.setAttribute("aria-live", "polite");
15882
15948
  var baseShortcutKeyCodes = [
15883
15949
  // - (zoom out)
15884
15950
  189,
@@ -15910,7 +15976,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15910
15976
  _this.atlasMapLiveStateInfo.id = "atlas-map-state";
15911
15977
  _this.atlasMapLiveStateInfo.classList.add("hidden-accessible-element");
15912
15978
  _this.map.getCanvasContainer().appendChild(_this.atlasMapLiveStateInfo);
15913
- _this.atlasMapLiveStateInfo.setAttribute("aria-live", "assertive");
15914
15979
  }
15915
15980
  };
15916
15981
  this.initializeMapStyleInfo = function () {
@@ -15919,10 +15984,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
15919
15984
  _this.atlasMapStyleInfo.setAttribute("aria-hidden", "true");
15920
15985
  _this.atlasMapStyleInfo.id = "atlas-map-style";
15921
15986
  _this.atlasMapStyleInfo.classList.add("hidden-accessible-element");
15922
- _this.updateMapStyle();
15923
- _this.map.events.add("styledata", _this.updateMapStyle);
15987
+ _this.map.events.add("stylechanged", _this.updateMapStyle);
15924
15988
  _this.map.getCanvasContainer().appendChild(_this.atlasMapStyleInfo);
15925
- _this.atlasMapStyleInfo.setAttribute("aria-live", "polite");
15926
15989
  };
15927
15990
  this.updateMapStyle = function () {
15928
15991
  _this.atlasMapStyleInfo.innerHTML = "<p>Map style: " + _this.map.getStyle().style + ".</p>";
@@ -16220,15 +16283,106 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16220
16283
  _this.map.layers.add(_this.incidentLayer, "labels");
16221
16284
  }
16222
16285
  //Create a popup but leave it closed so we can update it and display it later.
16223
- _this.popup = new Popup({
16286
+ _this.clickPopup = new Popup({
16224
16287
  position: [0, 0],
16225
16288
  pixelOffset: [0, -18]
16226
16289
  });
16227
16290
  _this.map.addEventListener("mouseover", _this.incidentLayerName, _this.cursorToPointer);
16228
16291
  _this.map.addEventListener("mouseleave", _this.incidentLayerName, _this.cursorToDefault);
16229
16292
  _this.map.addEventListener("click", _this.incidentLayerName, _this.openIncidentPopup);
16293
+ _this.map.events.addOnce('idle', _this.setAccessiblePopups);
16294
+ _this.map.events.add('moveend', _this.setAccessiblePopups);
16230
16295
  };
16296
+ this.accessiblePopups = [];
16297
+ this.setAccessiblePopups = function () { return __awaiter(_this, void 0, void 0, function () {
16298
+ var features, localizedStrings, createPopup, insertHiddenBefore, insertHiddenInFront, addHidden;
16299
+ var _this = this;
16300
+ return __generator(this, function (_a) {
16301
+ switch (_a.label) {
16302
+ case 0:
16303
+ this.accessiblePopups.forEach(function (popup) { return popup.remove(); });
16304
+ this.accessiblePopups = [];
16305
+ features = this.map.layers.getRenderedShapes(this.map.getCamera().bounds, this.incidentLayer);
16306
+ return [4 /*yield*/, this.map._getLocalizedStrings()];
16307
+ case 1:
16308
+ localizedStrings = _a.sent();
16309
+ createPopup = function (features, idx) {
16310
+ var incidentFeature = features[idx];
16311
+ var incidentPosition = incidentFeature.geometry.coordinates;
16312
+ var point = new Point(new Position(incidentPosition[0], incidentPosition[1]));
16313
+ var incident = new Incident(incidentFeature.properties, point, localizedStrings);
16314
+ var popup = IncidentPopupFactory.build(incident, _this.incidentLanguage);
16315
+ var element = popup.getPopupContainer();
16316
+ element.addEventListener('focusin', function (event) {
16317
+ // side effects: clear other managed popups
16318
+ _this.clickPopup.remove();
16319
+ _this.accessiblePopups.filter(function (p) { return p !== popup; }).forEach(function (popup) { return popup.remove(); });
16320
+ // insert previous and next popups
16321
+ if (idx - 1 >= 0) {
16322
+ insertHiddenBefore(popup, createPopup(features, idx - 1));
16323
+ }
16324
+ if (idx + 1 < features.length) {
16325
+ addHidden(createPopup(features, idx + 1));
16326
+ }
16327
+ // if we are on boundaries: add the first / last popup
16328
+ // to maintain popups on full page navigation cycle
16329
+ if (idx >= 2 && idx == features.length - 1) {
16330
+ insertHiddenInFront(createPopup(features, 0));
16331
+ }
16332
+ if (idx == 0 && features.length >= 2) {
16333
+ addHidden(createPopup(features, features.length - 1));
16334
+ }
16335
+ });
16336
+ if (idx == features.length - 1) {
16337
+ element.addEventListener('focusout', function (event) {
16338
+ // close the popup if we detect the focus moving away from the page (relatedTarget === null)
16339
+ // (will remain open otherwise)
16340
+ if (event.relatedTarget === null) {
16341
+ popup.close();
16342
+ }
16343
+ });
16344
+ }
16345
+ _this.accessiblePopups.push(popup);
16346
+ return popup;
16347
+ };
16348
+ insertHiddenBefore = function (base, toInsert) {
16349
+ toInsert.open(_this.map);
16350
+ toInsert.close();
16351
+ var containerToSwapIn = toInsert.getPopupContainer();
16352
+ var baseContainer = base.getPopupContainer();
16353
+ baseContainer.parentElement.insertBefore(containerToSwapIn, baseContainer);
16354
+ };
16355
+ insertHiddenInFront = function (toInsert) {
16356
+ toInsert.open(_this.map);
16357
+ toInsert.close();
16358
+ var containerToSwapIn = toInsert.getPopupContainer();
16359
+ var parent = containerToSwapIn.parentElement;
16360
+ parent.insertBefore(containerToSwapIn, parent.firstElementChild);
16361
+ };
16362
+ addHidden = function (popup) {
16363
+ popup.open(_this.map);
16364
+ popup.close();
16365
+ };
16366
+ if (features.length > 0) {
16367
+ addHidden(createPopup(features, 0));
16368
+ }
16369
+ if (features.length > 1) {
16370
+ addHidden(createPopup(features, features.length - 1));
16371
+ }
16372
+ return [2 /*return*/];
16373
+ }
16374
+ });
16375
+ }); };
16231
16376
  this.removeFromMap = function () {
16377
+ var _a;
16378
+ _this.map.removeEventListener("mouseover", _this.incidentLayerName, _this.cursorToPointer);
16379
+ _this.map.removeEventListener("mouseleave", _this.incidentLayerName, _this.cursorToDefault);
16380
+ _this.map.removeEventListener("click", _this.incidentLayerName, _this.openIncidentPopup);
16381
+ _this.map.events.remove('idle', _this.setAccessiblePopups);
16382
+ _this.map.events.remove('moveend', _this.setAccessiblePopups);
16383
+ _this.accessiblePopups.forEach(function (popup) { return popup.remove(); });
16384
+ _this.accessiblePopups = [];
16385
+ (_a = _this.clickPopup) === null || _a === void 0 ? void 0 : _a.remove();
16232
16386
  if (_this.map.layers.getLayerById(_this.incidentLayerName) != null) {
16233
16387
  _this.map.layers.remove(_this.incidentLayerName);
16234
16388
  }
@@ -16243,14 +16397,22 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
16243
16397
  _this.map.getCanvas().style.cursor = "";
16244
16398
  };
16245
16399
  this.openIncidentPopup = function (data) {
16246
- _this.popup.remove();
16400
+ _this.clickPopup.remove();
16401
+ _this.accessiblePopups.forEach(function (popup) { return popup.close(); });
16247
16402
  var incidentPosition = data.position;
16248
16403
  var incidentFeature = data.features[0];
16249
16404
  _this.map._getLocalizedStrings().then(function (localizedStrings) {
16250
16405
  var point = new Point(new Position(incidentPosition[0], incidentPosition[1]));
16251
16406
  var incident = new Incident(incidentFeature.properties, point, localizedStrings);
16252
- _this.popup = IncidentPopupFactory.build(incident, _this.incidentLanguage);
16253
- _this.popup.open(_this.map);
16407
+ _this.clickPopup = IncidentPopupFactory.build(incident, _this.incidentLanguage);
16408
+ _this.clickPopup.open(_this.map);
16409
+ var element = _this.clickPopup.getPopupContainer();
16410
+ // ensures popup is closed on tabbing when the focus is moved away from the window
16411
+ element.addEventListener('focusout', function (event) {
16412
+ if (event.relatedTarget === null) {
16413
+ _this.clickPopup.close();
16414
+ }
16415
+ });
16254
16416
  });
16255
16417
  };
16256
16418
  this.map = map;
@@ -21958,17 +22120,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21958
22120
  * Triggers the user provided function to fetch the token and stores it.
21959
22121
  * @internal
21960
22122
  */
21961
- this._triggerTokenFetch = function () {
22123
+ this._triggerTokenFetch = function (isAnonymousAuth) {
22124
+ if (isAnonymousAuth === void 0) { isAnonymousAuth = false; }
21962
22125
  return new Promise(function (resolve, reject) {
22126
+ if (typeof _this.options.getToken !== "function") {
22127
+ reject(new Error("Token cannot be " + (isAnonymousAuth ? 'fetched' : 'renewed') + " because getToken was not set or is not a function."));
22128
+ return;
22129
+ }
21963
22130
  _this.options.getToken(function (token) {
21964
22131
  try {
21965
22132
  // Try to get the timeout first as this will guarantee the token is correctly formatted.
21966
22133
  var timeout = _this._getTokenExpiry(token) - AuthenticationManager.constants.tokenRefreshClockSkew;
21967
- _this._storeAccessToken(token);
21968
- clearTimeout(_this.tokenTimeOutHandle); // Clear the previous refresh timeout in case it hadn't triggered yet.
21969
- // @ts-ignore
21970
- // tslint:disable-next-line: no-string-based-set-timeout
21971
- _this.tokenTimeOutHandle = setTimeout(_this._triggerTokenFetch, timeout * 1000);
22134
+ _this._storeToken(token);
22135
+ _this._setTimeoutTokenFetch(timeout);
21972
22136
  resolve();
21973
22137
  }
21974
22138
  catch (_a) {
@@ -21979,6 +22143,18 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
21979
22143
  }, _this.map);
21980
22144
  });
21981
22145
  };
22146
+ /**
22147
+ * Create a timer to trigger the user provided function to fetch the token.
22148
+ * @param seconds delay in seconds
22149
+ * @internal
22150
+ */
22151
+ this._setTimeoutTokenFetch = function (seconds) {
22152
+ clearTimeout(_this.tokenTimeOutHandle); // Clear the previous refresh timeout in case it hadn't triggered yet.
22153
+ // @ts-ignore
22154
+ // tslint:disable-next-line: no-string-based-set-timeout
22155
+ _this.tokenTimeOutHandle = setTimeout(_this._triggerTokenFetch, Math.min(seconds * 1000, 0x7fffffff) // setTimeout will fire immediately if the delay is greater than 2^31-1.
22156
+ );
22157
+ };
21982
22158
  var serviceOptions = map.getServiceOptions();
21983
22159
  this.options = serviceOptions.authOptions;
21984
22160
  this.sessionId = serviceOptions.sessionId;
@@ -22020,6 +22196,28 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22020
22196
  }
22021
22197
  else if (_this.options.authType === exports.AuthenticationType.anonymous) {
22022
22198
  // Anonymous authentication, just call the users provided callback.
22199
+ resolve(_this._triggerTokenFetch(true));
22200
+ }
22201
+ else if (_this.options.authType === exports.AuthenticationType.sas) {
22202
+ if (_this.options.sasToken) {
22203
+ var expiresIn = -1;
22204
+ try {
22205
+ expiresIn = _this._getTokenExpiry(_this.options.sasToken);
22206
+ }
22207
+ catch (_a) {
22208
+ reject(new Error("An invalid sasToken was provided."));
22209
+ return;
22210
+ }
22211
+ if (expiresIn > AuthenticationManager.constants.tokenRefreshClockSkew) {
22212
+ // Save the initial token
22213
+ _this._storeToken(_this.options.sasToken);
22214
+ // Create a timer to refresh the token
22215
+ _this._setTimeoutTokenFetch(expiresIn - AuthenticationManager.constants.tokenRefreshClockSkew);
22216
+ resolve();
22217
+ return;
22218
+ }
22219
+ }
22220
+ // Call the users provided callback to fetch the token.
22023
22221
  resolve(_this._triggerTokenFetch());
22024
22222
  }
22025
22223
  else {
@@ -22145,8 +22343,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22145
22343
  }
22146
22344
  return token_1;
22147
22345
  }
22148
- else if (this.options.authType === exports.AuthenticationType.anonymous) {
22149
- var token = this._getItem(AuthenticationManager.constants.storage.accessTokenKey);
22346
+ else if (this.options.authType === exports.AuthenticationType.anonymous
22347
+ || this.options.authType === exports.AuthenticationType.sas) {
22348
+ var token = this._getItem(AuthenticationManager.constants.storage.tokenKey);
22150
22349
  if (!token) {
22151
22350
  // Cached Token not present, invoke the user provided callback function to fetch function
22152
22351
  this._triggerTokenFetch();
@@ -22161,7 +22360,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22161
22360
  }
22162
22361
  else if (expiresIn <= 0) {
22163
22362
  // token renew failed and dont have a token.
22164
- this._saveItem(AuthenticationManager.constants.storage.accessTokenKey, "");
22363
+ this._saveItem(AuthenticationManager.constants.storage.tokenKey, "");
22165
22364
  throw new Error(AuthenticationManager.constants.errors.tokenExpired);
22166
22365
  }
22167
22366
  }
@@ -22190,9 +22389,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22190
22389
  * @param token token fetched from the user's server endpoint
22191
22390
  * @internal
22192
22391
  */
22193
- AuthenticationManager.prototype._storeAccessToken = function (token) {
22392
+ AuthenticationManager.prototype._storeToken = function (token) {
22194
22393
  // Store the value
22195
- this._saveItem(AuthenticationManager.constants.storage.accessTokenKey, token);
22394
+ this._saveItem(AuthenticationManager.constants.storage.tokenKey, token);
22196
22395
  var tokenEvent = {
22197
22396
  map: this.map,
22198
22397
  type: AuthenticationManager.constants.events.tokenAcquired
@@ -22281,7 +22480,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22281
22480
  }
22282
22481
  };
22283
22482
  /**
22284
- * Return the number of milliseconds since 1970/01/01
22483
+ * Return the number of seconds since 1970/01/01
22285
22484
  * @ignore
22286
22485
  */
22287
22486
  AuthenticationManager.prototype._getCurrentTime = function () {
@@ -22300,6 +22499,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22300
22499
  request.headers[constants.msClientIdHeaderName] = this.options.clientId;
22301
22500
  request.headers[constants.authorizationHeaderName] = constants.authorizationTokenPrefix + token;
22302
22501
  break;
22502
+ case exports.AuthenticationType.sas:
22503
+ request.headers[constants.authorizationHeaderName] = constants.jwtSasPrefix + token;
22504
+ break;
22303
22505
  case exports.AuthenticationType.subscriptionKey:
22304
22506
  request.headers["subscription-key"] = token;
22305
22507
  break;
@@ -22315,7 +22517,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
22315
22517
  // Enable localStorage for IE, as sessionStorage does not work for localhost.
22316
22518
  preferredCacheLocation: "localStorage",
22317
22519
  storage: {
22318
- accessTokenKey: "access.token.key",
22520
+ tokenKey: "access.token.key",
22319
22521
  testStorageKey: "testStorage"
22320
22522
  },
22321
22523
  events: {
@@ -24900,6 +25102,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
24900
25102
  * @default true
24901
25103
  */
24902
25104
  _this.showLogo = true;
25105
+ /**
25106
+ * Specifies if the map should display labels
25107
+ * @default true
25108
+ */
25109
+ _this.showLabels = true;
24903
25110
  /**
24904
25111
  * Additional custom attribution appended to map attribution.
24905
25112
  * Default `undefined`
@@ -25471,6 +25678,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25471
25678
  }
25472
25679
  StyleManager.prototype.updateIndoorState = function (theme, tilesetId) {
25473
25680
  var _this = this;
25681
+ var _a;
25474
25682
  var styleset = this.map.styles.getMapConfiguration();
25475
25683
  if (styleset) {
25476
25684
  this.preservedPreindoorStyleset = styleset;
@@ -25480,6 +25688,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25480
25688
  this.map.styles.setMapConfiguration("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
25481
25689
  }
25482
25690
  else {
25691
+ var didTilesetIdChange_1 = ((_a = this.indoorState) === null || _a === void 0 ? void 0 : _a.tilesetId) !== tilesetId;
25483
25692
  this.indoorState = {
25484
25693
  tilesetId: tilesetId,
25485
25694
  theme: theme
@@ -25493,7 +25702,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25493
25702
  var targetStylePrefix = currentStyle + "_indoor";
25494
25703
  var candidateStyle = definitions.styles.find(function (style) { return style.name.startsWith(targetStylePrefix); });
25495
25704
  if (candidateStyle) {
25496
- _this.map.setStyle({ style: candidateStyle.name });
25705
+ // force style reload if tileset id has changed to make sure the tiles will be re-requested with new tileset applied in indoor source placeholder
25706
+ _this.map.setStyle({ style: candidateStyle.name }, !didTilesetIdChange_1);
25497
25707
  }
25498
25708
  });
25499
25709
  }
@@ -25531,7 +25741,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25531
25741
  return baseName in styleNamesMap ? styleNamesMap[baseName] : baseName;
25532
25742
  };
25533
25743
  if (!this.serviceOptions.styleSet) {
25534
- newPromise = new HijackablePromise(this._request(this.serviceOptions.staticAssetsDomain, constants.stylePath + "/" + constants.styleResourcePath, "StyleDefinitions").then(function (definitions) { return ({
25744
+ newPromise = new HijackablePromise(this._request(this.serviceOptions.staticAssetsDomain, constants.stylePath + "/" + constants.styleResourcePath, "StyleDefinitions", { version: this.serviceOptions.styleDefinitionsVersion }).then(function (definitions) { return ({
25535
25745
  version: isNaN(definitions.version) ? 0 : parseFloat(definitions.version),
25536
25746
  defaultStyle: definitions.defaultStyle,
25537
25747
  styles: definitions.styles
@@ -25558,9 +25768,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25558
25768
  domain: _this.serviceOptions.staticAssetsDomain,
25559
25769
  path: constants.stylePath + "/" + constants.styleResourcePath + "/" + style.name,
25560
25770
  queryParams: {
25561
- //[constants.apiVersionQueryParameter]: this.serviceOptions.styleDefinitionsVersion,
25562
- // thus far we don't need to differentiate based on parameter here, as stylePatch will be called on cached styles as well
25563
- //language: styleOptions.language
25771
+ styleVersion: _this.serviceOptions.styleDefinitionsVersion,
25564
25772
  },
25565
25773
  protocol: "https"
25566
25774
  }).toString(),
@@ -25604,10 +25812,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25604
25812
  /**
25605
25813
  * @internal
25606
25814
  */
25607
- StyleManager.prototype.setStyle = function (styleOptions) {
25815
+ StyleManager.prototype.setStyle = function (styleOptions, diff) {
25816
+ if (diff === void 0) { diff = true; }
25608
25817
  try {
25609
25818
  this.map._getMap().setStyle(this.getStyle(styleOptions), {
25610
- diff: true,
25819
+ diff: diff,
25611
25820
  stylePatch: this._stylePatch.bind(this),
25612
25821
  validate: this.serviceOptions.validateStyle
25613
25822
  });
@@ -25718,7 +25927,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25718
25927
  currentLayerGroupLayers = [];
25719
25928
  };
25720
25929
  nextStyle.layers.forEach(function (nextLayer) {
25721
- var _a, _b, _c;
25930
+ var _a, _b, _c, _d, _e;
25722
25931
  var layerGroup = LayerGroupComparator.getLayerGroup(nextLayer);
25723
25932
  currentLayerGroupId = currentLayerGroupId ? currentLayerGroupId : layerGroup;
25724
25933
  // Set visiblity of fill-extrusion layers according to StyleOptions.showBuildingModels
@@ -25740,6 +25949,20 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25740
25949
  nextLayer.layout.visibility = "visible";
25741
25950
  }
25742
25951
  }
25952
+ // Set visibility of labels
25953
+ var isLabelLayerGroup = layerGroup === 'labels' || layerGroup === 'labels_places' || layerGroup === 'labels_indoor';
25954
+ if (isLabelLayerGroup && nextLayer.type === 'symbol') {
25955
+ if (styleOptions.showLabels) {
25956
+ updateLayoutProperty(nextLayer.id, "visibility", "visible");
25957
+ nextLayer.layout = (_d = nextLayer.layout) !== null && _d !== void 0 ? _d : {};
25958
+ nextLayer.layout.visibility = "visible";
25959
+ }
25960
+ else {
25961
+ updateLayoutProperty(nextLayer.id, "visibility", "none");
25962
+ nextLayer.layout = (_e = nextLayer.layout) !== null && _e !== void 0 ? _e : {};
25963
+ nextLayer.layout.visibility = "none";
25964
+ }
25965
+ }
25743
25966
  // Once this _stylePatch returns control to maplibre the next style will be applied immediately in the same context.
25744
25967
  // To avoid potential data races update LayerManager with new a new set of FundamentalMapLayers from here instead of
25745
25968
  // waiting for a styledata.load event to trigger a sync in a different context.
@@ -25802,7 +26025,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25802
26025
  // If there was a previous styledata change event attached, remove it.
25803
26026
  // When the sprite url changes between style changes then mapbox can't perform the diff
25804
26027
  // In such cases it recalculate the style again. Removing previous attached
25805
- // event listner makes sure that style changed event is not fired twice in these cases.
26028
+ // event listener makes sure that style changed event is not fired twice in these cases.
25806
26029
  this.map.events.remove("styledata", this._onStyleData);
25807
26030
  this.map.events.addOnce("styledata", this._onStyleData);
25808
26031
  };
@@ -25831,8 +26054,16 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25831
26054
  if (url.includes(constants.styleResourcePlaceholder)) {
25832
26055
  params.url = params.url.replace(constants.styleResourcePlaceholder, constants.styleResourcePath);
25833
26056
  }
25834
- params.url = params.url + ("" + (url.includes('?') ? '&' : '?') + constants.apiVersionQueryParameter + "=" + this.serviceOptions.styleAPIVersion);
25835
- (_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.signRequest(params);
26057
+ if (params.url.toLocaleLowerCase().includes(this.serviceOptions.domain.toLocaleLowerCase()) ||
26058
+ params.url.toLocaleLowerCase().includes(this.serviceOptions.staticAssetsDomain.toLocaleLowerCase())) {
26059
+ // Only add API version param for Azure maps domain requests
26060
+ var targetUrl = new URL(params.url);
26061
+ if (!targetUrl.searchParams.get(constants.apiVersionQueryParameter)) {
26062
+ targetUrl.searchParams.set(constants.apiVersionQueryParameter, this.serviceOptions.styleAPIVersion);
26063
+ params.url = targetUrl.href;
26064
+ }
26065
+ (_a = this.map.authentication) === null || _a === void 0 ? void 0 : _a.signRequest(params);
26066
+ }
25836
26067
  };
25837
26068
  /**
25838
26069
  * Fetches a json resource at the specified domain and path.
@@ -26237,8 +26468,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26237
26468
  /**
26238
26469
  * Set the map control's style options. Any options not specified will default to their current values.
26239
26470
  * @param options The options for setting the style of the map control.
26471
+ * @param diff [true] If false, forces a 'full' style update, removing the current style and building the given one instead of attempting a diff-based update. Defaults to true.
26240
26472
  */
26241
- Map.prototype.setStyle = function (options) {
26473
+ Map.prototype.setStyle = function (options, diff) {
26474
+ if (diff === void 0) { diff = true; }
26242
26475
  // This option may only be set when initializing the map.
26243
26476
  // The delete operation will handle non-exist property.
26244
26477
  delete options.preserveDrawingBuffer;
@@ -26276,7 +26509,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26276
26509
  // if the language is changed, then either those delegates need changed
26277
26510
  // or the styledata event manually invoked.
26278
26511
  this.styleOptions = newOptions;
26279
- this._setStyleComponents(newOptions);
26512
+ this._setStyleComponents(newOptions, diff);
26280
26513
  };
26281
26514
  /**
26282
26515
  * Returns the map control's current style settings.
@@ -26938,10 +27171,11 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
26938
27171
  /**
26939
27172
  * @internal
26940
27173
  */
26941
- Map.prototype._rebuildStyle = function () {
27174
+ Map.prototype._rebuildStyle = function (diff) {
27175
+ if (diff === void 0) { diff = true; }
26942
27176
  return __awaiter(this, void 0, void 0, function () {
26943
27177
  return __generator(this, function (_a) {
26944
- this.styles.setStyle(this.styleOptions);
27178
+ this.styles.setStyle(this.styleOptions, diff);
26945
27179
  this.imageSprite._restoreImages();
26946
27180
  return [2 /*return*/];
26947
27181
  });
@@ -27052,8 +27286,9 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27052
27286
  * Removes sources and layers that aren't used by the new style or any remaining layers.
27053
27287
  * @private
27054
27288
  */
27055
- Map.prototype._setStyleComponents = function (styleOptions) {
27289
+ Map.prototype._setStyleComponents = function (styleOptions, diff) {
27056
27290
  var _this = this;
27291
+ if (diff === void 0) { diff = true; }
27057
27292
  if (this.removed) {
27058
27293
  return;
27059
27294
  }
@@ -27063,7 +27298,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27063
27298
  _this.styleOptions.style = styleSet.defaultStyle;
27064
27299
  }
27065
27300
  _this.styleOptions = styleOptions;
27066
- _this._rebuildStyle();
27301
+ _this._rebuildStyle(diff);
27067
27302
  });
27068
27303
  return;
27069
27304
  };
@@ -27109,7 +27344,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
27109
27344
  var w = BoundingBox.getWest(bounds);
27110
27345
  var n = BoundingBox.getNorth(bounds);
27111
27346
  var e = BoundingBox.getEast(bounds);
27112
- if (isNaN(s) || isNaN(w) || isNaN(n) || isNaN(e)) {
27347
+ if (!isFinite(s) || !isFinite(w) || !isFinite(n) || !isFinite(e)) {
27113
27348
  throw new Error("The bounds specified are invalid: [" + bounds + "]");
27114
27349
  }
27115
27350
  while (w > e) {