@itwin/map-layers 3.1.0-dev.8 → 3.2.0-dev.3

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 (143) hide show
  1. package/CHANGELOG.md +40 -4
  2. package/lib/cjs/MapLayerPreferences.d.ts +8 -8
  3. package/lib/cjs/MapLayerPreferences.d.ts.map +1 -1
  4. package/lib/cjs/MapLayerPreferences.js +13 -13
  5. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  6. package/lib/cjs/map-layers.d.ts +2 -0
  7. package/lib/cjs/map-layers.d.ts.map +1 -1
  8. package/lib/cjs/map-layers.js +2 -0
  9. package/lib/cjs/map-layers.js.map +1 -1
  10. package/lib/cjs/mapLayers.d.ts +15 -17
  11. package/lib/cjs/mapLayers.d.ts.map +1 -1
  12. package/lib/cjs/mapLayers.js +25 -35
  13. package/lib/cjs/mapLayers.js.map +1 -1
  14. package/lib/cjs/public/locales/en/mapLayers.json +4 -0
  15. package/lib/cjs/ui/FeatureInfoUiItemsProvider.d.ts +11 -0
  16. package/lib/cjs/ui/FeatureInfoUiItemsProvider.d.ts.map +1 -0
  17. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +51 -0
  18. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -0
  19. package/lib/cjs/ui/Interfaces.d.ts +19 -3
  20. package/lib/cjs/ui/Interfaces.d.ts.map +1 -1
  21. package/lib/cjs/ui/Interfaces.js.map +1 -1
  22. package/lib/cjs/ui/MapFeatureInfoTool.d.ts +14 -0
  23. package/lib/cjs/ui/MapFeatureInfoTool.d.ts.map +1 -0
  24. package/lib/cjs/ui/MapFeatureInfoTool.js +51 -0
  25. package/lib/cjs/ui/MapFeatureInfoTool.js.map +1 -0
  26. package/lib/cjs/ui/MapLayersUiItemsProvider.d.ts +4 -18
  27. package/lib/cjs/ui/MapLayersUiItemsProvider.d.ts.map +1 -1
  28. package/lib/cjs/ui/MapLayersUiItemsProvider.js +13 -29
  29. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
  30. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  31. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +23 -15
  32. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  33. package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
  34. package/lib/cjs/ui/widget/BasemapPanel.js +13 -13
  35. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  36. package/lib/cjs/ui/widget/BasemapPanel.scss +5 -1
  37. package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts +41 -0
  38. package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts.map +1 -0
  39. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +140 -0
  40. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -0
  41. package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts +8 -0
  42. package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts.map +1 -0
  43. package/lib/cjs/ui/widget/FeatureInfoWidget.js +72 -0
  44. package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -0
  45. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  46. package/lib/cjs/ui/widget/MapLayerDroppable.js +14 -11
  47. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  48. package/lib/cjs/ui/widget/MapLayerManager.d.ts +2 -2
  49. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
  50. package/lib/cjs/ui/widget/MapLayerManager.js +25 -23
  51. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  52. package/lib/cjs/ui/widget/MapLayerSettingsMenu.d.ts.map +1 -1
  53. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js +5 -5
  54. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  55. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -1
  56. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +2 -2
  57. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  58. package/lib/cjs/ui/widget/MapLayersWidget.d.ts.map +1 -1
  59. package/lib/cjs/ui/widget/MapLayersWidget.js +2 -2
  60. package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -1
  61. package/lib/cjs/ui/widget/MapManagerSettings.js +16 -16
  62. package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -1
  63. package/lib/cjs/ui/widget/MapUrlDialog.d.ts +3 -3
  64. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
  65. package/lib/cjs/ui/widget/MapUrlDialog.js +50 -44
  66. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  67. package/lib/cjs/ui/widget/SubLayersPopupButton.js +3 -3
  68. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
  69. package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
  70. package/lib/cjs/ui/widget/SubLayersTree.js +24 -18
  71. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  72. package/lib/esm/MapLayerPreferences.d.ts +8 -8
  73. package/lib/esm/MapLayerPreferences.d.ts.map +1 -1
  74. package/lib/esm/MapLayerPreferences.js +13 -13
  75. package/lib/esm/MapLayerPreferences.js.map +1 -1
  76. package/lib/esm/map-layers.d.ts +2 -0
  77. package/lib/esm/map-layers.d.ts.map +1 -1
  78. package/lib/esm/map-layers.js +2 -0
  79. package/lib/esm/map-layers.js.map +1 -1
  80. package/lib/esm/mapLayers.d.ts +15 -17
  81. package/lib/esm/mapLayers.d.ts.map +1 -1
  82. package/lib/esm/mapLayers.js +25 -35
  83. package/lib/esm/mapLayers.js.map +1 -1
  84. package/lib/esm/public/locales/en/mapLayers.json +4 -0
  85. package/lib/esm/ui/FeatureInfoUiItemsProvider.d.ts +11 -0
  86. package/lib/esm/ui/FeatureInfoUiItemsProvider.d.ts.map +1 -0
  87. package/lib/esm/ui/FeatureInfoUiItemsProvider.js +47 -0
  88. package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -0
  89. package/lib/esm/ui/Interfaces.d.ts +19 -3
  90. package/lib/esm/ui/Interfaces.d.ts.map +1 -1
  91. package/lib/esm/ui/Interfaces.js.map +1 -1
  92. package/lib/esm/ui/MapFeatureInfoTool.d.ts +14 -0
  93. package/lib/esm/ui/MapFeatureInfoTool.d.ts.map +1 -0
  94. package/lib/esm/ui/MapFeatureInfoTool.js +46 -0
  95. package/lib/esm/ui/MapFeatureInfoTool.js.map +1 -0
  96. package/lib/esm/ui/MapLayersUiItemsProvider.d.ts +4 -18
  97. package/lib/esm/ui/MapLayersUiItemsProvider.d.ts.map +1 -1
  98. package/lib/esm/ui/MapLayersUiItemsProvider.js +14 -29
  99. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
  100. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  101. package/lib/esm/ui/widget/AttachLayerPopupButton.js +23 -15
  102. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  103. package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
  104. package/lib/esm/ui/widget/BasemapPanel.js +14 -14
  105. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  106. package/lib/esm/ui/widget/BasemapPanel.scss +5 -1
  107. package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts +41 -0
  108. package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts.map +1 -0
  109. package/lib/esm/ui/widget/FeatureInfoDataProvider.js +136 -0
  110. package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -0
  111. package/lib/esm/ui/widget/FeatureInfoWidget.d.ts +8 -0
  112. package/lib/esm/ui/widget/FeatureInfoWidget.d.ts.map +1 -0
  113. package/lib/esm/ui/widget/FeatureInfoWidget.js +68 -0
  114. package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -0
  115. package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  116. package/lib/esm/ui/widget/MapLayerDroppable.js +14 -11
  117. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  118. package/lib/esm/ui/widget/MapLayerManager.d.ts +2 -2
  119. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
  120. package/lib/esm/ui/widget/MapLayerManager.js +25 -23
  121. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  122. package/lib/esm/ui/widget/MapLayerSettingsMenu.d.ts.map +1 -1
  123. package/lib/esm/ui/widget/MapLayerSettingsMenu.js +5 -5
  124. package/lib/esm/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  125. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -1
  126. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +2 -2
  127. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  128. package/lib/esm/ui/widget/MapLayersWidget.d.ts.map +1 -1
  129. package/lib/esm/ui/widget/MapLayersWidget.js +2 -2
  130. package/lib/esm/ui/widget/MapLayersWidget.js.map +1 -1
  131. package/lib/esm/ui/widget/MapManagerSettings.js +16 -16
  132. package/lib/esm/ui/widget/MapManagerSettings.js.map +1 -1
  133. package/lib/esm/ui/widget/MapUrlDialog.d.ts +3 -3
  134. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
  135. package/lib/esm/ui/widget/MapUrlDialog.js +50 -44
  136. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  137. package/lib/esm/ui/widget/SubLayersPopupButton.js +3 -3
  138. package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
  139. package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
  140. package/lib/esm/ui/widget/SubLayersTree.js +24 -18
  141. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  142. package/lib/public/locales/en/mapLayers.json +4 -0
  143. package/package.json +30 -29
package/CHANGELOG.md CHANGED
@@ -1,6 +1,42 @@
1
1
  # Change Log - @itwin/map-layers
2
2
 
3
- This log was last generated on Wed, 12 Jan 2022 14:52:38 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.
4
40
 
5
41
  ## 2.19.28
6
42
  Wed, 12 Jan 2022 14:52:38 GMT
@@ -259,7 +295,7 @@ Mon, 24 May 2021 15:58:39 GMT
259
295
 
260
296
  ### Updates
261
297
 
262
- - Fix 'npm run cover' that would never complete.
298
+ - Fix 'npm run cover' that would never complete.
263
299
  - Exposed the map masking option in the map layers settings UI.
264
300
  - Move map tile trees to Viewport to handle synching correctly
265
301
  - Update to latest classnames package
@@ -334,7 +370,7 @@ Tue, 09 Mar 2021 20:28:13 GMT
334
370
 
335
371
  ### Updates
336
372
 
337
- - Restored base layer visibility button in map manager.
373
+ - Restored base layer visibility button in map manager.
338
374
  - Updated to use TypeScript 4.1
339
375
  - begin rename project from iModel.js to iTwin.js
340
376
 
@@ -359,7 +395,7 @@ Thu, 18 Feb 2021 22:10:13 GMT
359
395
  ### Updates
360
396
 
361
397
  - Provide default props to map-layers widget when used as an extension.
362
- - 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.
363
399
 
364
400
  ## 2.11.2
365
401
  Thu, 18 Feb 2021 02:50:59 GMT
@@ -41,24 +41,24 @@ export declare class MapLayerPreferences {
41
41
  * @param source source to be stored on the setting service
42
42
  * @param storeOnIModel if true store the settings object on the model, if false store it on the project
43
43
  */
44
- static storeSource(source: MapLayerSource, storeOnIModel: boolean, iTwinId: GuidString, iModelId: GuidString): Promise<boolean>;
44
+ static storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean>;
45
45
  /** Replace the old map layer source with a new map layer source.
46
46
  *
47
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
48
  *
49
49
  * @param oldSource
50
50
  * @param newSource
51
- * @param projectId
51
+ * @param iTwinId
52
52
  * @param iModelId
53
53
  */
54
- static replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, projectId: GuidString, iModelId: GuidString): Promise<void>;
54
+ static replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void>;
55
55
  /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.
56
56
  *
57
57
  * @param source The source to delete. The name is used to identify the source.
58
58
  * @param iTwinId
59
59
  * @param iModelId
60
60
  */
61
- static deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId: GuidString): Promise<void>;
61
+ static deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void>;
62
62
  /** Deletes the current setting with the provided key if it is defined at the same preference level.
63
63
  *
64
64
  * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.
@@ -74,16 +74,16 @@ export declare class MapLayerPreferences {
74
74
  private static delete;
75
75
  /** Attempts to get a map layer based off a specific url.
76
76
  * @param url
77
- * @param projectId
77
+ * @param iTwinId
78
78
  * @param iModelId
79
79
  */
80
- static getByUrl(url: string, projectId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined>;
80
+ static getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined>;
81
81
  /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.
82
- * @param projectId id of the project
82
+ * @param iTwinId id of the iTwin
83
83
  * @param iModelId id of the iModel
84
84
  * @throws if any of the calls to grab settings fail.
85
85
  */
86
- static getSources(projectId: GuidString, iModelId: GuidString): Promise<MapLayerSource[]>;
86
+ static getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]>;
87
87
  private static get _preferenceNamespace();
88
88
  }
89
89
  //# sourceMappingURL=MapLayerPreferences.d.ts.map
@@ -1 +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,MA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IAEpK;;;;;;OAMG;WACiB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IA8B9I;;;;;;;;OAQG;WACiB,aAAa,CAAC,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA0ClJ;;;;;OAKG;WACiB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnH;;;;;;;;;;;OAWG;mBACkB,MAAM;IA+E3B;;;;OAIG;WACiB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC;IA0B9H;;;;OAIG;WACiB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA6CrG,OAAO,CAAC,MAAM,KAAK,oBAAoB,GAEtC;CACF"}
@@ -29,7 +29,7 @@ class MapLayerPreferences {
29
29
  * @param source source to be stored on the setting service
30
30
  * @param storeOnIModel if true store the settings object on the model, if false store it on the project
31
31
  */
32
- static async storeSource(source, storeOnIModel, iTwinId, iModelId) {
32
+ static async storeSource(source, iTwinId, iModelId, storeOnIModel) {
33
33
  if (!mapLayers_1.MapLayersUI.iTwinConfig)
34
34
  return false;
35
35
  const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
@@ -63,10 +63,10 @@ class MapLayerPreferences {
63
63
  *
64
64
  * @param oldSource
65
65
  * @param newSource
66
- * @param projectId
66
+ * @param iTwinId
67
67
  * @param iModelId
68
68
  */
69
- static async replaceSource(oldSource, newSource, projectId, iModelId) {
69
+ static async replaceSource(oldSource, newSource, iTwinId, iModelId) {
70
70
  if (!mapLayers_1.MapLayersUI.iTwinConfig)
71
71
  return;
72
72
  const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
@@ -76,7 +76,7 @@ class MapLayerPreferences {
76
76
  accessToken,
77
77
  namespace: MapLayerPreferences._preferenceNamespace,
78
78
  key: oldSource.name,
79
- iTwinId: projectId,
79
+ iTwinId,
80
80
  iModelId,
81
81
  });
82
82
  }
@@ -85,7 +85,7 @@ class MapLayerPreferences {
85
85
  accessToken,
86
86
  namespace: MapLayerPreferences._preferenceNamespace,
87
87
  key: oldSource.name,
88
- iTwinId: projectId,
88
+ iTwinId,
89
89
  });
90
90
  storeOnIModel = true;
91
91
  }
@@ -98,7 +98,7 @@ class MapLayerPreferences {
98
98
  await mapLayers_1.MapLayersUI.iTwinConfig.save({
99
99
  accessToken,
100
100
  key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,
101
- iTwinId: projectId,
101
+ iTwinId,
102
102
  iModelId: storeOnIModel ? iModelId : undefined,
103
103
  content: mapLayerSetting,
104
104
  });
@@ -224,10 +224,10 @@ class MapLayerPreferences {
224
224
  }
225
225
  /** Attempts to get a map layer based off a specific url.
226
226
  * @param url
227
- * @param projectId
227
+ * @param iTwinId
228
228
  * @param iModelId
229
229
  */
230
- static async getByUrl(url, projectId, iModelId) {
230
+ static async getByUrl(url, iTwinId, iModelId) {
231
231
  var _a;
232
232
  if (!mapLayers_1.MapLayersUI.iTwinConfig)
233
233
  return undefined;
@@ -236,7 +236,7 @@ class MapLayerPreferences {
236
236
  accessToken,
237
237
  namespace: MapLayerPreferences._preferenceNamespace,
238
238
  key: "",
239
- iTwinId: projectId,
239
+ iTwinId,
240
240
  iModelId,
241
241
  });
242
242
  if (undefined === settingResponse || 0 === settingResponse.length)
@@ -250,11 +250,11 @@ class MapLayerPreferences {
250
250
  return savedMapLayer;
251
251
  }
252
252
  /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.
253
- * @param projectId id of the project
253
+ * @param iTwinId id of the iTwin
254
254
  * @param iModelId id of the iModel
255
255
  * @throws if any of the calls to grab settings fail.
256
256
  */
257
- static async getSources(projectId, iModelId) {
257
+ static async getSources(iTwinId, iModelId) {
258
258
  if (!mapLayers_1.MapLayersUI.iTwinConfig)
259
259
  return [];
260
260
  const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
@@ -264,7 +264,7 @@ class MapLayerPreferences {
264
264
  accessToken,
265
265
  namespace: MapLayerPreferences._preferenceNamespace,
266
266
  key: "",
267
- iTwinId: projectId,
267
+ iTwinId,
268
268
  });
269
269
  if (undefined !== userResultByProject)
270
270
  mapLayerList.push(userResultByProject);
@@ -277,7 +277,7 @@ class MapLayerPreferences {
277
277
  accessToken,
278
278
  namespace: MapLayerPreferences._preferenceNamespace,
279
279
  key: "",
280
- iTwinId: projectId,
280
+ iTwinId,
281
281
  iModelId,
282
282
  });
283
283
  if (undefined !== userResultByIModel)
@@ -1 +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,WAA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,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,IAAI;YACF,MAAM,kBAAkB,GAAG,MAAM,uBAAW,CAAC,WAAW,CAAC,GAAG,CAAC;gBAC3D,WAAW;gBACX,SAAS,EAAE,mBAAmB,CAAC,oBAAoB;gBACnD,GAAG,EAAE,EAAE;gBACP,OAAO,EAAE,SAAS;gBAClB,QAAQ;aACT,CAAC,CAAC;YACH,IAAI,SAAS,KAAK,kBAAkB;gBAClC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,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
+ {"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,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,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,MAAM,MAAM,GAAY,MAAM,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE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AAe,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, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): 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 iTwinId\r\n * @param iModelId\r\n */\r\n public static async replaceSource(oldSource: MapLayerSource, newSource: 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 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,\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,\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,\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 iTwinId\r\n * @param iModelId\r\n */\r\n public static async getByUrl(url: string, iTwinId: 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,\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 iTwinId id of the iTwin\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(iTwinId: 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,\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,\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,5 +1,7 @@
1
1
  export * from "./mapLayers";
2
2
  export * from "./ui/Interfaces";
3
3
  export * from "./ui/MapLayersUiItemsProvider";
4
+ export * from "./ui/FeatureInfoUiItemsProvider";
5
+ export * from "./ui/MapFeatureInfoTool";
4
6
  export * from "./ui/widget/MapLayersWidget";
5
7
  //# sourceMappingURL=map-layers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers.d.ts","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"map-layers.d.ts","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC"}
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./mapLayers"), exports);
18
18
  __exportStar(require("./ui/Interfaces"), exports);
19
19
  __exportStar(require("./ui/MapLayersUiItemsProvider"), exports);
20
+ __exportStar(require("./ui/FeatureInfoUiItemsProvider"), exports);
21
+ __exportStar(require("./ui/MapFeatureInfoTool"), exports);
20
22
  __exportStar(require("./ui/widget/MapLayersWidget"), exports);
21
23
  //# sourceMappingURL=map-layers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers.js","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,kDAAgC;AAChC,gEAA8C;AAC9C,8DAA4C","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\nexport * from \"./mapLayers\";\r\nexport * from \"./ui/Interfaces\";\r\nexport * from \"./ui/MapLayersUiItemsProvider\";\r\nexport * from \"./ui/widget/MapLayersWidget\";\r\n"]}
1
+ {"version":3,"file":"map-layers.js","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,kDAAgC;AAChC,gEAA8C;AAC9C,kEAAgD;AAChD,0DAAwC;AACxC,8DAA4C","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\nexport * from \"./mapLayers\";\r\nexport * from \"./ui/Interfaces\";\r\nexport * from \"./ui/MapLayersUiItemsProvider\";\r\nexport * from \"./ui/FeatureInfoUiItemsProvider\";\r\nexport * from \"./ui/MapFeatureInfoTool\";\r\nexport * from \"./ui/widget/MapLayersWidget\";\r\n"]}
@@ -1,30 +1,28 @@
1
+ import { Localization } from "@itwin/core-common";
1
2
  import { UserPreferencesAccess } from "@itwin/core-frontend";
3
+ import { MapFeatureInfoOptions, MapLayerOptions } from "./ui/Interfaces";
4
+ export interface MapLayersConfig {
5
+ localization?: Localization;
6
+ /** If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored. */
7
+ iTwinConfig?: UserPreferencesAccess;
8
+ mapLayerOptions?: MapLayerOptions;
9
+ featureInfoOpts?: MapFeatureInfoOptions;
10
+ }
2
11
  /** MapLayersUI is use when the package is used as a dependency to another app.
3
12
  * '''ts
4
- * await MapLayersUI.initialize(registerItemsProvider);
13
+ * await MapLayersUI.initialize({...MapLayersInitProps});
5
14
  * '''
6
15
  * @beta
7
16
  */
8
17
  export declare class MapLayersUI {
9
18
  private static _defaultNs;
10
- private static _uiItemsProvider;
11
- private static _itemsProviderRegistered?;
19
+ static localization: Localization;
20
+ private static _uiItemsProviders;
12
21
  private static _iTwinConfig?;
13
22
  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}
21
- * iconSpec={MapLayersWidgetControl.iconSpec} />,
22
- * ```
23
- *
24
- * If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored.
25
- */
26
- static initialize(registerItemsProvider?: boolean, iTwinConfig?: UserPreferencesAccess): Promise<void>;
27
- /** Unregisters internationalization service namespace and UiItemManager / control */
23
+ /** Used to initialize the Map Layers */
24
+ static initialize(config?: MapLayersConfig): Promise<void>;
25
+ /** Unregisters internationalization service namespace and UiItemManager */
28
26
  static terminate(): void;
29
27
  /** The internationalization service namespace. */
30
28
  static get localizationNamespace(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"mapLayers.d.ts","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIxE;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAe;IACxC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA2B;IAC1D,OAAO,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAU;IAElD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAwB;IACpD,WAAkB,WAAW,IAAI,qBAAqB,GAAG,SAAS,CAA8B;IAEhG;;;;;;;;;;;OAWG;WACiB,UAAU,CAAC,qBAAqB,UAAO,EAAE,WAAW,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAchH,qFAAqF;WACvE,SAAS;IAWvB,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;CACF"}
1
+ {"version":3,"file":"mapLayers.d.ts","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAa,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIxE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kGAAkG;IAClG,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,qBAAqB,CAAC;CACzC;AAED;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAe;IACxC,OAAc,YAAY,EAAE,YAAY,CAAC;IACzC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAyB;IAEzD,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAwB;IAEpD,WAAkB,WAAW,IAAI,qBAAqB,GAAG,SAAS,CAEjE;IAED,wCAAwC;WACpB,UAAU,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBvE,4EAA4E;WAC9D,SAAS;IAQvB,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;CACF"}
@@ -1,59 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MapLayersUI = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
4
  const core_frontend_1 = require("@itwin/core-frontend");
9
5
  const MapLayersUiItemsProvider_1 = require("./ui/MapLayersUiItemsProvider");
10
6
  const appui_abstract_1 = require("@itwin/appui-abstract");
7
+ const FeatureInfoUiItemsProvider_1 = require("./ui/FeatureInfoUiItemsProvider");
11
8
  /** MapLayersUI is use when the package is used as a dependency to another app.
12
9
  * '''ts
13
- * await MapLayersUI.initialize(registerItemsProvider);
10
+ * await MapLayersUI.initialize({...MapLayersInitProps});
14
11
  * '''
15
12
  * @beta
16
13
  */
17
14
  class MapLayersUI {
18
- static get iTwinConfig() { return this._iTwinConfig; }
19
- /** Used to initialize the Map Layers.
20
- *
21
- * If `registerItemsProvider` is true, the UiItemsProvider will automatically insert the UI items into the host applications UI.
22
- * If it is false, explicitly add widget definition to a specific FrontStage definition using the following syntax.
23
- *
24
- * ```tsx
25
- * <Widget id={MapLayersWidgetControl.id} label={MapLayersWidgetControl.label} control={MapLayersWidgetControl}
26
- * iconSpec={MapLayersWidgetControl.iconSpec} />,
27
- * ```
28
- *
29
- * If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored.
30
- */
31
- static async initialize(registerItemsProvider = true, iTwinConfig) {
32
- MapLayersUI._iTwinConfig = iTwinConfig;
15
+ static get iTwinConfig() {
16
+ return this._iTwinConfig;
17
+ }
18
+ /** Used to initialize the Map Layers */
19
+ static async initialize(config) {
20
+ var _a, _b;
33
21
  // register namespace containing localized strings for this package
34
- await core_frontend_1.IModelApp.localization.registerNamespace(this.localizationNamespace);
35
- // _uiItemsProvider always created to provide access to localization.
36
- MapLayersUI._uiItemsProvider = new MapLayersUiItemsProvider_1.MapLayersUiItemsProvider(core_frontend_1.IModelApp.localization);
37
- if (registerItemsProvider) {
38
- appui_abstract_1.UiItemsManager.register(MapLayersUI._uiItemsProvider);
22
+ MapLayersUI.localization = (_a = config === null || config === void 0 ? void 0 : config.localization) !== null && _a !== void 0 ? _a : core_frontend_1.IModelApp.localization;
23
+ await MapLayersUI.localization.registerNamespace(MapLayersUI.localizationNamespace);
24
+ MapLayersUI._iTwinConfig = config === null || config === void 0 ? void 0 : config.iTwinConfig;
25
+ MapLayersUI._uiItemsProviders.push(new MapLayersUiItemsProvider_1.MapLayersUiItemsProvider({ ...config === null || config === void 0 ? void 0 : config.mapLayerOptions }));
26
+ // Register the FeatureInfo widget only if MapHit was provided.
27
+ if ((_b = config === null || config === void 0 ? void 0 : config.featureInfoOpts) === null || _b === void 0 ? void 0 : _b.onMapHit) {
28
+ MapLayersUI._uiItemsProviders.push(new FeatureInfoUiItemsProvider_1.FeatureInfoUiItemsProvider({ ...config === null || config === void 0 ? void 0 : config.featureInfoOpts }));
39
29
  }
40
- MapLayersUI._itemsProviderRegistered = registerItemsProvider;
30
+ MapLayersUI._uiItemsProviders.forEach((uiProvider) => {
31
+ appui_abstract_1.UiItemsManager.register(uiProvider);
32
+ });
41
33
  }
42
- /** Unregisters internationalization service namespace and UiItemManager / control */
34
+ /** Unregisters internationalization service namespace and UiItemManager */
43
35
  static terminate() {
44
- core_frontend_1.IModelApp.localization.unregisterNamespace(this.localizationNamespace);
45
- if (MapLayersUI._itemsProviderRegistered !== undefined) {
46
- if (MapLayersUI._itemsProviderRegistered) {
47
- appui_abstract_1.UiItemsManager.unregister(MapLayersUI._uiItemsProvider.id);
48
- }
49
- MapLayersUI._itemsProviderRegistered = undefined;
50
- }
36
+ core_frontend_1.IModelApp.localization.unregisterNamespace(MapLayersUI.localizationNamespace);
37
+ MapLayersUI._uiItemsProviders.forEach((uiProvider) => {
38
+ appui_abstract_1.UiItemsManager.unregister(uiProvider.id);
39
+ });
51
40
  }
52
41
  /** The internationalization service namespace. */
53
42
  static get localizationNamespace() {
54
- return this._defaultNs;
43
+ return MapLayersUI._defaultNs;
55
44
  }
56
45
  }
57
46
  exports.MapLayersUI = MapLayersUI;
58
47
  MapLayersUI._defaultNs = "mapLayers";
48
+ MapLayersUI._uiItemsProviders = [];
59
49
  //# sourceMappingURL=mapLayers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapLayers.js","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,wDAAwE;AACxE,4EAAyE;AACzE,0DAAuD;AAEvD;;;;;GAKG;AACH,MAAa,WAAW;IAMf,MAAM,KAAK,WAAW,KAAwC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEhG;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,GAAG,IAAI,EAAE,WAAmC;QAC9F,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC;QAEvC,mEAAmE;QACnE,MAAM,yBAAS,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAE3E,qEAAqE;QACrE,WAAW,CAAC,gBAAgB,GAAG,IAAI,mDAAwB,CAAC,yBAAS,CAAC,YAAY,CAAC,CAAC;QACpF,IAAI,qBAAqB,EAAE;YACzB,+BAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;SACvD;QACD,WAAW,CAAC,wBAAwB,GAAG,qBAAqB,CAAC;IAC/D,CAAC;IAED,qFAAqF;IAC9E,MAAM,CAAC,SAAS;QACrB,yBAAS,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAEvE,IAAI,WAAW,CAAC,wBAAwB,KAAK,SAAS,EAAE;YACtD,IAAI,WAAW,CAAC,wBAAwB,EAAE;gBACxC,+BAAc,CAAC,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;aAC5D;YACD,WAAW,CAAC,wBAAwB,GAAG,SAAS,CAAC;SAClD;IACH,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;;AAjDH,kCAkDC;AAjDgB,sBAAU,GAAG,WAAW,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { IModelApp, UserPreferencesAccess } from \"@itwin/core-frontend\";\r\nimport { MapLayersUiItemsProvider } from \"./ui/MapLayersUiItemsProvider\";\r\nimport { UiItemsManager } from \"@itwin/appui-abstract\";\r\n\r\n/** MapLayersUI is use when the package is used as a dependency to another app.\r\n * '''ts\r\n * await MapLayersUI.initialize(registerItemsProvider);\r\n * '''\r\n * @beta\r\n */\r\nexport class MapLayersUI {\r\n private static _defaultNs = \"mapLayers\";\r\n private static _uiItemsProvider: MapLayersUiItemsProvider;\r\n private static _itemsProviderRegistered?: boolean;\r\n\r\n private static _iTwinConfig?: UserPreferencesAccess;\r\n public static get iTwinConfig(): UserPreferencesAccess | undefined { return this._iTwinConfig; }\r\n\r\n /** Used to initialize the Map Layers.\r\n *\r\n * If `registerItemsProvider` is true, the UiItemsProvider will automatically insert the UI items into the host applications UI.\r\n * If it is false, explicitly add widget definition to a specific FrontStage definition using the following syntax.\r\n *\r\n * ```tsx\r\n * <Widget id={MapLayersWidgetControl.id} label={MapLayersWidgetControl.label} control={MapLayersWidgetControl}\r\n * iconSpec={MapLayersWidgetControl.iconSpec} />,\r\n * ```\r\n *\r\n * If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored.\r\n */\r\n public static async initialize(registerItemsProvider = true, iTwinConfig?: UserPreferencesAccess): Promise<void> {\r\n MapLayersUI._iTwinConfig = iTwinConfig;\r\n\r\n // register namespace containing localized strings for this package\r\n await IModelApp.localization.registerNamespace(this.localizationNamespace);\r\n\r\n // _uiItemsProvider always created to provide access to localization.\r\n MapLayersUI._uiItemsProvider = new MapLayersUiItemsProvider(IModelApp.localization);\r\n if (registerItemsProvider) {\r\n UiItemsManager.register(MapLayersUI._uiItemsProvider);\r\n }\r\n MapLayersUI._itemsProviderRegistered = registerItemsProvider;\r\n }\r\n\r\n /** Unregisters internationalization service namespace and UiItemManager / control */\r\n public static terminate() {\r\n IModelApp.localization.unregisterNamespace(this.localizationNamespace);\r\n\r\n if (MapLayersUI._itemsProviderRegistered !== undefined) {\r\n if (MapLayersUI._itemsProviderRegistered) {\r\n UiItemsManager.unregister(MapLayersUI._uiItemsProvider.id);\r\n }\r\n MapLayersUI._itemsProviderRegistered = undefined;\r\n }\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return this._defaultNs;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"mapLayers.js","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":";;;AAKA,wDAAwE;AACxE,4EAAyE;AACzE,0DAAwE;AACxE,gFAA6E;AAW7E;;;;;GAKG;AACH,MAAa,WAAW;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AAC,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,WAAW,CAAC,UAAU,CAAC;IAChC,CAAC;;AAjDH,kCAkDC;AAjDgB,sBAAU,GAAG,WAAW,CAAC;AAEzB,6BAAiB,GAAsB,EAAE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { IModelApp, UserPreferencesAccess } from \"@itwin/core-frontend\";\r\nimport { MapLayersUiItemsProvider } from \"./ui/MapLayersUiItemsProvider\";\r\nimport { UiItemsManager, UiItemsProvider } from \"@itwin/appui-abstract\";\r\nimport { FeatureInfoUiItemsProvider } from \"./ui/FeatureInfoUiItemsProvider\";\r\nimport { MapFeatureInfoOptions, MapLayerOptions } from \"./ui/Interfaces\";\r\n\r\nexport interface MapLayersConfig {\r\n localization?: Localization;\r\n /** If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored. */\r\n iTwinConfig?: UserPreferencesAccess;\r\n mapLayerOptions?: MapLayerOptions;\r\n featureInfoOpts?: MapFeatureInfoOptions;\r\n}\r\n\r\n/** MapLayersUI is use when the package is used as a dependency to another app.\r\n * '''ts\r\n * await MapLayersUI.initialize({...MapLayersInitProps});\r\n * '''\r\n * @beta\r\n */\r\nexport class MapLayersUI {\r\n private static _defaultNs = \"mapLayers\";\r\n public static localization: Localization;\r\n private static _uiItemsProviders: UiItemsProvider[] = [];\r\n\r\n private static _iTwinConfig?: UserPreferencesAccess;\r\n\r\n public static get iTwinConfig(): UserPreferencesAccess | undefined {\r\n return this._iTwinConfig;\r\n }\r\n\r\n /** Used to initialize the Map Layers */\r\n public static async initialize(config?: MapLayersConfig): Promise<void> {\r\n // register namespace containing localized strings for this package\r\n MapLayersUI.localization = config?.localization ?? IModelApp.localization;\r\n await MapLayersUI.localization.registerNamespace(\r\n MapLayersUI.localizationNamespace\r\n );\r\n\r\n MapLayersUI._iTwinConfig = config?.iTwinConfig;\r\n\r\n MapLayersUI._uiItemsProviders.push(\r\n new MapLayersUiItemsProvider({ ...config?.mapLayerOptions })\r\n );\r\n\r\n // Register the FeatureInfo widget only if MapHit was provided.\r\n if (config?.featureInfoOpts?.onMapHit) {\r\n MapLayersUI._uiItemsProviders.push(\r\n new FeatureInfoUiItemsProvider({ ...config?.featureInfoOpts })\r\n );\r\n }\r\n\r\n MapLayersUI._uiItemsProviders.forEach((uiProvider) => {\r\n UiItemsManager.register(uiProvider);\r\n });\r\n }\r\n\r\n /** Unregisters internationalization service namespace and UiItemManager */\r\n public static terminate() {\r\n IModelApp.localization.unregisterNamespace(MapLayersUI.localizationNamespace);\r\n\r\n MapLayersUI._uiItemsProviders.forEach((uiProvider) => {\r\n UiItemsManager.unregister(uiProvider.id);\r\n });\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return MapLayersUI._defaultNs;\r\n }\r\n}\r\n"]}
@@ -77,6 +77,10 @@
77
77
  "ToggleVisibility": "Toggle Visibility",
78
78
  "SettingsButtonTooltip": "Settings"
79
79
  },
80
+ "FeatureInfoWidget": {
81
+ "Label": "Map Layers Info",
82
+ "NoRecords": "No Results"
83
+ },
80
84
  "LayerMenu": {
81
85
  "Detach": "Detach",
82
86
  "ZoomToLayer": "Zoom to layer"
@@ -0,0 +1,11 @@
1
+ import { AbstractWidgetProps, AbstractZoneLocation, CommonToolbarItem, StagePanelLocation, StagePanelSection, ToolbarOrientation, ToolbarUsage, UiItemsProvider } from "@itwin/appui-abstract";
2
+ import { MapFeatureInfoOptions } from "./Interfaces";
3
+ export declare class FeatureInfoUiItemsProvider implements UiItemsProvider {
4
+ private _featureInfoOpts;
5
+ readonly id = "FeatureInfoUiItemsProvider";
6
+ static readonly widgetId = "map-layers:mapFeatureInfoWidget";
7
+ constructor(_featureInfoOpts: MapFeatureInfoOptions);
8
+ provideToolbarButtonItems(_stageId: string, stageUsage: string, toolbarUsage: ToolbarUsage, toolbarOrientation: ToolbarOrientation): CommonToolbarItem[];
9
+ provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
10
+ }
11
+ //# sourceMappingURL=FeatureInfoUiItemsProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeatureInfoUiItemsProvider.d.ts","sourceRoot":"","sources":["../../../src/ui/FeatureInfoUiItemsProvider.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAc,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAC;AAGxN,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAIrD,qBAAa,0BAA2B,YAAW,eAAe;IAI7C,OAAO,CAAC,gBAAgB;IAH3C,SAAgB,EAAE,gCAAgC;IAClD,gBAAuB,QAAQ,qCAAqC;gBAEzC,gBAAgB,EAAE,qBAAqB;IAE3D,yBAAyB,CAC9B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,YAAY,EAC1B,kBAAkB,EAAE,kBAAkB,GACrC,iBAAiB,EAAE;IAiBf,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,YAAY,CAAC,EAAE,oBAAoB,GAAG,aAAa,CAAC,mBAAmB,CAAC;CAiBhM"}