@itwin/map-layers 5.2.2 → 5.2.4
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 +18 -1
- package/lib/cjs/public/locales/en/mapLayers.json +9 -2
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +1 -1
- package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
- package/lib/cjs/ui/Interfaces.d.ts +4 -2
- package/lib/cjs/ui/Interfaces.d.ts.map +1 -1
- package/lib/cjs/ui/Interfaces.js.map +1 -1
- package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
- package/lib/cjs/ui/widget/BasemapPanel.js +79 -52
- package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts +1 -0
- package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.js +17 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.d.ts +4 -1
- package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapLayerManager.js +10 -6
- package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/cjs/ui/widget/MapUrlDialog.js +22 -11
- package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/esm/public/locales/en/mapLayers.json +9 -2
- package/lib/esm/ui/FeatureInfoUiItemsProvider.js +1 -1
- package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
- package/lib/esm/ui/Interfaces.d.ts +4 -2
- package/lib/esm/ui/Interfaces.d.ts.map +1 -1
- package/lib/esm/ui/Interfaces.js.map +1 -1
- package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
- package/lib/esm/ui/widget/BasemapPanel.js +80 -53
- package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoWidget.d.ts +1 -0
- package/lib/esm/ui/widget/FeatureInfoWidget.d.ts.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoWidget.js +15 -0
- package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.d.ts +4 -1
- package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapLayerManager.js +10 -6
- package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
- package/lib/esm/ui/widget/MapUrlDialog.js +22 -11
- package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
- package/lib/public/locales/en/mapLayers.json +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# Change Log - @itwin/map-layers
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 07 Nov 2023 13:43:31 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.2.4
|
|
6
|
+
Tue, 07 Nov 2023 13:43:31 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Fix UI refresh issues after a saved view is applied.
|
|
11
|
+
|
|
12
|
+
## 5.2.3
|
|
13
|
+
Thu, 26 Oct 2023 13:09:22 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- Fixed base map translation issues
|
|
18
|
+
- Fix warning message after a failed attempt to provide credentials
|
|
19
|
+
- Fix an issue in the 'Add New Layer' dialog where invalid credentials warning would not appear after a first invalid attempt.
|
|
20
|
+
- Make the MapFeatureInfo Widget appear only when results are available.
|
|
4
21
|
|
|
5
22
|
## 5.2.2
|
|
6
23
|
Thu, 05 Oct 2023 18:48:11 GMT
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"Close": "Close source map layers pop-up"
|
|
5
5
|
},
|
|
6
6
|
"Basemap": {
|
|
7
|
-
"BaseLayer": "Base
|
|
7
|
+
"BaseLayer": "Base",
|
|
8
8
|
"BaseMapPanelTitle": "Map Layers",
|
|
9
9
|
"ColorFill": "Solid Fill Color",
|
|
10
|
-
"SelectBaseMap": "Select
|
|
10
|
+
"SelectBaseMap": "Select base layer"
|
|
11
11
|
},
|
|
12
12
|
"ColorDialog": {
|
|
13
13
|
"Title": "Specify Base Color"
|
|
@@ -147,5 +147,12 @@
|
|
|
147
147
|
},
|
|
148
148
|
"TransparencyPopup": {
|
|
149
149
|
"SetTransparency": "Set transparency"
|
|
150
|
+
},
|
|
151
|
+
"WellKnownBaseMaps" : {
|
|
152
|
+
"BingProvider" : {
|
|
153
|
+
"Aerial" : "Bing Maps: Aerial Imagery",
|
|
154
|
+
"Hybrid" : "Bing Maps: Aerial Imagery with labels",
|
|
155
|
+
"Street" : "Bing Maps: Streets"
|
|
156
|
+
}
|
|
150
157
|
}
|
|
151
158
|
}
|
|
@@ -45,7 +45,7 @@ class FeatureInfoUiItemsProvider {
|
|
|
45
45
|
label: mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:FeatureInfoWidget.Label"),
|
|
46
46
|
icon: React.createElement(itwinui_icons_react_1.SvgMapInfo, null),
|
|
47
47
|
content: React.createElement(FeatureInfoWidget_1.MapFeatureInfoWidget, { featureInfoOpts: this._featureInfoOpts }),
|
|
48
|
-
defaultState: appui_react_1.WidgetState.
|
|
48
|
+
defaultState: appui_react_1.WidgetState.Hidden,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
return widgets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfoUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/FeatureInfoUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA+B;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,UAAU,KAAK,+BAAiB,CAAC,GAAG,IAAK,UAAU,KAAK,wBAAU,CAAC,OAAO,IAAI,QAAQ,KAAK,gCAAkB,CAAC,KAAK,EAAI;YACzH,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,0BAA0B,CAAC,QAAQ;gBACvC,KAAK,EAAE,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC;gBACvF,IAAI,EAAE,oBAAC,gCAAU,OAAE;gBACnB,OAAO,EAAE,oBAAC,wCAAoB,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI;gBACzE,YAAY,EAAE,yBAAW,CAAC,MAAM;aACjC,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;;AAzCH,gEA0CC;AAxCwB,mCAAQ,GAAG,iCAAiC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport * as React from \"react\";\nimport { StagePanelLocation, StagePanelSection, StageUsage, ToolbarHelper, ToolbarItem, ToolbarOrientation, ToolbarUsage, ToolItemDef, UiItemsProvider, WidgetState } from \"@itwin/appui-react\";\nimport { MapFeatureInfoWidget } from \"./widget/FeatureInfoWidget\";\nimport { MapFeatureInfoOptions } from \"./Interfaces\";\nimport { MapLayersUI } from \"../mapLayers\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { MapFeatureInfoTool } from \"@itwin/map-layers-formats\";\nimport { SvgMapInfo } from \"@itwin/itwinui-icons-react\";\n\nexport const getMapFeatureInfoToolItemDef = (): ToolItemDef =>\n new ToolItemDef({\n toolId: MapFeatureInfoTool.toolId,\n iconSpec: <SvgMapInfo/>,\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\n description: () => MapFeatureInfoTool.description,\n execute: async () => { await IModelApp.tools.run(MapFeatureInfoTool.toolId); },\n });\n\nexport class FeatureInfoUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\n public readonly id = \"FeatureInfoUiItemsProvider\";\n public static readonly widgetId = \"map-layers:mapFeatureInfoWidget\";\n\n public constructor(private _featureInfoOpts: MapFeatureInfoOptions) { }\n\n public provideToolbarItems(\n _stageId: string,\n stageUsage: string,\n toolbarUsage: ToolbarUsage,\n toolbarOrientation: ToolbarOrientation,\n ): ReadonlyArray<ToolbarItem> {\n if (\n !this._featureInfoOpts?.disableDefaultFeatureInfoTool &&\n stageUsage === StageUsage.General &&\n toolbarUsage === ToolbarUsage.ContentManipulation &&\n toolbarOrientation === ToolbarOrientation.Vertical\n ) {\n return [\n ToolbarHelper.createToolbarItemFromItemDef(60, getMapFeatureInfoToolItemDef()),\n ];\n }\n\n return [];\n }\n\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection) {\n const widgets = [];\n\n const tmpSection = section ?? StagePanelSection.End;\n if (tmpSection === StagePanelSection.End && stageUsage === StageUsage.General && location === StagePanelLocation.Right ) {\n widgets.push({\n id: FeatureInfoUiItemsProvider.widgetId,\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\n icon: <SvgMapInfo/>,\n content: <MapFeatureInfoWidget featureInfoOpts={this._featureInfoOpts} />,\n defaultState: WidgetState.
|
|
1
|
+
{"version":3,"file":"FeatureInfoUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/FeatureInfoUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA+B;AAC/B,oDAAgM;AAChM,kEAAkE;AAElE,4CAA2C;AAC3C,wDAAiD;AACjD,kEAA+D;AAC/D,oEAAwD;AAEjD,MAAM,4BAA4B,GAAG,GAAgB,EAAE,CAC5D,IAAI,yBAAW,CAAC;IACd,MAAM,EAAE,uCAAkB,CAAC,MAAM;IACjC,QAAQ,EAAE,oBAAC,g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Y,CAAC,kBAAkB,CAAC,mCAAmC,CAAC;gBACvF,IAAI,EAAE,oBAAC,gCAAU,OAAE;gBACnB,OAAO,EAAE,oBAAC,wCAAoB,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI;gBACzE,YAAY,EAAE,yBAAW,CAAC,MAAM;aACjC,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;;AAzCH,gEA0CC;AAxCwB,mCAAQ,GAAG,iCAAiC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport * as React from \"react\";\nimport { StagePanelLocation, StagePanelSection, StageUsage, ToolbarHelper, ToolbarItem, ToolbarOrientation, ToolbarUsage, ToolItemDef, UiItemsProvider, WidgetState } from \"@itwin/appui-react\";\nimport { MapFeatureInfoWidget } from \"./widget/FeatureInfoWidget\";\nimport { MapFeatureInfoOptions } from \"./Interfaces\";\nimport { MapLayersUI } from \"../mapLayers\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { MapFeatureInfoTool } from \"@itwin/map-layers-formats\";\nimport { SvgMapInfo } from \"@itwin/itwinui-icons-react\";\n\nexport const getMapFeatureInfoToolItemDef = (): ToolItemDef =>\n new ToolItemDef({\n toolId: MapFeatureInfoTool.toolId,\n iconSpec: <SvgMapInfo/>,\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\n description: () => MapFeatureInfoTool.description,\n execute: async () => { await IModelApp.tools.run(MapFeatureInfoTool.toolId); },\n });\n\nexport class FeatureInfoUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\n public readonly id = \"FeatureInfoUiItemsProvider\";\n public static readonly widgetId = \"map-layers:mapFeatureInfoWidget\";\n\n public constructor(private _featureInfoOpts: MapFeatureInfoOptions) { }\n\n public provideToolbarItems(\n _stageId: string,\n stageUsage: string,\n toolbarUsage: ToolbarUsage,\n toolbarOrientation: ToolbarOrientation,\n ): ReadonlyArray<ToolbarItem> {\n if (\n !this._featureInfoOpts?.disableDefaultFeatureInfoTool &&\n stageUsage === StageUsage.General &&\n toolbarUsage === ToolbarUsage.ContentManipulation &&\n toolbarOrientation === ToolbarOrientation.Vertical\n ) {\n return [\n ToolbarHelper.createToolbarItemFromItemDef(60, getMapFeatureInfoToolItemDef()),\n ];\n }\n\n return [];\n }\n\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection) {\n const widgets = [];\n\n const tmpSection = section ?? StagePanelSection.End;\n if (tmpSection === StagePanelSection.End && stageUsage === StageUsage.General && location === StagePanelLocation.Right ) {\n widgets.push({\n id: FeatureInfoUiItemsProvider.widgetId,\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\n icon: <SvgMapInfo/>,\n content: <MapFeatureInfoWidget featureInfoOpts={this._featureInfoOpts} />,\n defaultState: WidgetState.Hidden,\n });\n }\n\n return widgets;\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BeEvent } from "@itwin/core-bentley";
|
|
2
|
-
import { MapSubLayerProps } from "@itwin/core-common";
|
|
2
|
+
import { BaseMapLayerSettings, MapSubLayerProps } from "@itwin/core-common";
|
|
3
3
|
import { HitDetail, MapLayerImageryProvider, MapTileTreeScaleRangeVisibility } from "@itwin/core-frontend";
|
|
4
4
|
export interface StyleMapLayerSettings {
|
|
5
5
|
/** Name */
|
|
6
6
|
name: string;
|
|
7
|
-
/** source (i.URL for ImageMapLayerSettings or modelId for ModelMapLayerSettings)
|
|
7
|
+
/** source (i.URL for ImageMapLayerSettings or modelId for ModelMapLayerSettings) */
|
|
8
8
|
source: string;
|
|
9
9
|
/** Controls visibility of layer */
|
|
10
10
|
visible: boolean;
|
|
@@ -33,6 +33,8 @@ export interface MapLayerOptions {
|
|
|
33
33
|
hideExternalMapLayers?: boolean;
|
|
34
34
|
fetchPublicMapLayerSources?: boolean;
|
|
35
35
|
mapTypeOptions?: MapTypesOptions;
|
|
36
|
+
/** Optional list of base map-layers to display in the base map select control */
|
|
37
|
+
baseMapLayers?: BaseMapLayerSettings[];
|
|
36
38
|
}
|
|
37
39
|
export interface MapFeatureInfoPropertyGridOptions {
|
|
38
40
|
isPropertySelectionEnabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interfaces.d.ts","sourceRoot":"","sources":["../../../src/ui/Interfaces.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAG,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Interfaces.d.ts","sourceRoot":"","sources":["../../../src/ui/Interfaces.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAG,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAE3G,MAAM,WAAW,qBAAqB;IACpC,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,+BAA+B,CAAC;IAChD,2MAA2M;IAC3M,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qCAAqC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,iCAAiC;IACjC,aAAa,EAAE,OAAO,CAAC;IACvB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IAEnC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,cAAc,CAAC,EAAE,eAAe,CAAC;IAEjC,iFAAiF;IACjF,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACxC;AAED,MAAM,WAAW,iCAAiC;IAChD,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,oBAAY,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC;AAE5D,MAAM,WAAW,qBAAqB;IACpC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,iCAAiC,CAAC;CACzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/ui/Interfaces.ts"],"names":[],"mappings":"","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { MapSubLayerProps } from \"@itwin/core-common\";\nimport { HitDetail, MapLayerImageryProvider, MapTileTreeScaleRangeVisibility } from \"@itwin/core-frontend\";\n\nexport interface StyleMapLayerSettings {\n /** Name */\n name: string;\n /** source (i.URL for ImageMapLayerSettings or modelId for ModelMapLayerSettings)
|
|
1
|
+
{"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../../src/ui/Interfaces.ts"],"names":[],"mappings":"","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { BaseMapLayerSettings, MapSubLayerProps } from \"@itwin/core-common\";\nimport { HitDetail, MapLayerImageryProvider, MapTileTreeScaleRangeVisibility } from \"@itwin/core-frontend\";\n\nexport interface StyleMapLayerSettings {\n /** Name */\n name: string;\n /** source (i.URL for ImageMapLayerSettings or modelId for ModelMapLayerSettings) */\n source: string;\n /** Controls visibility of layer */\n visible: boolean;\n treeVisibility: MapTileTreeScaleRangeVisibility;\n /** A transparency value from 0.0 (fully opaque) to 1.0 (fully transparent) to apply to map graphics when drawing, or false to indicate the transparency should not be overridden. Default value: false. */\n transparency: number;\n /** Transparent background */\n transparentBackground: boolean;\n /** set map as underlay or overlay */\n isOverlay: boolean;\n /** layer index in the viewport */\n layerIndex: number;\n /** Available map sub-layer */\n subLayers?: MapSubLayerProps[];\n /** sub-layer panel displayed. */\n showSubLayers: boolean;\n /** Some format can publish only a single layer at a time (i.e WMTS) */\n provider?: MapLayerImageryProvider;\n\n selected: boolean;\n}\n\nexport interface MapTypesOptions {\n readonly supportTileUrl: boolean;\n readonly supportWmsAuthentication: boolean;\n}\n\nexport interface MapLayerOptions {\n hideExternalMapLayers?: boolean;\n fetchPublicMapLayerSources?: boolean;\n mapTypeOptions?: MapTypesOptions;\n\n /** Optional list of base map-layers to display in the base map select control */\n baseMapLayers?: BaseMapLayerSettings[];\n}\n\nexport interface MapFeatureInfoPropertyGridOptions {\n isPropertySelectionEnabled?: boolean;\n}\n\nexport type MapHitEvent = BeEvent<(hit: HitDetail) => void>;\n\nexport interface MapFeatureInfoOptions {\n disableDefaultFeatureInfoTool?: boolean;\n showLoadProgressAnimation?: boolean;\n propertyGridOptions?: MapFeatureInfoPropertyGridOptions;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasemapPanel.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"BasemapPanel.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAgBA,OAAO,qBAAqB,CAAC;AAM7B,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAmNpD"}
|
|
@@ -12,24 +12,19 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
12
12
|
const core_react_1 = require("@itwin/core-react");
|
|
13
13
|
const imodel_components_react_1 = require("@itwin/imodel-components-react");
|
|
14
14
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
15
|
-
const React = require("react");
|
|
16
15
|
const mapLayers_1 = require("../../mapLayers");
|
|
17
16
|
const MapLayerManager_1 = require("./MapLayerManager");
|
|
18
17
|
const TransparencyPopupButton_1 = require("./TransparencyPopupButton");
|
|
18
|
+
const React = require("react");
|
|
19
19
|
require("./BasemapPanel.scss");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return undefined;
|
|
23
|
-
if (backgroundBase instanceof core_common_1.ImageMapLayerSettings || backgroundBase instanceof core_common_1.ColorDef)
|
|
24
|
-
return backgroundBase.toJSON();
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
20
|
+
const customBaseMapValue = "customBaseMap";
|
|
21
|
+
const getSelectKeyFromProvider = (base) => `${base.provider ? `${base.provider.name}.${core_common_1.BackgroundMapType[base.provider.type]}` : `${base.name}`}`;
|
|
27
22
|
/** @internal */
|
|
28
23
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
29
24
|
function BasemapPanel(props) {
|
|
30
25
|
const [useColorLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:Basemap.ColorFill"));
|
|
31
26
|
const { activeViewport, bases } = (0, MapLayerManager_1.useSourceMapContext)();
|
|
32
|
-
const [selectedBaseMap, setSelectedBaseMap] = React.useState(
|
|
27
|
+
const [selectedBaseMap, setSelectedBaseMap] = React.useState(activeViewport?.displayStyle.settings.mapImagery.backgroundBase);
|
|
33
28
|
const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {
|
|
34
29
|
if (activeViewport) {
|
|
35
30
|
const mapImagery = activeViewport.displayStyle.settings.mapImagery;
|
|
@@ -47,6 +42,7 @@ function BasemapPanel(props) {
|
|
|
47
42
|
return 0;
|
|
48
43
|
}
|
|
49
44
|
});
|
|
45
|
+
const [customBaseMap, setCustomBaseMap] = React.useState();
|
|
50
46
|
const [baseMapVisible, setBaseMapVisible] = React.useState(() => {
|
|
51
47
|
if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.ImageMapLayerSettings) {
|
|
52
48
|
return activeViewport.displayStyle.backgroundMapBase.visible;
|
|
@@ -54,27 +50,34 @@ function BasemapPanel(props) {
|
|
|
54
50
|
return false;
|
|
55
51
|
});
|
|
56
52
|
const handleMapImageryChanged = React.useCallback((args) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (JSON.stringify(baseMap)
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
const baseMap = args.backgroundBase;
|
|
54
|
+
// Optimization: If serialized 'backgroundBase' objects are identical, skip refresh
|
|
55
|
+
if (JSON.stringify(baseMap.toJSON()) === JSON.stringify(selectedBaseMap?.toJSON()))
|
|
56
|
+
return;
|
|
57
|
+
setSelectedBaseMap(baseMap); // cache current base map objects
|
|
58
|
+
if (baseMap instanceof core_common_1.ImageMapLayerSettings) {
|
|
59
|
+
if (baseMap.transparency !== baseMapTransparencyValue)
|
|
60
|
+
setBaseMapTransparencyValue(baseMap.transparency);
|
|
61
|
+
if (baseMap.visible !== baseMapVisible)
|
|
62
|
+
setBaseMapVisible(baseMap.visible);
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
else if (baseMap instanceof core_common_1.ColorDef) {
|
|
65
|
+
if (baseMap.getAlpha() !== baseMapTransparencyValue) {
|
|
66
|
+
setBaseMapTransparencyValue(baseMap.getAlpha() / 255);
|
|
67
|
+
}
|
|
71
68
|
}
|
|
72
|
-
}, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap
|
|
69
|
+
}, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap]);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
const handleDisplayStyleChange = (vp) => {
|
|
72
|
+
handleMapImageryChanged(vp.displayStyle.settings.mapImagery);
|
|
73
|
+
};
|
|
74
|
+
return activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);
|
|
75
|
+
}, [activeViewport, handleMapImageryChanged]);
|
|
73
76
|
// Monitor display style's onMapImageryChanged event
|
|
74
77
|
React.useEffect(() => {
|
|
75
78
|
return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);
|
|
76
79
|
}, [activeViewport, handleMapImageryChanged]);
|
|
77
|
-
// Monitor viewport updates, and refresh the widget accordingly.
|
|
80
|
+
// Monitor viewport updates, and refresh the widget accordingly .
|
|
78
81
|
// Note: This is needed for multiple viewport applications.
|
|
79
82
|
React.useEffect(() => {
|
|
80
83
|
if (activeViewport) {
|
|
@@ -90,10 +93,18 @@ function BasemapPanel(props) {
|
|
|
90
93
|
const baseMapOptions = React.useMemo(() => {
|
|
91
94
|
const baseOptions = [];
|
|
92
95
|
baseOptions.push({ value: useColorLabel, label: useColorLabel });
|
|
93
|
-
if (bases)
|
|
94
|
-
baseOptions.push(...bases.map((
|
|
96
|
+
if (bases) {
|
|
97
|
+
baseOptions.push(...bases.map((bgProvider) => {
|
|
98
|
+
const value = getSelectKeyFromProvider(bgProvider);
|
|
99
|
+
const label = mapLayers_1.MapLayersUI.translate(`WellKnownBaseMaps.${value}`);
|
|
100
|
+
return { value, label };
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
if (customBaseMap) {
|
|
104
|
+
baseOptions.push({ value: customBaseMapValue, label: customBaseMap.name });
|
|
105
|
+
}
|
|
95
106
|
return baseOptions;
|
|
96
|
-
}, [bases, useColorLabel]);
|
|
107
|
+
}, [bases, useColorLabel, customBaseMap]);
|
|
97
108
|
const [presetColors] = React.useState([
|
|
98
109
|
core_common_1.ColorDef.create(core_common_1.ColorByName.grey),
|
|
99
110
|
core_common_1.ColorDef.create(core_common_1.ColorByName.lightGrey),
|
|
@@ -104,26 +115,36 @@ function BasemapPanel(props) {
|
|
|
104
115
|
core_common_1.ColorDef.create(core_common_1.ColorByName.tan),
|
|
105
116
|
core_common_1.ColorDef.create(core_common_1.ColorByName.darkBrown),
|
|
106
117
|
]);
|
|
107
|
-
const baseIsColor = React.useMemo(() =>
|
|
118
|
+
const baseIsColor = React.useMemo(() => selectedBaseMap instanceof core_common_1.ColorDef, [selectedBaseMap]);
|
|
108
119
|
const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);
|
|
109
|
-
const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);
|
|
120
|
+
const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap.toJSON() : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);
|
|
110
121
|
const [colorDialogTitle] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:ColorDialog.Title"));
|
|
111
122
|
const selectedBaseMapValue = React.useMemo(() => {
|
|
112
123
|
if (baseIsMap) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
if (selectedBaseMap instanceof core_common_1.BaseMapLayerSettings && selectedBaseMap.provider) {
|
|
125
|
+
const mapName = getSelectKeyFromProvider(selectedBaseMap);
|
|
126
|
+
const foundItem = baseMapOptions.find((value) => value.value === mapName);
|
|
127
|
+
if (foundItem)
|
|
128
|
+
return foundItem;
|
|
129
|
+
}
|
|
130
|
+
else if (selectedBaseMap instanceof core_common_1.BaseMapLayerSettings) {
|
|
131
|
+
// We got a custom base map, create en entry for it.
|
|
132
|
+
setCustomBaseMap(selectedBaseMap);
|
|
133
|
+
return { value: customBaseMapValue, label: selectedBaseMap.name };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (baseIsColor) {
|
|
137
|
+
return baseMapOptions[0];
|
|
117
138
|
}
|
|
118
|
-
return
|
|
119
|
-
}, [selectedBaseMap, baseMapOptions
|
|
139
|
+
return { value: "", label: "" }; // will display the place holder
|
|
140
|
+
}, [baseIsMap, baseIsColor, selectedBaseMap, baseMapOptions]);
|
|
120
141
|
const handleBackgroundColorDialogOk = React.useCallback((bgColorDef) => {
|
|
121
142
|
appui_react_1.UiFramework.dialogs.modal.close();
|
|
122
143
|
if (activeViewport) {
|
|
123
144
|
// change color and make sure previously set transparency is not lost.
|
|
124
145
|
const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
|
|
125
146
|
activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);
|
|
126
|
-
setSelectedBaseMap(bgColorDef
|
|
147
|
+
setSelectedBaseMap(bgColorDef);
|
|
127
148
|
}
|
|
128
149
|
}, [activeViewport]);
|
|
129
150
|
const handleBackgroundColorDialogCancel = React.useCallback(() => {
|
|
@@ -134,26 +155,32 @@ function BasemapPanel(props) {
|
|
|
134
155
|
appui_react_1.UiFramework.dialogs.modal.open(React.createElement(imodel_components_react_1.ColorPickerDialog, { dialogTitle: colorDialogTitle, color: newColor, colorPresets: presetColors, colorInputType: "rgb", onOkResult: handleBackgroundColorDialogOk, onCancelResult: handleBackgroundColorDialogCancel }));
|
|
135
156
|
}, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
136
157
|
const handleBaseMapSelection = React.useCallback((value) => {
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
if (activeViewport && value) {
|
|
159
|
+
if (value === customBaseMapValue && customBaseMap) {
|
|
160
|
+
setSelectedBaseMap(customBaseMap);
|
|
161
|
+
activeViewport.displayStyle.backgroundMapBase = customBaseMap;
|
|
162
|
+
}
|
|
163
|
+
else if (bases) {
|
|
164
|
+
const baseMap = bases.find((provider) => getSelectKeyFromProvider(provider) === value);
|
|
165
|
+
if (baseMap) {
|
|
166
|
+
const baseProps = baseMap.toJSON();
|
|
167
|
+
if (activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.BaseMapLayerSettings) {
|
|
168
|
+
activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ ...baseProps, visible: baseMapVisible });
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
activeViewport.displayStyle.backgroundMapBase = core_common_1.BaseMapLayerSettings.fromJSON({ ...baseProps, visible: baseMapVisible });
|
|
172
|
+
}
|
|
173
|
+
setSelectedBaseMap(baseMap);
|
|
143
174
|
}
|
|
144
175
|
else {
|
|
145
|
-
|
|
176
|
+
const bgColorDef = core_common_1.ColorDef.fromJSON(bgColor);
|
|
177
|
+
const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
|
|
178
|
+
activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);
|
|
179
|
+
setSelectedBaseMap(bgColorDef);
|
|
146
180
|
}
|
|
147
|
-
setSelectedBaseMap(baseProps);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
const bgColorDef = core_common_1.ColorDef.fromJSON(bgColor);
|
|
151
|
-
const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
|
|
152
|
-
activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);
|
|
153
|
-
setSelectedBaseMap(bgColorDef.toJSON());
|
|
154
181
|
}
|
|
155
182
|
}
|
|
156
|
-
}, [
|
|
183
|
+
}, [activeViewport, bases, customBaseMap, baseMapVisible, bgColor]);
|
|
157
184
|
const handleVisibilityChange = React.useCallback(() => {
|
|
158
185
|
if (activeViewport) {
|
|
159
186
|
const newState = !baseMapVisible;
|
|
@@ -168,10 +195,10 @@ function BasemapPanel(props) {
|
|
|
168
195
|
const [selectBaseMapLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:Basemap.SelectBaseMap"));
|
|
169
196
|
const [toggleVisibility] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:Widget.ToggleVisibility"));
|
|
170
197
|
return (React.createElement(React.Fragment, null,
|
|
198
|
+
React.createElement("span", { className: "map-manager-base-label" }, baseLayerLabel),
|
|
171
199
|
React.createElement("div", { className: "map-manager-base-item" },
|
|
172
200
|
React.createElement(itwinui_react_1.Button, { className: "map-manager-basemap-visibility map-manager-visibility-icon", size: "small", styleType: "borderless", title: toggleVisibility, onClick: handleVisibilityChange, disabled: props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.ImageMapLayerSettings) },
|
|
173
201
|
React.createElement(core_react_1.WebFontIcon, { iconName: baseMapVisible ? "icon-visibility" : "icon-visibility-hide-2" })),
|
|
174
|
-
React.createElement("span", { className: "map-manager-base-label" }, baseLayerLabel),
|
|
175
202
|
React.createElement(itwinui_react_1.Select, { className: "map-manager-base-item-select", options: baseMapOptions, placeholder: selectBaseMapLabel, value: selectedBaseMapValue.value, onChange: handleBaseMapSelection, size: "small", disabled: props.disabled }),
|
|
176
203
|
baseIsColor &&
|
|
177
204
|
React.createElement(imodel_components_react_1.ColorSwatch, { className: "map-manager-base-item-color", colorDef: core_common_1.ColorDef.fromJSON(bgColor), round: false, onColorPick: handleBgColorClick }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C,2CAA2C;;;AAE3C,oDAAiD;AACjD,oDAA8K;AAC9K,kDAAgD;AAChD,4EAAgF;AAChF,wDAAoE;AACpE,+BAA+B;AAC/B,+CAA8C;AAC9C,uDAAwD;AACxD,uEAAoE;AACpE,+BAA6B;AAE7B,SAAS,mBAAmB,CAAC,cAA6C;IACxE,IAAI,CAAC,cAAc;QACjB,OAAO,SAAS,CAAC;IAEnB,IAAI,cAAc,YAAY,mCAAqB,IAAI,cAAc,YAAY,sBAAQ;QACvF,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC;IAEjC,OAAO,SAAS,CAAC;AACnB,CAAC;AAMD,gBAAgB;AAChB,gEAAgE;AAChE,SAAgB,YAAY,CAAC,KAAwB;IACnD,MAAM,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACnH,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,IAAA,qCAAmB,GAAE,CAAC;IACxD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAA6B,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;IAC/K,MAAM,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;QAClF,IA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B,GAAI;YAE9I,oBAAC,iDAAuB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,CAChJ,CACL,CACJ,CAAC;AACJ,CAAC;AAjLD,oCAiLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/* eslint-disable deprecation/deprecation */\n// cSpell:ignore droppable Sublayer Basemap\n\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { BaseLayerProps, BaseLayerSettings, BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings, MapImagerySettings, MapLayerProps } from \"@itwin/core-common\";\nimport { WebFontIcon } from \"@itwin/core-react\";\nimport { ColorPickerDialog, ColorSwatch } from \"@itwin/imodel-components-react\";\nimport { Button, Select, SelectOption } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { useSourceMapContext } from \"./MapLayerManager\";\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\nimport \"./BasemapPanel.scss\";\n\nfunction getBaseMapFromStyle(backgroundBase: BaseLayerSettings | undefined) {\n if (!backgroundBase)\n return undefined;\n\n if (backgroundBase instanceof ImageMapLayerSettings || backgroundBase instanceof ColorDef)\n return backgroundBase.toJSON();\n\n return undefined;\n}\n\ninterface BasemapPanelProps {\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function BasemapPanel(props: BasemapPanelProps) {\n const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\n const { activeViewport, bases } = useSourceMapContext();\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<BaseLayerProps | undefined>(getBaseMapFromStyle(activeViewport?.displayStyle.settings.mapImagery.backgroundBase));\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\n if (activeViewport) {\n const mapImagery = activeViewport.displayStyle.settings.mapImagery;\n if (mapImagery.backgroundBase instanceof ImageMapLayerSettings) {\n return mapImagery.backgroundBase.transparency;\n } else if (mapImagery.backgroundBase instanceof ColorDef ) {\n return mapImagery.backgroundBase.getAlpha()/255;\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n });\n\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n return activeViewport.displayStyle.backgroundMapBase.visible;\n }\n return false;\n });\n\n const handleMapImageryChanged = React.useCallback((args: Readonly<MapImagerySettings>) => {\n // selectedBaseMap\n const baseMap = getBaseMapFromStyle(args.backgroundBase);\n if (JSON.stringify(baseMap) !== JSON.stringify(selectedBaseMap))\n setSelectedBaseMap(baseMap);\n\n // baseMapTransparencyValue\n if (args.backgroundBase instanceof ImageMapLayerSettings && args.backgroundBase.transparency !== baseMapTransparencyValue) {\n setBaseMapTransparencyValue(args.backgroundBase.transparency);\n } else if (args.backgroundBase instanceof ColorDef && args.backgroundBase.getAlpha() !== baseMapTransparencyValue ) {\n setBaseMapTransparencyValue(args.backgroundBase.getAlpha()/255);\n }\n\n // baseMapVisible\n if (args.backgroundBase instanceof ImageMapLayerSettings && args.backgroundBase.visible !== baseMapVisible) {\n setBaseMapVisible(args.backgroundBase.visible);\n }\n }, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap, setBaseMapTransparencyValue, setBaseMapVisible, setSelectedBaseMap]);\n\n // Monitor display style's onMapImageryChanged event\n React.useEffect(() => {\n return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly.\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n if (activeViewport) {\n handleMapImageryChanged(activeViewport.displayStyle.settings.mapImagery);\n }\n }, [activeViewport, handleMapImageryChanged]);\n\n const handleBasemapTransparencyChange = React.useCallback((transparency: number) => {\n if (activeViewport) {\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\n setBaseMapTransparencyValue(transparency);\n }\n }, [activeViewport]);\n\n const baseMapOptions = React.useMemo<SelectOption<string>[]>(() => {\n const baseOptions: SelectOption<string>[] = [];\n\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\n\n if (bases)\n baseOptions.push(...bases.map((value) => ({ value: value.name, label: value.name })));\n return baseOptions;\n }, [bases, useColorLabel]);\n\n const [presetColors] = React.useState([\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ]);\n\n const baseIsColor = React.useMemo(() => typeof selectedBaseMap === \"number\", [selectedBaseMap]);\n const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);\n const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap as number : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);\n const [colorDialogTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:ColorDialog.Title\"));\n const selectedBaseMapValue = React.useMemo(() => {\n if (baseIsMap) {\n const mapName = (selectedBaseMap! as MapLayerProps).name;\n const foundItem = baseMapOptions.find((value) => value.label === mapName);\n if (foundItem)\n return foundItem;\n }\n return baseMapOptions[0];\n }, [selectedBaseMap, baseMapOptions, baseIsMap]);\n\n const handleBackgroundColorDialogOk = React.useCallback((bgColorDef: ColorDef) => {\n UiFramework.dialogs.modal.close();\n if (activeViewport) {\n // change color and make sure previously set transparency is not lost.\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef.toJSON());\n }\n }, [activeViewport]);\n\n const handleBackgroundColorDialogCancel = React.useCallback(() => {\n UiFramework.dialogs.modal.close();\n }, []);\n\n const handleBgColorClick = React.useCallback((newColor: ColorDef, e: React.MouseEvent<Element, MouseEvent>) => {\n e.preventDefault();\n UiFramework.dialogs.modal.open(<ColorPickerDialog dialogTitle={colorDialogTitle} color={newColor} colorPresets={presetColors} colorInputType={\"rgb\"}\n onOkResult={handleBackgroundColorDialogOk} onCancelResult={handleBackgroundColorDialogCancel} />);\n }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleBaseMapSelection = React.useCallback((value: string) => {\n if (bases && activeViewport && value) {\n const baseMap = bases.find((map) => map.name === value);\n if (baseMap) {\n const baseProps: MapLayerProps = baseMap.toJSON();\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({...baseProps, visible: baseMapVisible});\n } else {\n activeViewport.displayStyle.backgroundMapBase = BaseMapLayerSettings.fromJSON({...baseProps, visible: baseMapVisible});\n }\n setSelectedBaseMap(baseProps);\n } else {\n const bgColorDef = ColorDef.fromJSON(bgColor);\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef.toJSON());\n }\n }\n }, [baseMapVisible, bases, activeViewport, bgColor]);\n\n const handleVisibilityChange = React.useCallback(() => {\n if (activeViewport) {\n const newState = !baseMapVisible;\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\n }\n setBaseMapVisible(newState);\n }\n }, [baseMapVisible, activeViewport]);\n\n const [baseLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\n const [selectBaseMapLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n\n return (\n <>\n <div className=\"map-manager-base-item\" >\n <Button className=\"map-manager-basemap-visibility map-manager-visibility-icon\" size=\"small\" styleType=\"borderless\" title={toggleVisibility} onClick={handleVisibilityChange} disabled={props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings)}>\n <WebFontIcon iconName={baseMapVisible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\n <Select className=\"map-manager-base-item-select\"\n options={baseMapOptions}\n placeholder={selectBaseMapLabel}\n value={selectedBaseMapValue.value}\n onChange={handleBaseMapSelection} size=\"small\"\n disabled={props.disabled}\n />\n {\n baseIsColor &&\n <ColorSwatch className=\"map-manager-base-item-color\" colorDef={ColorDef.fromJSON(bgColor)} round={false} onColorPick={handleBgColorClick} />\n }\n <TransparencyPopupButton disabled={props.disabled} transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\n </div>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C,2CAA2C;;;AAE3C,oDAAiD;AACjD,oDAAiL;AACjL,kDAAgD;AAChD,4EAAgF;AAChF,wDAAoE;AACpE,+CAA8C;AAC9C,uDAAwD;AACxD,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AO,EAAC,SAAS,EAAC,YAAY,EAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,cAAc,IAAI,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,iBAAiB,YAAY,mCAAqB,CAAC;gBAC3S,oBAAC,wBAAW,IAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,wBAAwB,GAAI,CACjF;YACT,oBAAC,sBAAM,IAAC,SAAS,EAAC,8BAA8B,EAC9C,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,oBAAoB,CAAC,KAAK,EACjC,QAAQ,EAAE,sBAAsB,EAAE,IAAI,EAAC,OAAO,EAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB;YAEA,WAAW;gBACX,oBAAC,qCAAW,IAAC,SAAS,EAAC,6BAA6B,EAAC,QAAQ,EAAE,sBAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,GAAI;YAE9I,oBAAC,iDAAuB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,CAChJ,CACL,CACJ,CAAC;AACJ,CAAC;AAnND,oCAmNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/* eslint-disable deprecation/deprecation */\n// cSpell:ignore droppable Sublayer Basemap\n\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { BackgroundMapType, BaseLayerSettings, BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings, MapImagerySettings, MapLayerProps } from \"@itwin/core-common\";\nimport { WebFontIcon } from \"@itwin/core-react\";\nimport { ColorPickerDialog, ColorSwatch } from \"@itwin/imodel-components-react\";\nimport { Button, Select, SelectOption } from \"@itwin/itwinui-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { useSourceMapContext } from \"./MapLayerManager\";\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\nimport * as React from \"react\";\nimport \"./BasemapPanel.scss\";\nimport { Viewport } from \"@itwin/core-frontend\";\n\nconst customBaseMapValue = \"customBaseMap\";\nconst getSelectKeyFromProvider = (base: BaseMapLayerSettings) => `${base.provider ? `${base.provider.name}.${BackgroundMapType[base.provider.type]}` : `${base.name}`}`;\n\ninterface BasemapPanelProps {\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function BasemapPanel(props: BasemapPanelProps) {\n const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\n const { activeViewport, bases } = useSourceMapContext();\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<BaseLayerSettings | undefined>(activeViewport?.displayStyle.settings.mapImagery.backgroundBase);\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\n if (activeViewport) {\n const mapImagery = activeViewport.displayStyle.settings.mapImagery;\n if (mapImagery.backgroundBase instanceof ImageMapLayerSettings) {\n return mapImagery.backgroundBase.transparency;\n } else if (mapImagery.backgroundBase instanceof ColorDef ) {\n return mapImagery.backgroundBase.getAlpha()/255;\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n });\n const [customBaseMap, setCustomBaseMap] = React.useState<BaseMapLayerSettings|undefined>();\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n return activeViewport.displayStyle.backgroundMapBase.visible;\n }\n return false;\n });\n\n const handleMapImageryChanged = React.useCallback((args: Readonly<MapImagerySettings>) => {\n const baseMap = args.backgroundBase;\n\n // Optimization: If serialized 'backgroundBase' objects are identical, skip refresh\n if (JSON.stringify(baseMap.toJSON()) === JSON.stringify(selectedBaseMap?.toJSON()))\n return;\n\n setSelectedBaseMap(baseMap); // cache current base map objects\n\n if (baseMap instanceof ImageMapLayerSettings) {\n if (baseMap.transparency !== baseMapTransparencyValue)\n setBaseMapTransparencyValue(baseMap.transparency);\n\n if (baseMap.visible !== baseMapVisible)\n setBaseMapVisible(baseMap.visible);\n\n } else if (baseMap instanceof ColorDef) {\n if (baseMap.getAlpha() !== baseMapTransparencyValue ) {\n setBaseMapTransparencyValue(baseMap.getAlpha()/255);\n }\n }\n }, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap]);\n\n React.useEffect(() => {\n const handleDisplayStyleChange = (vp: Viewport) => {\n handleMapImageryChanged(vp.displayStyle.settings.mapImagery);\n };\n return activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor display style's onMapImageryChanged event\n React.useEffect(() => {\n return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly .\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n if (activeViewport) {\n handleMapImageryChanged(activeViewport.displayStyle.settings.mapImagery);\n }\n }, [activeViewport, handleMapImageryChanged]);\n\n const handleBasemapTransparencyChange = React.useCallback((transparency: number) => {\n if (activeViewport) {\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\n setBaseMapTransparencyValue(transparency);\n }\n }, [activeViewport]);\n\n const baseMapOptions = React.useMemo<SelectOption<string>[]>(() => {\n const baseOptions: SelectOption<string>[] = [];\n\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\n\n if (bases) {\n baseOptions.push(...bases.map((bgProvider) => {\n const value = getSelectKeyFromProvider(bgProvider);\n const label = MapLayersUI.translate(`WellKnownBaseMaps.${value}`);\n return { value, label };\n } ));\n }\n if (customBaseMap) {\n baseOptions.push({value: customBaseMapValue, label: customBaseMap.name});\n }\n return baseOptions;\n }, [bases, useColorLabel, customBaseMap]);\n\n const [presetColors] = React.useState([\n ColorDef.create(ColorByName.grey),\n ColorDef.create(ColorByName.lightGrey),\n ColorDef.create(ColorByName.darkGrey),\n ColorDef.create(ColorByName.lightBlue),\n ColorDef.create(ColorByName.lightGreen),\n ColorDef.create(ColorByName.darkGreen),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.darkBrown),\n ]);\n\n const baseIsColor = React.useMemo(() => selectedBaseMap instanceof ColorDef, [selectedBaseMap]);\n const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);\n const bgColor = React.useMemo(() => baseIsColor ? (selectedBaseMap as ColorDef).toJSON(): presetColors[0].toJSON(),\n [baseIsColor, selectedBaseMap, presetColors]);\n const [colorDialogTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:ColorDialog.Title\"));\n const selectedBaseMapValue = React.useMemo(() => {\n if (baseIsMap) {\n if (selectedBaseMap instanceof BaseMapLayerSettings && selectedBaseMap.provider) {\n const mapName = getSelectKeyFromProvider(selectedBaseMap);\n const foundItem = baseMapOptions.find((value) => value.value === mapName);\n if (foundItem)\n return foundItem;\n } else if (selectedBaseMap instanceof BaseMapLayerSettings) {\n // We got a custom base map, create en entry for it.\n setCustomBaseMap(selectedBaseMap);\n return {value: customBaseMapValue, label: selectedBaseMap.name};\n }\n } else if (baseIsColor) {\n return baseMapOptions[0];\n }\n return {value: \"\", label: \"\"}; // will display the place holder\n\n }, [baseIsMap, baseIsColor, selectedBaseMap, baseMapOptions]);\n\n const handleBackgroundColorDialogOk = React.useCallback((bgColorDef: ColorDef) => {\n UiFramework.dialogs.modal.close();\n if (activeViewport) {\n // change color and make sure previously set transparency is not lost.\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef);\n }\n }, [activeViewport]);\n\n const handleBackgroundColorDialogCancel = React.useCallback(() => {\n UiFramework.dialogs.modal.close();\n }, []);\n\n const handleBgColorClick = React.useCallback((newColor: ColorDef, e: React.MouseEvent<Element, MouseEvent>) => {\n e.preventDefault();\n UiFramework.dialogs.modal.open(<ColorPickerDialog dialogTitle={colorDialogTitle} color={newColor} colorPresets={presetColors} colorInputType={\"rgb\"}\n onOkResult={handleBackgroundColorDialogOk} onCancelResult={handleBackgroundColorDialogCancel} />);\n }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleBaseMapSelection = React.useCallback((value: string) => {\n if (activeViewport && value) {\n if (value === customBaseMapValue && customBaseMap) {\n setSelectedBaseMap(customBaseMap);\n activeViewport.displayStyle.backgroundMapBase = customBaseMap;\n } else if (bases) {\n const baseMap = bases.find((provider) => getSelectKeyFromProvider(provider) === value);\n if (baseMap) {\n const baseProps: MapLayerProps = baseMap.toJSON();\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({...baseProps, visible: baseMapVisible});\n } else {\n activeViewport.displayStyle.backgroundMapBase = BaseMapLayerSettings.fromJSON({...baseProps, visible: baseMapVisible});\n }\n setSelectedBaseMap(baseMap);\n } else {\n const bgColorDef = ColorDef.fromJSON(bgColor);\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n setSelectedBaseMap(bgColorDef);\n }\n }\n }\n }, [activeViewport, bases, customBaseMap, baseMapVisible, bgColor]);\n\n const handleVisibilityChange = React.useCallback(() => {\n if (activeViewport) {\n const newState = !baseMapVisible;\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\n }\n setBaseMapVisible(newState);\n }\n }, [baseMapVisible, activeViewport]);\n\n const [baseLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\n const [selectBaseMapLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n\n return (\n <>\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\n <div className=\"map-manager-base-item\" >\n <Button className=\"map-manager-basemap-visibility map-manager-visibility-icon\" size=\"small\" styleType=\"borderless\" title={toggleVisibility} onClick={handleVisibilityChange} disabled={props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings)}>\n <WebFontIcon iconName={baseMapVisible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n <Select className=\"map-manager-base-item-select\"\n options={baseMapOptions}\n placeholder={selectBaseMapLabel}\n value={selectedBaseMapValue.value}\n onChange={handleBaseMapSelection} size=\"small\"\n disabled={props.disabled}\n />\n {\n baseIsColor &&\n <ColorSwatch className=\"map-manager-base-item-color\" colorDef={ColorDef.fromJSON(bgColor)} round={false} onColorPick={handleBgColorClick} />\n }\n <TransparencyPopupButton disabled={props.disabled} transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\n </div>\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfoWidget.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"FeatureInfoWidget.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAKtD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,sDAG9C;AAGD,UAAU,yBAAyB;IACjC,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAGD,wBAAgB,oBAAoB,CAAC,EAAE,eAAe,EAAE,EAAE,yBAAyB,eA4DlF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MapFeatureInfoWidget = void 0;
|
|
3
|
+
exports.MapFeatureInfoWidget = exports.useSpecificWidgetDef = void 0;
|
|
4
4
|
/*---------------------------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -10,6 +10,13 @@ const components_react_1 = require("@itwin/components-react");
|
|
|
10
10
|
const core_react_1 = require("@itwin/core-react");
|
|
11
11
|
const FeatureInfoDataProvider_1 = require("./FeatureInfoDataProvider");
|
|
12
12
|
const mapLayers_1 = require("../../mapLayers");
|
|
13
|
+
const appui_react_1 = require("@itwin/appui-react");
|
|
14
|
+
const FeatureInfoUiItemsProvider_1 = require("../FeatureInfoUiItemsProvider");
|
|
15
|
+
function useSpecificWidgetDef(id) {
|
|
16
|
+
const frontstageDef = (0, appui_react_1.useActiveFrontstageDef)();
|
|
17
|
+
return frontstageDef?.findWidgetDef(id);
|
|
18
|
+
}
|
|
19
|
+
exports.useSpecificWidgetDef = useSpecificWidgetDef;
|
|
13
20
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
21
|
function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
15
22
|
const dataProvider = React.useRef();
|
|
@@ -25,6 +32,15 @@ function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
25
32
|
dataProvider?.current?.onUnload();
|
|
26
33
|
};
|
|
27
34
|
}, []);
|
|
35
|
+
const widgetDef = useSpecificWidgetDef(FeatureInfoUiItemsProvider_1.FeatureInfoUiItemsProvider.widgetId);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (hasData) {
|
|
38
|
+
widgetDef?.setWidgetState(appui_react_1.WidgetState.Open);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
widgetDef?.setWidgetState(appui_react_1.WidgetState.Hidden);
|
|
42
|
+
}
|
|
43
|
+
}, [widgetDef, hasData]);
|
|
28
44
|
React.useEffect(() => {
|
|
29
45
|
dataProvider.current?.onDataChanged.addListener(handleDataChanged);
|
|
30
46
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,8DAAkF;AAClF,kDAA0F;AAE1F,uEAAmE;AAEnE,+CAA8C;
|
|
1
|
+
{"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,8DAAkF;AAClF,kDAA0F;AAE1F,uEAAmE;AAEnE,+CAA8C;AAC9C,oDAAyE;AACzE,8EAA2E;AAE3E,SAAgB,oBAAoB,CAAC,EAAU;IAC7C,MAAM,aAAa,GAAG,IAAA,oCAAsB,GAAE,CAAC;IAC/C,OAAO,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;AAC1C,CAAC;AAHD,oDAGC;AAOD,gEAAgE;AAChE,SAAgB,oBAAoB,CAAC,EAAE,eAAe,EAA6B;IAEjF,MAAM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,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;QACnE,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACxE,CAAC,CAAC;IAEJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QAC9D,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,CAAC,oBAAC,yBAAY;YAAC;gBAAM,+BAAI,gBAAgB,CAAK,CAAO,CAAe,CAAC,CAAC;KAC9E;SAAM;QACL,IAAI,YAAY,CAAC,OAAO;YACtB,OAAO,CACL,oBAAC,uCAA0B,IAAC,QAAQ,EAAE,YAAY;gBAChD,oBAAC,0DAAuC,IACtC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,CAAC,OAAO,EAClC,WAAW,EAAE,wBAAW,CAAC,QAAQ,EACjC,0BAA0B,EAAE,eAAe,EAAE,mBAAmB,EAAE,0BAA0B,GAAI,CACvE,CAC9B,CAAC;;YAEF,OAAO,CAAC,yCAAK,CAAC,CAAC;KAClB;AACH,CAAC;AA5DD,oDA4DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\n\nimport { VirtualizedPropertyGridWithDataProvider } from \"@itwin/components-react\";\nimport { FillCentered, Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\n\nimport { FeatureInfoDataProvider} from \"./FeatureInfoDataProvider\";\nimport { MapFeatureInfoOptions } from \"../Interfaces\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { useActiveFrontstageDef, WidgetState } from \"@itwin/appui-react\";\nimport { FeatureInfoUiItemsProvider } from \"../FeatureInfoUiItemsProvider\";\n\nexport function useSpecificWidgetDef(id: string) {\n const frontstageDef = useActiveFrontstageDef();\n return frontstageDef?.findWidgetDef(id);\n}\n\n// MapFeatureInfoWidgetProps\ninterface MapFeatureInfoWidgetProps {\n featureInfoOpts: MapFeatureInfoOptions;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapFeatureInfoWidget({ featureInfoOpts }: MapFeatureInfoWidgetProps) {\n\n const dataProvider = React.useRef<FeatureInfoDataProvider>();\n const [hasData, setHasData] = React.useState<boolean>(false);\n\n const [noRecordsMessage] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.NoRecords\"));\n\n const [{ width, height }, setSize] = React.useState({ width: 0, height: 0 });\n\n const handleDataChanged = () => {\n setHasData(dataProvider.current !== undefined && dataProvider.current.hasRecords);\n };\n\n React.useEffect(() => {\n dataProvider.current = new FeatureInfoDataProvider();\n return () => {\n dataProvider?.current?.onUnload();\n };\n }, []);\n\n const widgetDef = useSpecificWidgetDef(FeatureInfoUiItemsProvider.widgetId);\n\n React.useEffect(() => {\n if (hasData) {\n widgetDef?.setWidgetState(WidgetState.Open);\n } else {\n widgetDef?.setWidgetState(WidgetState.Hidden);\n }\n }, [widgetDef, hasData]);\n\n React.useEffect(() => {\n\n dataProvider.current?.onDataChanged.addListener(handleDataChanged);\n return () => {\n dataProvider.current?.onDataChanged.removeListener(handleDataChanged);\n };\n\n }, []);\n\n const handleResize = React.useCallback((w: number, h: number) => {\n setSize({ width: w, height: h });\n }, []);\n\n if (!hasData) {\n return (<FillCentered><span><i>{noRecordsMessage}</i></span></FillCentered>);\n } else {\n if (dataProvider.current)\n return (\n <ResizableContainerObserver onResize={handleResize}>\n <VirtualizedPropertyGridWithDataProvider\n width={width}\n height={height}\n dataProvider={dataProvider.current}\n orientation={Orientation.Vertical}\n isPropertySelectionEnabled={featureInfoOpts?.propertyGridOptions?.isPropertySelectionEnabled} />\n </ResizableContainerObserver>\n );\n else\n return (<></>);\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseMapLayerSettings } from "@itwin/core-common";
|
|
1
2
|
import { MapLayerSource, ScreenViewport } from "@itwin/core-frontend";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { MapLayerOptions, StyleMapLayerSettings } from "../Interfaces";
|
|
@@ -6,7 +7,7 @@ import "./MapLayerManager.scss";
|
|
|
6
7
|
export interface SourceMapContextProps {
|
|
7
8
|
readonly sources: MapLayerSource[];
|
|
8
9
|
readonly loadingSources: boolean;
|
|
9
|
-
readonly bases:
|
|
10
|
+
readonly bases: BaseMapLayerSettings[];
|
|
10
11
|
readonly refreshFromStyle: () => void;
|
|
11
12
|
readonly activeViewport?: ScreenViewport;
|
|
12
13
|
readonly backgroundLayers?: StyleMapLayerSettings[];
|
|
@@ -14,6 +15,8 @@ export interface SourceMapContextProps {
|
|
|
14
15
|
readonly mapLayerOptions?: MapLayerOptions;
|
|
15
16
|
}
|
|
16
17
|
/** @internal */
|
|
18
|
+
export declare const defaultBaseMapLayers: BaseMapLayerSettings[];
|
|
19
|
+
/** @internal */
|
|
17
20
|
export declare const SourceMapContext: React.Context<SourceMapContextProps>;
|
|
18
21
|
/** @internal */
|
|
19
22
|
export declare function useSourceMapContext(): SourceMapContextProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerManager.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerManager.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapLayerManager.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerManager.tsx"],"names":[],"mappings":"AAUA,OAAO,EAA4C,oBAAoB,EAAoF,MAAM,oBAAoB,CAAC;AACtL,OAAO,EACiF,cAAc,EACpG,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,wBAAwB,CAAC;AAMhC,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IACvC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjD,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;CAC5C;AAED,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,wBAIhC,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,sCAK3B,CAAC;AAEH,gBAAgB;AAChB,wBAAgB,mBAAmB,IAAI,qBAAqB,CAE3D;AAwCD,UAAU,oBAAoB;IAC5B,oBAAoB,EAAE,MAAM,WAAW,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAoe1D"}
|