@itwin/map-layers 3.0.0-extension.0 → 3.0.1

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 (72) hide show
  1. package/CHANGELOG.md +121 -4
  2. package/README.md +1 -1
  3. package/lib/cjs/MapLayerPreferences.d.ts +89 -0
  4. package/lib/cjs/MapLayerPreferences.d.ts.map +1 -0
  5. package/lib/cjs/MapLayerPreferences.js +312 -0
  6. package/lib/cjs/MapLayerPreferences.js.map +1 -0
  7. package/lib/cjs/mapLayers.d.ts +18 -13
  8. package/lib/cjs/mapLayers.d.ts.map +1 -1
  9. package/lib/cjs/mapLayers.js +25 -17
  10. package/lib/cjs/mapLayers.js.map +1 -1
  11. package/lib/cjs/public/locales/en/mapLayers.json +5 -2
  12. package/lib/cjs/ui/MapLayersUiItemsProvider.js +1 -1
  13. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
  14. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  15. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +5 -3
  16. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  17. package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
  18. package/lib/cjs/ui/widget/BasemapPanel.js +5 -4
  19. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  20. package/lib/cjs/ui/widget/MapLayerManager.d.ts +2 -2
  21. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
  22. package/lib/cjs/ui/widget/MapLayerManager.js +24 -10
  23. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  24. package/lib/cjs/ui/widget/MapLayerManager.scss +0 -7
  25. package/lib/cjs/ui/widget/MapManagerSettings.d.ts.map +1 -1
  26. package/lib/cjs/ui/widget/MapManagerSettings.js +51 -22
  27. package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -1
  28. package/lib/cjs/ui/widget/MapManagerSettings.scss +1 -1
  29. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
  30. package/lib/cjs/ui/widget/MapUrlDialog.js +231 -161
  31. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  32. package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
  33. package/lib/cjs/ui/widget/SubLayersTree.js +1 -1
  34. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  35. package/lib/cjs/ui/widget/TransparencyPopupButton.js +2 -2
  36. package/lib/cjs/ui/widget/TransparencyPopupButton.js.map +1 -1
  37. package/lib/esm/MapLayerPreferences.d.ts +89 -0
  38. package/lib/esm/MapLayerPreferences.d.ts.map +1 -0
  39. package/lib/esm/MapLayerPreferences.js +308 -0
  40. package/lib/esm/MapLayerPreferences.js.map +1 -0
  41. package/lib/esm/mapLayers.d.ts +18 -13
  42. package/lib/esm/mapLayers.d.ts.map +1 -1
  43. package/lib/esm/mapLayers.js +26 -18
  44. package/lib/esm/mapLayers.js.map +1 -1
  45. package/lib/esm/public/locales/en/mapLayers.json +5 -2
  46. package/lib/esm/ui/MapLayersUiItemsProvider.js +1 -1
  47. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
  48. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  49. package/lib/esm/ui/widget/AttachLayerPopupButton.js +6 -4
  50. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  51. package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
  52. package/lib/esm/ui/widget/BasemapPanel.js +6 -5
  53. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  54. package/lib/esm/ui/widget/MapLayerManager.d.ts +2 -2
  55. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
  56. package/lib/esm/ui/widget/MapLayerManager.js +21 -7
  57. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  58. package/lib/esm/ui/widget/MapLayerManager.scss +0 -7
  59. package/lib/esm/ui/widget/MapManagerSettings.d.ts.map +1 -1
  60. package/lib/esm/ui/widget/MapManagerSettings.js +53 -24
  61. package/lib/esm/ui/widget/MapManagerSettings.js.map +1 -1
  62. package/lib/esm/ui/widget/MapManagerSettings.scss +1 -1
  63. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
  64. package/lib/esm/ui/widget/MapUrlDialog.js +233 -163
  65. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  66. package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
  67. package/lib/esm/ui/widget/SubLayersTree.js +1 -1
  68. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  69. package/lib/esm/ui/widget/TransparencyPopupButton.js +2 -2
  70. package/lib/esm/ui/widget/TransparencyPopupButton.js.map +1 -1
  71. package/lib/public/locales/en/mapLayers.json +5 -2
  72. package/package.json +34 -39
package/CHANGELOG.md CHANGED
@@ -1,6 +1,123 @@
1
1
  # Change Log - @itwin/map-layers
2
2
 
3
- This log was last generated on Tue, 21 Sep 2021 21:06:40 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 24 Feb 2022 15:26:55 GMT and should not be manually modified.
4
+
5
+ ## 3.0.1
6
+ Thu, 24 Feb 2022 15:26:55 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.0.0
11
+ Mon, 24 Jan 2022 14:00:52 GMT
12
+
13
+ ### Updates
14
+
15
+ - Upgrade target to ES2019 and deliver both a CommonJs and ESModule version of package
16
+ - Layers could not be added through MapLayers widget when UserPreferences was not set. Fix various issues related to user preferences.
17
+ - Fixed various CSS issues in map-layers widget after recent UI framework changes.
18
+ - No longer display username/password fields by default in the custom map layers dialog: If validation fails and reports authentication is needed, we then ask end-user for credentials.
19
+ - Use QuantityNumericInput for 'Elevation Offset' and 'Model Height' fields instead of hardcoded units.
20
+ - Migrated from Toggle to ToggleSwitch component in map-layers widget
21
+ - rename contextId -> iTwinId
22
+ - Unregister maplayers itemsProvider and widget control on terminate.
23
+ - Now use 'DisplayStyleState.backgroundMapBase' instead of 'DisplayStyleState.changeBaseMapProps' to update the mapImagery.
24
+ - use new @itwin package names
25
+ - rename to @itwin/map-layers
26
+ - remove ClientRequestContext and its subclasses
27
+ - Replace usage of I18N with generic Localization interface.
28
+ - Renamed an iModel's parent container to iTwin
29
+ - Ignore lint warning for deprecated class
30
+ - Upgraded itwinui-react to 1.16.2. Fixed editor sizes.
31
+ - Update to latest itwinui-react
32
+ - Incorporating iTwinUI-CSS and iTwinUI-React into iModel.js
33
+ - Update to React 17.
34
+ - Created imodel-components folder & package and moved color, lineweight, navigationaids, quantity, timeline & viewport. Deprecated MessageSeverity in ui-core & added it ui-abstract. Added MessagePresenter interface to ui-abstract.
35
+ - Replace deprecated ThemedSelect component with iTwinUI-react Select component.
36
+ - Remove itwinUi css overrides.
37
+ - Replaced ui-core Slider with one from iTwinUi-react.
38
+ - Update to latest types/react package
39
+ - Lock down and update version numbers so docs will build.
40
+
41
+ ## 2.19.28
42
+ Wed, 12 Jan 2022 14:52:38 GMT
43
+
44
+ _Version update only_
45
+
46
+ ## 2.19.27
47
+ Wed, 05 Jan 2022 20:07:20 GMT
48
+
49
+ _Version update only_
50
+
51
+ ## 2.19.26
52
+ Wed, 08 Dec 2021 20:54:53 GMT
53
+
54
+ _Version update only_
55
+
56
+ ## 2.19.25
57
+ Fri, 03 Dec 2021 20:05:49 GMT
58
+
59
+ _Version update only_
60
+
61
+ ## 2.19.24
62
+ Mon, 29 Nov 2021 18:44:31 GMT
63
+
64
+ ### Updates
65
+
66
+ - Fixed UI spacing issues in map-layers widget.
67
+
68
+ ## 2.19.23
69
+ Mon, 22 Nov 2021 20:41:40 GMT
70
+
71
+ _Version update only_
72
+
73
+ ## 2.19.22
74
+ Wed, 17 Nov 2021 01:23:26 GMT
75
+
76
+ _Version update only_
77
+
78
+ ## 2.19.21
79
+ Wed, 10 Nov 2021 10:58:24 GMT
80
+
81
+ _Version update only_
82
+
83
+ ## 2.19.20
84
+ Fri, 29 Oct 2021 16:14:22 GMT
85
+
86
+ ### Updates
87
+
88
+ - Added Mask transparency to map-layers widget.
89
+
90
+ ## 2.19.19
91
+ Mon, 25 Oct 2021 16:16:25 GMT
92
+
93
+ ### Updates
94
+
95
+ - Drop unnecessary dep on @bentley/react-scripts
96
+
97
+ ## 2.19.18
98
+ Thu, 21 Oct 2021 20:59:44 GMT
99
+
100
+ _Version update only_
101
+
102
+ ## 2.19.17
103
+ Thu, 14 Oct 2021 21:19:43 GMT
104
+
105
+ _Version update only_
106
+
107
+ ## 2.19.16
108
+ Mon, 11 Oct 2021 17:37:46 GMT
109
+
110
+ _Version update only_
111
+
112
+ ## 2.19.15
113
+ Fri, 08 Oct 2021 16:44:23 GMT
114
+
115
+ _Version update only_
116
+
117
+ ## 2.19.14
118
+ Fri, 01 Oct 2021 13:07:03 GMT
119
+
120
+ _Version update only_
4
121
 
5
122
  ## 2.19.13
6
123
  Tue, 21 Sep 2021 21:06:40 GMT
@@ -178,7 +295,7 @@ Mon, 24 May 2021 15:58:39 GMT
178
295
 
179
296
  ### Updates
180
297
 
181
- - Fix 'npm run cover' that would never complete.
298
+ - Fix 'npm run cover' that would never complete.
182
299
  - Exposed the map masking option in the map layers settings UI.
183
300
  - Move map tile trees to Viewport to handle synching correctly
184
301
  - Update to latest classnames package
@@ -253,7 +370,7 @@ Tue, 09 Mar 2021 20:28:13 GMT
253
370
 
254
371
  ### Updates
255
372
 
256
- - Restored base layer visibility button in map manager.
373
+ - Restored base layer visibility button in map manager.
257
374
  - Updated to use TypeScript 4.1
258
375
  - begin rename project from iModel.js to iTwin.js
259
376
 
@@ -278,7 +395,7 @@ Thu, 18 Feb 2021 22:10:13 GMT
278
395
  ### Updates
279
396
 
280
397
  - Provide default props to map-layers widget when used as an extension.
281
- - ArcGIS token-based authentification support: MapLayerManager now monitor provider status and display a warning icon when there is a authentifiation error while loading tiles. User is allowed to provide credentials without the need to fully re-attach the layer. Invalid credentials feedback is now provided. It is now possible to save an ArcGIS layer requiring authentification in the settings service, althoug redentials wont be persisted.
398
+ - ArcGIS token-based authentification support: MapLayerManager now monitor provider status and display a warning icon when there is a authentifiation error while loading tiles. User is allowed to provide credentials without the need to fully re-attach the layer. Invalid credentials feedback is now provided. It is now possible to save an ArcGIS layer requiring authentification in the settings service, althoug redentials wont be persisted.
282
399
 
283
400
  ## 2.11.2
284
401
  Thu, 18 Feb 2021 02:50:59 GMT
package/README.md CHANGED
@@ -29,4 +29,4 @@ This package can also be installed into an application and the method MapLayersU
29
29
 
30
30
  ## Contributing
31
31
 
32
- [Contributing to iTwin.js](https://github.com/imodeljs/imodeljs/blob/master/CONTRIBUTING.md)
32
+ [Contributing to iTwin.js](https://github.com/iTwin/itwinjs-core/blob/master/CONTRIBUTING.md)
@@ -0,0 +1,89 @@
1
+ import { MapLayerSource } from "@itwin/core-frontend";
2
+ import { BeEvent, GuidString } from "@itwin/core-bentley";
3
+ /** @internal */
4
+ export interface MapLayerPreferencesContent {
5
+ url: string;
6
+ name: string;
7
+ formatId: string;
8
+ transparentBackground: boolean | undefined;
9
+ }
10
+ /** @internal */
11
+ export declare enum MapLayerSourceChangeType {
12
+ Added = 0,
13
+ Removed = 1,
14
+ Replaced = 2
15
+ }
16
+ /** @internal */
17
+ export interface MapLayerSourceArg {
18
+ readonly source: MapLayerSource;
19
+ readonly iTwinId: GuidString;
20
+ readonly iModelId: GuidString;
21
+ }
22
+ /** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].
23
+ *
24
+ * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.
25
+ *
26
+ * @internal
27
+ */
28
+ export declare class MapLayerPreferences {
29
+ /** Event raised whenever a source is added, replaced or removed:
30
+ * changeType : Type of changed occurred.
31
+ * oldSource : Source that was removed or replaced.
32
+ * newSource : Source that was added or replacement of oldSource.
33
+ *
34
+ * @see [[MapLayerSourceChangeType]]
35
+ */
36
+ static readonly onLayerSourceChanged: BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource | undefined, newSource?: MapLayerSource | undefined) => void>;
37
+ /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.
38
+ *
39
+ * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when
40
+ * a project setting exists with same name or map layer url.
41
+ * @param source source to be stored on the setting service
42
+ * @param storeOnIModel if true store the settings object on the model, if false store it on the project
43
+ */
44
+ static storeSource(source: MapLayerSource, storeOnIModel: boolean, iTwinId: GuidString, iModelId: GuidString): Promise<boolean>;
45
+ /** Replace the old map layer source with a new map layer source.
46
+ *
47
+ * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)
48
+ *
49
+ * @param oldSource
50
+ * @param newSource
51
+ * @param projectId
52
+ * @param iModelId
53
+ */
54
+ static replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, projectId: GuidString, iModelId: GuidString): Promise<void>;
55
+ /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.
56
+ *
57
+ * @param source The source to delete. The name is used to identify the source.
58
+ * @param iTwinId
59
+ * @param iModelId
60
+ */
61
+ static deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId: GuidString): Promise<void>;
62
+ /** Deletes the current setting with the provided key if it is defined at the same preference level.
63
+ *
64
+ * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.
65
+ *
66
+ * The two potential preference levels are iTwin and iModel.
67
+ *
68
+ * @param url
69
+ * @param name
70
+ * @param iTwinId
71
+ * @param iModelId
72
+ * @param storeOnIModel
73
+ */
74
+ private static delete;
75
+ /** Attempts to get a map layer based off a specific url.
76
+ * @param url
77
+ * @param projectId
78
+ * @param iModelId
79
+ */
80
+ static getByUrl(url: string, projectId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined>;
81
+ /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.
82
+ * @param projectId id of the project
83
+ * @param iModelId id of the iModel
84
+ * @throws if any of the calls to grab settings fail.
85
+ */
86
+ static getSources(projectId: GuidString, iModelId: GuidString): Promise<MapLayerSource[]>;
87
+ private static get _preferenceNamespace();
88
+ }
89
+ //# sourceMappingURL=MapLayerPreferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayerPreferences.d.ts","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,cAAc,EAA+C,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG1D,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC;CAC5C;AAED,gBAAgB;AAChB,oBAAY,wBAAwB;IAClC,KAAK,IAAI;IACT,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED,gBAAgB;AAChB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;OAMG;IACH,gBAAuB,oBAAoB,uBAA4B,wBAAwB,qFAA6D,IAAI,EAAI;IAEpK;;;;;;OAMG;WACiB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IA8B5I;;;;;;;;OAQG;WACiB,aAAa,CAAC,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA0CnJ;;;;;OAKG;WACiB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BlH;;;;;;;;;;;OAWG;mBACkB,MAAM;IA+E3B;;;;OAIG;WACiB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC;IA0BhI;;;;OAIG;WACiB,UAAU,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA6CtG,OAAO,CAAC,MAAM,KAAK,oBAAoB,GAEtC;CACF"}
@@ -0,0 +1,312 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MapLayerPreferences = exports.MapLayerSourceChangeType = void 0;
8
+ const core_frontend_1 = require("@itwin/core-frontend");
9
+ const core_bentley_1 = require("@itwin/core-bentley");
10
+ const mapLayers_1 = require("./mapLayers");
11
+ /** @internal */
12
+ var MapLayerSourceChangeType;
13
+ (function (MapLayerSourceChangeType) {
14
+ MapLayerSourceChangeType[MapLayerSourceChangeType["Added"] = 0] = "Added";
15
+ MapLayerSourceChangeType[MapLayerSourceChangeType["Removed"] = 1] = "Removed";
16
+ MapLayerSourceChangeType[MapLayerSourceChangeType["Replaced"] = 2] = "Replaced";
17
+ })(MapLayerSourceChangeType = exports.MapLayerSourceChangeType || (exports.MapLayerSourceChangeType = {}));
18
+ /** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].
19
+ *
20
+ * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.
21
+ *
22
+ * @internal
23
+ */
24
+ class MapLayerPreferences {
25
+ /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.
26
+ *
27
+ * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when
28
+ * a project setting exists with same name or map layer url.
29
+ * @param source source to be stored on the setting service
30
+ * @param storeOnIModel if true store the settings object on the model, if false store it on the project
31
+ */
32
+ static async storeSource(source, storeOnIModel, iTwinId, iModelId) {
33
+ if (!mapLayers_1.MapLayersUI.iTwinConfig)
34
+ return false;
35
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
36
+ const sourceJSON = source.toJSON();
37
+ const mapLayerSetting = {
38
+ url: sourceJSON.url,
39
+ name: sourceJSON.name,
40
+ formatId: sourceJSON.formatId,
41
+ transparentBackground: sourceJSON.transparentBackground,
42
+ };
43
+ const result = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);
44
+ if (result) {
45
+ await mapLayers_1.MapLayersUI.iTwinConfig.save({
46
+ accessToken,
47
+ content: mapLayerSetting,
48
+ namespace: MapLayerPreferences._preferenceNamespace,
49
+ key: sourceJSON.name,
50
+ iTwinId,
51
+ iModelId: storeOnIModel ? iModelId : undefined,
52
+ });
53
+ MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, core_frontend_1.MapLayerSource.fromJSON(mapLayerSetting));
54
+ return true;
55
+ }
56
+ else {
57
+ return false;
58
+ }
59
+ }
60
+ /** Replace the old map layer source with a new map layer source.
61
+ *
62
+ * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)
63
+ *
64
+ * @param oldSource
65
+ * @param newSource
66
+ * @param projectId
67
+ * @param iModelId
68
+ */
69
+ static async replaceSource(oldSource, newSource, projectId, iModelId) {
70
+ if (!mapLayers_1.MapLayersUI.iTwinConfig)
71
+ return;
72
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
73
+ let storeOnIModel = false;
74
+ try {
75
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
76
+ accessToken,
77
+ namespace: MapLayerPreferences._preferenceNamespace,
78
+ key: oldSource.name,
79
+ iTwinId: projectId,
80
+ iModelId,
81
+ });
82
+ }
83
+ catch (_err) {
84
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
85
+ accessToken,
86
+ namespace: MapLayerPreferences._preferenceNamespace,
87
+ key: oldSource.name,
88
+ iTwinId: projectId,
89
+ });
90
+ storeOnIModel = true;
91
+ }
92
+ const mapLayerSetting = {
93
+ url: newSource.url,
94
+ name: newSource.name,
95
+ formatId: newSource.formatId,
96
+ transparentBackground: newSource.transparentBackground,
97
+ };
98
+ await mapLayers_1.MapLayersUI.iTwinConfig.save({
99
+ accessToken,
100
+ key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,
101
+ iTwinId: projectId,
102
+ iModelId: storeOnIModel ? iModelId : undefined,
103
+ content: mapLayerSetting,
104
+ });
105
+ MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);
106
+ }
107
+ /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.
108
+ *
109
+ * @param source The source to delete. The name is used to identify the source.
110
+ * @param iTwinId
111
+ * @param iModelId
112
+ */
113
+ static async deleteByName(source, iTwinId, iModelId) {
114
+ if (!mapLayers_1.MapLayersUI.iTwinConfig)
115
+ return;
116
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
117
+ try {
118
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
119
+ accessToken,
120
+ namespace: MapLayerPreferences._preferenceNamespace,
121
+ key: source.name,
122
+ iTwinId,
123
+ iModelId,
124
+ });
125
+ }
126
+ catch (_err) {
127
+ // failed to store based on iModelId, attempt using iTwinId
128
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
129
+ accessToken,
130
+ namespace: MapLayerPreferences._preferenceNamespace,
131
+ key: source.name,
132
+ iTwinId,
133
+ });
134
+ }
135
+ MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);
136
+ }
137
+ /** Deletes the current setting with the provided key if it is defined at the same preference level.
138
+ *
139
+ * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.
140
+ *
141
+ * The two potential preference levels are iTwin and iModel.
142
+ *
143
+ * @param url
144
+ * @param name
145
+ * @param iTwinId
146
+ * @param iModelId
147
+ * @param storeOnIModel
148
+ */
149
+ static async delete(url, name, iTwinId, iModelId, storeOnIModel) {
150
+ if (!mapLayers_1.MapLayersUI.iTwinConfig)
151
+ return true;
152
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
153
+ const iTwinPreferenceByName = await mapLayers_1.MapLayersUI.iTwinConfig.get({
154
+ accessToken,
155
+ namespace: MapLayerPreferences._preferenceNamespace,
156
+ key: name,
157
+ iTwinId,
158
+ });
159
+ if (undefined !== iTwinPreferenceByName && storeOnIModel) {
160
+ const errorMessage = core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.LayerExistsAsProjectSetting", { layer: iTwinPreferenceByName.name });
161
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Error, errorMessage));
162
+ return false;
163
+ }
164
+ else if (iTwinPreferenceByName) {
165
+ const infoMessage = core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.LayerExistsOverwriting", { layer: iTwinPreferenceByName.name });
166
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Info, infoMessage));
167
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
168
+ accessToken,
169
+ namespace: MapLayerPreferences._preferenceNamespace,
170
+ key: iTwinPreferenceByName.name,
171
+ iTwinId,
172
+ });
173
+ }
174
+ // check if setting with url already exists, if it does, delete it
175
+ const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);
176
+ if (settingFromUrl && storeOnIModel) {
177
+ const errorMessage = core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting", { url: settingFromUrl.url, name: settingFromUrl.name });
178
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Error, errorMessage));
179
+ return false;
180
+ }
181
+ else if (settingFromUrl) {
182
+ const infoMessage = core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.LayerWithUrlExistsOverwriting", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });
183
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Info, infoMessage));
184
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
185
+ accessToken,
186
+ namespace: MapLayerPreferences._preferenceNamespace,
187
+ key: settingFromUrl.name,
188
+ iTwinId,
189
+ });
190
+ }
191
+ if (iModelId) { // delete any settings on model so user can update them if theres collisions
192
+ const settingOnIModelFromName = await mapLayers_1.MapLayersUI.iTwinConfig.get({
193
+ accessToken,
194
+ namespace: MapLayerPreferences._preferenceNamespace,
195
+ key: name,
196
+ iTwinId,
197
+ iModelId,
198
+ });
199
+ const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);
200
+ if (settingOnIModelFromName) {
201
+ const infoMessage = core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.LayerExistsOverwriting", { layer: settingOnIModelFromName.name });
202
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Info, infoMessage));
203
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
204
+ accessToken,
205
+ namespace: MapLayerPreferences._preferenceNamespace,
206
+ key: settingOnIModelFromName.name,
207
+ iTwinId,
208
+ iModelId,
209
+ });
210
+ }
211
+ if (settingFromUrlOnIModel) {
212
+ const infoMessage = core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.LayerWithUrlExistsOverwriting", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });
213
+ core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Info, infoMessage));
214
+ await mapLayers_1.MapLayersUI.iTwinConfig.delete({
215
+ accessToken,
216
+ namespace: MapLayerPreferences._preferenceNamespace,
217
+ key: settingFromUrlOnIModel.name,
218
+ iTwinId,
219
+ iModelId,
220
+ });
221
+ }
222
+ }
223
+ return true;
224
+ }
225
+ /** Attempts to get a map layer based off a specific url.
226
+ * @param url
227
+ * @param projectId
228
+ * @param iModelId
229
+ */
230
+ static async getByUrl(url, projectId, iModelId) {
231
+ var _a;
232
+ if (!mapLayers_1.MapLayersUI.iTwinConfig)
233
+ return undefined;
234
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
235
+ const settingResponse = await mapLayers_1.MapLayersUI.iTwinConfig.get({
236
+ accessToken,
237
+ namespace: MapLayerPreferences._preferenceNamespace,
238
+ key: "",
239
+ iTwinId: projectId,
240
+ iModelId,
241
+ });
242
+ if (undefined === settingResponse || 0 === settingResponse.length)
243
+ return undefined;
244
+ let savedMapLayer;
245
+ (_a = settingResponse.settingsMap) === null || _a === void 0 ? void 0 : _a.forEach((savedLayer) => {
246
+ if (savedLayer.url === url) {
247
+ savedMapLayer = savedLayer;
248
+ }
249
+ });
250
+ return savedMapLayer;
251
+ }
252
+ /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.
253
+ * @param projectId id of the project
254
+ * @param iModelId id of the iModel
255
+ * @throws if any of the calls to grab settings fail.
256
+ */
257
+ static async getSources(projectId, iModelId) {
258
+ if (!mapLayers_1.MapLayersUI.iTwinConfig)
259
+ return [];
260
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
261
+ const mapLayerList = [];
262
+ try {
263
+ const userResultByProject = await mapLayers_1.MapLayersUI.iTwinConfig.get({
264
+ accessToken,
265
+ namespace: MapLayerPreferences._preferenceNamespace,
266
+ key: "",
267
+ iTwinId: projectId,
268
+ });
269
+ if (undefined !== userResultByProject)
270
+ mapLayerList.push(userResultByProject);
271
+ }
272
+ catch (err) {
273
+ throw new Error(core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.ErrorRetrieveUserProject", { errorMessage: err }));
274
+ }
275
+ try {
276
+ const userResultByIModel = await mapLayers_1.MapLayersUI.iTwinConfig.get({
277
+ accessToken,
278
+ namespace: MapLayerPreferences._preferenceNamespace,
279
+ key: "",
280
+ iTwinId: projectId,
281
+ iModelId,
282
+ });
283
+ if (undefined !== userResultByIModel)
284
+ mapLayerList.push(userResultByIModel);
285
+ }
286
+ catch (err) {
287
+ throw new Error(core_frontend_1.IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.ErrorRetrieveUserProject", { errorMessage: err }));
288
+ }
289
+ const savedMapLayerSources = [];
290
+ for (const mapLayer of mapLayerList) {
291
+ mapLayer.forEach((savedLayer) => {
292
+ const mapLayerSource = core_frontend_1.MapLayerSource.fromJSON(savedLayer);
293
+ if (mapLayerSource)
294
+ savedMapLayerSources.push(mapLayerSource);
295
+ });
296
+ }
297
+ return savedMapLayerSources;
298
+ }
299
+ static get _preferenceNamespace() {
300
+ return "MapLayerSource-SettingsService";
301
+ }
302
+ }
303
+ exports.MapLayerPreferences = MapLayerPreferences;
304
+ /** Event raised whenever a source is added, replaced or removed:
305
+ * changeType : Type of changed occurred.
306
+ * oldSource : Source that was removed or replaced.
307
+ * newSource : Source that was added or replacement of oldSource.
308
+ *
309
+ * @see [[MapLayerSourceChangeType]]
310
+ */
311
+ MapLayerPreferences.onLayerSourceChanged = new core_bentley_1.BeEvent(); // Used to notify the frontend that it needs to update its list of available layers
312
+ //# sourceMappingURL=MapLayerPreferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,aAAsB,EAAE,OAAmB,EAAE,QAAoB;QACvH,IAAI,CAAC,uBAAW,CAAC,WAAW;YAC1B,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAErI,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,eAAe,GAA+B;YAClD,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,qBAAqB,EAAE,UAAU,CAAC,qBAAqB;SACxD,CAAC;QAEF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AAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAhTH,kDAiTC;AAhTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","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\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\r\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\r\nimport { MapLayersUI } from \"./mapLayers\";\r\n\r\n/** @internal */\r\nexport interface MapLayerPreferencesContent {\r\n url: string;\r\n name: string;\r\n formatId: string;\r\n transparentBackground: boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\nexport enum MapLayerSourceChangeType {\r\n Added = 0,\r\n Removed = 1,\r\n Replaced = 2,\r\n}\r\n\r\n/** @internal */\r\nexport interface MapLayerSourceArg {\r\n readonly source: MapLayerSource;\r\n readonly iTwinId: GuidString;\r\n readonly iModelId: GuidString;\r\n}\r\n\r\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\r\n *\r\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\r\n *\r\n * @internal\r\n */\r\nexport class MapLayerPreferences {\r\n /** Event raised whenever a source is added, replaced or removed:\r\n * changeType : Type of changed occurred.\r\n * oldSource : Source that was removed or replaced.\r\n * newSource : Source that was added or replacement of oldSource.\r\n *\r\n * @see [[MapLayerSourceChangeType]]\r\n */\r\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\r\n\r\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\r\n *\r\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\r\n * a project setting exists with same name or map layer url.\r\n * @param source source to be stored on the setting service\r\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\r\n */\r\n public static async storeSource(source: MapLayerSource, storeOnIModel: boolean, iTwinId: GuidString, iModelId: GuidString): Promise<boolean> {\r\n if (!MapLayersUI.iTwinConfig)\r\n return false;\r\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\r\n\r\n const sourceJSON = source.toJSON();\r\n const mapLayerSetting: MapLayerPreferencesContent = {\r\n url: sourceJSON.url,\r\n name: sourceJSON.name,\r\n formatId: sourceJSON.formatId,\r\n transparentBackground: sourceJSON.transparentBackground,\r\n };\r\n\r\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\r\n if (result) {\r\n await MapLayersUI.iTwinConfig.save({\r\n accessToken,\r\n content: mapLayerSetting,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: sourceJSON.name,\r\n iTwinId,\r\n iModelId: storeOnIModel ? iModelId : undefined,\r\n });\r\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /** Replace the old map layer source with a new map layer source.\r\n *\r\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\r\n *\r\n * @param oldSource\r\n * @param newSource\r\n * @param projectId\r\n * @param iModelId\r\n */\r\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, projectId: GuidString, iModelId: GuidString): Promise<void> {\r\n if (!MapLayersUI.iTwinConfig)\r\n return;\r\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\r\n\r\n let storeOnIModel = false;\r\n try {\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: oldSource.name,\r\n iTwinId: projectId,\r\n iModelId,\r\n });\r\n } catch (_err) {\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: oldSource.name,\r\n iTwinId: projectId,\r\n });\r\n storeOnIModel = true;\r\n }\r\n\r\n const mapLayerSetting: MapLayerPreferencesContent = {\r\n url: newSource.url,\r\n name: newSource.name,\r\n formatId: newSource.formatId,\r\n transparentBackground: newSource.transparentBackground,\r\n };\r\n\r\n await MapLayersUI.iTwinConfig.save({\r\n accessToken,\r\n key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,\r\n iTwinId: projectId,\r\n iModelId: storeOnIModel ? iModelId : undefined,\r\n content: mapLayerSetting,\r\n });\r\n\r\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\r\n }\r\n\r\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\r\n *\r\n * @param source The source to delete. The name is used to identify the source.\r\n * @param iTwinId\r\n * @param iModelId\r\n */\r\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId: GuidString): Promise<void> {\r\n if (!MapLayersUI.iTwinConfig)\r\n return;\r\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\r\n\r\n try {\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: source.name,\r\n iTwinId,\r\n iModelId,\r\n });\r\n } catch (_err) {\r\n // failed to store based on iModelId, attempt using iTwinId\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: source.name,\r\n iTwinId,\r\n });\r\n }\r\n\r\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\r\n }\r\n\r\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\r\n *\r\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\r\n *\r\n * The two potential preference levels are iTwin and iModel.\r\n *\r\n * @param url\r\n * @param name\r\n * @param iTwinId\r\n * @param iModelId\r\n * @param storeOnIModel\r\n */\r\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId: GuidString, storeOnIModel: boolean): Promise<boolean> {\r\n if (!MapLayersUI.iTwinConfig)\r\n return true;\r\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\r\n\r\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: name,\r\n iTwinId,\r\n });\r\n\r\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\r\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\r\n return false;\r\n } else if (iTwinPreferenceByName) {\r\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: iTwinPreferenceByName.name,\r\n iTwinId,\r\n });\r\n }\r\n\r\n // check if setting with url already exists, if it does, delete it\r\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\r\n if (settingFromUrl && storeOnIModel) {\r\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\r\n return false;\r\n } else if (settingFromUrl) {\r\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: settingFromUrl.name,\r\n iTwinId,\r\n });\r\n }\r\n\r\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\r\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: name,\r\n iTwinId,\r\n iModelId,\r\n });\r\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\r\n if (settingOnIModelFromName) {\r\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: settingOnIModelFromName.name,\r\n iTwinId,\r\n iModelId,\r\n });\r\n }\r\n if (settingFromUrlOnIModel) {\r\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\r\n await MapLayersUI.iTwinConfig.delete({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: settingFromUrlOnIModel.name,\r\n iTwinId,\r\n iModelId,\r\n });\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /** Attempts to get a map layer based off a specific url.\r\n * @param url\r\n * @param projectId\r\n * @param iModelId\r\n */\r\n public static async getByUrl(url: string, projectId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\r\n if (!MapLayersUI.iTwinConfig)\r\n return undefined;\r\n\r\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\r\n\r\n const settingResponse = await MapLayersUI.iTwinConfig.get({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: \"\",\r\n iTwinId: projectId,\r\n iModelId,\r\n });\r\n\r\n if (undefined === settingResponse || 0 === settingResponse.length)\r\n return undefined;\r\n\r\n let savedMapLayer;\r\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\r\n if (savedLayer.url === url) {\r\n savedMapLayer = savedLayer;\r\n }\r\n });\r\n return savedMapLayer;\r\n }\r\n\r\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\r\n * @param projectId id of the project\r\n * @param iModelId id of the iModel\r\n * @throws if any of the calls to grab settings fail.\r\n */\r\n public static async getSources(projectId: GuidString, iModelId: GuidString): Promise<MapLayerSource[]> {\r\n if (!MapLayersUI.iTwinConfig)\r\n return [];\r\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\r\n\r\n const mapLayerList = [];\r\n\r\n try {\r\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: \"\",\r\n iTwinId: projectId,\r\n });\r\n if (undefined !== userResultByProject)\r\n mapLayerList.push(userResultByProject);\r\n } catch (err: any) {\r\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\r\n }\r\n\r\n try {\r\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\r\n accessToken,\r\n namespace: MapLayerPreferences._preferenceNamespace,\r\n key: \"\",\r\n iTwinId: projectId,\r\n iModelId,\r\n });\r\n if (undefined !== userResultByIModel)\r\n mapLayerList.push(userResultByIModel);\r\n } catch (err: any) {\r\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\r\n }\r\n\r\n const savedMapLayerSources: MapLayerSource[] = [];\r\n for (const mapLayer of mapLayerList) {\r\n mapLayer.forEach((savedLayer: any) => {\r\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\r\n if (mapLayerSource)\r\n savedMapLayerSources.push(mapLayerSource);\r\n });\r\n }\r\n return savedMapLayerSources;\r\n }\r\n\r\n private static get _preferenceNamespace() {\r\n return \"MapLayerSource-SettingsService\";\r\n }\r\n}\r\n"]}
@@ -1,25 +1,30 @@
1
- /**
2
- * MapLayersApi is use when the package is used as a dependency to another app and not used as an extension.
1
+ import { UserPreferencesAccess } from "@itwin/core-frontend";
2
+ /** MapLayersUI is use when the package is used as a dependency to another app.
3
3
  * '''ts
4
- * // if registerItemsProvider is false the MapLayersWidgetControl control will be registered with appui-react's ConfigurableUiManager
5
- * // so it can be explicitly added to a stage via a FrontstageDef.
6
- * await MapLayersUI.initialize (registerItemsProvider);
4
+ * await MapLayersUI.initialize(registerItemsProvider);
7
5
  * '''
8
6
  * @beta
9
7
  */
10
8
  export declare class MapLayersUI {
11
9
  private static _defaultNs;
12
10
  private static _uiItemsProvider;
13
- /** Used to initialize the MapLayersAPI when used as a package. If `registerItemsProvider` is true then the
14
- * UiItemsProvider will automatically insert the UI items into the host applications UI. If it is false then
15
- * explicitly add widget definition to a specific FrontStage definition using the following syntax.
16
- * ``` tsx
17
- * <Widget id={MapLayersWidgetControl.id} label={MapLayersWidgetControl.label} control={MapLayersWidgetControl}
11
+ private static _itemsProviderRegistered?;
12
+ private static _iTwinConfig?;
13
+ static get iTwinConfig(): UserPreferencesAccess | undefined;
14
+ /** Used to initialize the Map Layers.
15
+ *
16
+ * If `registerItemsProvider` is true, the UiItemsProvider will automatically insert the UI items into the host applications UI.
17
+ * If it is false, explicitly add widget definition to a specific FrontStage definition using the following syntax.
18
+ *
19
+ * ```tsx
20
+ * <Widget id={MapLayersWidgetControl.id} label={MapLayersWidgetControl.label} control={MapLayersWidgetControl}
18
21
  * iconSpec={MapLayersWidgetControl.iconSpec} />,
19
- * ```
22
+ * ```
23
+ *
24
+ * If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored.
20
25
  */
21
- static initialize(registerItemsProvider?: boolean): Promise<void>;
22
- /** Unregisters the GeoTools internationalization service namespace */
26
+ static initialize(registerItemsProvider?: boolean, iTwinConfig?: UserPreferencesAccess): Promise<void>;
27
+ /** Unregisters internationalization service namespace and UiItemManager / control */
23
28
  static terminate(): void;
24
29
  /** The internationalization service namespace. */
25
30
  static get localizationNamespace(): string;