@itwin/map-layers-formats 5.11.0-dev.1 → 5.11.0-dev.11

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/README.md +30 -1
  3. package/lib/cjs/AzureMaps/AzureMaps.d.ts +40 -0
  4. package/lib/cjs/AzureMaps/AzureMaps.d.ts.map +1 -0
  5. package/lib/cjs/AzureMaps/AzureMaps.js +124 -0
  6. package/lib/cjs/AzureMaps/AzureMaps.js.map +1 -0
  7. package/lib/cjs/AzureMaps/AzureMapsImageryFormat.d.ts +20 -0
  8. package/lib/cjs/AzureMaps/AzureMapsImageryFormat.d.ts.map +1 -0
  9. package/lib/cjs/AzureMaps/AzureMapsImageryFormat.js +52 -0
  10. package/lib/cjs/AzureMaps/AzureMapsImageryFormat.js.map +1 -0
  11. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.d.ts +24 -0
  12. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.d.ts.map +1 -0
  13. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.js +86 -0
  14. package/lib/cjs/AzureMaps/AzureMapsImageryProvider.js.map +1 -0
  15. package/lib/cjs/map-layers-formats.d.ts +2 -0
  16. package/lib/cjs/map-layers-formats.d.ts.map +1 -1
  17. package/lib/cjs/map-layers-formats.js +2 -0
  18. package/lib/cjs/map-layers-formats.js.map +1 -1
  19. package/lib/cjs/mapLayersFormats.d.ts +12 -0
  20. package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
  21. package/lib/cjs/mapLayersFormats.js +8 -0
  22. package/lib/cjs/mapLayersFormats.js.map +1 -1
  23. package/lib/esm/AzureMaps/AzureMaps.d.ts +40 -0
  24. package/lib/esm/AzureMaps/AzureMaps.d.ts.map +1 -0
  25. package/lib/esm/AzureMaps/AzureMaps.js +121 -0
  26. package/lib/esm/AzureMaps/AzureMaps.js.map +1 -0
  27. package/lib/esm/AzureMaps/AzureMapsImageryFormat.d.ts +20 -0
  28. package/lib/esm/AzureMaps/AzureMapsImageryFormat.d.ts.map +1 -0
  29. package/lib/esm/AzureMaps/AzureMapsImageryFormat.js +48 -0
  30. package/lib/esm/AzureMaps/AzureMapsImageryFormat.js.map +1 -0
  31. package/lib/esm/AzureMaps/AzureMapsImageryProvider.d.ts +24 -0
  32. package/lib/esm/AzureMaps/AzureMapsImageryProvider.d.ts.map +1 -0
  33. package/lib/esm/AzureMaps/AzureMapsImageryProvider.js +81 -0
  34. package/lib/esm/AzureMaps/AzureMapsImageryProvider.js.map +1 -0
  35. package/lib/esm/map-layers-formats.d.ts +2 -0
  36. package/lib/esm/map-layers-formats.d.ts.map +1 -1
  37. package/lib/esm/map-layers-formats.js +2 -0
  38. package/lib/esm/map-layers-formats.js.map +1 -1
  39. package/lib/esm/mapLayersFormats.d.ts +12 -0
  40. package/lib/esm/mapLayersFormats.d.ts.map +1 -1
  41. package/lib/esm/mapLayersFormats.js +8 -0
  42. package/lib/esm/mapLayersFormats.js.map +1 -1
  43. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,6 +1,26 @@
1
1
  # Change Log - @itwin/map-layers-formats
2
2
 
3
- This log was last generated on Tue, 19 May 2026 19:47:05 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 11 Jun 2026 21:11:10 GMT and should not be manually modified.
4
+
5
+ ## 5.10.2
6
+ Thu, 11 Jun 2026 21:09:38 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.10.1
11
+ Mon, 08 Jun 2026 18:45:58 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 5.10.0
16
+ Wed, 03 Jun 2026 20:19:47 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 5.9.5
21
+ Mon, 01 Jun 2026 17:34:00 GMT
22
+
23
+ _Version update only_
4
24
 
5
25
  ## 5.9.4
6
26
  Tue, 19 May 2026 19:45:27 GMT
package/README.md CHANGED
@@ -8,4 +8,33 @@ The __@itwin/map-layers-formats__ Enables additional map-layers formats in iTwin
8
8
 
9
9
  ## List of formats
10
10
 
11
- ArcGIS Feature service
11
+ - ArcGIS Feature service
12
+ - Google Maps
13
+ - Azure Maps
14
+
15
+ ## Azure Maps basemaps
16
+
17
+ `@itwin/map-layers-formats` can register Azure Maps support after `IModelApp.startup`:
18
+
19
+ ```ts
20
+ await MapLayersFormats.initialize();
21
+ ```
22
+
23
+ Provide the Azure Maps subscription key through `IModelApp` startup:
24
+
25
+ ```ts
26
+ await IModelApp.startup({
27
+ mapLayerOptions: {
28
+ ["AzureMaps"]: {
29
+ key: "subscription-key",
30
+ value: "abc123",
31
+ },
32
+ },
33
+ });
34
+ ```
35
+
36
+ Then apply Azure Maps basemaps through the extension API:
37
+
38
+ ```ts
39
+ AzureMaps.applyBackgroundMap(viewport.displayStyle, BackgroundMapType.Hybrid);
40
+ ```
@@ -0,0 +1,40 @@
1
+ /** @packageDocumentation
2
+ * @module MapLayersFormats
3
+ */
4
+ import { BackgroundMapType, BaseMapLayerSettings, ImageMapLayerSettings } from "@itwin/core-common";
5
+ import { type DisplayStyleState } from "@itwin/core-frontend";
6
+ /**
7
+ * Azure Maps API.
8
+ * @beta
9
+ */
10
+ export declare const AzureMaps: {
11
+ /**
12
+ * Creates Azure Maps base-layer settings for the supplied basemap type.
13
+ * @beta
14
+ */
15
+ createBaseLayerSettings: (type: BackgroundMapType) => BaseMapLayerSettings;
16
+ /**
17
+ * Creates any Azure Maps background helper layers required by the supplied basemap type.
18
+ * Hybrid is composed from aerial imagery plus an internal road-labels helper layer.
19
+ * @beta
20
+ */
21
+ createBackgroundLayers: (type: BackgroundMapType) => ImageMapLayerSettings[];
22
+ /**
23
+ * Removes any Azure Maps helper layers owned by this package from the display style.
24
+ * @beta
25
+ */
26
+ clearBackgroundLayers: (displayStyle: DisplayStyleState) => void;
27
+ /**
28
+ * Applies the requested Azure Maps basemap to the supplied display style.
29
+ * Preserves the existing base-layer display state, such as visibility and transparency,
30
+ * while replacing the basemap source with the Azure Maps equivalent.
31
+ * @beta
32
+ */
33
+ applyBackgroundMap: (displayStyle: DisplayStyleState, type: BackgroundMapType) => void;
34
+ /**
35
+ * Identifies the active Azure Maps basemap type for the supplied display style, if any.
36
+ * @beta
37
+ */
38
+ getBackgroundMapType: (displayStyle: DisplayStyleState) => BackgroundMapType | undefined;
39
+ };
40
+ //# sourceMappingURL=AzureMaps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureMaps.d.ts","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMaps.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAqB,oBAAoB,EAAsB,qBAAqB,EAAgD,MAAM,oBAAoB,CAAC;AACzL,OAAO,EAAE,KAAK,iBAAiB,EAAa,MAAM,sBAAsB,CAAC;AA2CzE;;;GAGG;AAEH,eAAO,MAAM,SAAS;IACpB;;;OAGG;oCAC6B,iBAAiB;IAKjD;;;;OAIG;mCAC4B,iBAAiB;IAMhD;;;OAGG;0CACmC,iBAAiB;IAQvD;;;;;OAKG;uCACgC,iBAAiB,QAAQ,iBAAiB;IAmB7E;;;OAGG;yCACkC,iBAAiB,KAAG,iBAAiB,GAAG,SAAS;CAgBvF,CAAC"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module MapLayersFormats
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AzureMaps = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const core_frontend_1 = require("@itwin/core-frontend");
13
+ const AzureMapsImageryFormat_js_1 = require("./AzureMapsImageryFormat.js");
14
+ const streetUrl = "https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.road";
15
+ const aerialUrl = "https://atlas.microsoft.com/map/tile?tilesetId=microsoft.imagery";
16
+ const roadLabelsUrl = "https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.labels.road";
17
+ const roadLabelsRole = "roadLabels";
18
+ function assertRegistered() {
19
+ if (!core_frontend_1.IModelApp.mapLayerFormatRegistry.isRegistered(AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId))
20
+ throw new Error("AzureMaps format is not registered");
21
+ }
22
+ function baseLayerProps(type) {
23
+ switch (type) {
24
+ case core_common_1.BackgroundMapType.Street:
25
+ return { formatId: AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId, name: "Azure Maps: Streets", url: streetUrl };
26
+ case core_common_1.BackgroundMapType.Aerial:
27
+ return { formatId: AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId, name: "Azure Maps: Aerial Imagery", url: aerialUrl };
28
+ case core_common_1.BackgroundMapType.Hybrid:
29
+ return { formatId: AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId, name: "Azure Maps: Hybrid", url: aerialUrl };
30
+ }
31
+ }
32
+ function roadLabelsLayerProps() {
33
+ const properties = { azureMapsRole: roadLabelsRole };
34
+ return {
35
+ formatId: AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId,
36
+ name: "Azure Maps: Road labels",
37
+ url: roadLabelsUrl,
38
+ transparentBackground: true,
39
+ properties,
40
+ };
41
+ }
42
+ function isOwnedRoadLabelsLayer(layer) {
43
+ // Identify by format + role marker, not URL: a persisted style created against an older
44
+ // roadLabelsUrl must still be recognized so Hybrid round-trips and cleanup stay correct.
45
+ return layer instanceof core_common_1.ImageMapLayerSettings
46
+ && layer.formatId === AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId
47
+ && layer.properties?.azureMapsRole === roadLabelsRole;
48
+ }
49
+ /**
50
+ * Azure Maps API.
51
+ * @beta
52
+ */
53
+ // eslint-disable-next-line @typescript-eslint/naming-convention
54
+ exports.AzureMaps = {
55
+ /**
56
+ * Creates Azure Maps base-layer settings for the supplied basemap type.
57
+ * @beta
58
+ */
59
+ createBaseLayerSettings: (type) => {
60
+ assertRegistered();
61
+ return core_common_1.BaseMapLayerSettings.fromJSON(baseLayerProps(type));
62
+ },
63
+ /**
64
+ * Creates any Azure Maps background helper layers required by the supplied basemap type.
65
+ * Hybrid is composed from aerial imagery plus an internal road-labels helper layer.
66
+ * @beta
67
+ */
68
+ createBackgroundLayers: (type) => {
69
+ return type === core_common_1.BackgroundMapType.Hybrid
70
+ ? [core_common_1.ImageMapLayerSettings.fromJSON(roadLabelsLayerProps())]
71
+ : [];
72
+ },
73
+ /**
74
+ * Removes any Azure Maps helper layers owned by this package from the display style.
75
+ * @beta
76
+ */
77
+ clearBackgroundLayers: (displayStyle) => {
78
+ const layers = displayStyle.settings.mapImagery.backgroundLayers;
79
+ for (let index = layers.length - 1; index >= 0; --index) {
80
+ if (isOwnedRoadLabelsLayer(layers[index]))
81
+ displayStyle.detachMapLayerByIndex({ index, isOverlay: false });
82
+ }
83
+ },
84
+ /**
85
+ * Applies the requested Azure Maps basemap to the supplied display style.
86
+ * Preserves the existing base-layer display state, such as visibility and transparency,
87
+ * while replacing the basemap source with the Azure Maps equivalent.
88
+ * @beta
89
+ */
90
+ applyBackgroundMap: (displayStyle, type) => {
91
+ assertRegistered();
92
+ exports.AzureMaps.clearBackgroundLayers(displayStyle);
93
+ const azureBaseProps = baseLayerProps(type);
94
+ const previousBase = displayStyle.backgroundMapBase;
95
+ displayStyle.backgroundMapBase = previousBase instanceof core_common_1.BaseMapLayerSettings
96
+ ? core_common_1.BaseMapLayerSettings.fromJSON({
97
+ ...azureBaseProps,
98
+ visible: previousBase.visible,
99
+ transparency: previousBase.transparency,
100
+ transparentBackground: previousBase.transparentBackground,
101
+ })
102
+ : core_common_1.BaseMapLayerSettings.fromJSON(azureBaseProps);
103
+ for (const layer of exports.AzureMaps.createBackgroundLayers(type))
104
+ displayStyle.attachMapLayer({ mapLayerIndex: { index: -1, isOverlay: false }, settings: layer });
105
+ },
106
+ /**
107
+ * Identifies the active Azure Maps basemap type for the supplied display style, if any.
108
+ * @beta
109
+ */
110
+ getBackgroundMapType: (displayStyle) => {
111
+ const baseLayer = displayStyle.backgroundMapBase;
112
+ if (!(baseLayer instanceof core_common_1.BaseMapLayerSettings) || baseLayer.formatId !== AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat.formatId)
113
+ return undefined;
114
+ if (baseLayer.url === streetUrl)
115
+ return core_common_1.BackgroundMapType.Street;
116
+ if (baseLayer.url === aerialUrl) {
117
+ return displayStyle.settings.mapImagery.backgroundLayers.some(isOwnedRoadLabelsLayer)
118
+ ? core_common_1.BackgroundMapType.Hybrid
119
+ : core_common_1.BackgroundMapType.Aerial;
120
+ }
121
+ return undefined;
122
+ },
123
+ };
124
+ //# sourceMappingURL=AzureMaps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureMaps.js","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMaps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAyL;AACzL,wDAAyE;AACzE,2EAAsE;AAEtE,MAAM,SAAS,GAAG,oEAAoE,CAAC;AACvF,MAAM,SAAS,GAAG,kEAAkE,CAAC;AACrF,MAAM,aAAa,GAAG,2EAA2E,CAAC;AAClG,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,SAAS,gBAAgB;IACvB,IAAI,CAAC,yBAAS,CAAC,sBAAsB,CAAC,YAAY,CAAC,mDAAuB,CAAC,QAAQ,CAAC;QAClF,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc,CAAC,IAAuB;IAC7C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,+BAAiB,CAAC,MAAM;YAC3B,OAAO,EAAE,QAAQ,EAAE,mDAAuB,CAAC,QAAQ,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,EAAE,SAAS,EAAE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;IAED;;;OAGG;IACH,oBAAoB,EAAE,CAAC,YAA+B,EAAiC,EAAE;QACvF,MAAM,SAAS,GAAG,YAAY,CAAC,iBAAiB,CAAC;QACjD,IAAI,CAAC,CAAC,SAAS,YAAY,kCAAoB,CAAC,IAAI,SAAS,CAAC,QAAQ,KAAK,mDAAuB,CAAC,QAAQ;YACzG,OAAO,SAAS,CAAC;QAEnB,IAAI,SAAS,CAAC,GAAG,KAAK,SAAS;YAC7B,OAAO,+BAAiB,CAAC,MAAM,CAAC;QAElC,IAAI,SAAS,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,sBAAsB,CAAC;gBACnF,CAAC,CAAC,+BAAiB,CAAC,MAAM;gBAC1B,CAAC,CAAC,+BAAiB,CAAC,MAAM,CAAC;QAC/B,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { BackgroundMapType, BaseMapLayerProps, BaseMapLayerSettings, ImageMapLayerProps, ImageMapLayerSettings, MapLayerProviderProperties, MapLayerSettings } from \"@itwin/core-common\";\r\nimport { type DisplayStyleState, IModelApp } from \"@itwin/core-frontend\";\r\nimport { AzureMapsMapLayerFormat } from \"./AzureMapsImageryFormat.js\";\r\n\r\nconst streetUrl = \"https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.road\";\r\nconst aerialUrl = \"https://atlas.microsoft.com/map/tile?tilesetId=microsoft.imagery\";\r\nconst roadLabelsUrl = \"https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.labels.road\";\r\nconst roadLabelsRole = \"roadLabels\";\r\n\r\nfunction assertRegistered(): void {\r\n if (!IModelApp.mapLayerFormatRegistry.isRegistered(AzureMapsMapLayerFormat.formatId))\r\n throw new Error(\"AzureMaps format is not registered\");\r\n}\r\n\r\nfunction baseLayerProps(type: BackgroundMapType): BaseMapLayerProps {\r\n switch (type) {\r\n case BackgroundMapType.Street:\r\n return { formatId: AzureMapsMapLayerFormat.formatId, name: \"Azure Maps: Streets\", url: streetUrl };\r\n case BackgroundMapType.Aerial:\r\n return { formatId: AzureMapsMapLayerFormat.formatId, name: \"Azure Maps: Aerial Imagery\", url: aerialUrl };\r\n case BackgroundMapType.Hybrid:\r\n return { formatId: AzureMapsMapLayerFormat.formatId, name: \"Azure Maps: Hybrid\", url: aerialUrl };\r\n }\r\n}\r\n\r\nfunction roadLabelsLayerProps(): ImageMapLayerProps {\r\n const properties: MapLayerProviderProperties = { azureMapsRole: roadLabelsRole };\r\n return {\r\n formatId: AzureMapsMapLayerFormat.formatId,\r\n name: \"Azure Maps: Road labels\",\r\n url: roadLabelsUrl,\r\n transparentBackground: true,\r\n properties,\r\n };\r\n}\r\n\r\nfunction isOwnedRoadLabelsLayer(layer: MapLayerSettings): layer is ImageMapLayerSettings {\r\n // Identify by format + role marker, not URL: a persisted style created against an older\r\n // roadLabelsUrl must still be recognized so Hybrid round-trips and cleanup stay correct.\r\n return layer instanceof ImageMapLayerSettings\r\n && layer.formatId === AzureMapsMapLayerFormat.formatId\r\n && layer.properties?.azureMapsRole === roadLabelsRole;\r\n}\r\n\r\n/**\r\n * Azure Maps API.\r\n * @beta\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const AzureMaps = {\r\n /**\r\n * Creates Azure Maps base-layer settings for the supplied basemap type.\r\n * @beta\r\n */\r\n createBaseLayerSettings: (type: BackgroundMapType) => {\r\n assertRegistered();\r\n return BaseMapLayerSettings.fromJSON(baseLayerProps(type));\r\n },\r\n\r\n /**\r\n * Creates any Azure Maps background helper layers required by the supplied basemap type.\r\n * Hybrid is composed from aerial imagery plus an internal road-labels helper layer.\r\n * @beta\r\n */\r\n createBackgroundLayers: (type: BackgroundMapType) => {\r\n return type === BackgroundMapType.Hybrid\r\n ? [ImageMapLayerSettings.fromJSON(roadLabelsLayerProps())]\r\n : [];\r\n },\r\n\r\n /**\r\n * Removes any Azure Maps helper layers owned by this package from the display style.\r\n * @beta\r\n */\r\n clearBackgroundLayers: (displayStyle: DisplayStyleState) => {\r\n const layers = displayStyle.settings.mapImagery.backgroundLayers;\r\n for (let index = layers.length - 1; index >= 0; --index) {\r\n if (isOwnedRoadLabelsLayer(layers[index]))\r\n displayStyle.detachMapLayerByIndex({ index, isOverlay: false });\r\n }\r\n },\r\n\r\n /**\r\n * Applies the requested Azure Maps basemap to the supplied display style.\r\n * Preserves the existing base-layer display state, such as visibility and transparency,\r\n * while replacing the basemap source with the Azure Maps equivalent.\r\n * @beta\r\n */\r\n applyBackgroundMap: (displayStyle: DisplayStyleState, type: BackgroundMapType) => {\r\n assertRegistered();\r\n AzureMaps.clearBackgroundLayers(displayStyle);\r\n\r\n const azureBaseProps = baseLayerProps(type);\r\n const previousBase = displayStyle.backgroundMapBase;\r\n displayStyle.backgroundMapBase = previousBase instanceof BaseMapLayerSettings\r\n ? BaseMapLayerSettings.fromJSON({\r\n ...azureBaseProps,\r\n visible: previousBase.visible,\r\n transparency: previousBase.transparency,\r\n transparentBackground: previousBase.transparentBackground,\r\n })\r\n : BaseMapLayerSettings.fromJSON(azureBaseProps);\r\n\r\n for (const layer of AzureMaps.createBackgroundLayers(type))\r\n displayStyle.attachMapLayer({ mapLayerIndex: { index: -1, isOverlay: false }, settings: layer });\r\n },\r\n\r\n /**\r\n * Identifies the active Azure Maps basemap type for the supplied display style, if any.\r\n * @beta\r\n */\r\n getBackgroundMapType: (displayStyle: DisplayStyleState): BackgroundMapType | undefined => {\r\n const baseLayer = displayStyle.backgroundMapBase;\r\n if (!(baseLayer instanceof BaseMapLayerSettings) || baseLayer.formatId !== AzureMapsMapLayerFormat.formatId)\r\n return undefined;\r\n\r\n if (baseLayer.url === streetUrl)\r\n return BackgroundMapType.Street;\r\n\r\n if (baseLayer.url === aerialUrl) {\r\n return displayStyle.settings.mapImagery.backgroundLayers.some(isOwnedRoadLabelsLayer)\r\n ? BackgroundMapType.Hybrid\r\n : BackgroundMapType.Aerial;\r\n }\r\n\r\n return undefined;\r\n },\r\n};\r\n"]}
@@ -0,0 +1,20 @@
1
+ /** @packageDocumentation
2
+ * @module MapLayersFormats
3
+ */
4
+ import { ImageMapLayerSettings } from "@itwin/core-common";
5
+ import { ImageryMapLayerFormat, MapLayerImageryProvider, type MapLayerSourceValidation, type ValidateSourceArgs } from "@itwin/core-frontend";
6
+ /**
7
+ * Azure Maps imagery layer format.
8
+ * @beta
9
+ */
10
+ export declare class AzureMapsMapLayerFormat extends ImageryMapLayerFormat {
11
+ /** Azure Maps imagery layer format.
12
+ * @beta
13
+ */
14
+ static formatId: string;
15
+ private static validateAzureSourceUrl;
16
+ static validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation>;
17
+ /** @internal */
18
+ static createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined;
19
+ }
20
+ //# sourceMappingURL=AzureMapsImageryFormat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureMapsImageryFormat.d.ts","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAa,uBAAuB,EAAwB,KAAK,wBAAwB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI/K;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,qBAAqB;IAChE;;OAEG;IACH,OAAuB,QAAQ,SAAe;IAE9C,OAAO,CAAC,MAAM,CAAC,sBAAsB;WAiBR,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAYlG,gBAAgB;WACO,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,GAAG,SAAS;CAGnH"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module MapLayersFormats
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AzureMapsMapLayerFormat = void 0;
11
+ const core_frontend_1 = require("@itwin/core-frontend");
12
+ const mapLayersFormats_js_1 = require("../mapLayersFormats.js");
13
+ const AzureMapsImageryProvider_js_1 = require("./AzureMapsImageryProvider.js");
14
+ /**
15
+ * Azure Maps imagery layer format.
16
+ * @beta
17
+ */
18
+ class AzureMapsMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat {
19
+ /** Azure Maps imagery layer format.
20
+ * @beta
21
+ */
22
+ static formatId = "AzureMaps";
23
+ static validateAzureSourceUrl(url) {
24
+ let parsedUrl;
25
+ try {
26
+ parsedUrl = new URL(url);
27
+ }
28
+ catch {
29
+ return core_frontend_1.MapLayerSourceStatus.InvalidUrl;
30
+ }
31
+ if (!parsedUrl.protocol.startsWith("http"))
32
+ return core_frontend_1.MapLayerSourceStatus.InvalidUrl;
33
+ if (parsedUrl.hostname !== "atlas.microsoft.com" || parsedUrl.pathname !== "/map/tile")
34
+ return core_frontend_1.MapLayerSourceStatus.IncompatibleFormat;
35
+ return parsedUrl.searchParams.has("tilesetId") ? core_frontend_1.MapLayerSourceStatus.Valid : core_frontend_1.MapLayerSourceStatus.InvalidUrl;
36
+ }
37
+ static async validate(args) {
38
+ const urlStatus = AzureMapsMapLayerFormat.validateAzureSourceUrl(args.source.url);
39
+ if (urlStatus !== core_frontend_1.MapLayerSourceStatus.Valid)
40
+ return { status: urlStatus };
41
+ const accessKey = core_frontend_1.IModelApp.mapLayerFormatRegistry.configOptions.AzureMaps;
42
+ if (undefined === (0, AzureMapsImageryProvider_js_1.getAzureMapsSubscriptionKey)(accessKey, mapLayersFormats_js_1.MapLayersFormats.azureMapsOpts?.subscriptionKey))
43
+ return { status: core_frontend_1.MapLayerSourceStatus.RequireAuth };
44
+ return { status: core_frontend_1.MapLayerSourceStatus.Valid };
45
+ }
46
+ /** @internal */
47
+ static createImageryProvider(settings) {
48
+ return new AzureMapsImageryProvider_js_1.AzureMapsLayerImageryProvider(settings, mapLayersFormats_js_1.MapLayersFormats.azureMapsOpts?.subscriptionKey);
49
+ }
50
+ }
51
+ exports.AzureMapsMapLayerFormat = AzureMapsMapLayerFormat;
52
+ //# sourceMappingURL=AzureMapsImageryFormat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureMapsImageryFormat.js","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAA+K;AAC/K,gEAA0D;AAC1D,+EAA2G;AAE3G;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,qCAAqB;IAChE;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAG,WAAW,CAAC;IAEtC,MAAM,CAAC,sBAAsB,CAAC,GAAW;QAC/C,IAAI,SAAc,CAAC;QACnB,IAAI,CAAC;YACH,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,oCAAoB,CAAC,UAAU,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;YACxC,OAAO,oCAAoB,CAAC,UAAU,CAAC;QAEzC,IAAI,SAAS,CAAC,QAAQ,KAAK,qBAAqB,IAAI,SAAS,CAAC,QAAQ,KAAK,WAAW;YACpF,OAAO,oCAAoB,CAAC,kBAAkB,CAAC;QAEjD,OAAO,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oCAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,oCAAoB,CAAC,UAAU,CAAC;IAChH,CAAC;IAEM,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,IAAwB;QAC5D,MAAM,SAAS,GAAG,uBAAuB,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClF,IAAI,SAAS,KAAK,oCAAoB,CAAC,KAAK;YAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAE/B,MAAM,SAAS,GAAG,yBAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,SAAS,CAAC;QAC3E,IAAI,SAAS,KAAK,IAAA,yDAA2B,EAAC,SAAS,EAAE,sCAAgB,CAAC,aAAa,EAAE,eAAe,CAAC;YACvG,OAAO,EAAE,MAAM,EAAE,oCAAoB,CAAC,WAAW,EAAE,CAAC;QAEtD,OAAO,EAAE,MAAM,EAAE,oCAAoB,CAAC,KAAK,EAAE,CAAC;IAChD,CAAC;IAED,gBAAgB;IACT,MAAM,CAAU,qBAAqB,CAAC,QAA+B;QAC1E,OAAO,IAAI,2DAA6B,CAAC,QAAQ,EAAE,sCAAgB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACtG,CAAC;;AAtCH,0DAuCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\r\nimport { ImageryMapLayerFormat, IModelApp, MapLayerImageryProvider, MapLayerSourceStatus, type MapLayerSourceValidation, type ValidateSourceArgs } from \"@itwin/core-frontend\";\r\nimport { MapLayersFormats } from \"../mapLayersFormats.js\";\r\nimport { AzureMapsLayerImageryProvider, getAzureMapsSubscriptionKey } from \"./AzureMapsImageryProvider.js\";\r\n\r\n/**\r\n * Azure Maps imagery layer format.\r\n * @beta\r\n */\r\nexport class AzureMapsMapLayerFormat extends ImageryMapLayerFormat {\r\n /** Azure Maps imagery layer format.\r\n * @beta\r\n */\r\n public static override formatId = \"AzureMaps\";\r\n\r\n private static validateAzureSourceUrl(url: string): MapLayerSourceStatus {\r\n let parsedUrl: URL;\r\n try {\r\n parsedUrl = new URL(url);\r\n } catch {\r\n return MapLayerSourceStatus.InvalidUrl;\r\n }\r\n\r\n if (!parsedUrl.protocol.startsWith(\"http\"))\r\n return MapLayerSourceStatus.InvalidUrl;\r\n\r\n if (parsedUrl.hostname !== \"atlas.microsoft.com\" || parsedUrl.pathname !== \"/map/tile\")\r\n return MapLayerSourceStatus.IncompatibleFormat;\r\n\r\n return parsedUrl.searchParams.has(\"tilesetId\") ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl;\r\n }\r\n\r\n public static override async validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation> {\r\n const urlStatus = AzureMapsMapLayerFormat.validateAzureSourceUrl(args.source.url);\r\n if (urlStatus !== MapLayerSourceStatus.Valid)\r\n return { status: urlStatus };\r\n\r\n const accessKey = IModelApp.mapLayerFormatRegistry.configOptions.AzureMaps;\r\n if (undefined === getAzureMapsSubscriptionKey(accessKey, MapLayersFormats.azureMapsOpts?.subscriptionKey))\r\n return { status: MapLayerSourceStatus.RequireAuth };\r\n\r\n return { status: MapLayerSourceStatus.Valid };\r\n }\r\n\r\n /** @internal */\r\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined {\r\n return new AzureMapsLayerImageryProvider(settings, MapLayersFormats.azureMapsOpts?.subscriptionKey);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,24 @@
1
+ /** @packageDocumentation
2
+ * @module MapLayersFormats
3
+ */
4
+ import { ImageMapLayerSettings, type ImageSource, type MapLayerKey } from "@itwin/core-common";
5
+ import { MapLayerImageryProvider, ScreenViewport } from "@itwin/core-frontend";
6
+ /** @internal */
7
+ export declare const azureMapsSubscriptionKeyParameter = "subscription-key";
8
+ /** @internal */
9
+ export declare function getAzureMapsSubscriptionKey(accessKey: MapLayerKey | undefined, fallbackSubscriptionKey?: string): string | undefined;
10
+ /**
11
+ * Azure Maps imagery provider.
12
+ * @beta
13
+ */
14
+ export declare class AzureMapsLayerImageryProvider extends MapLayerImageryProvider {
15
+ private readonly _subscriptionKey?;
16
+ constructor(settings: ImageMapLayerSettings, _subscriptionKey?: string | undefined);
17
+ private reportAzureAuthFailure;
18
+ loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined>;
19
+ constructUrl(y: number, x: number, zoom: number): Promise<string>;
20
+ /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [addAttributions] instead. */
21
+ addLogoCards(cards: HTMLTableElement): void;
22
+ addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=AzureMapsImageryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAa,uBAAuB,EAA8E,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtK,gBAAgB;AAChB,eAAO,MAAM,iCAAiC,qBAAqB,CAAC;AAEpE,gBAAgB;AAChB,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,WAAW,GAAG,SAAS,EAAE,uBAAuB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOpI;AAQD;;;GAGG;AACH,qBAAa,6BAA8B,SAAQ,uBAAuB;IACpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAAnE,QAAQ,EAAE,qBAAqB,EAAmB,gBAAgB,CAAC,EAAE,MAAM,YAAA;IAI9F,OAAO,CAAC,sBAAsB;IAWR,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAsB1F,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQvF,sGAAsG;IACtF,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAOrC,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAInG"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module MapLayersFormats
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AzureMapsLayerImageryProvider = exports.azureMapsSubscriptionKeyParameter = void 0;
11
+ exports.getAzureMapsSubscriptionKey = getAzureMapsSubscriptionKey;
12
+ const core_frontend_1 = require("@itwin/core-frontend");
13
+ /** @internal */
14
+ exports.azureMapsSubscriptionKeyParameter = "subscription-key";
15
+ /** @internal */
16
+ function getAzureMapsSubscriptionKey(accessKey, fallbackSubscriptionKey) {
17
+ // A layer access key takes precedence, but an empty value falls through to the configured fallback
18
+ // rather than disabling auth outright.
19
+ if (accessKey !== undefined && accessKey.value.length > 0)
20
+ return accessKey.value;
21
+ return fallbackSubscriptionKey !== undefined && fallbackSubscriptionKey.length > 0 ? fallbackSubscriptionKey : undefined;
22
+ }
23
+ class AzureMapsRequireAuthError extends Error {
24
+ constructor() {
25
+ super(`Azure Maps requires a non-empty ${exports.azureMapsSubscriptionKeyParameter} credential`);
26
+ }
27
+ }
28
+ /**
29
+ * Azure Maps imagery provider.
30
+ * @beta
31
+ */
32
+ class AzureMapsLayerImageryProvider extends core_frontend_1.MapLayerImageryProvider {
33
+ _subscriptionKey;
34
+ constructor(settings, _subscriptionKey) {
35
+ super(settings, true);
36
+ this._subscriptionKey = _subscriptionKey;
37
+ }
38
+ reportAzureAuthFailure() {
39
+ this.setStatus(core_frontend_1.MapLayerImageryProviderStatus.RequireAuth);
40
+ if (this._hasSuccessfullyFetchedTile) {
41
+ const msg = core_frontend_1.IModelApp.localization.getLocalizedString("iModelJs:MapLayers.Messages.LoadTileTokenError", { layerName: this._settings.name });
42
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Warning, msg));
43
+ }
44
+ }
45
+ // The base loadTile marks `_hasSuccessfullyFetchedTile` as soon as a response is received, before
46
+ // inspecting its status. Azure returns 401/403 for missing/invalid credentials, so this override
47
+ // detects that before the success is recorded, ensuring no spurious token warning on the first fetch.
48
+ async loadTile(row, column, zoomLevel) {
49
+ try {
50
+ const tileUrl = await this.constructUrl(row, column, zoomLevel);
51
+ if (tileUrl.length === 0)
52
+ return undefined;
53
+ const tileResponse = await this.makeTileRequest(tileUrl);
54
+ if (tileResponse.status === 401 || tileResponse.status === 403) {
55
+ this.reportAzureAuthFailure();
56
+ return undefined;
57
+ }
58
+ this._hasSuccessfullyFetchedTile = true;
59
+ return await this.getImageFromTileResponse(tileResponse, zoomLevel);
60
+ }
61
+ catch (error) {
62
+ if (error instanceof AzureMapsRequireAuthError)
63
+ this.reportAzureAuthFailure();
64
+ return undefined;
65
+ }
66
+ }
67
+ async constructUrl(y, x, zoom) {
68
+ const subscriptionKey = getAzureMapsSubscriptionKey(this._settings.accessKey, this._subscriptionKey);
69
+ if (undefined === subscriptionKey)
70
+ throw new AzureMapsRequireAuthError();
71
+ return `${this._settings.url}&${exports.azureMapsSubscriptionKeyParameter}=${encodeURIComponent(subscriptionKey)}&api-version=2.0&zoom=${zoom}&x=${x}&y=${y}`;
72
+ }
73
+ /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [addAttributions] instead. */
74
+ addLogoCards(cards) {
75
+ if (!cards.dataset.azureMapsLogoCard) {
76
+ cards.dataset.azureMapsLogoCard = "true";
77
+ cards.appendChild(core_frontend_1.IModelApp.makeLogoCard({ heading: "Azure Maps", notice: core_frontend_1.IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.AzureMapsCopyright") }));
78
+ }
79
+ }
80
+ async addAttributions(cards, _vp) {
81
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
82
+ return Promise.resolve(this.addLogoCards(cards));
83
+ }
84
+ }
85
+ exports.AzureMapsLayerImageryProvider = AzureMapsLayerImageryProvider;
86
+ //# sourceMappingURL=AzureMapsImageryProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/AzureMaps/AzureMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AASH,kEAOC;AAbD,wDAAsK;AAEtK,gBAAgB;AACH,QAAA,iCAAiC,GAAG,kBAAkB,CAAC;AAEpE,gBAAgB;AAChB,SAAgB,2BAA2B,CAAC,SAAkC,EAAE,uBAAgC;IAC9G,mGAAmG;IACnG,uCAAuC;IACvC,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QACvD,OAAO,SAAS,CAAC,KAAK,CAAC;IAEzB,OAAO,uBAAuB,KAAK,SAAS,IAAI,uBAAuB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3H,CAAC;AAED,MAAM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------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { ImageMapLayerSettings, type ImageSource, type MapLayerKey } from \"@itwin/core-common\";\r\nimport { IModelApp, MapLayerImageryProvider, MapLayerImageryProviderStatus, NotifyMessageDetails, OutputMessagePriority, ScreenViewport } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport const azureMapsSubscriptionKeyParameter = \"subscription-key\";\r\n\r\n/** @internal */\r\nexport function getAzureMapsSubscriptionKey(accessKey: MapLayerKey | undefined, fallbackSubscriptionKey?: string): string | undefined {\r\n // A layer access key takes precedence, but an empty value falls through to the configured fallback\r\n // rather than disabling auth outright.\r\n if (accessKey !== undefined && accessKey.value.length > 0)\r\n return accessKey.value;\r\n\r\n return fallbackSubscriptionKey !== undefined && fallbackSubscriptionKey.length > 0 ? fallbackSubscriptionKey : undefined;\r\n}\r\n\r\nclass AzureMapsRequireAuthError extends Error {\r\n public constructor() {\r\n super(`Azure Maps requires a non-empty ${azureMapsSubscriptionKeyParameter} credential`);\r\n }\r\n}\r\n\r\n/**\r\n * Azure Maps imagery provider.\r\n * @beta\r\n */\r\nexport class AzureMapsLayerImageryProvider extends MapLayerImageryProvider {\r\n public constructor(settings: ImageMapLayerSettings, private readonly _subscriptionKey?: string) {\r\n super(settings, true);\r\n }\r\n\r\n private reportAzureAuthFailure(): void {\r\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\r\n if (this._hasSuccessfullyFetchedTile) {\r\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.LoadTileTokenError\", { layerName: this._settings.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\r\n }\r\n }\r\n\r\n // The base loadTile marks `_hasSuccessfullyFetchedTile` as soon as a response is received, before\r\n // inspecting its status. Azure returns 401/403 for missing/invalid credentials, so this override\r\n // detects that before the success is recorded, ensuring no spurious token warning on the first fetch.\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n try {\r\n const tileUrl = await this.constructUrl(row, column, zoomLevel);\r\n if (tileUrl.length === 0)\r\n return undefined;\r\n\r\n const tileResponse = await this.makeTileRequest(tileUrl);\r\n if (tileResponse.status === 401 || tileResponse.status === 403) {\r\n this.reportAzureAuthFailure();\r\n return undefined;\r\n }\r\n\r\n this._hasSuccessfullyFetchedTile = true;\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error) {\r\n if (error instanceof AzureMapsRequireAuthError)\r\n this.reportAzureAuthFailure();\r\n\r\n return undefined;\r\n }\r\n }\r\n\r\n public override async constructUrl(y: number, x: number, zoom: number): Promise<string> {\r\n const subscriptionKey = getAzureMapsSubscriptionKey(this._settings.accessKey, this._subscriptionKey);\r\n if (undefined === subscriptionKey)\r\n throw new AzureMapsRequireAuthError();\r\n\r\n return `${this._settings.url}&${azureMapsSubscriptionKeyParameter}=${encodeURIComponent(subscriptionKey)}&api-version=2.0&zoom=${zoom}&x=${x}&y=${y}`;\r\n }\r\n\r\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [addAttributions] instead. */\r\n public override addLogoCards(cards: HTMLTableElement): void {\r\n if (!cards.dataset.azureMapsLogoCard) {\r\n cards.dataset.azureMapsLogoCard = \"true\";\r\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"Azure Maps\", notice: IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.AzureMapsCopyright\") }));\r\n }\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void> {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return Promise.resolve(this.addLogoCards(cards));\r\n }\r\n}\r\n"]}
@@ -1,4 +1,6 @@
1
1
  export * from "./ArcGisFeature/ArcGisFeatureProvider.js";
2
+ export * from "./AzureMaps/AzureMaps.js";
3
+ export * from "./AzureMaps/AzureMapsImageryFormat.js";
2
4
  export * from "./GoogleMaps/GoogleMaps.js";
3
5
  export * from "./GoogleMaps/GoogleMapsSession.js";
4
6
  export * from "./GoogleMaps/GoogleMapsImageryFormat.js";
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers-formats.d.ts","sourceRoot":"","sources":["../../src/map-layers-formats.ts"],"names":[],"mappings":"AAKA,cAAc,0CAA0C,CAAC;AACzD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAA;AACvD,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C;;GAEG;AAEH;;GAEG"}
1
+ {"version":3,"file":"map-layers-formats.d.ts","sourceRoot":"","sources":["../../src/map-layers-formats.ts"],"names":[],"mappings":"AAKA,cAAc,0CAA0C,CAAC;AACzD,cAAc,0BAA0B,CAAC;AACzC,cAAc,uCAAuC,CAAC;AACtD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAA;AACvD,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C;;GAEG;AAEH;;GAEG"}
@@ -19,6 +19,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  __exportStar(require("./ArcGisFeature/ArcGisFeatureProvider.js"), exports);
22
+ __exportStar(require("./AzureMaps/AzureMaps.js"), exports);
23
+ __exportStar(require("./AzureMaps/AzureMapsImageryFormat.js"), exports);
22
24
  __exportStar(require("./GoogleMaps/GoogleMaps.js"), exports);
23
25
  __exportStar(require("./GoogleMaps/GoogleMapsSession.js"), exports);
24
26
  __exportStar(require("./GoogleMaps/GoogleMapsImageryFormat.js"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers-formats.js","sourceRoot":"","sources":["../../src/map-layers-formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,2EAAyD;AACzD,6DAA2C;AAC3C,oEAAkD;AAClD,0EAAuD;AACvD,wDAAsC;AACtC,gEAA8C;AAE9C;;GAEG;AAEH;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport * from \"./ArcGisFeature/ArcGisFeatureProvider.js\";\r\nexport * from \"./GoogleMaps/GoogleMaps.js\";\r\nexport * from \"./GoogleMaps/GoogleMapsSession.js\";\r\nexport * from \"./GoogleMaps/GoogleMapsImageryFormat.js\"\r\nexport * from \"./mapLayersFormats.js\";\r\nexport * from \"./Tools/MapFeatureInfoTool.js\";\r\n\r\n/** @docs-package-description\r\n * This package provides support for additional map layer formats that are not included in the @itwin/core-frontend package.\r\n */\r\n\r\n/** @docs-group-description MapLayersFormats\r\n * APIs for working with the map layer formats provided by this package.\r\n */\r\n"]}
1
+ {"version":3,"file":"map-layers-formats.js","sourceRoot":"","sources":["../../src/map-layers-formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,2EAAyD;AACzD,2DAAyC;AACzC,wEAAsD;AACtD,6DAA2C;AAC3C,oEAAkD;AAClD,0EAAuD;AACvD,wDAAsC;AACtC,gEAA8C;AAE9C;;GAEG;AAEH;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport * from \"./ArcGisFeature/ArcGisFeatureProvider.js\";\r\nexport * from \"./AzureMaps/AzureMaps.js\";\r\nexport * from \"./AzureMaps/AzureMapsImageryFormat.js\";\r\nexport * from \"./GoogleMaps/GoogleMaps.js\";\r\nexport * from \"./GoogleMaps/GoogleMapsSession.js\";\r\nexport * from \"./GoogleMaps/GoogleMapsImageryFormat.js\"\r\nexport * from \"./mapLayersFormats.js\";\r\nexport * from \"./Tools/MapFeatureInfoTool.js\";\r\n\r\n/** @docs-package-description\r\n * This package provides support for additional map layer formats that are not included in the @itwin/core-frontend package.\r\n */\r\n\r\n/** @docs-group-description MapLayersFormats\r\n * APIs for working with the map layer formats provided by this package.\r\n */\r\n"]}
@@ -6,6 +6,8 @@ import { GoogleMapsSessionManager } from "./map-layers-formats.js";
6
6
  export interface MapLayersFormatsConfig {
7
7
  localization?: Localization;
8
8
  googleMapsOpts?: GoogleMapsOptions;
9
+ /** Azure Maps options. */
10
+ azureMapsOpts?: AzureMapsOptions;
9
11
  }
10
12
  /** Google Maps options.
11
13
  * @beta
@@ -13,6 +15,13 @@ export interface MapLayersFormatsConfig {
13
15
  export interface GoogleMapsOptions {
14
16
  sessionManager?: GoogleMapsSessionManager;
15
17
  }
18
+ /** Azure Maps options.
19
+ * @beta
20
+ */
21
+ export interface AzureMapsOptions {
22
+ /** Azure Maps subscription key used when a layer does not supply its own access key. */
23
+ subscriptionKey?: string;
24
+ }
16
25
  /** The primary API for the `@itwin/map-layers-formats` package. It allows the package's features to be [[initialize]]d.
17
26
  * @beta
18
27
  */
@@ -20,6 +29,7 @@ export declare class MapLayersFormats {
20
29
  private static _defaultNs;
21
30
  static localization: Localization;
22
31
  private static _googleMapsOpts?;
32
+ private static _azureMapsOpts?;
23
33
  /** Registers the [MapLayerFormat]($frontend)s provided by this package for use with [IModelApp]($frontend).
24
34
  * Typically, an application will call `MapLayersFormats.initialize` immediately after [IModelApp.startup]($frontend).
25
35
  * This function has no effect if called **before** [IModelApp.startup]($frontend) or **after** [IModelApp.shutdown]($frontend).
@@ -28,5 +38,7 @@ export declare class MapLayersFormats {
28
38
  /** The internationalization service namespace. */
29
39
  static get localizationNamespace(): string;
30
40
  static get googleMapsOpts(): GoogleMapsOptions | undefined;
41
+ /** Azure Maps options supplied during initialization. */
42
+ static get azureMapsOpts(): AzureMapsOptions | undefined;
31
43
  }
32
44
  //# sourceMappingURL=mapLayersFormats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapLayersFormats.d.ts","sourceRoot":"","sources":["../../src/mapLayersFormats.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,CAAC,EAAE,iBAAiB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,wBAAwB,CAAA;CAC1C;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAsB;IAC/C,OAAc,YAAY,EAAE,YAAY,CAAC;IAEzC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAoB;IAEnD;;;OAGG;WACiB,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9E,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,WAAkB,cAAc,kCAE/B;CAEF"}
1
+ {"version":3,"file":"mapLayersFormats.d.ts","sourceRoot":"","sources":["../../src/mapLayersFormats.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,0BAA0B;IAC1B,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,CAAC,EAAE,wBAAwB,CAAA;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAsB;IAC/C,OAAc,YAAY,EAAE,YAAY,CAAC;IAEzC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAoB;IACnD,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAmB;IAEjD;;;OAGG;WACiB,UAAU,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB9E,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,WAAkB,cAAc,kCAE/B;IAED,yDAAyD;IACzD,WAAkB,aAAa,iCAE9B;CAEF"}
@@ -11,6 +11,7 @@ exports.MapLayersFormats = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_frontend_1 = require("@itwin/core-frontend");
13
13
  const ArcGisFeatureFormat_js_1 = require("./ArcGisFeature/ArcGisFeatureFormat.js");
14
+ const AzureMapsImageryFormat_js_1 = require("./AzureMaps/AzureMapsImageryFormat.js");
14
15
  const GoogleMapsImageryFormat_js_1 = require("./GoogleMaps/GoogleMapsImageryFormat.js");
15
16
  const OgcApiFeaturesFormat_js_1 = require("./OgcApiFeatures/OgcApiFeaturesFormat.js");
16
17
  const MapFeatureInfoTool_js_1 = require("./Tools/MapFeatureInfoTool.js");
@@ -21,6 +22,7 @@ class MapLayersFormats {
21
22
  static _defaultNs = "mapLayersFormats";
22
23
  static localization;
23
24
  static _googleMapsOpts;
25
+ static _azureMapsOpts;
24
26
  /** Registers the [MapLayerFormat]($frontend)s provided by this package for use with [IModelApp]($frontend).
25
27
  * Typically, an application will call `MapLayersFormats.initialize` immediately after [IModelApp.startup]($frontend).
26
28
  * This function has no effect if called **before** [IModelApp.startup]($frontend) or **after** [IModelApp.shutdown]($frontend).
@@ -31,12 +33,14 @@ class MapLayersFormats {
31
33
  core_frontend_1.IModelApp.mapLayerFormatRegistry.register(ArcGisFeatureFormat_js_1.ArcGisFeatureMapLayerFormat);
32
34
  core_frontend_1.IModelApp.mapLayerFormatRegistry.register(OgcApiFeaturesFormat_js_1.OgcApiFeaturesMapLayerFormat);
33
35
  core_frontend_1.IModelApp.mapLayerFormatRegistry.register(GoogleMapsImageryFormat_js_1.GoogleMapsMapLayerFormat);
36
+ core_frontend_1.IModelApp.mapLayerFormatRegistry.register(AzureMapsImageryFormat_js_1.AzureMapsMapLayerFormat);
34
37
  }
35
38
  // register namespace containing localized strings for this package
36
39
  MapLayersFormats.localization = config?.localization ?? core_frontend_1.IModelApp.localization;
37
40
  await MapLayersFormats.localization.registerNamespace(MapLayersFormats.localizationNamespace);
38
41
  MapFeatureInfoTool_js_1.MapFeatureInfoTool.register(MapLayersFormats.localizationNamespace);
39
42
  MapLayersFormats._googleMapsOpts = config?.googleMapsOpts;
43
+ MapLayersFormats._azureMapsOpts = config?.azureMapsOpts;
40
44
  }
41
45
  /** The internationalization service namespace. */
42
46
  static get localizationNamespace() {
@@ -45,6 +49,10 @@ class MapLayersFormats {
45
49
  static get googleMapsOpts() {
46
50
  return MapLayersFormats._googleMapsOpts;
47
51
  }
52
+ /** Azure Maps options supplied during initialization. */
53
+ static get azureMapsOpts() {
54
+ return MapLayersFormats._azureMapsOpts;
55
+ }
48
56
  }
49
57
  exports.MapLayersFormats = MapLayersFormats;
50
58
  //# sourceMappingURL=mapLayersFormats.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapLayersFormats.js","sourceRoot":"","sources":["../../src/mapLayersFormats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sDAA6C;AAE7C,wDAAiD;AACjD,mFAAqF;AACrF,wFAAmF;AACnF,sFAAwF;AACxF,yEAAmE;AAkBnE;;GAEG;AACH,MAAa,gBAAgB;IAEnB,MAAM,CAAC,UAAU,GAAG,kBAAkB,CAAC;IACxC,MAAM,CAAC,YAAY,CAAe;IAEjC,MAAM,CAAC,eAAe,CAAqB;IAEnD;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC5D,IAAA,qBAAM,EAAC,yBAAS,CAAC,WAAW,EAAE,kGAAkG,CAAC,CAAC;QAClI,IAAI,yBAAS,CAAC,WAAW,EAAE,CAAC;YAC1B,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,oDAA2B,CAAC,CAAC;YACvE,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,sDAA4B,CAAC,CAAC;YACxE,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,qDAAwB,CAAC,CAAC;QACtE,CAAC;QAED,mEAAmE;QACnE,gBAAgB,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,yBAAS,CAAC,YAAY,CAAC;QAC/E,MAAM,gBAAgB,CAAC,YAAY,CAAC,iBAAiB,CACnD,gBAAgB,CAAC,qBAAqB,CACvC,CAAC;QAEF,0CAAkB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;QACpE,gBAAgB,CAAC,eAAe,GAAG,MAAM,EAAE,cAAc,CAAC;IAC5D,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACrC,CAAC;IAEM,MAAM,KAAK,cAAc;QAC9B,OAAO,gBAAgB,CAAC,eAAe,CAAC;IAC1C,CAAC;;AApCH,4CAsCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { ArcGisFeatureMapLayerFormat } from \"./ArcGisFeature/ArcGisFeatureFormat.js\";\r\nimport { GoogleMapsMapLayerFormat } from \"./GoogleMaps/GoogleMapsImageryFormat.js\";\r\nimport { OgcApiFeaturesMapLayerFormat } from \"./OgcApiFeatures/OgcApiFeaturesFormat.js\";\r\nimport { MapFeatureInfoTool } from \"./Tools/MapFeatureInfoTool.js\";\r\nimport { GoogleMapsSessionManager } from \"./map-layers-formats.js\";\r\n\r\n/** Configuration options.\r\n * @beta\r\n */\r\nexport interface MapLayersFormatsConfig {\r\n localization?: Localization;\r\n googleMapsOpts?: GoogleMapsOptions;\r\n}\r\n\r\n/** Google Maps options.\r\n * @beta\r\n */\r\nexport interface GoogleMapsOptions {\r\n sessionManager?: GoogleMapsSessionManager\r\n}\r\n\r\n/** The primary API for the `@itwin/map-layers-formats` package. It allows the package's features to be [[initialize]]d.\r\n * @beta\r\n */\r\nexport class MapLayersFormats {\r\n\r\n private static _defaultNs = \"mapLayersFormats\";\r\n public static localization: Localization;\r\n\r\n private static _googleMapsOpts?: GoogleMapsOptions;\r\n\r\n /** Registers the [MapLayerFormat]($frontend)s provided by this package for use with [IModelApp]($frontend).\r\n * Typically, an application will call `MapLayersFormats.initialize` immediately after [IModelApp.startup]($frontend).\r\n * This function has no effect if called **before** [IModelApp.startup]($frontend) or **after** [IModelApp.shutdown]($frontend).\r\n */\r\n public static async initialize(config?: MapLayersFormatsConfig): Promise<void> {\r\n assert(IModelApp.initialized, \"MapLayersFormats.initialize must be called after IModelApp.startup and before IModelApp.shutdown\");\r\n if (IModelApp.initialized) {\r\n IModelApp.mapLayerFormatRegistry.register(ArcGisFeatureMapLayerFormat);\r\n IModelApp.mapLayerFormatRegistry.register(OgcApiFeaturesMapLayerFormat);\r\n IModelApp.mapLayerFormatRegistry.register(GoogleMapsMapLayerFormat);\r\n }\r\n\r\n // register namespace containing localized strings for this package\r\n MapLayersFormats.localization = config?.localization ?? IModelApp.localization;\r\n await MapLayersFormats.localization.registerNamespace(\r\n MapLayersFormats.localizationNamespace,\r\n );\r\n\r\n MapFeatureInfoTool.register(MapLayersFormats.localizationNamespace);\r\n MapLayersFormats._googleMapsOpts = config?.googleMapsOpts;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return MapLayersFormats._defaultNs;\r\n }\r\n\r\n public static get googleMapsOpts() {\r\n return MapLayersFormats._googleMapsOpts;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"mapLayersFormats.js","sourceRoot":"","sources":["../../src/mapLayersFormats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sDAA6C;AAE7C,wDAAiD;AACjD,mFAAqF;AACrF,qFAAgF;AAChF,wFAAmF;AACnF,sFAAwF;AACxF,yEAAmE;AA4BnE;;GAEG;AACH,MAAa,gBAAgB;IAEnB,MAAM,CAAC,UAAU,GAAG,kBAAkB,CAAC;IACxC,MAAM,CAAC,YAAY,CAAe;IAEjC,MAAM,CAAC,eAAe,CAAqB;IAC3C,MAAM,CAAC,cAAc,CAAoB;IAEjD;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC5D,IAAA,qBAAM,EAAC,yBAAS,CAAC,WAAW,EAAE,kGAAkG,CAAC,CAAC;QAClI,IAAI,yBAAS,CAAC,WAAW,EAAE,CAAC;YAC1B,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,oDAA2B,CAAC,CAAC;YACvE,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,sDAA4B,CAAC,CAAC;YACxE,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,qDAAwB,CAAC,CAAC;YACpE,yBAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,mDAAuB,CAAC,CAAC;QACrE,CAAC;QAED,mEAAmE;QACnE,gBAAgB,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,yBAAS,CAAC,YAAY,CAAC;QAC/E,MAAM,gBAAgB,CAAC,YAAY,CAAC,iBAAiB,CACnD,gBAAgB,CAAC,qBAAqB,CACvC,CAAC;QAEF,0CAAkB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;QACpE,gBAAgB,CAAC,eAAe,GAAG,MAAM,EAAE,cAAc,CAAC;QAC1D,gBAAgB,CAAC,cAAc,GAAG,MAAM,EAAE,aAAa,CAAC;IAC1D,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACrC,CAAC;IAEM,MAAM,KAAK,cAAc;QAC9B,OAAO,gBAAgB,CAAC,eAAe,CAAC;IAC1C,CAAC;IAED,yDAAyD;IAClD,MAAM,KAAK,aAAa;QAC7B,OAAO,gBAAgB,CAAC,cAAc,CAAC;IACzC,CAAC;;AA5CH,4CA8CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { ArcGisFeatureMapLayerFormat } from \"./ArcGisFeature/ArcGisFeatureFormat.js\";\r\nimport { AzureMapsMapLayerFormat } from \"./AzureMaps/AzureMapsImageryFormat.js\";\r\nimport { GoogleMapsMapLayerFormat } from \"./GoogleMaps/GoogleMapsImageryFormat.js\";\r\nimport { OgcApiFeaturesMapLayerFormat } from \"./OgcApiFeatures/OgcApiFeaturesFormat.js\";\r\nimport { MapFeatureInfoTool } from \"./Tools/MapFeatureInfoTool.js\";\r\nimport { GoogleMapsSessionManager } from \"./map-layers-formats.js\";\r\n\r\n/** Configuration options.\r\n * @beta\r\n */\r\nexport interface MapLayersFormatsConfig {\r\n localization?: Localization;\r\n googleMapsOpts?: GoogleMapsOptions;\r\n /** Azure Maps options. */\r\n azureMapsOpts?: AzureMapsOptions;\r\n}\r\n\r\n/** Google Maps options.\r\n * @beta\r\n */\r\nexport interface GoogleMapsOptions {\r\n sessionManager?: GoogleMapsSessionManager\r\n}\r\n\r\n/** Azure Maps options.\r\n * @beta\r\n */\r\nexport interface AzureMapsOptions {\r\n /** Azure Maps subscription key used when a layer does not supply its own access key. */\r\n subscriptionKey?: string;\r\n}\r\n\r\n/** The primary API for the `@itwin/map-layers-formats` package. It allows the package's features to be [[initialize]]d.\r\n * @beta\r\n */\r\nexport class MapLayersFormats {\r\n\r\n private static _defaultNs = \"mapLayersFormats\";\r\n public static localization: Localization;\r\n\r\n private static _googleMapsOpts?: GoogleMapsOptions;\r\n private static _azureMapsOpts?: AzureMapsOptions;\r\n\r\n /** Registers the [MapLayerFormat]($frontend)s provided by this package for use with [IModelApp]($frontend).\r\n * Typically, an application will call `MapLayersFormats.initialize` immediately after [IModelApp.startup]($frontend).\r\n * This function has no effect if called **before** [IModelApp.startup]($frontend) or **after** [IModelApp.shutdown]($frontend).\r\n */\r\n public static async initialize(config?: MapLayersFormatsConfig): Promise<void> {\r\n assert(IModelApp.initialized, \"MapLayersFormats.initialize must be called after IModelApp.startup and before IModelApp.shutdown\");\r\n if (IModelApp.initialized) {\r\n IModelApp.mapLayerFormatRegistry.register(ArcGisFeatureMapLayerFormat);\r\n IModelApp.mapLayerFormatRegistry.register(OgcApiFeaturesMapLayerFormat);\r\n IModelApp.mapLayerFormatRegistry.register(GoogleMapsMapLayerFormat);\r\n IModelApp.mapLayerFormatRegistry.register(AzureMapsMapLayerFormat);\r\n }\r\n\r\n // register namespace containing localized strings for this package\r\n MapLayersFormats.localization = config?.localization ?? IModelApp.localization;\r\n await MapLayersFormats.localization.registerNamespace(\r\n MapLayersFormats.localizationNamespace,\r\n );\r\n\r\n MapFeatureInfoTool.register(MapLayersFormats.localizationNamespace);\r\n MapLayersFormats._googleMapsOpts = config?.googleMapsOpts;\r\n MapLayersFormats._azureMapsOpts = config?.azureMapsOpts;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return MapLayersFormats._defaultNs;\r\n }\r\n\r\n public static get googleMapsOpts() {\r\n return MapLayersFormats._googleMapsOpts;\r\n }\r\n\r\n /** Azure Maps options supplied during initialization. */\r\n public static get azureMapsOpts() {\r\n return MapLayersFormats._azureMapsOpts;\r\n }\r\n\r\n}\r\n"]}