azure-maps-control 2.1.11 → 2.1.14

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.
@@ -342,7 +342,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
342
342
  return Url;
343
343
  }());
344
344
 
345
- var version = "2.1.11";
345
+ var version = "2.1.14";
346
346
 
347
347
  /**
348
348
  * A helper class that provides methods for getting various forms of the map controls current version.
@@ -4316,11 +4316,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4316
4316
  * Default `true`
4317
4317
  */
4318
4318
  _this.autoSelectionMode = true;
4319
- /**
4320
- * theme
4321
- * when unset - all styles are selectable
4322
- */
4323
- _this.theme = undefined;
4324
4319
  return _this;
4325
4320
  }
4326
4321
  return StyleControlOptions;
@@ -4356,6 +4351,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4356
4351
  return;
4357
4352
  }
4358
4353
  Array.from(_this.styleOpsGrid.children).forEach(function (element) { return element.remove(); });
4354
+ _this.styleButtons.clear();
4359
4355
  _this.populateOpsGridFromDefinitions(definitions);
4360
4356
  };
4361
4357
  _this.mapToFriendlyStyleName = function (name, styleset) {
@@ -4470,6 +4466,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4470
4466
  if (image_1.src !== newSrc) {
4471
4467
  image_1.src = newSrc;
4472
4468
  }
4469
+ Object.entries(this.styleButtons).forEach(function (_a) {
4470
+ var _b = __read(_a, 2), buttonStyleName = _b[0], button = _b[1];
4471
+ return button.setAttribute('aria-current', buttonStyleName === styleName ? 'true' : 'false');
4472
+ });
4473
4473
  this.map.styles.definitions().then(function (styleset) {
4474
4474
  var newAlt = _this.mapToFriendlyStyleName(styleName, styleset);
4475
4475
  if (image_1.alt !== newAlt) {
@@ -4609,9 +4609,6 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4609
4609
  if (Array.isArray(this.options.mapStyles)) {
4610
4610
  styles = styles.filter(function (style) { return _this.options.mapStyles.includes(style.name.split("_indoor")[0]); });
4611
4611
  }
4612
- if (this.options.theme) {
4613
- styles = styles.filter(function (style) { return style.theme === _this.options.theme; });
4614
- }
4615
4612
  styles.forEach(function (style) {
4616
4613
  // Create fetch thumbnail request
4617
4614
  var requestParams = {
@@ -4634,9 +4631,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4634
4631
  positionTooltip(tooltip, styleOptionButton);
4635
4632
  }
4636
4633
  });
4634
+ var targetStyleName = this.map.getStyle().style;
4637
4635
  Object.entries(this.styleButtons).forEach(function (_a) {
4638
4636
  var _b = __read(_a, 2), styleName = _b[0], button = _b[1];
4639
- return button.setAttribute('aria-current', styleName === _this.map.getStyle().style ? 'true' : 'false');
4637
+ return button.setAttribute('aria-current', styleName === targetStyleName ? 'true' : 'false');
4640
4638
  });
4641
4639
  };
4642
4640
  StyleControl.InvertOrderPositions = [exports.ControlPosition.TopRight, exports.ControlPosition.BottomRight];
@@ -4802,13 +4800,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
4802
4800
  * This is invoked on init in constructTrafficButton and on each Map.setTraffic()
4803
4801
  */
4804
4802
  TrafficControl.prototype.updateButtonState = function () {
4805
- if (this.isActive) {
4806
- this.container.classList.add("in-use");
4807
- }
4808
- else {
4809
- this.container.classList.remove("in-use");
4810
- }
4811
4803
  if (this.trafficButton) {
4804
+ if (this.isActive) {
4805
+ this.container.classList.add("in-use");
4806
+ }
4807
+ else {
4808
+ this.container.classList.remove("in-use");
4809
+ }
4812
4810
  this.trafficButton.setAttribute("aria-pressed", this.isActive ? "true" : "false");
4813
4811
  }
4814
4812
  };
@@ -25288,6 +25286,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25288
25286
  var HijackablePromise = /** @class */ (function () {
25289
25287
  function HijackablePromise(origin) {
25290
25288
  var _this = this;
25289
+ this.isHijacked = function () { return _this._hijackedToResolve !== undefined || _this._hijackedToReject !== undefined; };
25291
25290
  this.isResolved = function () { return _this._hijackedToResolve !== undefined || _this._toResolve !== undefined; };
25292
25291
  this.isRejected = function () { return _this._hijackedToReject !== undefined || _this._toReject !== undefined; };
25293
25292
  this.resultIfResolved = function () { return _this._hijackedToResolve || _this._toResolve; };
@@ -25301,39 +25300,28 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25301
25300
  }
25302
25301
  else {
25303
25302
  // we retain the origin, and check if stays the same as resolved
25304
- // to make sure we do nothing if the promise was switched
25305
25303
  var retainedInvocator_1 = _this.origin;
25306
25304
  _this.origin.then(function (result) {
25307
- // origin was switched
25308
- if (retainedInvocator_1 !== _this.origin) {
25305
+ if (_this.isHijacked()) {
25309
25306
  return;
25310
25307
  }
25311
- if (!_this._hijackedToResolve) {
25308
+ // origin was switched during invocation, discard the result and follow the chain
25309
+ if (retainedInvocator_1 !== _this.origin) {
25310
+ _this._thenResolver(resolve, reject);
25311
+ }
25312
+ else {
25312
25313
  _this._toResolve = result;
25313
25314
  resolve(result);
25314
25315
  }
25315
25316
  }).catch(function (error) {
25316
- if (!_this._hijackedToReject) {
25317
- _this._toReject = error;
25318
- reject(error);
25319
- }
25320
- });
25321
- }
25322
- };
25323
- this._catchResolver = function (reject) {
25324
- if (_this._hijackedToReject) {
25325
- reject(_this._hijackedToReject);
25326
- }
25327
- else {
25328
- // we retain the origin, and check if stays the same as resolved
25329
- // to make sure we do nothing if the promise was switched
25330
- var retainedInvocator_2 = _this.origin;
25331
- _this.origin.catch(function (error) {
25332
- // origin was switched
25333
- if (retainedInvocator_2 !== _this.origin) {
25317
+ if (_this.isHijacked()) {
25334
25318
  return;
25335
25319
  }
25336
- if (!_this._hijackedToReject) {
25320
+ // origin was switched during invocation, discard the result and follow the chain
25321
+ if (retainedInvocator_1 !== _this.origin) {
25322
+ _this._thenResolver(resolve, reject);
25323
+ }
25324
+ else {
25337
25325
  _this._toReject = error;
25338
25326
  reject(error);
25339
25327
  }
@@ -25360,14 +25348,20 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25360
25348
  // tslint:disable-next-line: no-reserved-keywords
25361
25349
  HijackablePromise.prototype.catch = function (onrejected) {
25362
25350
  var _this = this;
25363
- return new Promise(function (_, reject) {
25351
+ return new Promise(function (resolve, reject) {
25352
+ _this._resolve = resolve;
25364
25353
  _this._reject = reject;
25365
- _this._catchResolver(reject);
25366
- }).then(onrejected);
25354
+ _this._thenResolver(resolve, reject);
25355
+ }).catch(onrejected);
25367
25356
  };
25368
25357
  // tslint:disable-next-line: no-reserved-keywords
25369
25358
  HijackablePromise.prototype.finally = function (onfinally) {
25370
- return this.origin.finally(onfinally);
25359
+ var _this = this;
25360
+ return new Promise(function (resolve, reject) {
25361
+ _this._resolve = resolve;
25362
+ _this._reject = reject;
25363
+ _this._thenResolver(resolve, reject);
25364
+ }).finally(onfinally);
25371
25365
  };
25372
25366
  HijackablePromise.prototype.hijackAndResolve = function (value) {
25373
25367
  this._hijackedToResolve = value;
@@ -25382,16 +25376,10 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25382
25376
  }
25383
25377
  };
25384
25378
  HijackablePromise.prototype.switchWith = function (promise) {
25385
- // switching the origin will discard the original in-progress promise result
25379
+ // switching the origin will discard the original in-progress promise result, as well any resolved non-hijacked state
25386
25380
  this.origin = promise;
25387
- // then has been invoked on this promise
25388
- if (this._resolve && this._reject) {
25389
- this._thenResolver(this._resolve, this._reject);
25390
- // catch has been invoked on this promise
25391
- }
25392
- else if (this._reject) {
25393
- this._catchResolver(this._reject);
25394
- }
25381
+ this._toResolve = undefined;
25382
+ this._toReject = undefined;
25395
25383
  };
25396
25384
  return HijackablePromise;
25397
25385
  }());
@@ -25424,7 +25412,8 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25424
25412
  var _this = this;
25425
25413
  this.definitions = function () { return _this.initPromise ? _this.initPromise : _this.initStyleset(); };
25426
25414
  /**
25427
- * Compatability indoor state used in styleDefinition filtering.
25415
+ * Compatibility indoor state used in styleDefinition filtering.
25416
+ * Legacy indoor module (2.0.6) will not set tilesetId
25428
25417
  */
25429
25418
  this.indoorState = undefined;
25430
25419
  /**
@@ -25481,13 +25470,13 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25481
25470
  }
25482
25471
  StyleManager.prototype.updateIndoorState = function (theme, tilesetId) {
25483
25472
  var _this = this;
25484
- var styleset = this.map.styles.getStyleSet();
25473
+ var styleset = this.map.styles.getMapConfiguration();
25485
25474
  if (styleset) {
25486
25475
  this.preservedPreindoorStyleset = styleset;
25487
25476
  // tilesetId fallback
25488
25477
  // MAGIC: if we are on a default style set - match existing style to the one in the default indoor style set
25489
- var desiredIndoorStyle = this.map.getStyle().style + "_indoor" + (theme === 'dark' ? '_dark' : '') + "_tileset_" + tilesetId;
25490
- this.map.styles.setStyleSet("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
25478
+ var desiredIndoorStyle = this.map.getStyle().style ? this.map.getStyle().style + "_indoor" + (theme === 'dark' ? '_dark' : '') + "_tileset_" + tilesetId : undefined;
25479
+ this.map.styles.setMapConfiguration("defaultIndoor_" + tilesetId, styleset === 'microsoft-maps:default' ? desiredIndoorStyle : undefined);
25491
25480
  }
25492
25481
  else {
25493
25482
  this.indoorState = {
@@ -25496,9 +25485,15 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25496
25485
  };
25497
25486
  this.initStyleset();
25498
25487
  this.definitions().then(function (definitions) {
25499
- var currentStyle = _this.map.getStyle().style;
25500
- var targetStyleName = currentStyle + "_indoor" + (_this.indoorState.theme == 'dark' ? '_dark' : '');
25501
- _this.map.setStyle({ style: targetStyleName });
25488
+ var currentStyle = (_this.map.getStyle().style || definitions.defaultStyle)
25489
+ .replace('_indoor_dark', '')
25490
+ .replace('_indoor', '');
25491
+ // we cannot compose the precise style name for auto theme, search for prefix style name match
25492
+ var targetStylePrefix = currentStyle + "_indoor";
25493
+ var candidateStyle = definitions.styles.find(function (style) { return style.name.startsWith(targetStylePrefix); });
25494
+ if (candidateStyle) {
25495
+ _this.map.setStyle({ style: candidateStyle.name });
25496
+ }
25502
25497
  });
25503
25498
  }
25504
25499
  };
@@ -25507,7 +25502,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25507
25502
  var styleset = this.preservedPreindoorStyleset;
25508
25503
  if (styleset) {
25509
25504
  // we need to revert to the styleset that was ap
25510
- this.map.styles.setStyleSet(styleset);
25505
+ this.map.styles.setMapConfiguration(styleset);
25511
25506
  }
25512
25507
  else {
25513
25508
  this.indoorState = undefined;
@@ -25539,7 +25534,19 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25539
25534
  version: isNaN(definitions.version) ? 0 : parseFloat(definitions.version),
25540
25535
  defaultStyle: definitions.defaultStyle,
25541
25536
  styles: definitions.styles
25542
- .filter(function (style) { return _this.indoorState ? style.name.includes('indoor') && style.name.endsWith(_this.indoorState.theme == 'dark' ? 'dark' : 'indoor') : !style.name.includes('indoor'); })
25537
+ .filter(function (style) {
25538
+ if (!_this.indoorState) {
25539
+ return !style.name.includes('indoor');
25540
+ // NOTE: azure-maps-indoor prior to 2.0.7 will not pass theme auto
25541
+ // the IndoorModule will request getTheme() from StyleManager and will call StyleManager.setStyleSet(theme == 'dark ? 'indoor_dark' : 'indoor') as approperaite
25542
+ }
25543
+ else if (_this.indoorState.theme === 'auto') {
25544
+ return style.name.endsWith(style.theme === 'dark' ? '_indoor_dark' : '_indoor');
25545
+ }
25546
+ else {
25547
+ return style.name.endsWith(_this.indoorState.theme === 'dark' ? '_indoor_dark' : '_indoor');
25548
+ }
25549
+ })
25543
25550
  .map(function (style) { return ({
25544
25551
  copyright: style.copyright.join(' '),
25545
25552
  name: style.name,
@@ -25614,7 +25621,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25614
25621
  StyleManager.prototype.getTheme = function (styleOptions) {
25615
25622
  var style = this._lookUp(styleOptions);
25616
25623
  if (!style) {
25617
- throw Error("Theme is not available.");
25624
+ return undefined;
25618
25625
  }
25619
25626
  return style.theme.toLowerCase();
25620
25627
  };
@@ -25631,7 +25638,7 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25631
25638
  /**
25632
25639
  * Replaces the style set used. Very costly as it reloads all controls and resources.
25633
25640
  */
25634
- StyleManager.prototype.setStyleSet = function (styleSet, styleName) {
25641
+ StyleManager.prototype.setMapConfiguration = function (styleSet, styleName) {
25635
25642
  var _this = this;
25636
25643
  this.serviceOptions.styleSet = styleSet;
25637
25644
  if (typeof styleSet === 'string') {
@@ -25653,9 +25660,24 @@ EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous po
25653
25660
  _this.map.setStyle({ style: targetStyleName });
25654
25661
  });
25655
25662
  };
25656
- StyleManager.prototype.getStyleSet = function () {
25663
+ StyleManager.prototype.getMapConfiguration = function () {
25657
25664
  return this.serviceOptions.styleSet;
25658
25665
  };
25666
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
25667
+ StyleManager.prototype.setStyleSet = function (styleSet) {
25668
+ this.updateIndoorState(styleSet === 'indoor_dark' ? 'dark' : 'light', null);
25669
+ };
25670
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
25671
+ StyleManager.prototype.getStyleSet = function () {
25672
+ var legacyStyleset = this.indoorState !== undefined
25673
+ ? (this.indoorState.theme === 'dark' ? 'indoor_dark' : 'indoor')
25674
+ : 'base';
25675
+ return legacyStyleset;
25676
+ };
25677
+ // backward-compatibility: this method preserves the interface that azure-maps-indoor@2.0.6 assumes
25678
+ StyleManager.prototype.clearStyleSet = function () {
25679
+ this.unsetIndoorState();
25680
+ };
25659
25681
  /**
25660
25682
  * Function invoked by mapbox after a style is fetched but before it is committed to the map state.
25661
25683
  *