@itwin/map-layers 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/lib/cjs/public/locales/en/mapLayers.json +7 -2
  3. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  4. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +144 -64
  5. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  6. package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
  7. package/lib/cjs/ui/widget/BasemapPanel.js +44 -15
  8. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  9. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  10. package/lib/cjs/ui/widget/MapLayerDroppable.js +26 -3
  11. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  12. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
  13. package/lib/cjs/ui/widget/MapLayerManager.js +35 -57
  14. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  15. package/lib/cjs/ui/widget/MapLayerManager.scss +2 -8
  16. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.d.ts +11 -0
  17. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.d.ts.map +1 -0
  18. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js +58 -0
  19. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js.map +1 -0
  20. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.scss +17 -0
  21. package/lib/cjs/ui/widget/MapUrlDialog.d.ts +7 -2
  22. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
  23. package/lib/cjs/ui/widget/MapUrlDialog.js +38 -134
  24. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  25. package/lib/cjs/ui/widget/MapUrlDialog.scss +10 -10
  26. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts +3 -1
  27. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
  28. package/lib/cjs/ui/widget/SubLayersDataProvider.js +3 -3
  29. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  30. package/lib/cjs/ui/widget/SubLayersPopupButton.js +1 -1
  31. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
  32. package/lib/cjs/ui/widget/SubLayersTree.d.ts +5 -0
  33. package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
  34. package/lib/cjs/ui/widget/SubLayersTree.js +12 -36
  35. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  36. package/lib/cjs/ui/widget/SubLayersTree.scss +12 -3
  37. package/lib/esm/public/locales/en/mapLayers.json +7 -2
  38. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  39. package/lib/esm/ui/widget/AttachLayerPopupButton.js +145 -65
  40. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  41. package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
  42. package/lib/esm/ui/widget/BasemapPanel.js +44 -15
  43. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  44. package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  45. package/lib/esm/ui/widget/MapLayerDroppable.js +27 -4
  46. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  47. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
  48. package/lib/esm/ui/widget/MapLayerManager.js +36 -58
  49. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  50. package/lib/esm/ui/widget/MapLayerManager.scss +2 -8
  51. package/lib/esm/ui/widget/MapSelectFeaturesDialog.d.ts +11 -0
  52. package/lib/esm/ui/widget/MapSelectFeaturesDialog.d.ts.map +1 -0
  53. package/lib/esm/ui/widget/MapSelectFeaturesDialog.js +54 -0
  54. package/lib/esm/ui/widget/MapSelectFeaturesDialog.js.map +1 -0
  55. package/lib/esm/ui/widget/MapSelectFeaturesDialog.scss +17 -0
  56. package/lib/esm/ui/widget/MapUrlDialog.d.ts +7 -2
  57. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
  58. package/lib/esm/ui/widget/MapUrlDialog.js +38 -134
  59. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  60. package/lib/esm/ui/widget/MapUrlDialog.scss +10 -10
  61. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts +3 -1
  62. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
  63. package/lib/esm/ui/widget/SubLayersDataProvider.js +3 -3
  64. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  65. package/lib/esm/ui/widget/SubLayersPopupButton.js +1 -1
  66. package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
  67. package/lib/esm/ui/widget/SubLayersTree.d.ts +5 -0
  68. package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
  69. package/lib/esm/ui/widget/SubLayersTree.js +13 -37
  70. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  71. package/lib/esm/ui/widget/SubLayersTree.scss +12 -3
  72. package/lib/public/locales/en/mapLayers.json +7 -2
  73. package/package.json +16 -15
@@ -5,7 +5,7 @@
5
5
  // cSpell:ignore droppable Sublayer Basemap
6
6
  // the following quiet warning caused by react-beautiful-dnd package
7
7
  /* eslint-disable @typescript-eslint/unbound-method */
8
- import { assert, BentleyError } from "@itwin/core-bentley";
8
+ import { BentleyError, compareStrings } from "@itwin/core-bentley";
9
9
  import { ImageMapLayerSettings } from "@itwin/core-common";
10
10
  import { ImageryMapTileTree, IModelApp, MapLayerSources, NotifyMessageDetails, OutputMessagePriority, } from "@itwin/core-frontend";
11
11
  import { ToggleSwitch } from "@itwin/itwinui-react";
@@ -107,10 +107,7 @@ export function MapLayerManager(props) {
107
107
  loadMapLayerSettingsFromViewport(activeViewport);
108
108
  }
109
109
  };
110
- IModelApp.tileAdmin.onTileTreeLoad.addListener(handleTileTreeLoad);
111
- return () => {
112
- IModelApp.tileAdmin.onTileTreeLoad.removeListener(handleTileTreeLoad);
113
- };
110
+ return IModelApp.tileAdmin.onTileTreeLoad.addListener(handleTileTreeLoad);
114
111
  }, [activeViewport, loadMapLayerSettingsFromViewport]);
115
112
  React.useEffect(() => {
116
113
  const handleScaleRangeVisibilityChanged = (layerIndexes) => {
@@ -128,10 +125,7 @@ export function MapLayerManager(props) {
128
125
  setBackgroundMapLayers(updateLayers(backgroundMapLayers));
129
126
  setOverlayMapLayers(updateLayers(overlayMapLayers));
130
127
  };
131
- activeViewport.onMapLayerScaleRangeVisibilityChanged.addListener(handleScaleRangeVisibilityChanged);
132
- return () => {
133
- activeViewport.onMapLayerScaleRangeVisibilityChanged.removeListener(handleScaleRangeVisibilityChanged);
134
- };
128
+ return activeViewport.onMapLayerScaleRangeVisibilityChanged.addListener(handleScaleRangeVisibilityChanged);
135
129
  }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);
136
130
  // Setup onMapImageryChanged events listening.
137
131
  React.useEffect(() => {
@@ -141,10 +135,7 @@ export function MapLayerManager(props) {
141
135
  loadMapLayerSettingsFromViewport(activeViewport);
142
136
  }
143
137
  };
144
- activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);
145
- return () => {
146
- activeViewport?.displayStyle.settings.onMapImageryChanged.removeListener(handleMapImageryChanged);
147
- };
138
+ return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);
148
139
  }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);
149
140
  const handleProviderStatusChanged = React.useCallback((_args) => {
150
141
  loadMapLayerSettingsFromViewport(activeViewport);
@@ -167,17 +158,14 @@ export function MapLayerManager(props) {
167
158
  loadMapLayerSettingsFromViewport(activeViewport);
168
159
  }, [activeViewport, loadMapLayerSettingsFromViewport]);
169
160
  React.useEffect(() => {
170
- async function fetchWmsMapData() {
171
- const sources = [];
172
- const bases = [];
161
+ async function fetchSources() {
162
+ let preferenceSources = [];
173
163
  const sourceLayers = await MapLayerSources.create(undefined, (fetchPublicMapLayerSources && !hideExternalMapLayersSection));
174
- const iModel = IModelApp.viewManager.selectedView ? IModelApp.viewManager.selectedView.iModel : undefined;
164
+ const iModel = activeViewport.iModel;
175
165
  try {
176
- const preferenceSources = (iModel?.iTwinId === undefined
177
- ? []
178
- : await MapLayerPreferences.getSources(iModel?.iTwinId, iModel?.iModelId));
179
- for (const source of preferenceSources)
180
- await MapLayerSources.addSourceToMapLayerSources(source);
166
+ if (iModel?.iTwinId !== undefined) {
167
+ preferenceSources = await MapLayerPreferences.getSources(iModel.iTwinId, iModel.iModelId);
168
+ }
181
169
  }
182
170
  catch (err) {
183
171
  IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, IModelApp.localization.getLocalizedString("mapLayers:CustomAttach.ErrorLoadingLayers"), BentleyError.getErrorMessage(err)));
@@ -185,16 +173,22 @@ export function MapLayerManager(props) {
185
173
  if (!isMounted.current) {
186
174
  return;
187
175
  }
188
- // This is where the list of layers first gets populated... I need to update it
189
- // MapUrlDialog gets around knowing MapLayerManager exists and vice versa by affecting the viewports displayStyle which MapLayerManager is listening for
190
- // We know when displayStyle changes we've added a layer, this layer may not be a custom layer
191
- sourceLayers?.layers.forEach((source) => { sources.push(source); });
176
+ // This is where the list of layers first gets populated...
177
+ const sources = [];
178
+ const bases = [];
179
+ const addSource = (source) => source.baseMap ? bases.push(source) : sources.push(source);
180
+ sourceLayers?.allSource.forEach(addSource);
181
+ preferenceSources.forEach((source) => {
182
+ // Do not add duplicate
183
+ if (!sources.find((curSource) => source.name === curSource.name))
184
+ addSource(source);
185
+ });
186
+ sources.sort((a, b) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));
192
187
  setMapSources(sources);
193
- sourceLayers?.bases.forEach((source) => { bases.push(source); });
194
188
  setBaseSources(bases);
195
189
  }
196
190
  setLoadingSources(true);
197
- fetchWmsMapData().then(() => {
191
+ fetchSources().then(() => {
198
192
  if (isMounted.current) {
199
193
  setLoadingSources(false);
200
194
  }
@@ -203,55 +197,39 @@ export function MapLayerManager(props) {
203
197
  setLoadingSources(false);
204
198
  }
205
199
  });
206
- }, [setMapSources, fetchPublicMapLayerSources, hideExternalMapLayersSection]);
207
- const updateMapSources = React.useCallback(() => {
208
- const newSources = [];
209
- MapLayerSources.getInstance()?.layers?.forEach((sourceLayer) => { newSources.push(sourceLayer); });
210
- setMapSources(newSources);
211
- }, [setMapSources]);
200
+ }, [setMapSources, fetchPublicMapLayerSources, hideExternalMapLayersSection, activeViewport.iModel]);
212
201
  /**
213
202
  * Handle change events in the MapLayerPreferences
214
203
  */
215
204
  React.useEffect(() => {
216
205
  const handleLayerSourceChange = async (changeType, oldSource, newSource) => {
217
- const removeSourceOnly = (changeType === MapLayerSourceChangeType.Removed);
218
206
  const removeSource = (changeType === MapLayerSourceChangeType.Replaced || changeType === MapLayerSourceChangeType.Removed);
219
207
  const addSource = (changeType === MapLayerSourceChangeType.Replaced || changeType === MapLayerSourceChangeType.Added);
208
+ let tmpSources = (mapSources ? [...mapSources] : undefined);
220
209
  if (removeSource) {
221
- if (oldSource) {
222
- const succeeded = MapLayerSources.removeLayerByName(oldSource.name);
223
- assert(succeeded);
224
- if (!succeeded) {
225
- return;
226
- }
227
- if (removeSourceOnly) {
228
- updateMapSources();
229
- return;
230
- }
210
+ if (oldSource && tmpSources) {
211
+ tmpSources = tmpSources.filter((source) => source.name !== oldSource.name);
212
+ // We don't update state in case of replacement... it will be done when the source is re-added right after.
213
+ if (changeType !== MapLayerSourceChangeType.Replaced)
214
+ setMapSources(tmpSources);
231
215
  }
232
216
  }
233
217
  if (addSource) {
234
- const sources = await MapLayerSources.addSourceToMapLayerSources(newSource);
235
- assert(sources !== undefined);
236
- if (sources) {
237
- updateMapSources();
218
+ if (tmpSources && newSource && !tmpSources.find((curSource) => newSource.name === curSource.name)) {
219
+ tmpSources.push(newSource);
220
+ tmpSources.sort((a, b) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));
221
+ setMapSources(tmpSources);
238
222
  }
239
223
  }
240
224
  };
241
- MapLayerPreferences.onLayerSourceChanged.addListener(handleLayerSourceChange);
242
- return (() => {
243
- MapLayerPreferences.onLayerSourceChanged.removeListener(handleLayerSourceChange);
244
- });
245
- }, [updateMapSources]);
225
+ return MapLayerPreferences.onLayerSourceChanged.addListener(handleLayerSourceChange);
226
+ }, [setMapSources, mapSources]);
246
227
  // update when a different display style is loaded.
247
228
  React.useEffect(() => {
248
229
  const handleDisplayStyleChange = (vp) => {
249
230
  loadMapLayerSettingsFromViewport(vp);
250
231
  };
251
- activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);
252
- return () => {
253
- activeViewport?.onDisplayStyleChanged.removeListener(handleDisplayStyleChange);
254
- };
232
+ return activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);
255
233
  }, [activeViewport, loadMapLayerSettingsFromViewport]);
256
234
  const handleOnMenuItemSelection = React.useCallback((action, mapLayerSettings) => {
257
235
  if (!activeViewport || !activeViewport.displayStyle)
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerManager.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerManager.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,2CAA2C;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAA6D,MAAM,oBAAoB,CAAC;AACtH,OAAO,EACL,kBAAkB,EAAE,SAAS,EAAyE,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,GAEnK,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,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eAAe,EAAE,cAAc,EACtD,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,EACvD,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,kBAAkB,EAAE,yBAAyB,EAC7C,6BAA6B,EAAE,2BAA2B,EAC1D,YAAY,EAAE,sBAAsB,GAAI,CACtC;oBAEN,6BAAK,SAAS,EAAC,2BAA2B;wBACxC,6BAAK,SAAS,EAAC,sBAAsB;4BACnC,8BAAM,SAAS,EAAC,4BAA4B,IAAE,aAAa,CAAQ;4BAAA,oBAAC,sBAAsB,IAAC,QAAQ,EAAE,CAAC,oBAAoB,EAAE,SAAS,EAAE,IAAI,GAAI,CAC3I;wBACN,oBAAC,iBAAiB,IAChB,QAAQ,EAAE,CAAC,oBAAoB,EAC/B,SAAS,EAAE,IAAI,EACf,UAAU,EAAE,gBAAgB,EAC5B,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,cAAc,EACtD,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,EACvD,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,kBAAkB,EAAE,yBAAyB,EAC7C,6BAA6B,EAAE,2BAA2B,EAC1D,YAAY,EAAE,sBAAsB,GAAI,CACtC,CACU,CAEf,CACoB,CAC9B,CAAC;AACJ,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// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport { assert, BentleyError } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, MapImagerySettings, MapSubLayerProps, MapSubLayerSettings } from \"@itwin/core-common\";\nimport {\n ImageryMapTileTree, IModelApp, MapLayerImageryProvider, MapLayerScaleRangeVisibility, MapLayerSource, MapLayerSources, NotifyMessageDetails, OutputMessagePriority,\n ScreenViewport, TileTreeOwner, Viewport,\n} from \"@itwin/core-frontend\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { DragDropContext, DropResult } from \"react-beautiful-dnd\";\nimport { MapLayerPreferences, MapLayerSourceChangeType } from \"../../MapLayerPreferences\";\nimport { MapLayerOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { BasemapPanel } from \"./BasemapPanel\";\nimport { MapLayerDroppable } from \"./MapLayerDroppable\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayerSettingsPopupButton } from \"./MapLayerSettingsPopupButton\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\n/** @internal */\nexport interface SourceMapContextProps {\n readonly sources: MapLayerSource[];\n readonly loadingSources: boolean;\n readonly bases: MapLayerSource[];\n readonly refreshFromStyle: () => void;\n readonly activeViewport?: ScreenViewport;\n readonly backgroundLayers?: StyleMapLayerSettings[];\n readonly overlayLayers?: StyleMapLayerSettings[];\n readonly mapLayerOptions?: MapLayerOptions;\n}\n\n/** @internal */\nexport const SourceMapContext = React.createContext<SourceMapContextProps>({ // eslint-disable-line @typescript-eslint/naming-convention\n sources: [],\n loadingSources: false,\n bases: [],\n refreshFromStyle: () => { },\n});\n\n/** @internal */\nexport function useSourceMapContext(): SourceMapContextProps {\n return React.useContext(SourceMapContext);\n}\n\nfunction getSubLayerProps(subLayerSettings: MapSubLayerSettings[]): MapSubLayerProps[] {\n return subLayerSettings.map((subLayer) => subLayer.toJSON());\n}\n\nfunction getMapLayerSettingsFromViewport(viewport: Viewport, getBackgroundMap: boolean, populateSubLayers = true): StyleMapLayerSettings[] | undefined {\n const displayStyle = viewport.displayStyle;\n if (!displayStyle)\n return undefined;\n\n const layers = new Array<StyleMapLayerSettings>();\n\n const displayStyleLayers = (getBackgroundMap ? displayStyle.settings.mapImagery.backgroundLayers : displayStyle.settings.mapImagery.overlayLayers);\n for (let layerIndex = 0; layerIndex < displayStyleLayers.length; layerIndex++) {\n const layerSettings = displayStyleLayers[layerIndex];\n const isOverlay = !getBackgroundMap;\n const layerProvider = viewport.getMapLayerImageryProvider({index: layerIndex, isOverlay});\n const treeVisibility = viewport.getMapLayerScaleRangeVisibility({index: layerIndex, isOverlay});\n const popSubLayers = populateSubLayers && (layerSettings instanceof ImageMapLayerSettings);\n layers.push({\n visible: layerSettings.visible,\n treeVisibility,\n name: layerSettings.name,\n source: layerSettings.source,\n transparency: layerSettings.transparency,\n transparentBackground: layerSettings.transparentBackground,\n subLayers: popSubLayers ? getSubLayerProps(layerSettings.subLayers) : undefined,\n showSubLayers: false,\n isOverlay,\n layerIndex,\n provider: layerProvider,\n });\n }\n\n // since we want to display higher level maps above lower maps in UI reverse their order here.\n return layers.reverse();\n}\n\ninterface MapLayerManagerProps {\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n mapLayerOptions?: MapLayerOptions;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerManager(props: MapLayerManagerProps) {\n const [mapSources, setMapSources] = React.useState<MapLayerSource[] | undefined>();\n const [loadingSources, setLoadingSources] = React.useState(false);\n const [baseSources, setBaseSources] = React.useState<MapLayerSource[] | undefined>();\n const [overlaysLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.OverlayLayers\"));\n const [underlaysLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.BackgroundLayers\"));\n const { activeViewport, mapLayerOptions } = props;\n const hideExternalMapLayersSection = mapLayerOptions?.hideExternalMapLayers ? mapLayerOptions.hideExternalMapLayers : false;\n const fetchPublicMapLayerSources = mapLayerOptions?.fetchPublicMapLayerSources ? mapLayerOptions.fetchPublicMapLayerSources : false;\n\n // map layer settings from display style\n const [backgroundMapLayers, setBackgroundMapLayers] = React.useState<StyleMapLayerSettings[] | undefined>(getMapLayerSettingsFromViewport(activeViewport, true));\n const [overlayMapLayers, setOverlayMapLayers] = React.useState<StyleMapLayerSettings[] | undefined>(getMapLayerSettingsFromViewport(activeViewport, false));\n\n const loadMapLayerSettingsFromViewport = React.useCallback((viewport: Viewport) => {\n setBackgroundMapLayers(getMapLayerSettingsFromViewport(viewport, true));\n setOverlayMapLayers(getMapLayerSettingsFromViewport(viewport, false));\n }, [setBackgroundMapLayers, setOverlayMapLayers]);\n\n const [backgroundMapVisible, setBackgroundMapVisible] = React.useState(() => {\n if (activeViewport) {\n return activeViewport.viewFlags.backgroundMap;\n }\n return false;\n });\n\n React.useEffect(() => {\n const updateBackgroundMapVisible = () => setBackgroundMapVisible(activeViewport.viewFlags.backgroundMap);\n return activeViewport.onDisplayStyleChanged.addListener(updateBackgroundMapVisible);\n }, [activeViewport]);\n\n // 'isMounted' is used to prevent any async operation once the hook has been\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\n const isMounted = React.useRef(false);\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n\n // Setup onTileTreeLoad events listening.\n // This is needed because we need to know when the imagery provider\n // is created, and be able to monitor to status change.\n React.useEffect(() => {\n const handleTileTreeLoad = (args: TileTreeOwner) => {\n\n // Ignore non-map tile trees\n if (args.tileTree instanceof ImageryMapTileTree) {\n loadMapLayerSettingsFromViewport(activeViewport);\n }\n };\n\n IModelApp.tileAdmin.onTileTreeLoad.addListener(handleTileTreeLoad);\n\n return () => {\n IModelApp.tileAdmin.onTileTreeLoad.removeListener(handleTileTreeLoad);\n };\n\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n React.useEffect(() => {\n const handleScaleRangeVisibilityChanged = (layerIndexes: MapLayerScaleRangeVisibility[]) => {\n const updateLayers = (array: StyleMapLayerSettings[] | undefined) => {\n if (array === undefined)\n return undefined;\n\n return array.map((curStyledLayer) => {\n const foundScaleRangeVisibility = layerIndexes.find((layerIdx) => layerIdx.index === curStyledLayer.layerIndex && layerIdx.isOverlay === curStyledLayer.isOverlay);\n if (undefined === foundScaleRangeVisibility)\n return curStyledLayer;\n else\n return { ...curStyledLayer, treeVisibility: foundScaleRangeVisibility.visibility };\n });\n\n };\n setBackgroundMapLayers(updateLayers(backgroundMapLayers));\n setOverlayMapLayers(updateLayers(overlayMapLayers));\n\n };\n activeViewport.onMapLayerScaleRangeVisibilityChanged.addListener(handleScaleRangeVisibilityChanged);\n\n return () => {\n activeViewport.onMapLayerScaleRangeVisibilityChanged.removeListener(handleScaleRangeVisibilityChanged);\n };\n\n }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);\n\n // Setup onMapImageryChanged events listening.\n\n React.useEffect(() => {\n const handleMapImageryChanged = (args: Readonly<MapImagerySettings>) => {\n\n if (args.backgroundLayers.length !== (backgroundMapLayers ? backgroundMapLayers.length : 0)\n || args.overlayLayers.length !== (overlayMapLayers ? overlayMapLayers.length : 0)) {\n loadMapLayerSettingsFromViewport(activeViewport);\n }\n };\n activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n\n return () => {\n activeViewport?.displayStyle.settings.onMapImageryChanged.removeListener(handleMapImageryChanged);\n };\n }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);\n\n const handleProviderStatusChanged = React.useCallback((_args: MapLayerImageryProvider) => {\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [loadMapLayerSettingsFromViewport, activeViewport]);\n\n // Triggered whenever a provider status change\n React.useEffect(() => {\n backgroundMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.addListener(handleProviderStatusChanged); });\n overlayMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.addListener(handleProviderStatusChanged); });\n\n return () => {\n backgroundMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.removeListener(handleProviderStatusChanged); });\n overlayMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.removeListener(handleProviderStatusChanged); });\n };\n\n }, [backgroundMapLayers, overlayMapLayers, activeViewport, loadMapLayerSettingsFromViewport, handleProviderStatusChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly.\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n // Update background map status\n setBackgroundMapVisible(activeViewport.viewFlags.backgroundMap);\n\n // Refresh list of layers\n loadMapLayerSettingsFromViewport(activeViewport);\n\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n React.useEffect(() => {\n async function fetchWmsMapData() {\n const sources: MapLayerSource[] = [];\n const bases: MapLayerSource[] = [];\n const sourceLayers = await MapLayerSources.create(undefined, (fetchPublicMapLayerSources && !hideExternalMapLayersSection));\n\n const iModel = IModelApp.viewManager.selectedView ? IModelApp.viewManager.selectedView.iModel : undefined;\n try {\n const preferenceSources = (iModel?.iTwinId === undefined\n ? []\n : await MapLayerPreferences.getSources(iModel?.iTwinId, iModel?.iModelId)\n );\n for (const source of preferenceSources)\n await MapLayerSources.addSourceToMapLayerSources(source);\n } catch (err) {\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorLoadingLayers\"), BentleyError.getErrorMessage(err)));\n }\n\n if (!isMounted.current) {\n return;\n }\n\n // This is where the list of layers first gets populated... I need to update it\n // MapUrlDialog gets around knowing MapLayerManager exists and vice versa by affecting the viewports displayStyle which MapLayerManager is listening for\n // We know when displayStyle changes we've added a layer, this layer may not be a custom layer\n sourceLayers?.layers.forEach((source: MapLayerSource) => { sources.push(source); });\n setMapSources(sources);\n sourceLayers?.bases.forEach((source: MapLayerSource) => { bases.push(source); });\n setBaseSources(bases);\n }\n\n setLoadingSources(true);\n fetchWmsMapData().then(() => {\n if (isMounted.current) {\n setLoadingSources(false);\n }\n\n }).catch(() => {\n if (isMounted.current) {\n setLoadingSources(false);\n }\n });\n }, [setMapSources, fetchPublicMapLayerSources, hideExternalMapLayersSection]);\n\n const updateMapSources = React.useCallback(() => {\n const newSources: MapLayerSource[] = [];\n MapLayerSources.getInstance()?.layers?.forEach((sourceLayer: MapLayerSource) => { newSources.push(sourceLayer); });\n setMapSources(newSources);\n }, [setMapSources]);\n\n /**\n * Handle change events in the MapLayerPreferences\n */\n React.useEffect(() => {\n const handleLayerSourceChange = async (changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => {\n const removeSourceOnly = (changeType === MapLayerSourceChangeType.Removed);\n const removeSource = (changeType === MapLayerSourceChangeType.Replaced || changeType === MapLayerSourceChangeType.Removed);\n const addSource = (changeType === MapLayerSourceChangeType.Replaced || changeType === MapLayerSourceChangeType.Added);\n\n if (removeSource) {\n if (oldSource) {\n const succeeded = MapLayerSources.removeLayerByName(oldSource.name);\n assert(succeeded);\n if (!succeeded) {\n return;\n }\n\n if (removeSourceOnly) {\n updateMapSources();\n return;\n }\n }\n }\n\n if (addSource) {\n const sources = await MapLayerSources.addSourceToMapLayerSources(newSource);\n assert(sources !== undefined);\n if (sources) {\n updateMapSources();\n }\n }\n };\n MapLayerPreferences.onLayerSourceChanged.addListener(handleLayerSourceChange);\n return (() => {\n MapLayerPreferences.onLayerSourceChanged.removeListener(handleLayerSourceChange);\n });\n }, [updateMapSources]);\n\n // update when a different display style is loaded.\n React.useEffect(() => {\n const handleDisplayStyleChange = (vp: Viewport) => {\n loadMapLayerSettingsFromViewport(vp);\n };\n activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);\n return () => {\n activeViewport?.onDisplayStyleChanged.removeListener(handleDisplayStyleChange);\n };\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const handleOnMenuItemSelection = React.useCallback((action: string, mapLayerSettings: StyleMapLayerSettings) => {\n if (!activeViewport || !activeViewport.displayStyle)\n return;\n\n const indexInDisplayStyle = activeViewport.displayStyle.findMapLayerIndexByNameAndSource(mapLayerSettings.name, mapLayerSettings.source, mapLayerSettings.isOverlay);\n if (indexInDisplayStyle < 0)\n return;\n\n switch (action) {\n case \"delete\":\n activeViewport.displayStyle.detachMapLayerByIndex({index: indexInDisplayStyle, isOverlay: mapLayerSettings.isOverlay});\n break;\n case \"zoom-to-layer\":\n activeViewport.viewMapLayerRange({index: indexInDisplayStyle, isOverlay: mapLayerSettings.isOverlay}, activeViewport).then((status) => {\n if (!status) {\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:Messages.NoRangeDefined\");\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, `${msg} [${mapLayerSettings.name}]`));\n }\n }).catch((_error) => { });\n break;\n }\n\n // force UI to update\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const handleLayerVisibilityChange = React.useCallback((mapLayerSettings: StyleMapLayerSettings) => {\n if (activeViewport) {\n const isVisible = !mapLayerSettings.visible;\n\n const displayStyle = activeViewport.displayStyle;\n const indexInDisplayStyle = displayStyle.findMapLayerIndexByNameAndSource(mapLayerSettings.name, mapLayerSettings.source, mapLayerSettings.isOverlay);\n if (-1 !== indexInDisplayStyle) {\n // update the display style\n displayStyle.changeMapLayerProps({ visible: isVisible }, {index: indexInDisplayStyle, isOverlay: mapLayerSettings.isOverlay});\n\n // force UI to update\n loadMapLayerSettingsFromViewport(activeViewport);\n }\n }\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const handleMapLayersToggle = React.useCallback(() => {\n if (activeViewport) {\n const newState = !backgroundMapVisible;\n activeViewport.viewFlags = activeViewport.viewFlags.with(\"backgroundMap\", newState);\n setBackgroundMapVisible(newState);\n }\n }, [backgroundMapVisible, setBackgroundMapVisible, activeViewport]);\n\n const handleOnMapLayerDragEnd = React.useCallback((result: DropResult /* , _provided: ResponderProvided*/) => {\n const { destination, source } = result;\n\n if (!destination) // dropped outside of list\n return;\n\n // item was not moved\n if (destination.droppableId === source.droppableId && destination.index === source.index)\n return;\n\n let fromMapLayer: StyleMapLayerSettings | undefined;\n if (source.droppableId === \"overlayMapLayers\" && overlayMapLayers)\n fromMapLayer = overlayMapLayers[source.index];\n else if (source.droppableId === \"backgroundMapLayers\" && backgroundMapLayers)\n fromMapLayer = backgroundMapLayers[source.index];\n\n if (!fromMapLayer || !activeViewport)\n return;\n\n const displayStyle = activeViewport.displayStyle;\n let toMapLayer: StyleMapLayerSettings | undefined;\n let toIndexInDisplayStyle = -1;\n\n // If destination.index is undefined then the user dropped the map at the end of list of maps. To get the \"actual\" index in the style, look up index in style by name.\n // We need to do this because the order of layers in UI are reversed so higher layers appear above lower layers.\n if (undefined !== destination.index) {\n if (destination.droppableId === \"overlayMapLayers\" && overlayMapLayers)\n toMapLayer = overlayMapLayers[destination.index];\n else if (destination.droppableId === \"backgroundMapLayers\" && backgroundMapLayers)\n toMapLayer = backgroundMapLayers[destination.index];\n if (toMapLayer)\n toIndexInDisplayStyle = displayStyle.findMapLayerIndexByNameAndSource(toMapLayer.name, toMapLayer.source, toMapLayer.isOverlay);\n }\n\n const fromIndexInDisplayStyle = displayStyle.findMapLayerIndexByNameAndSource(fromMapLayer.name, fromMapLayer.source, fromMapLayer.isOverlay);\n if (fromIndexInDisplayStyle < 0)\n return;\n\n if (destination.droppableId !== source.droppableId) {\n // see if we moved from \"overlayMapLayers\" to \"backgroundMapLayers\" or vice-versa\n const settings = activeViewport.displayStyle.mapLayerAtIndex({index: fromIndexInDisplayStyle, isOverlay: fromMapLayer.isOverlay});\n if (settings) {\n activeViewport.displayStyle.detachMapLayerByIndex({index: fromIndexInDisplayStyle, isOverlay: fromMapLayer.isOverlay});\n\n // Manually reverse index when moved from one section to the other\n if (fromMapLayer.isOverlay && backgroundMapLayers) {\n toIndexInDisplayStyle = displayStyle.settings.mapImagery.backgroundLayers.length - destination.index;\n } else if (!fromMapLayer.isOverlay && overlayMapLayers) {\n toIndexInDisplayStyle = overlayMapLayers.length - destination.index;\n }\n\n activeViewport.displayStyle.attachMapLayer({ settings, mapLayerIndex: {isOverlay: !fromMapLayer.isOverlay, index: toIndexInDisplayStyle} });\n }\n } else {\n if (undefined === destination.index) {\n displayStyle.moveMapLayerToBottom({index: fromIndexInDisplayStyle, isOverlay: destination.droppableId === \"overlayMapLayers\"});\n } else {\n if (toMapLayer) {\n if (toIndexInDisplayStyle !== -1)\n displayStyle.moveMapLayerToIndex(fromIndexInDisplayStyle, toIndexInDisplayStyle, toMapLayer.isOverlay);\n }\n }\n }\n // Note: display style change is automatically applied to view via DisplayStyleState._synchBackgroundMapImagery()\n // So no need to call Viewport.invalidateRenderPlan() here\n\n // force UI to update\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [loadMapLayerSettingsFromViewport, activeViewport, overlayMapLayers, backgroundMapLayers]);\n\n const handleRefreshFromStyle = React.useCallback(() => {\n if (activeViewport)\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const [baseMapPanelLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseMapPanelTitle\"));\n\n return (\n <SourceMapContext.Provider value={{\n activeViewport,\n loadingSources,\n sources: mapSources ? mapSources : [],\n bases: baseSources ? baseSources : [],\n refreshFromStyle: handleRefreshFromStyle,\n backgroundLayers: backgroundMapLayers,\n overlayLayers: overlayMapLayers,\n mapLayerOptions,\n }}>\n <div className=\"map-manager-top-header\">\n <span className=\"map-manager-header-label\">{baseMapPanelLabel}</span>\n <div className=\"map-manager-header-buttons-group\">\n <ToggleSwitch className=\"map-manager-toggle\" checked={backgroundMapVisible} onChange={handleMapLayersToggle} />\n <MapLayerSettingsPopupButton disabled={!backgroundMapVisible} />\n </div>\n </div>\n\n <div className=\"map-manager-container\">\n\n <div className=\"map-manager-basemap\">\n <BasemapPanel disabled={!backgroundMapVisible} />\n </div>\n {!hideExternalMapLayersSection &&\n <DragDropContext onDragEnd={handleOnMapLayerDragEnd}>\n <div className=\"map-manager-layer-wrapper\">\n <div className=\"map-manager-underlays\" >\n <span className=\"map-manager-underlays-label\">{underlaysLabel}</span><AttachLayerPopupButton disabled={!backgroundMapVisible} isOverlay={false} />\n </div>\n <MapLayerDroppable\n disabled={!backgroundMapVisible}\n isOverlay={false}\n layersList={backgroundMapLayers}\n mapTypesOptions={props.mapLayerOptions?.mapTypeOptions}\n getContainerForClone={props.getContainerForClone as any}\n activeViewport={props.activeViewport}\n onMenuItemSelected={handleOnMenuItemSelection}\n onItemVisibilityToggleClicked={handleLayerVisibilityChange}\n onItemEdited={handleRefreshFromStyle} />\n </div>\n\n <div className=\"map-manager-layer-wrapper\">\n <div className=\"map-manager-overlays\" >\n <span className=\"map-manager-overlays-label\">{overlaysLabel}</span><AttachLayerPopupButton disabled={!backgroundMapVisible} isOverlay={true} />\n </div>\n <MapLayerDroppable\n disabled={!backgroundMapVisible}\n isOverlay={true}\n layersList={overlayMapLayers}\n mapTypesOptions={props.mapLayerOptions?.mapTypeOptions}\n getContainerForClone={props.getContainerForClone as any}\n activeViewport={props.activeViewport}\n onMenuItemSelected={handleOnMenuItemSelection}\n onItemVisibilityToggleClicked={handleLayerVisibilityChange}\n onItemEdited={handleRefreshFromStyle} />\n </div>\n </DragDropContext>\n }\n </div >\n </SourceMapContext.Provider >\n );\n}\n\n"]}
1
+ {"version":3,"file":"MapLayerManager.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerManager.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,2CAA2C;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAA6D,MAAM,oBAAoB,CAAC;AACtH,OAAO,EACL,kBAAkB,EAAE,SAAS,EAAyE,eAAe,EAAE,oBAAoB,EAAE,qBAAqB,GAEnK,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAc,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,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U,EAAE,gBAAgB,EAC5B,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,cAAc,EACtD,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,EACvD,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,kBAAkB,EAAE,yBAAyB,EAC7C,6BAA6B,EAAE,2BAA2B,EAC1D,YAAY,EAAE,sBAAsB,GAAI,CACtC,CACU,CAEf,CACoB,CAC9B,CAAC;AACJ,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// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport { BentleyError, compareStrings } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, MapImagerySettings, MapSubLayerProps, MapSubLayerSettings } from \"@itwin/core-common\";\nimport {\n ImageryMapTileTree, IModelApp, MapLayerImageryProvider, MapLayerScaleRangeVisibility, MapLayerSource, MapLayerSources, NotifyMessageDetails, OutputMessagePriority,\n ScreenViewport, TileTreeOwner, Viewport,\n} from \"@itwin/core-frontend\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { DragDropContext, DropResult } from \"react-beautiful-dnd\";\nimport { MapLayerPreferences, MapLayerSourceChangeType } from \"../../MapLayerPreferences\";\nimport { MapLayerOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { BasemapPanel } from \"./BasemapPanel\";\nimport { MapLayerDroppable } from \"./MapLayerDroppable\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayerSettingsPopupButton } from \"./MapLayerSettingsPopupButton\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\n/** @internal */\nexport interface SourceMapContextProps {\n readonly sources: MapLayerSource[];\n readonly loadingSources: boolean;\n readonly bases: MapLayerSource[];\n readonly refreshFromStyle: () => void;\n readonly activeViewport?: ScreenViewport;\n readonly backgroundLayers?: StyleMapLayerSettings[];\n readonly overlayLayers?: StyleMapLayerSettings[];\n readonly mapLayerOptions?: MapLayerOptions;\n}\n\n/** @internal */\nexport const SourceMapContext = React.createContext<SourceMapContextProps>({ // eslint-disable-line @typescript-eslint/naming-convention\n sources: [],\n loadingSources: false,\n bases: [],\n refreshFromStyle: () => { },\n});\n\n/** @internal */\nexport function useSourceMapContext(): SourceMapContextProps {\n return React.useContext(SourceMapContext);\n}\n\nfunction getSubLayerProps(subLayerSettings: MapSubLayerSettings[]): MapSubLayerProps[] {\n return subLayerSettings.map((subLayer) => subLayer.toJSON());\n}\n\nfunction getMapLayerSettingsFromViewport(viewport: Viewport, getBackgroundMap: boolean, populateSubLayers = true): StyleMapLayerSettings[] | undefined {\n const displayStyle = viewport.displayStyle;\n if (!displayStyle)\n return undefined;\n\n const layers = new Array<StyleMapLayerSettings>();\n\n const displayStyleLayers = (getBackgroundMap ? displayStyle.settings.mapImagery.backgroundLayers : displayStyle.settings.mapImagery.overlayLayers);\n for (let layerIndex = 0; layerIndex < displayStyleLayers.length; layerIndex++) {\n const layerSettings = displayStyleLayers[layerIndex];\n const isOverlay = !getBackgroundMap;\n const layerProvider = viewport.getMapLayerImageryProvider({index: layerIndex, isOverlay});\n const treeVisibility = viewport.getMapLayerScaleRangeVisibility({index: layerIndex, isOverlay});\n const popSubLayers = populateSubLayers && (layerSettings instanceof ImageMapLayerSettings);\n layers.push({\n visible: layerSettings.visible,\n treeVisibility,\n name: layerSettings.name,\n source: layerSettings.source,\n transparency: layerSettings.transparency,\n transparentBackground: layerSettings.transparentBackground,\n subLayers: popSubLayers ? getSubLayerProps(layerSettings.subLayers) : undefined,\n showSubLayers: false,\n isOverlay,\n layerIndex,\n provider: layerProvider,\n });\n }\n\n // since we want to display higher level maps above lower maps in UI reverse their order here.\n return layers.reverse();\n}\n\ninterface MapLayerManagerProps {\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n mapLayerOptions?: MapLayerOptions;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerManager(props: MapLayerManagerProps) {\n const [mapSources, setMapSources] = React.useState<MapLayerSource[] | undefined>();\n const [loadingSources, setLoadingSources] = React.useState(false);\n const [baseSources, setBaseSources] = React.useState<MapLayerSource[] | undefined>();\n const [overlaysLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.OverlayLayers\"));\n const [underlaysLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.BackgroundLayers\"));\n const { activeViewport, mapLayerOptions } = props;\n const hideExternalMapLayersSection = mapLayerOptions?.hideExternalMapLayers ? mapLayerOptions.hideExternalMapLayers : false;\n const fetchPublicMapLayerSources = mapLayerOptions?.fetchPublicMapLayerSources ? mapLayerOptions.fetchPublicMapLayerSources : false;\n\n // map layer settings from display style\n const [backgroundMapLayers, setBackgroundMapLayers] = React.useState<StyleMapLayerSettings[] | undefined>(getMapLayerSettingsFromViewport(activeViewport, true));\n const [overlayMapLayers, setOverlayMapLayers] = React.useState<StyleMapLayerSettings[] | undefined>(getMapLayerSettingsFromViewport(activeViewport, false));\n\n const loadMapLayerSettingsFromViewport = React.useCallback((viewport: Viewport) => {\n setBackgroundMapLayers(getMapLayerSettingsFromViewport(viewport, true));\n setOverlayMapLayers(getMapLayerSettingsFromViewport(viewport, false));\n }, [setBackgroundMapLayers, setOverlayMapLayers]);\n\n const [backgroundMapVisible, setBackgroundMapVisible] = React.useState(() => {\n if (activeViewport) {\n return activeViewport.viewFlags.backgroundMap;\n }\n return false;\n });\n\n React.useEffect(() => {\n const updateBackgroundMapVisible = () => setBackgroundMapVisible(activeViewport.viewFlags.backgroundMap);\n return activeViewport.onDisplayStyleChanged.addListener(updateBackgroundMapVisible);\n }, [activeViewport]);\n\n // 'isMounted' is used to prevent any async operation once the hook has been\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\n const isMounted = React.useRef(false);\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n\n // Setup onTileTreeLoad events listening.\n // This is needed because we need to know when the imagery provider\n // is created, and be able to monitor to status change.\n React.useEffect(() => {\n const handleTileTreeLoad = (args: TileTreeOwner) => {\n\n // Ignore non-map tile trees\n if (args.tileTree instanceof ImageryMapTileTree) {\n loadMapLayerSettingsFromViewport(activeViewport);\n }\n };\n\n return IModelApp.tileAdmin.onTileTreeLoad.addListener(handleTileTreeLoad);\n\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n React.useEffect(() => {\n const handleScaleRangeVisibilityChanged = (layerIndexes: MapLayerScaleRangeVisibility[]) => {\n const updateLayers = (array: StyleMapLayerSettings[] | undefined) => {\n if (array === undefined)\n return undefined;\n\n return array.map((curStyledLayer) => {\n const foundScaleRangeVisibility = layerIndexes.find((layerIdx) => layerIdx.index === curStyledLayer.layerIndex && layerIdx.isOverlay === curStyledLayer.isOverlay);\n if (undefined === foundScaleRangeVisibility)\n return curStyledLayer;\n else\n return { ...curStyledLayer, treeVisibility: foundScaleRangeVisibility.visibility };\n });\n\n };\n setBackgroundMapLayers(updateLayers(backgroundMapLayers));\n setOverlayMapLayers(updateLayers(overlayMapLayers));\n\n };\n\n return activeViewport.onMapLayerScaleRangeVisibilityChanged.addListener(handleScaleRangeVisibilityChanged);\n\n }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);\n\n // Setup onMapImageryChanged events listening.\n\n React.useEffect(() => {\n const handleMapImageryChanged = (args: Readonly<MapImagerySettings>) => {\n\n if (args.backgroundLayers.length !== (backgroundMapLayers ? backgroundMapLayers.length : 0)\n || args.overlayLayers.length !== (overlayMapLayers ? overlayMapLayers.length : 0)) {\n loadMapLayerSettingsFromViewport(activeViewport);\n }\n };\n return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);\n\n const handleProviderStatusChanged = React.useCallback((_args: MapLayerImageryProvider) => {\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [loadMapLayerSettingsFromViewport, activeViewport]);\n\n // Triggered whenever a provider status change\n React.useEffect(() => {\n backgroundMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.addListener(handleProviderStatusChanged); });\n overlayMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.addListener(handleProviderStatusChanged); });\n\n return () => {\n backgroundMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.removeListener(handleProviderStatusChanged); });\n overlayMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.removeListener(handleProviderStatusChanged); });\n };\n\n }, [backgroundMapLayers, overlayMapLayers, activeViewport, loadMapLayerSettingsFromViewport, handleProviderStatusChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly.\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n // Update background map status\n setBackgroundMapVisible(activeViewport.viewFlags.backgroundMap);\n\n // Refresh list of layers\n loadMapLayerSettingsFromViewport(activeViewport);\n\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n React.useEffect(() => {\n async function fetchSources() {\n\n let preferenceSources: MapLayerSource[] = [];\n const sourceLayers = await MapLayerSources.create(undefined, (fetchPublicMapLayerSources && !hideExternalMapLayersSection));\n\n const iModel = activeViewport.iModel;\n try {\n if (iModel?.iTwinId !== undefined) {\n preferenceSources = await MapLayerPreferences.getSources(iModel.iTwinId, iModel.iModelId);\n }\n } catch (err) {\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorLoadingLayers\"), BentleyError.getErrorMessage(err)));\n }\n\n if (!isMounted.current) {\n return;\n }\n\n // This is where the list of layers first gets populated...\n const sources: MapLayerSource[] = [];\n const bases: MapLayerSource[] = [];\n const addSource = (source: MapLayerSource) => source.baseMap ? bases.push(source) : sources.push(source);\n sourceLayers?.allSource.forEach(addSource);\n preferenceSources.forEach((source) => {\n // Do not add duplicate\n if (!sources.find((curSource) => source.name === curSource.name))\n addSource(source);\n });\n sources.sort((a: MapLayerSource, b: MapLayerSource) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));\n\n setMapSources(sources);\n setBaseSources(bases);\n }\n\n setLoadingSources(true);\n\n fetchSources().then(() => {\n if (isMounted.current) {\n setLoadingSources(false);\n }\n\n }).catch(() => {\n if (isMounted.current) {\n setLoadingSources(false);\n }\n });\n }, [setMapSources, fetchPublicMapLayerSources, hideExternalMapLayersSection, activeViewport.iModel]);\n\n /**\n * Handle change events in the MapLayerPreferences\n */\n React.useEffect(() => {\n const handleLayerSourceChange = async (changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => {\n const removeSource = (changeType === MapLayerSourceChangeType.Replaced || changeType === MapLayerSourceChangeType.Removed);\n const addSource = (changeType === MapLayerSourceChangeType.Replaced || changeType === MapLayerSourceChangeType.Added);\n\n let tmpSources = (mapSources ? [...mapSources] : undefined);\n if (removeSource) {\n if (oldSource && tmpSources) {\n tmpSources = tmpSources.filter((source) => source.name !== oldSource.name);\n\n // We don't update state in case of replacement... it will be done when the source is re-added right after.\n if (changeType !== MapLayerSourceChangeType.Replaced )\n setMapSources(tmpSources);\n }\n }\n\n if (addSource) {\n if (tmpSources && newSource && !tmpSources.find((curSource) => newSource.name === curSource.name)) {\n tmpSources.push(newSource);\n tmpSources.sort((a: MapLayerSource, b: MapLayerSource) => compareStrings(a.name.toLowerCase(), b.name.toLowerCase()));\n setMapSources(tmpSources);\n }\n }\n };\n return MapLayerPreferences.onLayerSourceChanged.addListener(handleLayerSourceChange);\n\n }, [setMapSources, mapSources]);\n\n // update when a different display style is loaded.\n React.useEffect(() => {\n const handleDisplayStyleChange = (vp: Viewport) => {\n loadMapLayerSettingsFromViewport(vp);\n };\n return activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const handleOnMenuItemSelection = React.useCallback((action: string, mapLayerSettings: StyleMapLayerSettings) => {\n if (!activeViewport || !activeViewport.displayStyle)\n return;\n\n const indexInDisplayStyle = activeViewport.displayStyle.findMapLayerIndexByNameAndSource(mapLayerSettings.name, mapLayerSettings.source, mapLayerSettings.isOverlay);\n if (indexInDisplayStyle < 0)\n return;\n\n switch (action) {\n case \"delete\":\n activeViewport.displayStyle.detachMapLayerByIndex({index: indexInDisplayStyle, isOverlay: mapLayerSettings.isOverlay});\n break;\n case \"zoom-to-layer\":\n activeViewport.viewMapLayerRange({index: indexInDisplayStyle, isOverlay: mapLayerSettings.isOverlay}, activeViewport).then((status) => {\n if (!status) {\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:Messages.NoRangeDefined\");\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, `${msg} [${mapLayerSettings.name}]`));\n }\n }).catch((_error) => { });\n break;\n }\n\n // force UI to update\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const handleLayerVisibilityChange = React.useCallback((mapLayerSettings: StyleMapLayerSettings) => {\n if (activeViewport) {\n const isVisible = !mapLayerSettings.visible;\n\n const displayStyle = activeViewport.displayStyle;\n const indexInDisplayStyle = displayStyle.findMapLayerIndexByNameAndSource(mapLayerSettings.name, mapLayerSettings.source, mapLayerSettings.isOverlay);\n if (-1 !== indexInDisplayStyle) {\n // update the display style\n displayStyle.changeMapLayerProps({ visible: isVisible }, {index: indexInDisplayStyle, isOverlay: mapLayerSettings.isOverlay});\n\n // force UI to update\n loadMapLayerSettingsFromViewport(activeViewport);\n }\n }\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const handleMapLayersToggle = React.useCallback(() => {\n if (activeViewport) {\n const newState = !backgroundMapVisible;\n activeViewport.viewFlags = activeViewport.viewFlags.with(\"backgroundMap\", newState);\n setBackgroundMapVisible(newState);\n }\n }, [backgroundMapVisible, setBackgroundMapVisible, activeViewport]);\n\n const handleOnMapLayerDragEnd = React.useCallback((result: DropResult /* , _provided: ResponderProvided*/) => {\n const { destination, source } = result;\n\n if (!destination) // dropped outside of list\n return;\n\n // item was not moved\n if (destination.droppableId === source.droppableId && destination.index === source.index)\n return;\n\n let fromMapLayer: StyleMapLayerSettings | undefined;\n if (source.droppableId === \"overlayMapLayers\" && overlayMapLayers)\n fromMapLayer = overlayMapLayers[source.index];\n else if (source.droppableId === \"backgroundMapLayers\" && backgroundMapLayers)\n fromMapLayer = backgroundMapLayers[source.index];\n\n if (!fromMapLayer || !activeViewport)\n return;\n\n const displayStyle = activeViewport.displayStyle;\n let toMapLayer: StyleMapLayerSettings | undefined;\n let toIndexInDisplayStyle = -1;\n\n // If destination.index is undefined then the user dropped the map at the end of list of maps. To get the \"actual\" index in the style, look up index in style by name.\n // We need to do this because the order of layers in UI are reversed so higher layers appear above lower layers.\n if (undefined !== destination.index) {\n if (destination.droppableId === \"overlayMapLayers\" && overlayMapLayers)\n toMapLayer = overlayMapLayers[destination.index];\n else if (destination.droppableId === \"backgroundMapLayers\" && backgroundMapLayers)\n toMapLayer = backgroundMapLayers[destination.index];\n if (toMapLayer)\n toIndexInDisplayStyle = displayStyle.findMapLayerIndexByNameAndSource(toMapLayer.name, toMapLayer.source, toMapLayer.isOverlay);\n }\n\n const fromIndexInDisplayStyle = displayStyle.findMapLayerIndexByNameAndSource(fromMapLayer.name, fromMapLayer.source, fromMapLayer.isOverlay);\n if (fromIndexInDisplayStyle < 0)\n return;\n\n if (destination.droppableId !== source.droppableId) {\n // see if we moved from \"overlayMapLayers\" to \"backgroundMapLayers\" or vice-versa\n const settings = activeViewport.displayStyle.mapLayerAtIndex({index: fromIndexInDisplayStyle, isOverlay: fromMapLayer.isOverlay});\n if (settings) {\n activeViewport.displayStyle.detachMapLayerByIndex({index: fromIndexInDisplayStyle, isOverlay: fromMapLayer.isOverlay});\n\n // Manually reverse index when moved from one section to the other\n if (fromMapLayer.isOverlay && backgroundMapLayers) {\n toIndexInDisplayStyle = displayStyle.settings.mapImagery.backgroundLayers.length - destination.index;\n } else if (!fromMapLayer.isOverlay && overlayMapLayers) {\n toIndexInDisplayStyle = overlayMapLayers.length - destination.index;\n }\n\n activeViewport.displayStyle.attachMapLayer({ settings, mapLayerIndex: {isOverlay: !fromMapLayer.isOverlay, index: toIndexInDisplayStyle} });\n }\n } else {\n if (undefined === destination.index) {\n displayStyle.moveMapLayerToBottom({index: fromIndexInDisplayStyle, isOverlay: destination.droppableId === \"overlayMapLayers\"});\n } else {\n if (toMapLayer) {\n if (toIndexInDisplayStyle !== -1)\n displayStyle.moveMapLayerToIndex(fromIndexInDisplayStyle, toIndexInDisplayStyle, toMapLayer.isOverlay);\n }\n }\n }\n // Note: display style change is automatically applied to view via DisplayStyleState._synchBackgroundMapImagery()\n // So no need to call Viewport.invalidateRenderPlan() here\n\n // force UI to update\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [loadMapLayerSettingsFromViewport, activeViewport, overlayMapLayers, backgroundMapLayers]);\n\n const handleRefreshFromStyle = React.useCallback(() => {\n if (activeViewport)\n loadMapLayerSettingsFromViewport(activeViewport);\n }, [activeViewport, loadMapLayerSettingsFromViewport]);\n\n const [baseMapPanelLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseMapPanelTitle\"));\n\n return (\n <SourceMapContext.Provider value={{\n activeViewport,\n loadingSources,\n sources: mapSources ? mapSources : [],\n bases: baseSources ? baseSources : [],\n refreshFromStyle: handleRefreshFromStyle,\n backgroundLayers: backgroundMapLayers,\n overlayLayers: overlayMapLayers,\n mapLayerOptions,\n }}>\n <div className=\"map-manager-top-header\">\n <span className=\"map-manager-header-label\">{baseMapPanelLabel}</span>\n <div className=\"map-manager-header-buttons-group\">\n <ToggleSwitch className=\"map-manager-toggle\" checked={backgroundMapVisible} onChange={handleMapLayersToggle} />\n <MapLayerSettingsPopupButton disabled={!backgroundMapVisible} />\n </div>\n </div>\n\n <div className=\"map-manager-container\">\n\n <div className=\"map-manager-basemap\">\n <BasemapPanel disabled={!backgroundMapVisible} />\n </div>\n {!hideExternalMapLayersSection &&\n <DragDropContext onDragEnd={handleOnMapLayerDragEnd}>\n <div className=\"map-manager-layer-wrapper\">\n <div className=\"map-manager-underlays\" >\n <span className=\"map-manager-underlays-label\">{underlaysLabel}</span><AttachLayerPopupButton disabled={!backgroundMapVisible} isOverlay={false} />\n </div>\n <MapLayerDroppable\n disabled={!backgroundMapVisible}\n isOverlay={false}\n layersList={backgroundMapLayers}\n mapTypesOptions={props.mapLayerOptions?.mapTypeOptions}\n getContainerForClone={props.getContainerForClone as any}\n activeViewport={props.activeViewport}\n onMenuItemSelected={handleOnMenuItemSelection}\n onItemVisibilityToggleClicked={handleLayerVisibilityChange}\n onItemEdited={handleRefreshFromStyle} />\n </div>\n\n <div className=\"map-manager-layer-wrapper\">\n <div className=\"map-manager-overlays\" >\n <span className=\"map-manager-overlays-label\">{overlaysLabel}</span><AttachLayerPopupButton disabled={!backgroundMapVisible} isOverlay={true} />\n </div>\n <MapLayerDroppable\n disabled={!backgroundMapVisible}\n isOverlay={true}\n layersList={overlayMapLayers}\n mapTypesOptions={props.mapLayerOptions?.mapTypeOptions}\n getContainerForClone={props.getContainerForClone as any}\n activeViewport={props.activeViewport}\n onMenuItemSelected={handleOnMenuItemSelection}\n onItemVisibilityToggleClicked={handleLayerVisibilityChange}\n onItemEdited={handleRefreshFromStyle} />\n </div>\n </DragDropContext>\n }\n </div >\n </SourceMapContext.Provider >\n );\n}\n\n"]}
@@ -259,13 +259,8 @@ $default-font-size: --iui-font-size-1;
259
259
  .map-layer-source-item-warnMessage-icon {
260
260
  background-color: transparent;
261
261
  border: none;
262
- color: $buic-foreground-warning;
262
+ color: var(--iui-color-icon-warning);
263
263
  background-color: transparent;
264
-
265
- &:hover {
266
- color: $hovered-icon-color;
267
- }
268
-
269
264
  &:focus {
270
265
  outline: none;
271
266
  box-shadow: rgba(var(--iui-color-border-accent), var(--iui-opacity-4)) 0px 0px 0px 2px;
@@ -279,8 +274,7 @@ $default-font-size: --iui-font-size-1;
279
274
  }
280
275
 
281
276
  .map-manager-sublayer-panel {
282
- width: 400px;
283
- height: 400px;
277
+ width: 400px; // Ideally I would let the popup's content drives the width, unfortunately without an explicit width, the popup location is not consistent.
284
278
  color: $buic-foreground-body;
285
279
  font-size: $default-font-size;
286
280
  padding: 4px;
@@ -0,0 +1,11 @@
1
+ import "./MapSelectFeaturesDialog.scss";
2
+ import { MapLayerSource } from "@itwin/core-frontend";
3
+ import { MapSubLayerProps } from "@itwin/core-common";
4
+ export interface MapSelectFeaturesProps {
5
+ source: MapLayerSource;
6
+ subLayers: MapSubLayerProps[];
7
+ handleOk: (subLayers: MapSubLayerProps[]) => void;
8
+ handleCancel: () => void;
9
+ }
10
+ export declare function MapSelectFeaturesDialog(props: MapSelectFeaturesProps): JSX.Element;
11
+ //# sourceMappingURL=MapSelectFeaturesDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapSelectFeaturesDialog.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapSelectFeaturesDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,gCAAgC,CAAC;AAIxC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,KAAK,IAAI,CAAC;IAClD,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAKD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,eAqEpE"}
@@ -0,0 +1,54 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ // cSpell:ignore Modeless WMTS
6
+ import { Dialog, Icon } from "@itwin/core-react";
7
+ import * as React from "react";
8
+ import "./MapSelectFeaturesDialog.scss";
9
+ import { DialogButtonType } from "@itwin/appui-abstract";
10
+ import { MapLayersUI } from "../../mapLayers";
11
+ import { SubLayersTree } from "./SubLayersTree";
12
+ const minHeight = 250;
13
+ const maxSubLayers = 30;
14
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15
+ export function MapSelectFeaturesDialog(props) {
16
+ const [subLayers, setSubLayers] = React.useState(props.subLayers);
17
+ const [NoLayersSelectedMsg] = React.useState(() => MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.NoLayersSelected"));
18
+ const [dialogTitle] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.SelectLayersToCreate"));
19
+ const dialogContainer = React.useRef(null);
20
+ const handleOk = React.useCallback(() => {
21
+ props.handleOk(subLayers);
22
+ }, [props, subLayers]);
23
+ const handleCancel = React.useCallback(() => {
24
+ props.handleCancel();
25
+ }, [props]);
26
+ const hasVisibleLayers = () => subLayers.some((entry) => entry.visible);
27
+ const hasTooManyVisibleLayers = () => subLayers.filter((entry) => entry.visible).length > maxSubLayers;
28
+ const readyToSave = () => hasVisibleLayers();
29
+ const buttonCluster = [
30
+ { type: DialogButtonType.OK, onClick: handleOk, disabled: !readyToSave() },
31
+ { type: DialogButtonType.Cancel, onClick: handleCancel },
32
+ ];
33
+ function renderWarningMessage() {
34
+ let warningMessage;
35
+ // Get the proper warning message
36
+ if (!hasVisibleLayers()) {
37
+ warningMessage = NoLayersSelectedMsg;
38
+ }
39
+ else if (hasTooManyVisibleLayers()) {
40
+ warningMessage = MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.TooManyLayersSelected", { layerCount: subLayers.filter((entry) => entry.visible).length });
41
+ }
42
+ if (warningMessage !== undefined) {
43
+ return (React.createElement("div", { className: "map-layer-source-warnMessage" },
44
+ React.createElement(Icon, { className: "map-layer-source-warnMessage-icon", iconSpec: "icon-status-warning" }),
45
+ React.createElement("span", { className: "map-layer-source-warnMessage-label" }, warningMessage)));
46
+ }
47
+ return React.createElement(React.Fragment, null);
48
+ }
49
+ return (React.createElement("div", { ref: dialogContainer },
50
+ React.createElement(Dialog, { className: "map-layer-select-features-dialog", title: dialogTitle, opened: true, resizable: true, movable: true, modal: true, buttonCluster: buttonCluster, onClose: handleCancel, onEscape: handleCancel, minHeight: minHeight, maxWidth: 600, titleStyle: { paddingLeft: "10px" }, footerStyle: { paddingBottom: "10px", paddingRight: "10px" }, trapFocus: false },
51
+ React.createElement(SubLayersTree, { expandMode: "full", checkboxStyle: "standard", subLayers: subLayers, onSubLayerStateChange: () => setSubLayers([...subLayers]) }),
52
+ renderWarningMessage())));
53
+ }
54
+ //# sourceMappingURL=MapSelectFeaturesDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapSelectFeaturesDialog.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapSelectFeaturesDialog.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,8BAA8B;AAE9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,gCAAgC,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,gEAAgE;AAChE,MAAM,UAAU,uBAAuB,CAAC,KAA6B;IACnE,MAAM,CAAC,SAAS,EAAE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C,MAAM,EAAC,aAAa,EAAC,UAAU,EAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG;YAG3I,oBAAoB,EAAE,CAChB,CACJ,CACR,CAAC;AACJ,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// cSpell:ignore Modeless WMTS\n\nimport { Dialog, Icon } from \"@itwin/core-react\";\nimport * as React from \"react\";\nimport \"./MapSelectFeaturesDialog.scss\";\n\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { MapLayerSource } from \"@itwin/core-frontend\";\nimport { MapSubLayerProps } from \"@itwin/core-common\";\nimport { SubLayersTree } from \"./SubLayersTree\";\n\nexport interface MapSelectFeaturesProps {\n source: MapLayerSource;\n subLayers: MapSubLayerProps[];\n handleOk: (subLayers: MapSubLayerProps[]) => void;\n handleCancel: () => void;\n}\nconst minHeight = 250;\nconst maxSubLayers = 30;\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapSelectFeaturesDialog(props: MapSelectFeaturesProps) {\n const [subLayers, setSubLayers] = React.useState(props.subLayers);\n const [NoLayersSelectedMsg] = React.useState(()=>MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.NoLayersSelected\"));\n const [dialogTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.SelectLayersToCreate\"));\n\n const dialogContainer = React.useRef<HTMLDivElement>(null);\n\n const handleOk = React.useCallback(() => {\n props.handleOk(subLayers);\n }, [props, subLayers]);\n\n const handleCancel = React.useCallback(() => {\n props.handleCancel();\n }, [props]);\n\n const hasVisibleLayers = () => subLayers.some((entry)=>entry.visible);\n const hasTooManyVisibleLayers = () => subLayers.filter((entry)=>entry.visible).length > maxSubLayers;\n const readyToSave = () => hasVisibleLayers();\n const buttonCluster = [\n { type: DialogButtonType.OK, onClick: handleOk, disabled: !readyToSave() },\n { type: DialogButtonType.Cancel, onClick: handleCancel },\n ];\n\n function renderWarningMessage(): React.ReactNode {\n let warningMessage: string | undefined;\n\n // Get the proper warning message\n if (!hasVisibleLayers()) {\n warningMessage = NoLayersSelectedMsg;\n } else if (hasTooManyVisibleLayers()) {\n warningMessage = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.TooManyLayersSelected\", { layerCount: subLayers.filter((entry)=>entry.visible).length});\n }\n\n if (warningMessage !== undefined) {\n return (\n <div className=\"map-layer-source-warnMessage\">\n <Icon className=\"map-layer-source-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n <span className=\"map-layer-source-warnMessage-label\">{warningMessage}</span >\n </div>);\n }\n return <></>;\n }\n\n return (\n <div ref={dialogContainer}>\n <Dialog\n className=\"map-layer-select-features-dialog\"\n title={dialogTitle}\n opened={true}\n resizable={true}\n movable={true}\n modal={true}\n buttonCluster={buttonCluster}\n onClose={handleCancel}\n onEscape={handleCancel}\n minHeight={minHeight}\n maxWidth={600}\n titleStyle={{ paddingLeft: \"10px\" }}\n footerStyle={{ paddingBottom: \"10px\", paddingRight: \"10px\" }}\n trapFocus={false}\n >\n {/* 'onSubLayerStateChange' is used to trigger hook state change only, no need to update subLayer objects */}\n <SubLayersTree expandMode=\"full\" checkboxStyle=\"standard\" subLayers={subLayers} onSubLayerStateChange={() => setSubLayers([...subLayers])}/>\n\n {/* Warning message */}\n {renderWarningMessage()}\n </Dialog>\n </div >\n );\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ .map-layer-select-features-dialog {
7
+ z-Index: 21000;
8
+
9
+ }
10
+
11
+ .map-layer-select-features-dialog.core-dialog .core-dialog-container .core-dialog-area > .core-dialog-content {
12
+ overflow: hidden;
13
+ }
14
+ .map-layer-select-features-dialog .map-manager-sublayer-tree-content {
15
+ min-height: 200px;
16
+ }
17
+
@@ -1,5 +1,5 @@
1
1
  import { ImageMapLayerProps } from "@itwin/core-common";
2
- import { MapLayerSource, ScreenViewport } from "@itwin/core-frontend";
2
+ import { MapLayerSource, MapLayerSourceValidation, ScreenViewport } from "@itwin/core-frontend";
3
3
  import { MapTypesOptions } from "../Interfaces";
4
4
  import "./MapUrlDialog.scss";
5
5
  export declare const MAP_TYPES: {
@@ -9,15 +9,20 @@ export declare const MAP_TYPES: {
9
9
  tileUrl: string;
10
10
  arcGisFeature: string;
11
11
  };
12
+ export declare type LayerCreationMode = "single" | "multiple";
12
13
  interface MapUrlDialogProps {
13
14
  activeViewport?: ScreenViewport;
14
15
  isOverlay: boolean;
15
- onOkResult: () => void;
16
+ onOkResult: (result?: SourceState) => void;
16
17
  onCancelResult?: () => void;
17
18
  mapTypesOptions?: MapTypesOptions;
18
19
  layerRequiringCredentials?: ImageMapLayerProps;
19
20
  mapLayerSourceToEdit?: MapLayerSource;
20
21
  }
22
+ export interface SourceState {
23
+ source: MapLayerSource;
24
+ validation: MapLayerSourceValidation;
25
+ }
21
26
  export declare function MapUrlDialog(props: MapUrlDialogProps): JSX.Element;
22
27
  export {};
23
28
  //# sourceMappingURL=MapUrlDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MapUrlDialog.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapUrlDialog.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAC4B,cAAc,EAC8C,cAAc,EAC5G,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,qBAAqB,CAAC;AAI7B,eAAO,MAAM,SAAS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