@itwin/map-layers 4.0.0-dev.4 → 4.0.0-dev.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -5
- package/lib/cjs/MapLayerPreferences.js +1 -2
- package/lib/cjs/MapLayerPreferences.js.map +1 -1
- package/lib/cjs/mapLayers.js +10 -12
- package/lib/cjs/mapLayers.js.map +1 -1
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +1 -2
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
- package/lib/cjs/ui/MapFeatureInfoTool.d.ts.map +1 -1
- package/lib/cjs/ui/MapFeatureInfoTool.js +1 -1
- package/lib/cjs/ui/MapFeatureInfoTool.js.map +1 -1
- package/lib/cjs/ui/MapLayersUiItemsProvider.js +1 -1
- package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
- package/lib/cjs/ui/widget/AttachLayerPopupButton.js +20 -23
- package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/BasemapPanel.js +4 -4
- package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
- package/lib/cjs/ui/widget/ConfirmMessageDialog.js +4 -7
- package/lib/cjs/ui/widget/ConfirmMessageDialog.js.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +3 -4
- package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.js +10 -16
- package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerDroppable.js +4 -7
- package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.js +17 -19
- package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerSettingsMenu.js +2 -3
- package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +2 -2
- package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayersWidget.js +4 -4
- package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.js +35 -32
- package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/cjs/ui/widget/SelectMapFormat.js +7 -12
- package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersDataProvider.js +4 -5
- package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
- package/lib/cjs/ui/widget/SubLayersTree.js +28 -34
- package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
- package/lib/esm/MapLayerPreferences.js +1 -2
- package/lib/esm/MapLayerPreferences.js.map +1 -1
- package/lib/esm/mapLayers.js +10 -12
- package/lib/esm/mapLayers.js.map +1 -1
- package/lib/esm/ui/FeatureInfoUiItemsProvider.js +1 -2
- package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
- package/lib/esm/ui/MapFeatureInfoTool.d.ts.map +1 -1
- package/lib/esm/ui/MapFeatureInfoTool.js +2 -2
- package/lib/esm/ui/MapFeatureInfoTool.js.map +1 -1
- package/lib/esm/ui/MapLayersUiItemsProvider.js +1 -1
- package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
- package/lib/esm/ui/widget/AttachLayerPopupButton.js +21 -24
- package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/BasemapPanel.js +5 -5
- package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
- package/lib/esm/ui/widget/ConfirmMessageDialog.js +4 -7
- package/lib/esm/ui/widget/ConfirmMessageDialog.js.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoDataProvider.js +3 -4
- package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoWidget.js +10 -16
- package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerDroppable.js +5 -8
- package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.js +17 -19
- package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerSettingsMenu.js +2 -3
- package/lib/esm/ui/widget/MapLayerSettingsMenu.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +2 -2
- package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
- package/lib/esm/ui/widget/MapLayersWidget.js +4 -4
- package/lib/esm/ui/widget/MapLayersWidget.js.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.js +36 -33
- package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/esm/ui/widget/SelectMapFormat.js +7 -12
- package/lib/esm/ui/widget/SelectMapFormat.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersDataProvider.js +4 -5
- package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
- package/lib/esm/ui/widget/SubLayersTree.js +28 -34
- package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
- package/package.json +27 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# Change Log - @itwin/map-layers
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 08 Feb 2023 14:58:40 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.6.0
|
|
6
|
+
Wed, 08 Feb 2023 14:58:40 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Allow map-layer requiring authentication to be correctly initialized after a saved view restore.
|
|
11
|
+
- Added support for new viewport event (onMapLayerScaleRangeVisibilityChanged)
|
|
12
|
+
- Improved map-layer coordinate systems validation and error reporting.
|
|
13
|
+
- Fix Map Layers widget not updating after an iModel gets geolocated.
|
|
14
|
+
- Use EmptyLocalization for localization in tests to increase test performance
|
|
15
|
+
|
|
16
|
+
## 3.5.6
|
|
17
|
+
Fri, 24 Feb 2023 16:02:47 GMT
|
|
18
|
+
|
|
19
|
+
_Version update only_
|
|
4
20
|
|
|
5
21
|
## 3.5.5
|
|
6
22
|
Thu, 26 Jan 2023 22:53:28 GMT
|
|
@@ -32,7 +48,7 @@ Wed, 07 Dec 2022 19:12:37 GMT
|
|
|
32
48
|
|
|
33
49
|
### Updates
|
|
34
50
|
|
|
35
|
-
- MapLayers widget's preferences UI now support edit,delete buttons without having an iModel ID. Also fix an issue with edit.
|
|
51
|
+
- MapLayers widget's preferences UI now support edit,delete buttons without having an iModel ID. Also fix an issue with edit.
|
|
36
52
|
- Unpin classnames package
|
|
37
53
|
|
|
38
54
|
## 3.4.7
|
|
@@ -510,7 +526,7 @@ Mon, 24 May 2021 15:58:39 GMT
|
|
|
510
526
|
|
|
511
527
|
### Updates
|
|
512
528
|
|
|
513
|
-
- Fix 'npm run cover' that would never complete.
|
|
529
|
+
- Fix 'npm run cover' that would never complete.
|
|
514
530
|
- Exposed the map masking option in the map layers settings UI.
|
|
515
531
|
- Move map tile trees to Viewport to handle synching correctly
|
|
516
532
|
- Update to latest classnames package
|
|
@@ -585,7 +601,7 @@ Tue, 09 Mar 2021 20:28:13 GMT
|
|
|
585
601
|
|
|
586
602
|
### Updates
|
|
587
603
|
|
|
588
|
-
- Restored base layer visibility button in map manager.
|
|
604
|
+
- Restored base layer visibility button in map manager.
|
|
589
605
|
- Updated to use TypeScript 4.1
|
|
590
606
|
- begin rename project from iModel.js to iTwin.js
|
|
591
607
|
|
|
@@ -610,7 +626,7 @@ Thu, 18 Feb 2021 22:10:13 GMT
|
|
|
610
626
|
### Updates
|
|
611
627
|
|
|
612
628
|
- Provide default props to map-layers widget when used as an extension.
|
|
613
|
-
- 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.
|
|
629
|
+
- 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.
|
|
614
630
|
|
|
615
631
|
## 2.11.2
|
|
616
632
|
Thu, 18 Feb 2021 02:50:59 GMT
|
|
@@ -229,7 +229,6 @@ class MapLayerPreferences {
|
|
|
229
229
|
* @param iModelId
|
|
230
230
|
*/
|
|
231
231
|
static async getByUrl(url, iTwinId, iModelId) {
|
|
232
|
-
var _a;
|
|
233
232
|
if (!mapLayers_1.MapLayersUI.iTwinConfig)
|
|
234
233
|
return undefined;
|
|
235
234
|
const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? (await core_frontend_1.IModelApp.authorizationClient.getAccessToken()) : undefined;
|
|
@@ -243,7 +242,7 @@ class MapLayerPreferences {
|
|
|
243
242
|
if (undefined === settingResponse || 0 === settingResponse.length)
|
|
244
243
|
return undefined;
|
|
245
244
|
let savedMapLayer;
|
|
246
|
-
|
|
245
|
+
settingResponse.settingsMap?.forEach((savedLayer) => {
|
|
247
246
|
if (savedLayer.url === url) {
|
|
248
247
|
savedMapLayer = savedLayer;
|
|
249
248
|
}
|
|
@@ -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;AACh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AAG,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 namespace: MapLayerPreferences._preferenceNamespace,\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
|
+
{"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,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AAQ,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;;AAjTH,kDAkTC;AAjTC;;;;;;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 namespace: MapLayerPreferences._preferenceNamespace,\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"]}
|
package/lib/cjs/mapLayers.js
CHANGED
|
@@ -17,14 +17,13 @@ class MapLayersUI {
|
|
|
17
17
|
}
|
|
18
18
|
/** Used to initialize the Map Layers */
|
|
19
19
|
static async initialize(config) {
|
|
20
|
-
var _a;
|
|
21
20
|
// register namespace containing localized strings for this package
|
|
22
|
-
MapLayersUI.localization =
|
|
21
|
+
MapLayersUI.localization = config?.localization ?? core_frontend_1.IModelApp.localization;
|
|
23
22
|
await MapLayersUI.localization.registerNamespace(MapLayersUI.localizationNamespace);
|
|
24
|
-
MapLayersUI._iTwinConfig = config
|
|
25
|
-
MapLayersUI._featureInfoOpts = config
|
|
26
|
-
MapLayersUI._mapLayerOptions = config
|
|
27
|
-
if (!
|
|
23
|
+
MapLayersUI._iTwinConfig = config?.iTwinConfig;
|
|
24
|
+
MapLayersUI._featureInfoOpts = config?.featureInfoOpts;
|
|
25
|
+
MapLayersUI._mapLayerOptions = config?.mapLayerOptions;
|
|
26
|
+
if (!config?.delayItemsProviderRegister)
|
|
28
27
|
MapLayersUI.registerUiItemsProviders();
|
|
29
28
|
}
|
|
30
29
|
/** Registers the UiItemsProviders for MapLayers with optional overrides
|
|
@@ -33,17 +32,16 @@ class MapLayersUI {
|
|
|
33
32
|
* @beta
|
|
34
33
|
*/
|
|
35
34
|
static registerUiItemsProviders(config) {
|
|
36
|
-
var _a, _b, _c, _d, _e;
|
|
37
35
|
const mlProvider = new MapLayersUiItemsProvider_1.MapLayersUiItemsProvider({ ...MapLayersUI._mapLayerOptions });
|
|
38
|
-
const mlProviderId =
|
|
36
|
+
const mlProviderId = config?.mapLayerProviderOverrides?.providerId ?? mlProvider.id;
|
|
39
37
|
MapLayersUI._uiItemsProvidersId.push(mlProviderId);
|
|
40
|
-
appui_abstract_1.UiItemsManager.register(mlProvider, config
|
|
38
|
+
appui_abstract_1.UiItemsManager.register(mlProvider, config?.mapLayerProviderOverrides); // eslint-disable-line deprecation/deprecation
|
|
41
39
|
// Register the FeatureInfo widget only if MapHit was provided.
|
|
42
|
-
if (
|
|
40
|
+
if (MapLayersUI._featureInfoOpts?.onMapHit) {
|
|
43
41
|
const fiProvider = new FeatureInfoUiItemsProvider_1.FeatureInfoUiItemsProvider({ ...MapLayersUI._featureInfoOpts });
|
|
44
|
-
const fiProviderId =
|
|
42
|
+
const fiProviderId = config?.featureInfoProviderOverrides?.providerId ?? fiProvider.id;
|
|
45
43
|
MapLayersUI._uiItemsProvidersId.push(fiProviderId);
|
|
46
|
-
appui_abstract_1.UiItemsManager.register(fiProvider, config
|
|
44
|
+
appui_abstract_1.UiItemsManager.register(fiProvider, config?.featureInfoProviderOverrides); // eslint-disable-line deprecation/deprecation
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
/** Unregisters internationalization service namespace and UiItemManager */
|
package/lib/cjs/mapLayers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapLayers.js","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":";;;AAKA,wDAAwE;AACxE,4EAAyE;AACzE,0DAAgF;AAChF,gFAA6E;AAiB7E;;;;;GAKG;AACH,MAAa,WAAW;IAQf,MAAM,KAAK,WAAW;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAAwB
|
|
1
|
+
{"version":3,"file":"mapLayers.js","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":";;;AAKA,wDAAwE;AACxE,4EAAyE;AACzE,0DAAgF;AAChF,gFAA6E;AAiB7E;;;;;GAKG;AACH,MAAa,WAAW;IAQf,MAAM,KAAK,WAAW;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAAwB;QACrD,mEAAmE;QACnE,WAAW,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,yBAAS,CAAC,YAAY,CAAC;QAC1E,MAAM,WAAW,CAAC,YAAY,CAAC,iBAAiB,CAC9C,WAAW,CAAC,qBAAqB,CAClC,CAAC;QAEF,WAAW,CAAC,YAAY,GAAG,MAAM,EAAE,WAAW,CAAC;QAC/C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Y,CAAC,CAAC,CAAC,8CAA8C;QACzF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,WAAW,CAAC,UAAU,CAAC;IAChC,CAAC;;AA5DH,kCA6DC;AA5DgB,sBAAU,GAAG,WAAW,CAAC;AAEzB,+BAAmB,GAAa,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 { UiItemProviderOverrides, UiItemsManager } 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 delayItemsProviderRegister?: boolean;\r\n}\r\n/** Configuration for registering UiItemsProviders for the MapLayers package */\r\nexport interface MapLayersUiProviderConfig {\r\n mapLayerProviderOverrides?: UiItemProviderOverrides; // eslint-disable-line deprecation/deprecation\r\n featureInfoProviderOverrides?: UiItemProviderOverrides; // eslint-disable-line deprecation/deprecation\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 _uiItemsProvidersId: string[] = [];\r\n private static _iTwinConfig?: UserPreferencesAccess;\r\n private static _featureInfoOpts?: MapFeatureInfoOptions;\r\n private static _mapLayerOptions?: MapLayerOptions;\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 MapLayersUI._featureInfoOpts = config?.featureInfoOpts;\r\n MapLayersUI._mapLayerOptions = config?.mapLayerOptions;\r\n\r\n if (!config?.delayItemsProviderRegister)\r\n MapLayersUI.registerUiItemsProviders();\r\n }\r\n\r\n /** Registers the UiItemsProviders for MapLayers with optional overrides\r\n * This is useful for an app that wants to defer UiItemsProvider registration so that it\r\n * may limit the MapLayers widgets to a specific workflow\r\n * @beta\r\n */\r\n public static registerUiItemsProviders(config?: MapLayersUiProviderConfig) {\r\n const mlProvider = new MapLayersUiItemsProvider({ ...MapLayersUI._mapLayerOptions });\r\n const mlProviderId = config?.mapLayerProviderOverrides?.providerId ?? mlProvider.id;\r\n MapLayersUI._uiItemsProvidersId.push(mlProviderId);\r\n UiItemsManager.register(mlProvider, config?.mapLayerProviderOverrides); // eslint-disable-line deprecation/deprecation\r\n\r\n // Register the FeatureInfo widget only if MapHit was provided.\r\n if (MapLayersUI._featureInfoOpts?.onMapHit) {\r\n const fiProvider = new FeatureInfoUiItemsProvider({ ...MapLayersUI._featureInfoOpts });\r\n const fiProviderId = config?.featureInfoProviderOverrides?.providerId ?? fiProvider.id;\r\n MapLayersUI._uiItemsProvidersId.push(fiProviderId);\r\n UiItemsManager.register(fiProvider, config?.featureInfoProviderOverrides); // eslint-disable-line deprecation/deprecation\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._uiItemsProvidersId.forEach((uiProviderId) => {\r\n UiItemsManager.unregister(uiProviderId); // eslint-disable-line deprecation/deprecation\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"]}
|
|
@@ -18,8 +18,7 @@ class FeatureInfoUiItemsProvider {
|
|
|
18
18
|
}
|
|
19
19
|
provideToolbarButtonItems(_stageId, stageUsage, toolbarUsage, // eslint-disable-line deprecation/deprecation
|
|
20
20
|
toolbarOrientation) {
|
|
21
|
-
|
|
22
|
-
if (!((_a = this._featureInfoOpts) === null || _a === void 0 ? void 0 : _a.disableDefaultFeatureInfoTool) &&
|
|
21
|
+
if (!this._featureInfoOpts?.disableDefaultFeatureInfoTool &&
|
|
23
22
|
stageUsage === appui_abstract_1.StageUsage.General && // eslint-disable-line deprecation/deprecation
|
|
24
23
|
toolbarUsage === appui_abstract_1.ToolbarUsage.ContentManipulation && // eslint-disable-line deprecation/deprecation
|
|
25
24
|
toolbarOrientation === appui_abstract_1.ToolbarOrientation.Vertical // eslint-disable-line deprecation/deprecation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfoUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/FeatureInfoUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA+B;AAC/B,0DAAwN;AACxN,oDAAgE;AAChE,kEAAkE;AAElE,4CAA2C;AAC3C,6DAAsG;AAEtG,MAAa,0BAA0B;IAIrC,YAA2B,gBAAuC;QAAvC,qBAAgB,GAAhB,gBAAgB,CAAuB;QAHlD,OAAE,GAAG,4BAA4B,CAAC;IAGoB,CAAC;IAEhE,yBAAyB,CAC9B,QAAgB,EAChB,UAAkB,EAClB,YAA0B,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CAAkB,CAAC,KAAK,IAAI,OAAO,KAAK,kCAAiB,CAAC,GAAG,IAAI,GAAG,KAAK,yBAAW,CAAC,SAAS,CAAC,EAAE,EAAE,8CAA8C;YACpM,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,0BAA0B,CAAC,QAAQ;gBACvC,KAAK,EAAE,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC;gBACvF,IAAI,EAAE,UAAU;gBAChB,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,wCAAoB,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI;gBACxF,YAAY,EAAE,4BAAW,CAAC,MAAM,EAAE,8CAA8C;aACjF,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;;AA5CH,gEA6CC;AA3CwB,mCAAQ,GAAG,iCAAiC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as React from \"react\";\r\nimport { AbstractWidgetProps, AbstractZoneLocation, CommonToolbarItem, StagePanelLocation, StagePanelSection, StageUsage, ToolbarOrientation, ToolbarUsage, UiItemsProvider, WidgetState } from \"@itwin/appui-abstract\";\r\nimport { ToolbarHelper, UiFramework } from \"@itwin/appui-react\";\r\nimport { MapFeatureInfoWidget } from \"./widget/FeatureInfoWidget\";\r\nimport { MapFeatureInfoOptions } from \"./Interfaces\";\r\nimport { MapLayersUI } from \"../mapLayers\";\r\nimport { DefaultMapFeatureInfoTool, getDefaultMapFeatureInfoToolItemDef } from \"./MapFeatureInfoTool\";\r\n\r\nexport class FeatureInfoUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\r\n public readonly id = \"FeatureInfoUiItemsProvider\";\r\n public static readonly widgetId = \"map-layers:mapFeatureInfoWidget\";\r\n\r\n public constructor(private _featureInfoOpts: MapFeatureInfoOptions) { }\r\n\r\n public provideToolbarButtonItems(\r\n _stageId: string,\r\n stageUsage: string,\r\n toolbarUsage: ToolbarUsage, // eslint-disable-line deprecation/deprecation\r\n toolbarOrientation: ToolbarOrientation, // eslint-disable-line deprecation/deprecation\r\n ): CommonToolbarItem[] {\r\n if (\r\n !this._featureInfoOpts?.disableDefaultFeatureInfoTool &&\r\n stageUsage === StageUsage.General && // eslint-disable-line deprecation/deprecation\r\n toolbarUsage === ToolbarUsage.ContentManipulation && // eslint-disable-line deprecation/deprecation\r\n toolbarOrientation === ToolbarOrientation.Vertical // eslint-disable-line deprecation/deprecation\r\n ) {\r\n DefaultMapFeatureInfoTool.register(MapLayersUI.localizationNamespace);\r\n return [\r\n ToolbarHelper.createToolbarItemFromItemDef(60, getDefaultMapFeatureInfoToolItemDef()),\r\n ];\r\n }\r\n\r\n return [];\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps> {\r\n const widgets: AbstractWidgetProps[] = []; // eslint-disable-line deprecation/deprecation\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if ((undefined === section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.BottomRight) ||\r\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && section === StagePanelSection.End && \"1\" !== UiFramework.uiVersion)) { // eslint-disable-line deprecation/deprecation\r\n widgets.push({\r\n id: FeatureInfoUiItemsProvider.widgetId,\r\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\r\n icon: \"icon-map\",\r\n getWidgetContent: () => <MapFeatureInfoWidget featureInfoOpts={this._featureInfoOpts} />, // eslint-disable-line react/display-name\r\n defaultState: WidgetState.Closed, // eslint-disable-line deprecation/deprecation\r\n });\r\n }\r\n\r\n return widgets;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapFeatureInfoTool.d.ts","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,SAAS,EAGT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,
|
|
1
|
+
{"version":3,"file":"MapFeatureInfoTool.d.ts","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,SAAS,EAGT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,eAAO,MAAM,mCAAmC,QAAO,WAOnD,CAAC;AAEL,qBAAa,yBAA0B,SAAQ,aAAa;IAC1D,gBAAuB,QAAQ,gBAAqB,SAAS,KAAK,IAAI,EAAI;IAC1E,OAAuB,MAAM,SAAwB;IACrD,OAAuB,QAAQ,SAAc;IAE7B,sBAAsB,IAAI,OAAO;IAI3B,gBAAgB,CACpC,EAAE,EAAE,aAAa,GAChB,OAAO,CAAC,YAAY,CAAC;IAsBF,eAAe,CACnC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,YAAY,CAAC;IAMX,aAAa;CAK3B"}
|
|
@@ -25,7 +25,7 @@ class DefaultMapFeatureInfoTool extends core_frontend_1.PrimitiveTool {
|
|
|
25
25
|
async onDataButtonDown(ev) {
|
|
26
26
|
const hit = await core_frontend_1.IModelApp.locateManager.doLocate(new core_frontend_1.LocateResponse(), true, ev.point, ev.viewport, ev.inputSource);
|
|
27
27
|
if (hit !== undefined) {
|
|
28
|
-
const widgetDef = appui_react_1.
|
|
28
|
+
const widgetDef = appui_react_1.UiFramework.frontstages.findWidget(FeatureInfoUiItemsProvider_1.FeatureInfoUiItemsProvider.widgetId);
|
|
29
29
|
if (widgetDef && widgetDef.state !== appui_abstract_1.WidgetState.Open) // eslint-disable-line deprecation/deprecation
|
|
30
30
|
widgetDef.setWidgetState(appui_abstract_1.WidgetState.Open); // eslint-disable-line deprecation/deprecation
|
|
31
31
|
DefaultMapFeatureInfoTool.onMapHit.raiseEvent(hit);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapFeatureInfoTool.js","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAO8B;AAC9B,0DAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"MapFeatureInfoTool.js","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAO8B;AAC9B,0DAAoD;AACpD,oDAA8D;AAC9D,sDAA8C;AAC9C,6EAA0E;AAEnE,MAAM,mCAAmC,GAAG,GAAgB,EAAE,CACnE,IAAI,yBAAW,CAAC;IACd,MAAM,EAAE,yBAAyB,CAAC,MAAM;IACxC,QAAQ,EAAE,yBAAyB,CAAC,QAAQ;IAC5C,KAAK,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,OAAO;IAC9C,WAAW,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,WAAW;IACxD,OAAO,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,yBAAS,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CACtF,CAAC,CAAC;AAPQ,QAAA,mCAAmC,uCAO3C;AAEL,MAAa,yBAA0B,SAAQ,6BAAa;IAK1C,sBAAsB;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAEe,KAAK,CAAC,gBAAgB,CACpC,EAAiB;QAEjB,MAAM,GAAG,GAAG,MAAM,yBAAS,CAAC,aAAa,CAAC,QAAQ,CAChD,IAAI,8BAAc,EAAE,EACpB,IAAI,EACJ,EAAE,CAAC,KAAK,EACR,EAAE,CAAC,QAAQ,EACX,EAAE,CAAC,WAAW,CACf,CAAC;QACF,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,MAAM,SAAS,GAAG,yBAAW,CAAC,WAAW,CAAC,UAAU,CAClD,uDAA0B,CAAC,QAAQ,CACpC,CAAC;YACF,IAAI,SAAS,IAAI,SAAS,CAAC,KAAK,KAAK,4BAAW,CAAC,IAAI,EAAE,8CAA8C;gBACnG,SAAS,CAAC,cAAc,CAAC,4BAAW,CAAC,IAAI,CAAC,CAAC,CAAC,8CAA8C;YAE5F,yBAAyB,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACnD,OAAO,4BAAY,CAAC,GAAG,CAAC;SACzB;QAED,OAAO,4BAAY,CAAC,EAAE,CAAC;IACzB,CAAC;IAEe,KAAK,CAAC,eAAe,CACnC,GAAkB;QAElB,8GAA8G;QAC9G,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,4BAAY,CAAC,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,aAAa;QACxB,MAAM,IAAI,GAAG,IAAI,yBAAyB,EAAE,CAAC;QAC7C,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;;AA7CH,8DA8CC;AA7CwB,kCAAQ,GAAG,IAAI,sBAAO,EAA4B,CAAC;AACnD,gCAAM,GAAG,oBAAoB,CAAC;AAC9B,kCAAQ,GAAG,UAAU,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n BeButtonEvent,\r\n EventHandled,\r\n HitDetail,\r\n IModelApp,\r\n LocateResponse,\r\n PrimitiveTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { WidgetState } from \"@itwin/appui-abstract\";\r\nimport { ToolItemDef, UiFramework } from \"@itwin/appui-react\";\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { FeatureInfoUiItemsProvider } from \"./FeatureInfoUiItemsProvider\";\r\n\r\nexport const getDefaultMapFeatureInfoToolItemDef = (): ToolItemDef =>\r\n new ToolItemDef({\r\n toolId: DefaultMapFeatureInfoTool.toolId,\r\n iconSpec: DefaultMapFeatureInfoTool.iconSpec,\r\n label: () => DefaultMapFeatureInfoTool.flyover,\r\n description: () => DefaultMapFeatureInfoTool.description,\r\n execute: async () => { await IModelApp.tools.run(DefaultMapFeatureInfoTool.toolId); },\r\n });\r\n\r\nexport class DefaultMapFeatureInfoTool extends PrimitiveTool {\r\n public static readonly onMapHit = new BeEvent<(hit: HitDetail) => void>();\r\n public static override toolId = \"MapFeatureInfoTool\";\r\n public static override iconSpec = \"icon-map\";\r\n\r\n public override requireWriteableTarget(): boolean {\r\n return false;\r\n }\r\n\r\n public override async onDataButtonDown(\r\n ev: BeButtonEvent\r\n ): Promise<EventHandled> {\r\n const hit = await IModelApp.locateManager.doLocate(\r\n new LocateResponse(),\r\n true,\r\n ev.point,\r\n ev.viewport,\r\n ev.inputSource\r\n );\r\n if (hit !== undefined) {\r\n const widgetDef = UiFramework.frontstages.findWidget(\r\n FeatureInfoUiItemsProvider.widgetId\r\n );\r\n if (widgetDef && widgetDef.state !== WidgetState.Open) // eslint-disable-line deprecation/deprecation\r\n widgetDef.setWidgetState(WidgetState.Open); // eslint-disable-line deprecation/deprecation\r\n\r\n DefaultMapFeatureInfoTool.onMapHit.raiseEvent(hit);\r\n return EventHandled.Yes;\r\n }\r\n\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onResetButtonUp(\r\n _ev: BeButtonEvent\r\n ): Promise<EventHandled> {\r\n /* Common reset behavior for primitive tools is calling onReinitialize to restart or exitTool to terminate. */\r\n await this.onReinitialize();\r\n return EventHandled.No;\r\n }\r\n\r\n public async onRestartTool() {\r\n const tool = new DefaultMapFeatureInfoTool();\r\n if (!(await tool.run()))\r\n return this.exitTool();\r\n }\r\n}\r\n"]}
|
|
@@ -13,7 +13,7 @@ const mapLayers_1 = require("../mapLayers");
|
|
|
13
13
|
class MapLayersUiItemsProvider {
|
|
14
14
|
constructor(mapLayerOptions) {
|
|
15
15
|
this.id = "MapLayersUiItemsProvider";
|
|
16
|
-
this._mapLayerOptions = mapLayerOptions
|
|
16
|
+
this._mapLayerOptions = mapLayerOptions ?? {
|
|
17
17
|
hideExternalMapLayers: false,
|
|
18
18
|
mapTypeOptions: { supportTileUrl: false, supportWmsAuthentication: true },
|
|
19
19
|
fetchPublicMapLayerSources: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayersUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/MapLayersUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA+B;AAC/B,0DAAsJ;AACtJ,8DAA2D;AAC3D,oDAAiD;AAEjD,4CAA2C;AAE3C,MAAa,wBAAwB;IAInC,YAAmB,eAAiC;QAHpC,OAAE,GAAG,0BAA0B,CAAC;QAI9C,IAAI,CAAC,gBAAgB,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"MapLayersUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/MapLayersUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA+B;AAC/B,0DAAsJ;AACtJ,8DAA2D;AAC3D,oDAAiD;AAEjD,4CAA2C;AAE3C,MAAa,wBAAwB;IAInC,YAAmB,eAAiC;QAHpC,OAAE,GAAG,0BAA0B,CAAC;QAI9C,IAAI,CAAC,gBAAgB,GAAG,eAAe,IAAI;YACzC,qBAAqB,EAAE,KAAK;YAC5B,cAAc,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE;YACzE,0BAA0B,EAAE,KAAK;SAClC,CAAC;IACJ,CAAC;IAED,mDAAmD;IAC5C,cAAc,CAAC,QAAgB,EAAE,UAAkB,EAAE,QAA4B,EAAE,OAAsC,EAAE,YAAmC;QACnK,MAAM,OAAO,GAA0B,EAAE,CAAC,CAAC,8CAA8C;QAEzF,mDAAmD;QACnD,IAAI,CAAC,SAAS,KAAK,OAAO,IAAI,UAAU,KAAK,2BAAU,CAAC,OAAO,IAAI,YAAY,KAAK,qCAAoB,CAAC,WAAW,CAAC;YACnH,CAAC,UAAU,KAAK,2BAAU,CAAC,OAAO,IAAI,QAAQ,KAAK,mCAAkB,CAAC,KAAK,IAAI,OAAO,KAAK,kCAAiB,CAAC,KAAK,IAAI,GAAG,KAAK,yBAAW,CAAC,SAAS,CAAC,EAAE,EAAE,8CAA8C;YACtM,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,4BAA4B;gBAChC,KAAK,EAAE,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,wBAAwB,CAAC;gBAC5E,IAAI,EAAE,UAAU;gBAChB,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,iCAAe,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI,EAAE,yCAAyC;aAC/H,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7BD,4DA6BC","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 * as React from \"react\";\r\nimport { AbstractWidgetProps, AbstractZoneLocation, StagePanelLocation, StagePanelSection, StageUsage, UiItemsProvider } from \"@itwin/appui-abstract\";\r\nimport { MapLayersWidget } from \"./widget/MapLayersWidget\";\r\nimport { UiFramework } from \"@itwin/appui-react\";\r\nimport { MapLayerOptions } from \"./Interfaces\";\r\nimport { MapLayersUI } from \"../mapLayers\";\r\n\r\nexport class MapLayersUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\r\n public readonly id = \"MapLayersUiItemsProvider\";\r\n private _mapLayerOptions?: MapLayerOptions;\r\n\r\n public constructor(mapLayerOptions?: MapLayerOptions) {\r\n this._mapLayerOptions = mapLayerOptions ?? {\r\n hideExternalMapLayers: false,\r\n mapTypeOptions: { supportTileUrl: false, supportWmsAuthentication: true },\r\n fetchPublicMapLayerSources: false,\r\n };\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section: StagePanelSection | undefined, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps> {\r\n const widgets: AbstractWidgetProps[] = []; // eslint-disable-line deprecation/deprecation\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if ((undefined === section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||\r\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && section === StagePanelSection.Start && \"1\" !== UiFramework.uiVersion)) { // eslint-disable-line deprecation/deprecation\r\n widgets.push({\r\n id: \"map-layers:mapLayersWidget\",\r\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.Label\"),\r\n icon: \"icon-map\",\r\n getWidgetContent: () => <MapLayersWidget mapLayerOptions={this._mapLayerOptions} />, // eslint-disable-line react/display-name\r\n });\r\n }\r\n\r\n return widgets;\r\n }\r\n}\r\n"]}
|
|
@@ -24,7 +24,6 @@ var LayerAction;
|
|
|
24
24
|
})(LayerAction || (LayerAction = {}));
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
26
|
function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }) {
|
|
27
|
-
var _a, _b;
|
|
28
27
|
const [layerNameToAdd, setLayerNameToAdd] = React.useState();
|
|
29
28
|
const [sourceFilterString, setSourceFilterString] = React.useState();
|
|
30
29
|
const { placeholderLabel, addCustomLayerLabel, addCustomLayerToolTip, loadingMapSources, removeLayerDefButtonTitle, editLayerDefButtonTitle, removeLayerDefDialogTitle } = React.useMemo(() => {
|
|
@@ -54,16 +53,16 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
54
53
|
isMounted.current = false;
|
|
55
54
|
// We close any open dialogs that we might have opened
|
|
56
55
|
// This was added because the modal dialog remained remained displayed after the session expired.
|
|
57
|
-
appui_react_1.
|
|
56
|
+
appui_react_1.UiFramework.dialogs.modal.close();
|
|
58
57
|
};
|
|
59
58
|
}, []);
|
|
60
59
|
const handleFilterTextChanged = React.useCallback((event) => {
|
|
61
60
|
setSourceFilterString(event.target.value);
|
|
62
61
|
}, []);
|
|
63
62
|
const { loadingSources, sources, activeViewport, backgroundLayers, overlayLayers, mapLayerOptions } = (0, MapLayerManager_1.useSourceMapContext)();
|
|
64
|
-
const mapTypesOptions = mapLayerOptions
|
|
65
|
-
const iTwinId =
|
|
66
|
-
const iModelId =
|
|
63
|
+
const mapTypesOptions = mapLayerOptions?.mapTypeOptions;
|
|
64
|
+
const iTwinId = activeViewport?.iModel?.iTwinId;
|
|
65
|
+
const iModelId = activeViewport?.iModel?.iModelId;
|
|
67
66
|
const styleContainsLayer = React.useCallback((name) => {
|
|
68
67
|
if (backgroundLayers) {
|
|
69
68
|
if (-1 !== backgroundLayers.findIndex((layer) => layer.name === name))
|
|
@@ -85,15 +84,15 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
85
84
|
const handleModalUrlDialogCancel = React.useCallback(() => {
|
|
86
85
|
// close popup and refresh UI
|
|
87
86
|
setLoading(false);
|
|
88
|
-
appui_react_1.
|
|
87
|
+
appui_react_1.UiFramework.dialogs.modal.close();
|
|
89
88
|
resumeOutsideClick();
|
|
90
89
|
}, [resumeOutsideClick]);
|
|
91
90
|
React.useEffect(() => {
|
|
92
91
|
async function attemptToAddLayer(layerName) {
|
|
93
92
|
if (layerName && activeViewport) {
|
|
94
93
|
// if the layer is not in the style add it now.
|
|
95
|
-
if (undefined ===
|
|
96
|
-
const mapLayerSettings = sources
|
|
94
|
+
if (undefined === backgroundLayers?.find((layer) => layerName === layer.name) && undefined === overlayLayers?.find((layer) => layerName === layer.name)) {
|
|
95
|
+
const mapLayerSettings = sources?.find((source) => source.name === layerName);
|
|
97
96
|
if (mapLayerSettings === undefined) {
|
|
98
97
|
return;
|
|
99
98
|
}
|
|
@@ -119,7 +118,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
else if (status === core_frontend_1.MapLayerSourceStatus.RequireAuth && isMounted.current) {
|
|
122
|
-
appui_react_1.
|
|
121
|
+
appui_react_1.UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog_1.MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, layerRequiringCredentials: mapLayerSettings.toJSON(), onOkResult: () => handleModalUrlDialogOk(LayerAction.Attached), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
|
|
123
122
|
if (onHandleOutsideClick) {
|
|
124
123
|
onHandleOutsideClick(false);
|
|
125
124
|
}
|
|
@@ -151,17 +150,17 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
}, [setLayerNameToAdd, layerNameToAdd, activeViewport, sources, backgroundLayers, isOverlay, overlayLayers, onLayerAttached, handleModalUrlDialogOk, mapTypesOptions, handleModalUrlDialogCancel, onHandleOutsideClick]);
|
|
154
|
-
const options = React.useMemo(() => sources
|
|
153
|
+
const options = React.useMemo(() => sources?.filter((source) => !styleContainsLayer(source.name)), [sources, styleContainsLayer]);
|
|
155
154
|
const filteredOptions = React.useMemo(() => {
|
|
156
155
|
if (undefined === sourceFilterString || 0 === sourceFilterString.length) {
|
|
157
156
|
return options;
|
|
158
157
|
}
|
|
159
158
|
else {
|
|
160
|
-
return options
|
|
159
|
+
return options?.filter((option) => option.name.toLowerCase().includes(sourceFilterString?.toLowerCase()));
|
|
161
160
|
}
|
|
162
161
|
}, [options, sourceFilterString]);
|
|
163
162
|
const handleAddNewMapSource = React.useCallback(() => {
|
|
164
|
-
appui_react_1.
|
|
163
|
+
appui_react_1.UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog_1.MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, onOkResult: () => handleModalUrlDialogOk(LayerAction.Attached), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
|
|
165
164
|
if (onHandleOutsideClick) {
|
|
166
165
|
onHandleOutsideClick(false);
|
|
167
166
|
}
|
|
@@ -171,11 +170,10 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
171
170
|
setLayerNameToAdd(mapName);
|
|
172
171
|
}, []);
|
|
173
172
|
const handleKeypressOnSourceList = React.useCallback((event) => {
|
|
174
|
-
var _a, _b;
|
|
175
173
|
const key = event.key;
|
|
176
174
|
if (key === "Enter") {
|
|
177
175
|
event.preventDefault();
|
|
178
|
-
const mapName =
|
|
176
|
+
const mapName = event.currentTarget?.dataset?.value;
|
|
179
177
|
if (mapName && mapName.length) {
|
|
180
178
|
handleAttach(mapName);
|
|
181
179
|
}
|
|
@@ -185,7 +183,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
185
183
|
setLayerNameToAdd(mapName);
|
|
186
184
|
}, []);
|
|
187
185
|
const handleNoConfirmation = React.useCallback((_layerName) => {
|
|
188
|
-
appui_react_1.
|
|
186
|
+
appui_react_1.UiFramework.dialogs.modal.close();
|
|
189
187
|
resumeOutsideClick();
|
|
190
188
|
}, [resumeOutsideClick]);
|
|
191
189
|
const handleYesConfirmation = React.useCallback(async (source) => {
|
|
@@ -201,7 +199,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
201
199
|
core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Error, msg));
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
|
-
appui_react_1.
|
|
202
|
+
appui_react_1.UiFramework.dialogs.modal.close();
|
|
205
203
|
resumeOutsideClick();
|
|
206
204
|
}, [iTwinId, iModelId, resumeOutsideClick]);
|
|
207
205
|
/*
|
|
@@ -211,7 +209,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
211
209
|
event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.
|
|
212
210
|
const layerName = source.name;
|
|
213
211
|
const msg = mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.RemoveLayerDefDialogMessage", { layerName });
|
|
214
|
-
appui_react_1.
|
|
212
|
+
appui_react_1.UiFramework.dialogs.modal.open(React.createElement(ConfirmMessageDialog_1.ConfirmMessageDialog, { className: "map-sources-delete-confirmation", title: removeLayerDefDialogTitle, message: msg, maxWidth: 400, onClose: () => handleNoConfirmation(layerName), onEscape: () => handleNoConfirmation(layerName), onYesResult: async () => handleYesConfirmation(source), onNoResult: () => handleNoConfirmation(layerName) }));
|
|
215
213
|
if (onHandleOutsideClick) {
|
|
216
214
|
onHandleOutsideClick(false);
|
|
217
215
|
}
|
|
@@ -220,15 +218,14 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
220
218
|
Handle Edit layer button clicked
|
|
221
219
|
*/
|
|
222
220
|
const onItemEditButtonClicked = React.useCallback((event) => {
|
|
223
|
-
var _a, _b, _c;
|
|
224
221
|
event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.
|
|
225
|
-
const targetLayerName =
|
|
222
|
+
const targetLayerName = event?.currentTarget?.parentNode?.dataset?.value;
|
|
226
223
|
const matchingSource = sources.find((layerSource) => layerSource.name === targetLayerName);
|
|
227
224
|
// we expect a single layer source matching this name
|
|
228
225
|
if (matchingSource === undefined) {
|
|
229
226
|
return;
|
|
230
227
|
}
|
|
231
|
-
appui_react_1.
|
|
228
|
+
appui_react_1.UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog_1.MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, mapLayerSourceToEdit: matchingSource, onOkResult: () => handleModalUrlDialogOk(LayerAction.Edited), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
|
|
232
229
|
if (onHandleOutsideClick) {
|
|
233
230
|
onHandleOutsideClick(false);
|
|
234
231
|
}
|
|
@@ -239,7 +236,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
|
|
|
239
236
|
React.createElement(itwinui_react_1.Input, { type: "text", className: "map-manager-source-list-filter", placeholder: placeholderLabel, value: sourceFilterString, onChange: handleFilterTextChanged, size: "small" }),
|
|
240
237
|
React.createElement(itwinui_react_1.Button, { className: "map-manager-add-source-button", title: addCustomLayerToolTip, onClick: handleAddNewMapSource }, addCustomLayerLabel)),
|
|
241
238
|
React.createElement("div", { className: "map-manager-sources" },
|
|
242
|
-
React.createElement(UiCore.Listbox, { id: "map-sources", selectedValue: layerNameToAdd, className: "map-manager-source-list", onKeyPress: handleKeypressOnSourceList, onListboxValueChange: onListboxValueChange }, filteredOptions
|
|
239
|
+
React.createElement(UiCore.Listbox, { id: "map-sources", selectedValue: layerNameToAdd, className: "map-manager-source-list", onKeyPress: handleKeypressOnSourceList, onListboxValueChange: onListboxValueChange }, filteredOptions?.map((source) => React.createElement(UiCore.ListboxItem, { key: source.name, className: "map-source-list-entry", value: source.name, onMouseEnter: () => setLayerNameUnderCursor(source.name), onMouseLeave: () => setLayerNameUnderCursor(undefined) },
|
|
243
240
|
React.createElement("span", { className: "map-source-list-entry-name", title: source.name }, source.name),
|
|
244
241
|
// otherwise list feels cluttered.
|
|
245
242
|
(!!iTwinId && layerNameUnderCursor && layerNameUnderCursor === source.name) &&
|
|
@@ -290,11 +287,11 @@ function AttachLayerPopupButton(props) {
|
|
|
290
287
|
return;
|
|
291
288
|
}
|
|
292
289
|
// If clicking on button that open panel - don't trigger outside click processing
|
|
293
|
-
if (
|
|
290
|
+
if (buttonRef?.current && buttonRef?.current.contains(event.target)) {
|
|
294
291
|
return;
|
|
295
292
|
}
|
|
296
293
|
// If clicking the panel, this is not an outside clicked
|
|
297
|
-
if (panelRef.current &&
|
|
294
|
+
if (panelRef.current && panelRef?.current.contains(event.target)) {
|
|
298
295
|
return;
|
|
299
296
|
}
|
|
300
297
|
// If we reach this point, we got an outside clicked, no close the popup
|