@itwin/map-layers-formats 5.10.2 → 5.11.0-dev.10
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.
- package/CHANGELOG.md +1 -1
- package/README.md +30 -1
- package/lib/cjs/AzureMaps/AzureMaps.d.ts +40 -0
- package/lib/cjs/AzureMaps/AzureMaps.d.ts.map +1 -0
- package/lib/cjs/AzureMaps/AzureMaps.js +124 -0
- package/lib/cjs/AzureMaps/AzureMaps.js.map +1 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryFormat.d.ts +20 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryFormat.d.ts.map +1 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryFormat.js +52 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryFormat.js.map +1 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryProvider.d.ts +24 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryProvider.d.ts.map +1 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryProvider.js +86 -0
- package/lib/cjs/AzureMaps/AzureMapsImageryProvider.js.map +1 -0
- package/lib/cjs/map-layers-formats.d.ts +2 -0
- package/lib/cjs/map-layers-formats.d.ts.map +1 -1
- package/lib/cjs/map-layers-formats.js +2 -0
- package/lib/cjs/map-layers-formats.js.map +1 -1
- package/lib/cjs/mapLayersFormats.d.ts +12 -0
- package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
- package/lib/cjs/mapLayersFormats.js +8 -0
- package/lib/cjs/mapLayersFormats.js.map +1 -1
- package/lib/esm/AzureMaps/AzureMaps.d.ts +40 -0
- package/lib/esm/AzureMaps/AzureMaps.d.ts.map +1 -0
- package/lib/esm/AzureMaps/AzureMaps.js +121 -0
- package/lib/esm/AzureMaps/AzureMaps.js.map +1 -0
- package/lib/esm/AzureMaps/AzureMapsImageryFormat.d.ts +20 -0
- package/lib/esm/AzureMaps/AzureMapsImageryFormat.d.ts.map +1 -0
- package/lib/esm/AzureMaps/AzureMapsImageryFormat.js +48 -0
- package/lib/esm/AzureMaps/AzureMapsImageryFormat.js.map +1 -0
- package/lib/esm/AzureMaps/AzureMapsImageryProvider.d.ts +24 -0
- package/lib/esm/AzureMaps/AzureMapsImageryProvider.d.ts.map +1 -0
- package/lib/esm/AzureMaps/AzureMapsImageryProvider.js +81 -0
- package/lib/esm/AzureMaps/AzureMapsImageryProvider.js.map +1 -0
- package/lib/esm/map-layers-formats.d.ts +2 -0
- package/lib/esm/map-layers-formats.d.ts.map +1 -1
- package/lib/esm/map-layers-formats.js +2 -0
- package/lib/esm/map-layers-formats.js.map +1 -1
- package/lib/esm/mapLayersFormats.d.ts +12 -0
- package/lib/esm/mapLayersFormats.d.ts.map +1 -1
- package/lib/esm/mapLayersFormats.js +8 -0
- package/lib/esm/mapLayersFormats.js.map +1 -1
- package/package.json +12 -12
|
@@ -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,121 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module MapLayersFormats
|
|
7
|
+
*/
|
|
8
|
+
import { BackgroundMapType, BaseMapLayerSettings, ImageMapLayerSettings } from "@itwin/core-common";
|
|
9
|
+
import { IModelApp } from "@itwin/core-frontend";
|
|
10
|
+
import { AzureMapsMapLayerFormat } from "./AzureMapsImageryFormat.js";
|
|
11
|
+
const streetUrl = "https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.road";
|
|
12
|
+
const aerialUrl = "https://atlas.microsoft.com/map/tile?tilesetId=microsoft.imagery";
|
|
13
|
+
const roadLabelsUrl = "https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.labels.road";
|
|
14
|
+
const roadLabelsRole = "roadLabels";
|
|
15
|
+
function assertRegistered() {
|
|
16
|
+
if (!IModelApp.mapLayerFormatRegistry.isRegistered(AzureMapsMapLayerFormat.formatId))
|
|
17
|
+
throw new Error("AzureMaps format is not registered");
|
|
18
|
+
}
|
|
19
|
+
function baseLayerProps(type) {
|
|
20
|
+
switch (type) {
|
|
21
|
+
case BackgroundMapType.Street:
|
|
22
|
+
return { formatId: AzureMapsMapLayerFormat.formatId, name: "Azure Maps: Streets", url: streetUrl };
|
|
23
|
+
case BackgroundMapType.Aerial:
|
|
24
|
+
return { formatId: AzureMapsMapLayerFormat.formatId, name: "Azure Maps: Aerial Imagery", url: aerialUrl };
|
|
25
|
+
case BackgroundMapType.Hybrid:
|
|
26
|
+
return { formatId: AzureMapsMapLayerFormat.formatId, name: "Azure Maps: Hybrid", url: aerialUrl };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function roadLabelsLayerProps() {
|
|
30
|
+
const properties = { azureMapsRole: roadLabelsRole };
|
|
31
|
+
return {
|
|
32
|
+
formatId: AzureMapsMapLayerFormat.formatId,
|
|
33
|
+
name: "Azure Maps: Road labels",
|
|
34
|
+
url: roadLabelsUrl,
|
|
35
|
+
transparentBackground: true,
|
|
36
|
+
properties,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function isOwnedRoadLabelsLayer(layer) {
|
|
40
|
+
// Identify by format + role marker, not URL: a persisted style created against an older
|
|
41
|
+
// roadLabelsUrl must still be recognized so Hybrid round-trips and cleanup stay correct.
|
|
42
|
+
return layer instanceof ImageMapLayerSettings
|
|
43
|
+
&& layer.formatId === AzureMapsMapLayerFormat.formatId
|
|
44
|
+
&& layer.properties?.azureMapsRole === roadLabelsRole;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Azure Maps API.
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
51
|
+
export const AzureMaps = {
|
|
52
|
+
/**
|
|
53
|
+
* Creates Azure Maps base-layer settings for the supplied basemap type.
|
|
54
|
+
* @beta
|
|
55
|
+
*/
|
|
56
|
+
createBaseLayerSettings: (type) => {
|
|
57
|
+
assertRegistered();
|
|
58
|
+
return BaseMapLayerSettings.fromJSON(baseLayerProps(type));
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Creates any Azure Maps background helper layers required by the supplied basemap type.
|
|
62
|
+
* Hybrid is composed from aerial imagery plus an internal road-labels helper layer.
|
|
63
|
+
* @beta
|
|
64
|
+
*/
|
|
65
|
+
createBackgroundLayers: (type) => {
|
|
66
|
+
return type === BackgroundMapType.Hybrid
|
|
67
|
+
? [ImageMapLayerSettings.fromJSON(roadLabelsLayerProps())]
|
|
68
|
+
: [];
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Removes any Azure Maps helper layers owned by this package from the display style.
|
|
72
|
+
* @beta
|
|
73
|
+
*/
|
|
74
|
+
clearBackgroundLayers: (displayStyle) => {
|
|
75
|
+
const layers = displayStyle.settings.mapImagery.backgroundLayers;
|
|
76
|
+
for (let index = layers.length - 1; index >= 0; --index) {
|
|
77
|
+
if (isOwnedRoadLabelsLayer(layers[index]))
|
|
78
|
+
displayStyle.detachMapLayerByIndex({ index, isOverlay: false });
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Applies the requested Azure Maps basemap to the supplied display style.
|
|
83
|
+
* Preserves the existing base-layer display state, such as visibility and transparency,
|
|
84
|
+
* while replacing the basemap source with the Azure Maps equivalent.
|
|
85
|
+
* @beta
|
|
86
|
+
*/
|
|
87
|
+
applyBackgroundMap: (displayStyle, type) => {
|
|
88
|
+
assertRegistered();
|
|
89
|
+
AzureMaps.clearBackgroundLayers(displayStyle);
|
|
90
|
+
const azureBaseProps = baseLayerProps(type);
|
|
91
|
+
const previousBase = displayStyle.backgroundMapBase;
|
|
92
|
+
displayStyle.backgroundMapBase = previousBase instanceof BaseMapLayerSettings
|
|
93
|
+
? BaseMapLayerSettings.fromJSON({
|
|
94
|
+
...azureBaseProps,
|
|
95
|
+
visible: previousBase.visible,
|
|
96
|
+
transparency: previousBase.transparency,
|
|
97
|
+
transparentBackground: previousBase.transparentBackground,
|
|
98
|
+
})
|
|
99
|
+
: BaseMapLayerSettings.fromJSON(azureBaseProps);
|
|
100
|
+
for (const layer of AzureMaps.createBackgroundLayers(type))
|
|
101
|
+
displayStyle.attachMapLayer({ mapLayerIndex: { index: -1, isOverlay: false }, settings: layer });
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Identifies the active Azure Maps basemap type for the supplied display style, if any.
|
|
105
|
+
* @beta
|
|
106
|
+
*/
|
|
107
|
+
getBackgroundMapType: (displayStyle) => {
|
|
108
|
+
const baseLayer = displayStyle.backgroundMapBase;
|
|
109
|
+
if (!(baseLayer instanceof BaseMapLayerSettings) || baseLayer.formatId !== AzureMapsMapLayerFormat.formatId)
|
|
110
|
+
return undefined;
|
|
111
|
+
if (baseLayer.url === streetUrl)
|
|
112
|
+
return BackgroundMapType.Street;
|
|
113
|
+
if (baseLayer.url === aerialUrl) {
|
|
114
|
+
return displayStyle.settings.mapImagery.backgroundLayers.some(isOwnedRoadLabelsLayer)
|
|
115
|
+
? BackgroundMapType.Hybrid
|
|
116
|
+
: BackgroundMapType.Aerial;
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
//# 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,OAAO,EAAE,iBAAiB,EAAqB,oBAAoB,EAAsB,qBAAqB,EAAgD,MAAM,oBAAoB,CAAC;AACzL,OAAO,EAA0B,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;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,SAAS,CAAC,sBAAsB,CAAC,YAAY,CAAC,uBAAuB,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,iBAAiB,CAAC,MAAM;YAC3B,OAAO,EAAE,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;QACrG,KAAK,iBAAiB,CAAC,MAAM;YAC3B,OAAO,EAAE,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,EAAE,IAAI,EAAE,4BAA4B,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;QAC5G,KAAK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C,IAAI,SAAS,CAAC,QAAQ,KAAK,uBAAuB,CAAC,QAAQ;YACzG,OAAO,SAAS,CAAC;QAEnB,IAAI,SAAS,CAAC,GAAG,KAAK,SAAS;YAC7B,OAAO,iBAAiB,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,iBAAiB,CAAC,MAAM;gBAC1B,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAC/B,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BackgroundMapType, BaseMapLayerProps, BaseMapLayerSettings, ImageMapLayerProps, ImageMapLayerSettings, MapLayerProviderProperties, MapLayerSettings } from \"@itwin/core-common\";\nimport { type DisplayStyleState, IModelApp } from \"@itwin/core-frontend\";\nimport { AzureMapsMapLayerFormat } from \"./AzureMapsImageryFormat.js\";\n\nconst streetUrl = \"https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.road\";\nconst aerialUrl = \"https://atlas.microsoft.com/map/tile?tilesetId=microsoft.imagery\";\nconst roadLabelsUrl = \"https://atlas.microsoft.com/map/tile?tilesetId=microsoft.base.labels.road\";\nconst roadLabelsRole = \"roadLabels\";\n\nfunction assertRegistered(): void {\n if (!IModelApp.mapLayerFormatRegistry.isRegistered(AzureMapsMapLayerFormat.formatId))\n throw new Error(\"AzureMaps format is not registered\");\n}\n\nfunction baseLayerProps(type: BackgroundMapType): BaseMapLayerProps {\n switch (type) {\n case BackgroundMapType.Street:\n return { formatId: AzureMapsMapLayerFormat.formatId, name: \"Azure Maps: Streets\", url: streetUrl };\n case BackgroundMapType.Aerial:\n return { formatId: AzureMapsMapLayerFormat.formatId, name: \"Azure Maps: Aerial Imagery\", url: aerialUrl };\n case BackgroundMapType.Hybrid:\n return { formatId: AzureMapsMapLayerFormat.formatId, name: \"Azure Maps: Hybrid\", url: aerialUrl };\n }\n}\n\nfunction roadLabelsLayerProps(): ImageMapLayerProps {\n const properties: MapLayerProviderProperties = { azureMapsRole: roadLabelsRole };\n return {\n formatId: AzureMapsMapLayerFormat.formatId,\n name: \"Azure Maps: Road labels\",\n url: roadLabelsUrl,\n transparentBackground: true,\n properties,\n };\n}\n\nfunction isOwnedRoadLabelsLayer(layer: MapLayerSettings): layer is ImageMapLayerSettings {\n // Identify by format + role marker, not URL: a persisted style created against an older\n // roadLabelsUrl must still be recognized so Hybrid round-trips and cleanup stay correct.\n return layer instanceof ImageMapLayerSettings\n && layer.formatId === AzureMapsMapLayerFormat.formatId\n && layer.properties?.azureMapsRole === roadLabelsRole;\n}\n\n/**\n * Azure Maps API.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const AzureMaps = {\n /**\n * Creates Azure Maps base-layer settings for the supplied basemap type.\n * @beta\n */\n createBaseLayerSettings: (type: BackgroundMapType) => {\n assertRegistered();\n return BaseMapLayerSettings.fromJSON(baseLayerProps(type));\n },\n\n /**\n * Creates any Azure Maps background helper layers required by the supplied basemap type.\n * Hybrid is composed from aerial imagery plus an internal road-labels helper layer.\n * @beta\n */\n createBackgroundLayers: (type: BackgroundMapType) => {\n return type === BackgroundMapType.Hybrid\n ? [ImageMapLayerSettings.fromJSON(roadLabelsLayerProps())]\n : [];\n },\n\n /**\n * Removes any Azure Maps helper layers owned by this package from the display style.\n * @beta\n */\n clearBackgroundLayers: (displayStyle: DisplayStyleState) => {\n const layers = displayStyle.settings.mapImagery.backgroundLayers;\n for (let index = layers.length - 1; index >= 0; --index) {\n if (isOwnedRoadLabelsLayer(layers[index]))\n displayStyle.detachMapLayerByIndex({ index, isOverlay: false });\n }\n },\n\n /**\n * Applies the requested Azure Maps basemap to the supplied display style.\n * Preserves the existing base-layer display state, such as visibility and transparency,\n * while replacing the basemap source with the Azure Maps equivalent.\n * @beta\n */\n applyBackgroundMap: (displayStyle: DisplayStyleState, type: BackgroundMapType) => {\n assertRegistered();\n AzureMaps.clearBackgroundLayers(displayStyle);\n\n const azureBaseProps = baseLayerProps(type);\n const previousBase = displayStyle.backgroundMapBase;\n displayStyle.backgroundMapBase = previousBase instanceof BaseMapLayerSettings\n ? BaseMapLayerSettings.fromJSON({\n ...azureBaseProps,\n visible: previousBase.visible,\n transparency: previousBase.transparency,\n transparentBackground: previousBase.transparentBackground,\n })\n : BaseMapLayerSettings.fromJSON(azureBaseProps);\n\n for (const layer of AzureMaps.createBackgroundLayers(type))\n displayStyle.attachMapLayer({ mapLayerIndex: { index: -1, isOverlay: false }, settings: layer });\n },\n\n /**\n * Identifies the active Azure Maps basemap type for the supplied display style, if any.\n * @beta\n */\n getBackgroundMapType: (displayStyle: DisplayStyleState): BackgroundMapType | undefined => {\n const baseLayer = displayStyle.backgroundMapBase;\n if (!(baseLayer instanceof BaseMapLayerSettings) || baseLayer.formatId !== AzureMapsMapLayerFormat.formatId)\n return undefined;\n\n if (baseLayer.url === streetUrl)\n return BackgroundMapType.Street;\n\n if (baseLayer.url === aerialUrl) {\n return displayStyle.settings.mapImagery.backgroundLayers.some(isOwnedRoadLabelsLayer)\n ? BackgroundMapType.Hybrid\n : BackgroundMapType.Aerial;\n }\n\n return undefined;\n },\n};\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,48 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module MapLayersFormats
|
|
7
|
+
*/
|
|
8
|
+
import { ImageryMapLayerFormat, IModelApp, MapLayerSourceStatus } from "@itwin/core-frontend";
|
|
9
|
+
import { MapLayersFormats } from "../mapLayersFormats.js";
|
|
10
|
+
import { AzureMapsLayerImageryProvider, getAzureMapsSubscriptionKey } from "./AzureMapsImageryProvider.js";
|
|
11
|
+
/**
|
|
12
|
+
* Azure Maps imagery layer format.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export class AzureMapsMapLayerFormat extends ImageryMapLayerFormat {
|
|
16
|
+
/** Azure Maps imagery layer format.
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
static formatId = "AzureMaps";
|
|
20
|
+
static validateAzureSourceUrl(url) {
|
|
21
|
+
let parsedUrl;
|
|
22
|
+
try {
|
|
23
|
+
parsedUrl = new URL(url);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return MapLayerSourceStatus.InvalidUrl;
|
|
27
|
+
}
|
|
28
|
+
if (!parsedUrl.protocol.startsWith("http"))
|
|
29
|
+
return MapLayerSourceStatus.InvalidUrl;
|
|
30
|
+
if (parsedUrl.hostname !== "atlas.microsoft.com" || parsedUrl.pathname !== "/map/tile")
|
|
31
|
+
return MapLayerSourceStatus.IncompatibleFormat;
|
|
32
|
+
return parsedUrl.searchParams.has("tilesetId") ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl;
|
|
33
|
+
}
|
|
34
|
+
static async validate(args) {
|
|
35
|
+
const urlStatus = AzureMapsMapLayerFormat.validateAzureSourceUrl(args.source.url);
|
|
36
|
+
if (urlStatus !== MapLayerSourceStatus.Valid)
|
|
37
|
+
return { status: urlStatus };
|
|
38
|
+
const accessKey = IModelApp.mapLayerFormatRegistry.configOptions.AzureMaps;
|
|
39
|
+
if (undefined === getAzureMapsSubscriptionKey(accessKey, MapLayersFormats.azureMapsOpts?.subscriptionKey))
|
|
40
|
+
return { status: MapLayerSourceStatus.RequireAuth };
|
|
41
|
+
return { status: MapLayerSourceStatus.Valid };
|
|
42
|
+
}
|
|
43
|
+
/** @internal */
|
|
44
|
+
static createImageryProvider(settings) {
|
|
45
|
+
return new AzureMapsLayerImageryProvider(settings, MapLayersFormats.azureMapsOpts?.subscriptionKey);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# 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,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAA2B,oBAAoB,EAA0D,MAAM,sBAAsB,CAAC;AAC/K,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE3G;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,qBAAqB;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,oBAAoB,CAAC,UAAU,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;YACxC,OAAO,oBAAoB,CAAC,UAAU,CAAC;QAEzC,IAAI,SAAS,CAAC,QAAQ,KAAK,qBAAqB,IAAI,SAAS,CAAC,QAAQ,KAAK,WAAW;YACpF,OAAO,oBAAoB,CAAC,kBAAkB,CAAC;QAEjD,OAAO,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,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,oBAAoB,CAAC,KAAK;YAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAE/B,MAAM,SAAS,GAAG,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,SAAS,CAAC;QAC3E,IAAI,SAAS,KAAK,2BAA2B,CAAC,SAAS,EAAE,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC;YACvG,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,WAAW,EAAE,CAAC;QAEtD,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAChD,CAAC;IAED,gBAAgB;IACT,MAAM,CAAU,qBAAqB,CAAC,QAA+B;QAC1E,OAAO,IAAI,6BAA6B,CAAC,QAAQ,EAAE,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACtG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { ImageryMapLayerFormat, IModelApp, MapLayerImageryProvider, MapLayerSourceStatus, type MapLayerSourceValidation, type ValidateSourceArgs } from \"@itwin/core-frontend\";\nimport { MapLayersFormats } from \"../mapLayersFormats.js\";\nimport { AzureMapsLayerImageryProvider, getAzureMapsSubscriptionKey } from \"./AzureMapsImageryProvider.js\";\n\n/**\n * Azure Maps imagery layer format.\n * @beta\n */\nexport class AzureMapsMapLayerFormat extends ImageryMapLayerFormat {\n /** Azure Maps imagery layer format.\n * @beta\n */\n public static override formatId = \"AzureMaps\";\n\n private static validateAzureSourceUrl(url: string): MapLayerSourceStatus {\n let parsedUrl: URL;\n try {\n parsedUrl = new URL(url);\n } catch {\n return MapLayerSourceStatus.InvalidUrl;\n }\n\n if (!parsedUrl.protocol.startsWith(\"http\"))\n return MapLayerSourceStatus.InvalidUrl;\n\n if (parsedUrl.hostname !== \"atlas.microsoft.com\" || parsedUrl.pathname !== \"/map/tile\")\n return MapLayerSourceStatus.IncompatibleFormat;\n\n return parsedUrl.searchParams.has(\"tilesetId\") ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl;\n }\n\n public static override async validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation> {\n const urlStatus = AzureMapsMapLayerFormat.validateAzureSourceUrl(args.source.url);\n if (urlStatus !== MapLayerSourceStatus.Valid)\n return { status: urlStatus };\n\n const accessKey = IModelApp.mapLayerFormatRegistry.configOptions.AzureMaps;\n if (undefined === getAzureMapsSubscriptionKey(accessKey, MapLayersFormats.azureMapsOpts?.subscriptionKey))\n return { status: MapLayerSourceStatus.RequireAuth };\n\n return { status: MapLayerSourceStatus.Valid };\n }\n\n /** @internal */\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined {\n return new AzureMapsLayerImageryProvider(settings, MapLayersFormats.azureMapsOpts?.subscriptionKey);\n }\n}\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,81 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module MapLayersFormats
|
|
7
|
+
*/
|
|
8
|
+
import { IModelApp, MapLayerImageryProvider, MapLayerImageryProviderStatus, NotifyMessageDetails, OutputMessagePriority } from "@itwin/core-frontend";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const azureMapsSubscriptionKeyParameter = "subscription-key";
|
|
11
|
+
/** @internal */
|
|
12
|
+
export function getAzureMapsSubscriptionKey(accessKey, fallbackSubscriptionKey) {
|
|
13
|
+
// A layer access key takes precedence, but an empty value falls through to the configured fallback
|
|
14
|
+
// rather than disabling auth outright.
|
|
15
|
+
if (accessKey !== undefined && accessKey.value.length > 0)
|
|
16
|
+
return accessKey.value;
|
|
17
|
+
return fallbackSubscriptionKey !== undefined && fallbackSubscriptionKey.length > 0 ? fallbackSubscriptionKey : undefined;
|
|
18
|
+
}
|
|
19
|
+
class AzureMapsRequireAuthError extends Error {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(`Azure Maps requires a non-empty ${azureMapsSubscriptionKeyParameter} credential`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Azure Maps imagery provider.
|
|
26
|
+
* @beta
|
|
27
|
+
*/
|
|
28
|
+
export class AzureMapsLayerImageryProvider extends MapLayerImageryProvider {
|
|
29
|
+
_subscriptionKey;
|
|
30
|
+
constructor(settings, _subscriptionKey) {
|
|
31
|
+
super(settings, true);
|
|
32
|
+
this._subscriptionKey = _subscriptionKey;
|
|
33
|
+
}
|
|
34
|
+
reportAzureAuthFailure() {
|
|
35
|
+
this.setStatus(MapLayerImageryProviderStatus.RequireAuth);
|
|
36
|
+
if (this._hasSuccessfullyFetchedTile) {
|
|
37
|
+
const msg = IModelApp.localization.getLocalizedString("iModelJs:MapLayers.Messages.LoadTileTokenError", { layerName: this._settings.name });
|
|
38
|
+
IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// The base loadTile marks `_hasSuccessfullyFetchedTile` as soon as a response is received, before
|
|
42
|
+
// inspecting its status. Azure returns 401/403 for missing/invalid credentials, so this override
|
|
43
|
+
// detects that before the success is recorded, ensuring no spurious token warning on the first fetch.
|
|
44
|
+
async loadTile(row, column, zoomLevel) {
|
|
45
|
+
try {
|
|
46
|
+
const tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
47
|
+
if (tileUrl.length === 0)
|
|
48
|
+
return undefined;
|
|
49
|
+
const tileResponse = await this.makeTileRequest(tileUrl);
|
|
50
|
+
if (tileResponse.status === 401 || tileResponse.status === 403) {
|
|
51
|
+
this.reportAzureAuthFailure();
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
this._hasSuccessfullyFetchedTile = true;
|
|
55
|
+
return await this.getImageFromTileResponse(tileResponse, zoomLevel);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof AzureMapsRequireAuthError)
|
|
59
|
+
this.reportAzureAuthFailure();
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async constructUrl(y, x, zoom) {
|
|
64
|
+
const subscriptionKey = getAzureMapsSubscriptionKey(this._settings.accessKey, this._subscriptionKey);
|
|
65
|
+
if (undefined === subscriptionKey)
|
|
66
|
+
throw new AzureMapsRequireAuthError();
|
|
67
|
+
return `${this._settings.url}&${azureMapsSubscriptionKeyParameter}=${encodeURIComponent(subscriptionKey)}&api-version=2.0&zoom=${zoom}&x=${x}&y=${y}`;
|
|
68
|
+
}
|
|
69
|
+
/** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [addAttributions] instead. */
|
|
70
|
+
addLogoCards(cards) {
|
|
71
|
+
if (!cards.dataset.azureMapsLogoCard) {
|
|
72
|
+
cards.dataset.azureMapsLogoCard = "true";
|
|
73
|
+
cards.appendChild(IModelApp.makeLogoCard({ heading: "Azure Maps", notice: IModelApp.localization.getLocalizedString("iModelJs:BackgroundMap.AzureMapsCopyright") }));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async addAttributions(cards, _vp) {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
78
|
+
return Promise.resolve(this.addLogoCards(cards));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# 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;AAGH,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,oBAAoB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iBAAiB,EAAE,CAAC;YACrC,KAAK,CAAC,OAAO,CAAC,iBAAiB,GAAG,MAAM,CAAC;YACzC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,2CAA2C,CAAC,EAAE,CAAC,CAAC,CAAC;QACvK,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,KAAuB,EAAE,GAAmB;QAChF,4DAA4D;QAC5D,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { ImageMapLayerSettings, type ImageSource, type MapLayerKey } from \"@itwin/core-common\";\nimport { IModelApp, MapLayerImageryProvider, MapLayerImageryProviderStatus, NotifyMessageDetails, OutputMessagePriority, ScreenViewport } from \"@itwin/core-frontend\";\n\n/** @internal */\nexport const azureMapsSubscriptionKeyParameter = \"subscription-key\";\n\n/** @internal */\nexport function getAzureMapsSubscriptionKey(accessKey: MapLayerKey | undefined, fallbackSubscriptionKey?: string): string | undefined {\n // A layer access key takes precedence, but an empty value falls through to the configured fallback\n // rather than disabling auth outright.\n if (accessKey !== undefined && accessKey.value.length > 0)\n return accessKey.value;\n\n return fallbackSubscriptionKey !== undefined && fallbackSubscriptionKey.length > 0 ? fallbackSubscriptionKey : undefined;\n}\n\nclass AzureMapsRequireAuthError extends Error {\n public constructor() {\n super(`Azure Maps requires a non-empty ${azureMapsSubscriptionKeyParameter} credential`);\n }\n}\n\n/**\n * Azure Maps imagery provider.\n * @beta\n */\nexport class AzureMapsLayerImageryProvider extends MapLayerImageryProvider {\n public constructor(settings: ImageMapLayerSettings, private readonly _subscriptionKey?: string) {\n super(settings, true);\n }\n\n private reportAzureAuthFailure(): void {\n this.setStatus(MapLayerImageryProviderStatus.RequireAuth);\n if (this._hasSuccessfullyFetchedTile) {\n const msg = IModelApp.localization.getLocalizedString(\"iModelJs:MapLayers.Messages.LoadTileTokenError\", { layerName: this._settings.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Warning, msg));\n }\n }\n\n // The base loadTile marks `_hasSuccessfullyFetchedTile` as soon as a response is received, before\n // inspecting its status. Azure returns 401/403 for missing/invalid credentials, so this override\n // detects that before the success is recorded, ensuring no spurious token warning on the first fetch.\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n try {\n const tileUrl = await this.constructUrl(row, column, zoomLevel);\n if (tileUrl.length === 0)\n return undefined;\n\n const tileResponse = await this.makeTileRequest(tileUrl);\n if (tileResponse.status === 401 || tileResponse.status === 403) {\n this.reportAzureAuthFailure();\n return undefined;\n }\n\n this._hasSuccessfullyFetchedTile = true;\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error) {\n if (error instanceof AzureMapsRequireAuthError)\n this.reportAzureAuthFailure();\n\n return undefined;\n }\n }\n\n public override async constructUrl(y: number, x: number, zoom: number): Promise<string> {\n const subscriptionKey = getAzureMapsSubscriptionKey(this._settings.accessKey, this._subscriptionKey);\n if (undefined === subscriptionKey)\n throw new AzureMapsRequireAuthError();\n\n return `${this._settings.url}&${azureMapsSubscriptionKeyParameter}=${encodeURIComponent(subscriptionKey)}&api-version=2.0&zoom=${zoom}&x=${x}&y=${y}`;\n }\n\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [addAttributions] instead. */\n public override addLogoCards(cards: HTMLTableElement): void {\n if (!cards.dataset.azureMapsLogoCard) {\n cards.dataset.azureMapsLogoCard = \"true\";\n cards.appendChild(IModelApp.makeLogoCard({ heading: \"Azure Maps\", notice: IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.AzureMapsCopyright\") }));\n }\n }\n\n public override async addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return Promise.resolve(this.addLogoCards(cards));\n }\n}\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"}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
export * from "./ArcGisFeature/ArcGisFeatureProvider.js";
|
|
6
|
+
export * from "./AzureMaps/AzureMaps.js";
|
|
7
|
+
export * from "./AzureMaps/AzureMapsImageryFormat.js";
|
|
6
8
|
export * from "./GoogleMaps/GoogleMaps.js";
|
|
7
9
|
export * from "./GoogleMaps/GoogleMapsSession.js";
|
|
8
10
|
export * from "./GoogleMaps/GoogleMapsImageryFormat.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-layers-formats.js","sourceRoot":"","sources":["../../src/map-layers-formats.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./ArcGisFeature/ArcGisFeatureProvider.js\";\nexport * from \"./GoogleMaps/GoogleMaps.js\";\nexport * from \"./GoogleMaps/GoogleMapsSession.js\";\nexport * from \"./GoogleMaps/GoogleMapsImageryFormat.js\"\nexport * from \"./mapLayersFormats.js\";\nexport * from \"./Tools/MapFeatureInfoTool.js\";\n\n/** @docs-package-description\n * This package provides support for additional map layer formats that are not included in the @itwin/core-frontend package.\n */\n\n/** @docs-group-description MapLayersFormats\n * APIs for working with the map layer formats provided by this package.\n */\n"]}
|
|
1
|
+
{"version":3,"file":"map-layers-formats.js","sourceRoot":"","sources":["../../src/map-layers-formats.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./ArcGisFeature/ArcGisFeatureProvider.js\";\nexport * from \"./AzureMaps/AzureMaps.js\";\nexport * from \"./AzureMaps/AzureMapsImageryFormat.js\";\nexport * from \"./GoogleMaps/GoogleMaps.js\";\nexport * from \"./GoogleMaps/GoogleMapsSession.js\";\nexport * from \"./GoogleMaps/GoogleMapsImageryFormat.js\"\nexport * from \"./mapLayersFormats.js\";\nexport * from \"./Tools/MapFeatureInfoTool.js\";\n\n/** @docs-package-description\n * This package provides support for additional map layer formats that are not included in the @itwin/core-frontend package.\n */\n\n/** @docs-group-description MapLayersFormats\n * APIs for working with the map layer formats provided by this package.\n */\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;
|
|
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"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { assert } from "@itwin/core-bentley";
|
|
9
9
|
import { IModelApp } from "@itwin/core-frontend";
|
|
10
10
|
import { ArcGisFeatureMapLayerFormat } from "./ArcGisFeature/ArcGisFeatureFormat.js";
|
|
11
|
+
import { AzureMapsMapLayerFormat } from "./AzureMaps/AzureMapsImageryFormat.js";
|
|
11
12
|
import { GoogleMapsMapLayerFormat } from "./GoogleMaps/GoogleMapsImageryFormat.js";
|
|
12
13
|
import { OgcApiFeaturesMapLayerFormat } from "./OgcApiFeatures/OgcApiFeaturesFormat.js";
|
|
13
14
|
import { MapFeatureInfoTool } from "./Tools/MapFeatureInfoTool.js";
|
|
@@ -18,6 +19,7 @@ export class MapLayersFormats {
|
|
|
18
19
|
static _defaultNs = "mapLayersFormats";
|
|
19
20
|
static localization;
|
|
20
21
|
static _googleMapsOpts;
|
|
22
|
+
static _azureMapsOpts;
|
|
21
23
|
/** Registers the [MapLayerFormat]($frontend)s provided by this package for use with [IModelApp]($frontend).
|
|
22
24
|
* Typically, an application will call `MapLayersFormats.initialize` immediately after [IModelApp.startup]($frontend).
|
|
23
25
|
* This function has no effect if called **before** [IModelApp.startup]($frontend) or **after** [IModelApp.shutdown]($frontend).
|
|
@@ -28,12 +30,14 @@ export class MapLayersFormats {
|
|
|
28
30
|
IModelApp.mapLayerFormatRegistry.register(ArcGisFeatureMapLayerFormat);
|
|
29
31
|
IModelApp.mapLayerFormatRegistry.register(OgcApiFeaturesMapLayerFormat);
|
|
30
32
|
IModelApp.mapLayerFormatRegistry.register(GoogleMapsMapLayerFormat);
|
|
33
|
+
IModelApp.mapLayerFormatRegistry.register(AzureMapsMapLayerFormat);
|
|
31
34
|
}
|
|
32
35
|
// register namespace containing localized strings for this package
|
|
33
36
|
MapLayersFormats.localization = config?.localization ?? IModelApp.localization;
|
|
34
37
|
await MapLayersFormats.localization.registerNamespace(MapLayersFormats.localizationNamespace);
|
|
35
38
|
MapFeatureInfoTool.register(MapLayersFormats.localizationNamespace);
|
|
36
39
|
MapLayersFormats._googleMapsOpts = config?.googleMapsOpts;
|
|
40
|
+
MapLayersFormats._azureMapsOpts = config?.azureMapsOpts;
|
|
37
41
|
}
|
|
38
42
|
/** The internationalization service namespace. */
|
|
39
43
|
static get localizationNamespace() {
|
|
@@ -42,5 +46,9 @@ export class MapLayersFormats {
|
|
|
42
46
|
static get googleMapsOpts() {
|
|
43
47
|
return MapLayersFormats._googleMapsOpts;
|
|
44
48
|
}
|
|
49
|
+
/** Azure Maps options supplied during initialization. */
|
|
50
|
+
static get azureMapsOpts() {
|
|
51
|
+
return MapLayersFormats._azureMapsOpts;
|
|
52
|
+
}
|
|
45
53
|
}
|
|
46
54
|
//# sourceMappingURL=mapLayersFormats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapLayersFormats.js","sourceRoot":"","sources":["../../src/mapLayersFormats.ts"],"names":[],"mappings":"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2B,CAAC,CAAC;YACvE,SAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC;YACxE,SAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC;YACpE,SAAS,CAAC,sBAAsB,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;QACrE,CAAC;QAED,mEAAmE;QACnE,gBAAgB,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,SAAS,CAAC,YAAY,CAAC;QAC/E,MAAM,gBAAgB,CAAC,YAAY,CAAC,iBAAiB,CACnD,gBAAgB,CAAC,qBAAqB,CACvC,CAAC;QAEF,kBAAkB,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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module MapLayersFormats\n */\nimport { assert } from \"@itwin/core-bentley\";\nimport { Localization } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { ArcGisFeatureMapLayerFormat } from \"./ArcGisFeature/ArcGisFeatureFormat.js\";\nimport { AzureMapsMapLayerFormat } from \"./AzureMaps/AzureMapsImageryFormat.js\";\nimport { GoogleMapsMapLayerFormat } from \"./GoogleMaps/GoogleMapsImageryFormat.js\";\nimport { OgcApiFeaturesMapLayerFormat } from \"./OgcApiFeatures/OgcApiFeaturesFormat.js\";\nimport { MapFeatureInfoTool } from \"./Tools/MapFeatureInfoTool.js\";\nimport { GoogleMapsSessionManager } from \"./map-layers-formats.js\";\n\n/** Configuration options.\n * @beta\n */\nexport interface MapLayersFormatsConfig {\n localization?: Localization;\n googleMapsOpts?: GoogleMapsOptions;\n /** Azure Maps options. */\n azureMapsOpts?: AzureMapsOptions;\n}\n\n/** Google Maps options.\n * @beta\n */\nexport interface GoogleMapsOptions {\n sessionManager?: GoogleMapsSessionManager\n}\n\n/** Azure Maps options.\n * @beta\n */\nexport interface AzureMapsOptions {\n /** Azure Maps subscription key used when a layer does not supply its own access key. */\n subscriptionKey?: string;\n}\n\n/** The primary API for the `@itwin/map-layers-formats` package. It allows the package's features to be [[initialize]]d.\n * @beta\n */\nexport class MapLayersFormats {\n\n private static _defaultNs = \"mapLayersFormats\";\n public static localization: Localization;\n\n private static _googleMapsOpts?: GoogleMapsOptions;\n private static _azureMapsOpts?: AzureMapsOptions;\n\n /** Registers the [MapLayerFormat]($frontend)s provided by this package for use with [IModelApp]($frontend).\n * Typically, an application will call `MapLayersFormats.initialize` immediately after [IModelApp.startup]($frontend).\n * This function has no effect if called **before** [IModelApp.startup]($frontend) or **after** [IModelApp.shutdown]($frontend).\n */\n public static async initialize(config?: MapLayersFormatsConfig): Promise<void> {\n assert(IModelApp.initialized, \"MapLayersFormats.initialize must be called after IModelApp.startup and before IModelApp.shutdown\");\n if (IModelApp.initialized) {\n IModelApp.mapLayerFormatRegistry.register(ArcGisFeatureMapLayerFormat);\n IModelApp.mapLayerFormatRegistry.register(OgcApiFeaturesMapLayerFormat);\n IModelApp.mapLayerFormatRegistry.register(GoogleMapsMapLayerFormat);\n IModelApp.mapLayerFormatRegistry.register(AzureMapsMapLayerFormat);\n }\n\n // register namespace containing localized strings for this package\n MapLayersFormats.localization = config?.localization ?? IModelApp.localization;\n await MapLayersFormats.localization.registerNamespace(\n MapLayersFormats.localizationNamespace,\n );\n\n MapFeatureInfoTool.register(MapLayersFormats.localizationNamespace);\n MapLayersFormats._googleMapsOpts = config?.googleMapsOpts;\n MapLayersFormats._azureMapsOpts = config?.azureMapsOpts;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return MapLayersFormats._defaultNs;\n }\n\n public static get googleMapsOpts() {\n return MapLayersFormats._googleMapsOpts;\n }\n\n /** Azure Maps options supplied during initialization. */\n public static get azureMapsOpts() {\n return MapLayersFormats._azureMapsOpts;\n }\n\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/map-layers-formats",
|
|
3
|
-
"version": "5.10
|
|
3
|
+
"version": "5.11.0-dev.10",
|
|
4
4
|
"description": "Enables additional map-layers formats in iTwin.js",
|
|
5
5
|
"main": "lib/cjs/map-layers-formats.js",
|
|
6
6
|
"module": "lib/esm/map-layers-formats.js",
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
"source-map-support": "^0.5.6",
|
|
53
53
|
"typescript": "~5.6.2",
|
|
54
54
|
"fetch-mock": "~11.1.3",
|
|
55
|
-
"@itwin/appui-abstract": "5.10
|
|
56
|
-
"@itwin/build-tools": "5.10
|
|
57
|
-
"@itwin/core-bentley": "5.10.2",
|
|
58
|
-
"@itwin/core-common": "5.10.2",
|
|
55
|
+
"@itwin/appui-abstract": "5.11.0-dev.10",
|
|
56
|
+
"@itwin/build-tools": "5.11.0-dev.10",
|
|
59
57
|
"internal-tools": "3.0.0-dev.69",
|
|
60
|
-
"@itwin/core-
|
|
61
|
-
"@itwin/core-
|
|
58
|
+
"@itwin/core-geometry": "5.11.0-dev.10",
|
|
59
|
+
"@itwin/core-bentley": "5.11.0-dev.10",
|
|
60
|
+
"@itwin/core-frontend": "5.11.0-dev.10",
|
|
61
|
+
"@itwin/core-common": "5.11.0-dev.10"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@itwin/
|
|
65
|
-
"@itwin/core-
|
|
66
|
-
"@itwin/core-
|
|
67
|
-
"@itwin/
|
|
68
|
-
"@itwin/core-geometry": "5.10
|
|
64
|
+
"@itwin/core-bentley": "5.11.0-dev.10",
|
|
65
|
+
"@itwin/core-frontend": "5.11.0-dev.10",
|
|
66
|
+
"@itwin/core-common": "5.11.0-dev.10",
|
|
67
|
+
"@itwin/appui-abstract": "5.11.0-dev.10",
|
|
68
|
+
"@itwin/core-geometry": "5.11.0-dev.10"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"google-protobuf": "~3.20.1",
|