azure-maps-control
Version:
Map SDK for Azure Maps
1,110 lines (1,073 loc) • 2.23 MB
JavaScript
/*!
MICROSOFT SOFTWARE LICENSE TERMS
MICROSOFT AZURE MAPS WEB SDK
These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft’s rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.
1. INSTALLATION AND USE RIGHTS.
a) General. You may install and use any number of copies of the software to develop and test your applications.
b) User Region Parameters. The software will allow you to select from a View list to set the map view within your application for a given customer. By default the View parameter (also referred to as “user region parameter” is set to “Unified”. Countries/Regions that are not on the View list will default to the “Unified” View. It is your responsibility to determine the location of your users, and then set the View parameter correctly for that location. The View parameter 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 the software is made available.
c) Third Party Software. The software may include third party applications that Microsoft, not the third party, licenses to you under this agreement. Any included notices for third party applications are for your information only.
d) Microsoft Online Subscription Agreement. Some features of the software provide access to, or rely on, Microsoft Azure Services. The use of those services (but not the software) is governed by the separate terms and privacy policies associated with your Microsoft Azure subscription. The services may not be available in all regions. For more information see https://go.microsoft.com/fwLink/?LinkID=522330&clcid=0x9.
2. DISTRIBUTABLE CODE. The software is comprised of “Distributable Code”. “Distributable Code” is code that you are permitted to distribute in applications you develop if you comply with the terms below and otherwise set forth in these license terms.
a) Distribution Rights.
i. You may copy and distribute the object code form of the software.
i. Third Party Distribution. You may permit distributors of your applications to copy and distribute any of this distributable code you elect to distribute with your applications.
b) Distribution Requirements. For any code you distribute, you must:
i. add significant primary functionality to it in your applications;
ii. require distributors and external end users to agree to terms that protect it and Microsoft at least as much as this agreement; and
iii. indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your applications, except to the extent that any claim is based solely on the unmodified distributable code.
c) Distribution Restrictions. You may not:
i. use Microsoft’s trademarks or trade dress in your application in any way that suggests your application comes from or is endorsed by Microsoft; or
ii. modify or distribute the source code of any distributable code so that any part of it becomes subject to any license that requires that the distributable code, any other part of the software, or any of Microsoft’s other intellectual property be disclosed or distributed in source code form, or that others have the right to modify it.
3. DATA COLLECTION. The software may collect information about you and your use of the software and send that to Microsoft. Microsoft may use this information to provide services and improve Microsoft’s products and services. Your opt-out rights, if any, are described in the product documentation. Some features in the software may enable collection of data from users of your applications that access or use the software. If you use these features to enable data collection in your applications, you must comply with applicable law, including getting any required user consent, and maintain a prominent privacy policy that accurately informs users about how you use, collect, and share their data. You can learn more about Microsoft’s data collection and use in the product documentation and the Microsoft Privacy Statement at https://go.microsoft.com/fwlink/?LinkId=512132. You agree to comply with all applicable provisions of the Microsoft Privacy Statement.
4. SCOPE OF LICENSE. The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to):
a) work around any technical limitations in the software that only allow you to use it in certain ways;
b) reverse engineer, decompile, or disassemble the software, or attempt to do so, except and only to the extent permitted by licensing terms governing the use of open-source components that may be included with the software;
c) remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software;
d) use the software in any way that is against the law or to create or propagate malware; or
e) share, publish, distribute, or lend the software (except for any distributable code, subject to the terms above), provide the software as a stand-alone hosted solution for others to use, or transfer the software or this agreement to any third party.
5. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit http://aka.ms/exporting.
6. SUPPORT SERVICES. Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is “as is”, “with all faults”, and without warranty of any kind.
7. UPDATES. The software may periodically check for updates, and download and install them for you. You may obtain updates only from Microsoft or authorized sources. Microsoft may need to update your system to provide you with updates. You agree to receive these automatic updates without any additional notice. Updates may not include or support all existing software features, services, or peripheral devices.
8. ENTIRE AGREEMENT. This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software.
9. APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles. If you acquired the software in any other country, its laws apply. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court. If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court.
10. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you:
a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights.
b) Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software.
c) Germany and Austria.
i. Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software.
ii. Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law.
Subject to the foregoing clause ii., Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence.
11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
12. LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT, OR INCIDENTAL DAMAGES.
This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law.
It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages.
Please note: As this software is distributed in Canada, some of the clauses in this agreement are provided below in French.
Remarque: Ce logiciel étant distribué au Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.
EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.
LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
Cette limitation concerne:
• tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et
• les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.
Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard.
EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('azuremaps-maplibre-gl')) :
typeof define === 'function' && define.amd ? define(['exports', 'azuremaps-maplibre-gl'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.atlas = global.atlas || {}, global.maplibregl));
})(this, (function (exports, maplibregl) { 'use strict';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var f = n.default;
if (typeof f == "function") {
var a = function a () {
if (this instanceof a) {
return Reflect.construct(f, arguments, this.constructor);
}
return f.apply(this, arguments);
};
a.prototype = f.prototype;
} else a = {};
Object.defineProperty(a, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
function commonjsRequire(path) {
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var uuidRandom = {exports: {}};
var _nodeResolve_empty = {};
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
default: _nodeResolve_empty
});
var require$$0 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
(function (module) {
(function(){
var
buf,
bufIdx = 0,
hexBytes = [],
i
;
// Pre-calculate toString(16) for speed
for (i = 0; i < 256; i++) {
hexBytes[i] = (i + 0x100).toString(16).substr(1);
}
// Buffer random numbers for speed
// Reduce memory usage by decreasing this number (min 16)
// or improve speed by increasing this number (try 16384)
uuid.BUFFER_SIZE = 4096;
// Binary uuids
uuid.bin = uuidBin;
// Clear buffer
uuid.clearBuffer = function() {
buf = null;
bufIdx = 0;
};
// Test for uuid
uuid.test = function(uuid) {
if (typeof uuid === 'string') {
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(uuid);
}
return false;
};
// Node & Browser support
var crypt0;
if (typeof crypto !== 'undefined') {
crypt0 = crypto;
} else if( (typeof window !== 'undefined') && (typeof window.msCrypto !== 'undefined')) {
crypt0 = window.msCrypto; // IE11
}
if ((typeof commonjsRequire === 'function')) {
crypt0 = crypt0 || require$$0;
module.exports = uuid;
} else if (typeof window !== 'undefined') {
window.uuid = uuid;
}
// Use best available PRNG
// Also expose this so you can override it.
uuid.randomBytes = (function(){
if (crypt0) {
if (crypt0.randomBytes) {
return crypt0.randomBytes;
}
if (crypt0.getRandomValues) {
if (typeof Uint8Array.prototype.slice !== 'function') {
return function(n) {
var bytes = new Uint8Array(n);
crypt0.getRandomValues(bytes);
return Array.from(bytes);
};
}
return function(n) {
var bytes = new Uint8Array(n);
crypt0.getRandomValues(bytes);
return bytes;
};
}
}
return function(n) {
var i, r = [];
for (i = 0; i < n; i++) {
r.push(Math.floor(Math.random() * 256));
}
return r;
};
})();
// Buffer some random bytes for speed
function randomBytesBuffered(n) {
if (!buf || ((bufIdx + n) > uuid.BUFFER_SIZE)) {
bufIdx = 0;
buf = uuid.randomBytes(uuid.BUFFER_SIZE);
}
return buf.slice(bufIdx, bufIdx += n);
}
// uuid.bin
function uuidBin() {
var b = randomBytesBuffered(16);
b[6] = (b[6] & 0x0f) | 0x40;
b[8] = (b[8] & 0x3f) | 0x80;
return b;
}
// String UUIDv4 (Random)
function uuid() {
var b = uuidBin();
return hexBytes[b[0]] + hexBytes[b[1]] +
hexBytes[b[2]] + hexBytes[b[3]] + '-' +
hexBytes[b[4]] + hexBytes[b[5]] + '-' +
hexBytes[b[6]] + hexBytes[b[7]] + '-' +
hexBytes[b[8]] + hexBytes[b[9]] + '-' +
hexBytes[b[10]] + hexBytes[b[11]] +
hexBytes[b[12]] + hexBytes[b[13]] +
hexBytes[b[14]] + hexBytes[b[15]]
;
}
})();
} (uuidRandom));
var uuidRandomExports = uuidRandom.exports;
var uuid = /*@__PURE__*/getDefaultExportFromCjs(uuidRandomExports);
var env = {
domain: "atlas.microsoft.com",
staticAssetsDomain: "atlas.microsoft.com",
stylePath: "styling",
styleDefinitionsVersion: "2023-01-01",
appInsightsKey: "e96cb745-c6f5-409c-a775-c4313e468c1d",
aadInstance: "https://login.microsoftonline.com/"
};
var constants = {
apiVersionQueryParameter: "api-version",
authorizationHeaderName: "Authorization",
authorizationTokenPrefix: "Bearer ",
jwtSasPrefix: "jwt-sas ",
domainPlaceHolder: "{{azMapsDomain}}",
legacyDomainPlaceHolder: "{azMapsDomain}",
viewPlaceHolder: "{{azMapsView}}",
viewParameter: "view",
languagePlaceHolder: "{{azMapsLanguage}}",
stylePathHolder: "{{azMapsStylingPath}}",
styleResourcePlaceholder: "{{azMapsStylePath}}",
stylePath: "styling",
styleResourcePath: "styles",
styleApiVersion: "2.0",
mapAgentHeaderName: "Map-Agent",
msClientIdHeaderName: "x-ms-client-id",
msOriginHeaderName: "Ms-Am-Request-Origin",
msOriginHeaderValue: "MapControl",
aadResourceId: "https://atlas.microsoft.com/.default",
sessionIdHeaderName: "Session-Id"
};
var __values$k = (window && window.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
/**
* @private
*/
var Options = /** @class */ (function () {
function Options() {
}
/**
* @internal
*/
Options.prototype.merge = function () {
var e_1, _a;
var valuesList = [];
for (var _i = 0; _i < arguments.length; _i++) {
valuesList[_i] = arguments[_i];
}
var defaults;
try {
for (var valuesList_1 = __values$k(valuesList), valuesList_1_1 = valuesList_1.next(); !valuesList_1_1.done; valuesList_1_1 = valuesList_1.next()) {
var values = valuesList_1_1.value;
if (!values) {
continue;
}
for (var property in values) {
if (values.hasOwnProperty(property) && this.hasOwnProperty(property)) {
if (values[property] !== undefined && values[property] != null) {
// Check for nested options and merge them rather than simply overwriting.
if (this[property] instanceof Options) {
this[property].merge(values[property]);
}
else {
this[property] = values[property];
}
}
else {
// Assume a value of undefined or null intends to take the default value.
// Create a new object to access its defaults.
if (!defaults) {
defaults = new (Object.getPrototypeOf(this).constructor)();
}
this[property] = defaults[property];
}
}
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (valuesList_1_1 && !valuesList_1_1.done && (_a = valuesList_1.return)) _a.call(valuesList_1);
}
finally { if (e_1) throw e_1.error; }
}
return this;
};
return Options;
}());
var __extends$1n = (window && window.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read$h = (window && window.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
/**
* @private
*/
var UrlOptions = /** @class */ (function (_super) {
__extends$1n(UrlOptions, _super);
function UrlOptions() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.domain = undefined;
_this.headers = {};
_this.path = "";
_this.protocol = "https";
_this.queryParams = {};
_this.subdomain = "";
return _this;
}
return UrlOptions;
}(Options));
/**
* @private
*/
// tslint:disable-next-line:max-classes-per-file
var Url = /** @class */ (function () {
function Url(options) {
this.options = new UrlOptions().merge(options);
}
// tslint:disable-next-line:no-reserved-keywords
Url.prototype.get = function () {
return fetch(this.toString(), {
method: "GET",
mode: "cors",
headers: new Headers(this.options.headers),
}).then(function (response) {
if (response.ok) {
return response.json();
}
else {
throw new Error("HTTP ".concat(response.status, ": ").concat(response.statusText));
}
});
};
Url.prototype.toString = function () {
var self = this;
var queryParamsString = Object.entries(self.options.queryParams)
.map(function (_a) {
var _b = __read$h(_a, 2), key = _b[0], value = _b[1];
return "".concat(key, "=").concat(value);
})
.join("&");
var url = [];
var path = self.options.path || "";
// If path contains the protocol, don't add domain to the url.
if (Url.protoRegEx.test(path)) {
url.push(path);
}
else {
// domain may be empty for absolute paths or
// path itself might start with '/' for absolute paths
if (self.options.domain) {
if (!Url.protoRegEx.test(self.options.domain)) {
// If the domain doesn't include a protocol use the separate protocol and subdomain properties.
// If the domain includes a protocol assume it also includes the subdomain.
url.push("".concat(self.options.protocol, "://"));
url.push(self.options.subdomain ? "".concat(self.options.subdomain, ".") : "");
}
url.push(self.options.domain);
}
url.push(self.options.path ? "/".concat(path) : "");
}
url.push(queryParamsString ? "?".concat(queryParamsString) : "");
return url.join("");
};
Url.protoRegEx = new RegExp(/^(((file|http|https):\/\/)|blob:)/i);
return Url;
}());
/**
* A helper class that will parses and splits a culture code into its language and region parts.
*/
var CultureCode = /** @class */ (function () {
function CultureCode() {
}
/**
* Parses and splits the specified culture code.
* Splits based on the last index of "-".
* If a split can not be made the specified code will be considered just the language leaving region undefined.
* All string properties will be in lowercase for simplified string matching.
* @param code The culture code.
*/
CultureCode.parse = function (code) {
code = code.toLowerCase();
var index = code.lastIndexOf("-");
if (index !== -1) {
return {
code: code,
language: code.substring(0, index),
region: code.substring(index + 1)
};
}
return {
code: code,
language: code,
};
};
return CultureCode;
}());
/**
* A specific implementation of the LocaleIndex interface.
* Contains real information about the available/supported locales.
*/
var localeIndex = {
localizationsPath: "locs/mapcontrol/2019-3-12",
sensitiveUserRegions: ["il", "kr", "pk", "in", "cn", "ar", "bh", "eg", "jo", "sa", "kw", "om", "qa", "ma", "ae"],
locales: {
defaultLanguage: {
defaultRegion: {
code: "NGT",
strings: "en/resource.json"
},
latn: {
code: "NGT-Latn",
strings: "en/resource.json"
}
},
ar: {
defaultRegion: {
code: "ar",
strings: "ar-sa/resource.json"
}
},
bg: {
defaultRegion: {
code: "bg-BG",
strings: "bg-bg/resource.json"
}
},
cs: {
defaultRegion: {
code: "cs-CZ",
strings: "cs-cz/resource.json"
}
},
da: {
defaultRegion: {
code: "da-DK",
strings: "da-dk/resource.json"
}
},
de: {
defaultRegion: {
code: "de-DE",
strings: "de-de/resource.json"
}
},
el: {
defaultRegion: {
code: "el-GR",
strings: "el-gr/resource.json"
}
},
en: {
defaultRegion: {
code: "en",
strings: "en/resource.json"
},
us: {
code: "en-US",
strings: "en/resource.json"
},
au: {
code: "en-AU",
strings: "en/resource.json"
},
gb: {
code: "en-GB",
strings: "en/resource.json"
},
nz: {
code: "en-NZ",
strings: "en/resource.json"
}
},
es: {
defaultRegion: {
code: "es-ES",
strings: "es-es/resource.json"
},
mx: {
code: "es-MX",
strings: "es-mx/resource.json"
}
},
fi: {
defaultRegion: {
code: "fi-FI",
strings: "fi-fi/resource.json"
}
},
fr: {
defaultRegion: {
code: "fr-FR",
strings: "fr-fr/resource.json"
}
},
hu: {
defaultRegion: {
code: "hu-HU",
strings: "hu-hu/resource.json"
}
},
id: {
defaultRegion: {
code: "id-ID",
strings: "id-id/resource.json"
}
},
it: {
defaultRegion: {
code: "it-IT",
strings: "it-it/resource.json"
}
},
ko: {
defaultRegion: {
code: "ko-KR",
strings: "ko-kr/resource.json"
}
},
lt: {
defaultRegion: {
code: "lt-LT",
strings: "lt-lt/resource.json"
}
},
ms: {
defaultRegion: {
code: "ms-MY",
strings: "ms-my/resource.json"
}
},
nb: {
defaultRegion: {
code: "nb-NO",
strings: "nb-no/resource.json"
}
},
nl: {
defaultRegion: {
code: "nl-NL",
strings: "nl-nl/resource.json"
}
},
pl: {
defaultRegion: {
code: "pl-PL",
strings: "pl-pl/resource.json"
}
},
pt: {
defaultRegion: {
code: "pt-PT",
strings: "pt-pt/resource.json"
},
br: {
code: "pt-BR",
strings: "pt-br/resource.json"
}
},
ru: {
defaultRegion: {
code: "ru-RU",
strings: "ru-ru/resource.json"
}
},
sk: {
defaultRegion: {
code: "sk-SK",
strings: "sk-sk/resource.json"
}
},
sl: {
defaultRegion: {
code: "sl-SL",
strings: "sl-sl/resource.json"
}
},
sv: {
defaultRegion: {
code: "sv-SE",
strings: "sv-se/resource.json"
}
},
th: {
defaultRegion: {
code: "th-TH",
strings: "th-th/resource.json"
}
},
tr: {
defaultRegion: {
code: "tr-TR",
strings: "tr-tr/resource.json"
}
},
zh: {
// per https://microsoft.sharepoint.com/sites/globalreadiness/SitePages/Language-fallback.aspx
// Chinese - Neutral (zh) fallbacks to en-US
defaultRegion: {
code: "zh",
strings: "en/resource.json"
}
},
"zh-hans": {
defaultRegion: {
code: "zh-Hans",
strings: "zh-cn/resource.json"
},
cn: {
code: "zh-Hans-CN",
strings: "zh-cn/resource.json"
}
},
"zh-hant": {
// per discussion with global readiness team, we were explicitly asked to not fallback zh-hant to zh-tw
defaultRegion: {
code: "zh-Hant",
strings: "en/resource.json"
},
tw: {
code: "zh-Hant-TW",
strings: "zh-tw/resource.json"
}
}
}
};
/**
* An interface defining the contents of a specific localized strings json.
*/
var LocalizedStrings = /** @class */ (function () {
function LocalizedStrings() {
/**
* A localized version of `"Unknown"`.
*/
this.Unknown = "Unknown";
/**
* A localized version of `"Accident"`.
*/
this.Accident = "Accident";
/**
* A localized version of `"Fog"`.
*/
this.Fog = "Fog";
/**
* A localized version of `"Danger"`.
*/
this.Danger = "Danger";
/**
* A localized version of `"Rain"`.
*/
this.Rain = "Rain";
/**
* A localized version of `"Ice"`.
*/
this.Ice = "Ice";
/**
* A localized version of `"Jam"`.
*/
this.Jam = "Jam";
/**
* A localized version of `"Lane Closed"`.
*/
this.LaneClosed = "Lane Closed";
/**
* A localized version of `"Road Closed"`.
*/
this.RoadClosed = "Road Closed";
/**
* A localized version of `"Road Works"`.
*/
this.RoadWorks = "Road Works";
/**
* A localized version of `"Wind"`.
*/
this.Wind = "Wind";
/**
* A localized version of `"Flood"`.
*/
this.Flood = "Flood";
/**
* A localized version of `"Detour"`.
*/
this.Detour = "Detour";
}
return LocalizedStrings;
}());
/**
* A static class used for fetching localized strings and validating supported language codes.
*/
var Localizer = /** @class */ (function () {
function Localizer() {
}
/**
* Returns a supported culture code that best fits the requested one.
* @param locale The requested culture code.
*/
Localizer.getCode = function (locale) {
// If locale is set to 'auto', use the browser's configured language.
if (locale.localeCompare("auto", undefined, { sensitivity: "base" }) === 0) {
locale = navigator.language;
}
var code = CultureCode.parse(locale);
// If the requested culture code includes a sensitive region simply return the original code.
// This is to hopefully reduce the risk or providing bad content to users in a sensitive region.
return (localeIndex.sensitiveUserRegions.indexOf(code.region) === -1) ?
this.getLocaleData(code).code :
locale;
};
/**
* Returns a collection of localized strings that best fits the requested culture code.
* @param locale The requested culture code.
*/
Localizer.getStrings = function (locale) {
var localeData = this.getLocaleData(locale);
// For default locale no need to make a network request
// Its value is already defined in LocalizedStrings
// This will also make sure that request is not made for Bing maps
if (localeIndex.locales.defaultLanguage.defaultRegion.code === localeData.code) {
return new Promise(function (resolve) {
resolve(new LocalizedStrings());
});
}
else {
// Start a GET request
var request = new Url({
domain: env.staticAssetsDomain,
path: "".concat(localeIndex.localizationsPath, "/").concat(localeData.strings)
}).get();
// Return the response as a LocalizedStrings object.
return request.then(function (response) {
return response;
}, function () {
// If the request for the localized strings json fails return a default localization in English.
return new LocalizedStrings();
});
}
};
/**
* Gets the best fit locale data based on the specified culture code.
* @param locale The requested culture code.
*/
Localizer.getLocaleData = function (locale) {
// Convert the locale to a culture code if one wasn't already provided.
if (typeof locale === "string") {
locale = CultureCode.parse(locale);
}
// Check if the locale could be just the language.
// If so return the default locale data for that language.
if (localeIndex.locales[locale.code]) {
return localeIndex.locales[locale.code].defaultRegion;
}
// Check if the language is supported.
// If not use the default language.
var regionIndex;
if (localeIndex.locales[locale.language]) {
regionIndex = localeIndex.locales[locale.language];
}
else if (locale.language.indexOf("-") !== -1) {
// If the current language can't be matched but there is another "-"
// Try to use the language as if it is a full culture code.
return this.getLocaleData(locale.language);
}
else {
regionIndex = localeIndex.locales.defaultLanguage;
}
// Check if the region is supported for the chosen language.
// If not use the default region for the chosen language.
if (locale.region && regionIndex[locale.region]) {
return regionIndex[locale.region];
}
else {
return regionIndex.defaultRegion;
}
};
return Localizer;
}());
var UserAgent = /** @class */ (function () {
function UserAgent() {
}
/**
* Returns the Edge or IE browser version number.
* Edge will be version 12 or greater.
* IE will be version 11 or less.
* If the browser is not Edge or IE -1 will be returned.
*/
UserAgent.getEdgeOrIEVersion = function () {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0) {
// IE 10 or older
return parseInt(ua.substring(msie + 5, ua.indexOf(".", msie)), 10);
}
var trident = ua.indexOf("Trident/");
if (trident > 0) {
// IE 11
var rv = ua.indexOf("rv:");
return parseInt(ua.substring(rv + 3, ua.indexOf(".", rv)), 10);
}
var edge = ua.indexOf("Edge/");
if (edge > 0) {
// Edge (IE 12+)
return parseInt(ua.substring(edge + 5, ua.indexOf(".", edge)), 10);
}
// other browser
return -1;
};
/**
* Detects if the browser is IE or Edge.
*/
UserAgent.isEdgeOrIE = function () {
var version = this.getEdgeOrIEVersion();
return version !== -1;
};
/**
* Detects if the browser is IE but not Edge.
*/
UserAgent.isIE = function () {
var version = this.getEdgeOrIEVersion();
return version !== -1 && version <= 11;
};
return UserAgent;
}());
var version$2 = "3.6.0";
/**
* A helper class that provides methods for getting various forms of the map controls current version.
*/
var Version = /** @class */ (function () {
function Version() {
}
/**
* Returns the full version string for the map control.
* For example, `"1.3.5"`.
*/
Version.getFullVersion = function () {
return version$2;
};
/**
* Returns the endpoint compatible version string for the map control.
* For example, `"1.3.5"` becomes `"1.3"`.
*/
Version.getEndpointVersion = function () {
// Get the index of the second "."
var index = version$2.indexOf(".");
index = version$2.indexOf(".", index + 1);
// If the index of the second "." can't be found just return the whole version string.
if (index === -1) {
return version$2;
}
return version$2.substring(0, index);
};
return Version;
}());
var __extends$1m = (window && window.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read$g = (window && window.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray$b = (window && window.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
/**
* An enumeration used to specify the type of authentication mechanism to use.
*/
exports.AuthenticationType = void 0;
(function (AuthenticationType) {
/**
* The subscription key authentication mechanism.
* Literal value `"subscriptionKey"`
*/
AuthenticationType["subscriptionKey"] = "subscriptionKey";
/**
* The AAD implicit grant mechanism. Recommended for pages protected by a sign-in.
* By default the page will be redirected to the AAD login when the map control initializes.
* Specify a logged-in `PublicClientApplication` in the `AuthenticationOptions`
* for greater control over when/how the users signs in.
* Literal value `"aad"`
*/
AuthenticationType["aad"] = "aad";
/**
* The anonymous authentication mechanism. Recommended for public pages.
* Allows a callback responsible for acquiring an authentication token to be provided.
* Literal value `"anonymous"`
*/
AuthenticationType["anonymous"] = "anonymous";
/**
* The shared access signature authentication mechanism. Allows a callback responsible for acquiring a token to be provided on requests.
* Literal value `"sas"`.
*/
AuthenticationType["sas"] = "sas";
})(exports.AuthenticationType || (exports.AuthenticationType = {}));
/**
* Options for specifying how the map control should authenticate with the Azure Maps services.
*/
var AuthenticationOptions = /** @class */ (function (_super) {
__extends$1m(AuthenticationOptions, _super);
function AuthenticationOptions() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* The authentication mechanism to be used.
*/
_this.authType = undefined;
/**
* Subscription key from your Azure Maps account.
* Must be specified for subscription key authentication type.
*/
_this.subscriptionKey = undefined;
/**
* The Azure Maps client ID, This is an unique identifier used to identify the maps account.
* Preferred to always be specified, but must be specified for AAD and anonymous authentication types.
*/
_this.clientId = undefined;
/**
* The Azure AD registered app ID. This is the app ID of an app registered in your Azure AD tenant.
* Must be specified for AAD authentication type.
*/
_this.aadAppId = undefined;
/**
* The AAD tenant that owns the registered app specified by `aadAppId`.
* Must be specified for AAD authentication type.
*/
_this.aadTenant = undefined;
/**
* The AAD instance to use for logging in.
* Can be optionally specified when using the AAD authentication type.
* By default the `https://login.microsoftonline.com/` instance will be used.
*/
_this.aadInstance = undefined;
/**
* A callback to use with the anonymous/sas authentication mechanism.
* This callback will be responsible for resolving to a authentication token.
* E.g. fetching a CORS protected token from an endpoint.
*/
_this.getToken = undefined;
/**
* Optionally provide an initial token for sas authentication.
*/
_this.sasToken = undefined;
/**
* Optionally provide an existing `PublicClientApplication` from the MSAL.js library.
* This authentication context will be used to acquire the AAD token.
* Only used with the AAD authentication type.
* This auth context must be configured to use the same AAD app ID as `this.aadAppId`.
* If this is not provided all map instances will share their own private auth context.
*/
_this.authContext = undefined;
return _this;
}
/**
* Sets the required options to configure the subscription key authentication mechanism.
* @param subscriptionKey Subscription Key from your azure maps account
*/
AuthenticationOptions.prototype.setSubscriptionKey = function (key) {
this.authType = exports.AuthenticationType.subscriptionKey;
this.subscriptionKey = key;
};
/**
* Sets the required authentication options to configure the AAD implicit grant mechanism.
* @param clientId Client ID from your azure maps account
* @param aadAppId Azure AD App ID
* @param aadTenant Azure AD Tenant Name
* @param aadInstance An optional Azure AD Instance
* @param authContext An optional `PublicClientApplication` from the MSAL.js library
*/
AuthenticationOptions.prototype.setAadProperties = function (clientId, aadAppId, aadTenant, aadInstance, authContext) {
this.authType = exports.AuthenticationType.aad;
this.authContext = authContext || this.authContext;
this.aadInstance = aadInstance || this.aadInstance;
this.clientId = clientId;
this.aadAppId = aadAppId;
this.aadTenant = aadTenant;
};
/**
* Sets the required options to configure the anonymous authentication method.
* @param getTokenCallback Callback function responsible for resolving to an authentication token.
*/
AuthenticationOptions.prototype.setTokenCallbackFunction = function (getTokenCallback) {
this.authType = exports.AuthenticationType.anonymous;
this.getToken = getTokenCallback;
};
/**
* Sets the required options to configure the sas authentication method.
* @param getTokenCallback Callback function responsible for resolving to an authentication token.
*/
AuthenticationOptions.prototype.setSasCallbackFunction = function (getTokenCallback) {
this.authType = exports.AuthenticationType.sas;
this.getToken = getTokenCallback;
};
/**
* Override the standard merge behavior to handle mutually exclusive options.
* @internal
*/
AuthenticationOptions.prototype.merge = function () {
var valueList = [];
for (var _i = 0; _i < arguments.length; _i++) {
valueList[_i] = arguments[_i];
}
var merged = _super.prototype.merge.apply(this, __spreadArray$b([], __read$g(valueList), false));
if (merged.authType === exports.AuthenticationType.subscriptionKey) {
merged.authContext = merged.aadAppId = merged.getToken = undefined;
}
else if (merged.authType === exports.AuthenticationType.aad) {
merged.subscriptionKey = merged.getToken = undefined;
}
else if (merged.authType === exports.AuthenticationType.anonymous) {
merged.subscriptionKey = merged.authContext = merged.aadAppId = undefined;