@itwin/map-layers-formats 5.10.0-dev.1 → 5.10.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +29 -18
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js +3 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoTool.d.ts.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoTool.js +11 -5
- package/lib/cjs/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/cjs/internal/GoogleMapsUtils.d.ts.map +1 -1
- package/lib/cjs/internal/GoogleMapsUtils.js +19 -14
- package/lib/cjs/internal/GoogleMapsUtils.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +29 -18
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js +2 -2
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.js +3 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoTool.d.ts.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoTool.js +12 -6
- package/lib/esm/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/esm/internal/GoogleMapsUtils.d.ts.map +1 -1
- package/lib/esm/internal/GoogleMapsUtils.js +19 -14
- package/lib/esm/internal/GoogleMapsUtils.js.map +1 -1
- package/package.json +13 -13
|
@@ -13,6 +13,9 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
13
13
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
14
14
|
const MapInfoIcon_js_1 = require("../Icons/MapInfoIcon.js");
|
|
15
15
|
const MapFeatureInfoDecorator_js_1 = require("./MapFeatureInfoDecorator.js");
|
|
16
|
+
function isNonEmptyArray(arr) {
|
|
17
|
+
return !!arr && arr.length > 0;
|
|
18
|
+
}
|
|
16
19
|
class ActiveMapLayerState {
|
|
17
20
|
_activeMapLayers;
|
|
18
21
|
get activeMapLayers() { return this._activeMapLayers; }
|
|
@@ -25,13 +28,16 @@ class ActiveMapLayerState {
|
|
|
25
28
|
isVisible = true;
|
|
26
29
|
isInRange = true;
|
|
27
30
|
existsInDisplayStyle = true;
|
|
28
|
-
get hasMapLayers() { return
|
|
31
|
+
get hasMapLayers() { return this.hasActiveMapLayers(); }
|
|
32
|
+
hasActiveMapLayers() {
|
|
33
|
+
return isNonEmptyArray(this.activeMapLayers);
|
|
34
|
+
}
|
|
29
35
|
updateWithImagerySettings(imagery) {
|
|
30
36
|
const result = { exists: false, hidden: false };
|
|
31
37
|
this.existsInDisplayStyle = false;
|
|
32
38
|
this.isVisible = false;
|
|
33
|
-
if (this.
|
|
34
|
-
const oldMls = this.
|
|
39
|
+
if (this.hasActiveMapLayers()) {
|
|
40
|
+
const oldMls = this.activeMapLayers[0]; // consider only first layer for now
|
|
35
41
|
let newMls;
|
|
36
42
|
if (oldMls.isBaseLayer) {
|
|
37
43
|
if (typeof (imagery.backgroundBase) !== "number") {
|
|
@@ -55,13 +61,13 @@ class ActiveMapLayerState {
|
|
|
55
61
|
if (newJson === oldJson) {
|
|
56
62
|
// We consider newMls and OldMls to be the same mapLayer instance.
|
|
57
63
|
this.existsInDisplayStyle = true;
|
|
58
|
-
this.isVisible = newMls.visible ? true : false;
|
|
64
|
+
this.isVisible = (0, core_bentley_1.expectDefined)(newMls).visible ? true : false;
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
return result;
|
|
62
68
|
}
|
|
63
69
|
updateWithScaleRangeVisibility(layerIndexes) {
|
|
64
|
-
if (this.
|
|
70
|
+
if (this.hasActiveMapLayers()) {
|
|
65
71
|
const currentMls = this.activeMapLayers[0]; // consider only first layer for now
|
|
66
72
|
for (const scaleRangeVisibility of layerIndexes) {
|
|
67
73
|
if (currentMls.index?.index === scaleRangeVisibility.index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapFeatureInfoTool.js","sourceRoot":"","sources":["../../../src/Tools/MapFeatureInfoTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAC9C,oDAA+G;AAC/G,wDAkB8B;AAC9B,4DAAsD;AACtD,6EAAuE;AAYvE,MAAM,mBAAmB;IACf,gBAAgB,CAAuC;IAC/D,IAAW,eAAe,KAAK,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAA,CAAC;IAC7D,IAAW,eAAe,CAAC,MAA4C;QACrE,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAEnC,CAAC;IACM,SAAS,GAAY,IAAI,CAAC;IAC1B,SAAS,GAAY,IAAI,CAAC;IAC1B,oBAAoB,GAAY,IAAI,CAAC;IAE5C,IAAW,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA,CAAC;IAEvF,yBAAyB,CAAC,OAAwB;Q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,CAAC,CAAC;QACnJ,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,QAAQ,CAAC,IAAI,CAAC,8BAAc,CAAC,aAAa,CAAC,iBAAiB,EAAE,8BAAc,CAAC,WAAW,CAAC,CAAC,CAAC;QAE3F,mBAAmB;QACnB,MAAM,eAAe,GAAG,8BAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC1F,MAAM,YAAY,GAAG,8BAAc,CAAC,kBAAkB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAElF,yBAAS,CAAC,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;;AAjNH,gDAkNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, MapImageryProps, MapImagerySettings, MapLayerProps } from \"@itwin/core-common\";\r\nimport {\r\n BeButtonEvent,\r\n EventHandled,\r\n HitDetail,\r\n IModelApp,\r\n LocateFilterStatus,\r\n LocateResponse,\r\n MapFeatureInfo,\r\n MapLayerInfoFromTileTree,\r\n MapLayerScaleRangeVisibility,\r\n MapTileTreeScaleRangeVisibility,\r\n PrimitiveTool,\r\n ToolAssistance,\r\n ToolAssistanceImage,\r\n ToolAssistanceInputMethod,\r\n ToolAssistanceInstruction,\r\n ToolAssistanceSection,\r\n Viewport,\r\n} from \"@itwin/core-frontend\";\r\nimport { mapInfoIcon } from \"../Icons/MapInfoIcon.js\";\r\nimport { MapFeatureInfoDecorator } from \"./MapFeatureInfoDecorator.js\";\r\n\r\n/**\r\n * Data provided every time [[MapFeatureInfoTool]] retrieves feature information.\r\n * @see [[MapFeatureInfoToolData]]\r\n * @beta\r\n */\r\nexport interface MapFeatureInfoToolData {\r\n hit: HitDetail;\r\n mapInfo?: MapFeatureInfo;\r\n}\r\n\r\nclass ActiveMapLayerState {\r\n private _activeMapLayers: MapLayerInfoFromTileTree[]|undefined;\r\n public get activeMapLayers() {return this._activeMapLayers;}\r\n public set activeMapLayers(active: MapLayerInfoFromTileTree[]|undefined) {\r\n this._activeMapLayers = active;\r\n this.isVisible = true;\r\n this.isInRange = true;\r\n this.existsInDisplayStyle = true;\r\n\r\n }\r\n public isVisible: boolean = true;\r\n public isInRange: boolean = true;\r\n public existsInDisplayStyle: boolean = true;\r\n\r\n public get hasMapLayers() { return (this.activeMapLayers && this.activeMapLayers.length > 0);}\r\n\r\n public updateWithImagerySettings(imagery: MapImageryProps) {\r\n const result = {exists: false, hidden: false};\r\n this.existsInDisplayStyle = false;\r\n this.isVisible = false;\r\n if (this.hasMapLayers) {\r\n const oldMls = this._activeMapLayers![0]; // consider only first layer for now\r\n\r\n let newMls: MapLayerProps|undefined;\r\n if (oldMls.isBaseLayer) {\r\n if (typeof (imagery.backgroundBase) !== \"number\") {\r\n newMls = imagery.backgroundBase;\r\n }\r\n } else if (oldMls.index?.isOverlay && imagery.overlayLayers && imagery.overlayLayers.length > oldMls.index.index) {\r\n newMls = imagery.overlayLayers[oldMls.index.index];\r\n\r\n } else if ((oldMls.index !== undefined) && imagery.backgroundLayers && imagery.backgroundLayers.length > oldMls.index.index) {\r\n newMls = imagery.backgroundLayers[oldMls.index.index];\r\n }\r\n\r\n // We want to make sure that newMls and OldMls are the same (but ignoring the 'visible' flag).\r\n // by using the serialized JSON object\r\n let tmpNewMls = newMls;\r\n if (newMls && newMls.visible !== oldMls.settings.visible) {\r\n tmpNewMls = {...newMls, visible: oldMls.settings.visible};\r\n }\r\n const newJson = tmpNewMls ? JSON.stringify(tmpNewMls) : \"\";\r\n const oldJson = JSON.stringify(oldMls.settings.toJSON());\r\n\r\n if (newJson === oldJson ) {\r\n // We consider newMls and OldMls to be the same mapLayer instance.\r\n this.existsInDisplayStyle = true;\r\n this.isVisible = newMls!.visible ? true : false;\r\n }\r\n\r\n }\r\n return result;\r\n }\r\n\r\n public updateWithScaleRangeVisibility(layerIndexes: MapLayerScaleRangeVisibility[]) {\r\n if (this.hasMapLayers) {\r\n const currentMls = this.activeMapLayers![0]; // consider only first layer for now\r\n for (const scaleRangeVisibility of layerIndexes) {\r\n if (currentMls.index?.index === scaleRangeVisibility.index) {\r\n this.isInRange = scaleRangeVisibility.visibility === MapTileTreeScaleRangeVisibility.Visible || scaleRangeVisibility.visibility === MapTileTreeScaleRangeVisibility.Partial;\r\n }\r\n }\r\n }\r\n\r\n }\r\n}\r\n\r\n/** Tools that allow extracting feature information from map-layers.\r\n * Simulate feature highlight by drawing overlay decorations. It also\r\n * fire an event that provide further feature information meant to be displayed in a UI / Widget.\r\n * @see [[MapFeatureInfoToolData]]\r\n * @beta\r\n */\r\nexport class MapFeatureInfoTool extends PrimitiveTool {\r\n public readonly onInfoReady = new BeEvent<(data: MapFeatureInfoToolData) => void>();\r\n public readonly onInfoCleared = new BeEvent();\r\n\r\n public static override toolId = \"MapFeatureInfoTool\";\r\n public static override iconSpec = mapInfoIcon.dataUri;\r\n\r\n private _decorator: MapFeatureInfoDecorator = new MapFeatureInfoDecorator();\r\n private _layerSettingsCache = new Map<string, MapLayerInfoFromTileTree[]>();\r\n\r\n private _state: ActiveMapLayerState = new ActiveMapLayerState();\r\n private readonly _detachListeners: VoidFunction[] = [];\r\n private _detachOnMapImageryChanged: VoidFunction|undefined;\r\n\r\n public override requireWriteableTarget(): boolean {\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n protected setupAndPromptForNextAction(): void {\r\n this.showPrompt();\r\n }\r\n\r\n private updateDecorator(vp: Viewport) {\r\n if (this._state.existsInDisplayStyle) {\r\n if (this._state.isInRange) {\r\n this._decorator.hidden = !this._state.isVisible;\r\n }\r\n } else {\r\n // Flush existing decorations until a new selection is made\r\n this.onInfoCleared.raiseEvent();\r\n this._decorator.clearData();\r\n }\r\n vp.invalidateDecorations();\r\n }\r\n\r\n public override async onPostInstall() {\r\n await super.onPostInstall();\r\n\r\n this.setupAndPromptForNextAction();\r\n\r\n this.initLocateElements();\r\n IModelApp.locateManager.options.allowDecorations = true;\r\n\r\n this._layerSettingsCache.clear();\r\n\r\n // Listen of display style configuration changes, that way we don't have to restart the tool to be up to date.\r\n const vp = this.targetView;\r\n if (vp) {\r\n const mapImageryChangeHandler = (newImagery: Readonly<MapImagerySettings>) => {\r\n if (this._state.hasMapLayers) {\r\n this._state.updateWithImagerySettings(newImagery.toJSON());\r\n this.updateDecorator(vp);\r\n }\r\n this._layerSettingsCache.clear();\r\n };\r\n\r\n this._detachListeners.push(vp.onChangeView.addListener((viewport, _previousViewState) => {\r\n\r\n // When a saved view is loaded, 'onMapImageryChanged' events are no longer handled, we have to re-attach.\r\n if (this._detachOnMapImageryChanged) {\r\n this._detachOnMapImageryChanged();\r\n }\r\n this._detachOnMapImageryChanged = viewport.displayStyle.settings.onMapImageryChanged.addListener(mapImageryChangeHandler);\r\n\r\n if (this._state.hasMapLayers) {\r\n this._state.updateWithImagerySettings({\r\n backgroundBase: viewport.displayStyle.backgroundMapBase.toJSON(),\r\n backgroundLayers: viewport.displayStyle.getMapLayers(false).map((value) => value.toJSON()),\r\n overlayLayers: viewport.displayStyle.getMapLayers(true).map((value) => value.toJSON()),\r\n });\r\n this.updateDecorator(vp);\r\n }\r\n this._layerSettingsCache.clear();\r\n }));\r\n\r\n this._detachOnMapImageryChanged = vp.displayStyle.settings.onMapImageryChanged.addListener(mapImageryChangeHandler);\r\n\r\n // Every time a layer goes out of range it, its associated decoration should be hidden (and restore if enter again the range)\r\n this._detachListeners.push(vp.onMapLayerScaleRangeVisibilityChanged.addListener(((layerIndexes: MapLayerScaleRangeVisibility[]) => {\r\n if (this._state.hasMapLayers) {\r\n this._state.updateWithScaleRangeVisibility(layerIndexes);\r\n if (this._state.existsInDisplayStyle && this._state.isVisible) {\r\n this._decorator.hidden = !this._state.isInRange;\r\n vp.invalidateDecorations();\r\n }\r\n }\r\n this._layerSettingsCache.clear();\r\n })));\r\n\r\n }\r\n\r\n IModelApp.viewManager.addDecorator(this._decorator);\r\n\r\n }\r\n\r\n public override async onCleanup() {\r\n this._detachListeners.forEach((f) => f());\r\n this._detachListeners.length = 0;\r\n if (this._detachOnMapImageryChanged) {\r\n this._detachOnMapImageryChanged();\r\n }\r\n\r\n IModelApp.viewManager.dropDecorator(this._decorator);\r\n }\r\n\r\n /**\r\n * Get map layer information from a hit.\r\n * @param hit The hit to get info from.\r\n * @returns Returns a list of [[MapLayerInfoFromTileTree]]s.\r\n * @internal\r\n */\r\n private getMapLayerInfoFromHit(hit: HitDetail) {\r\n let mapLayerFromHit: MapLayerInfoFromTileTree[] = [];\r\n const fromCache = this._layerSettingsCache.get(hit.sourceId);\r\n if (fromCache) {\r\n mapLayerFromHit = fromCache;\r\n } else if (this.targetView) {\r\n mapLayerFromHit = this.targetView?.mapLayerFromHit(hit).filter(((info) => info.settings instanceof ImageMapLayerSettings && info.provider?.supportsMapFeatureInfo));\r\n this._layerSettingsCache.set(hit.sourceId, mapLayerFromHit);\r\n }\r\n\r\n return mapLayerFromHit;\r\n }\r\n\r\n public override async getToolTip(hit: HitDetail): Promise<HTMLElement | string> {\r\n const infos = this.getMapLayerInfoFromHit(hit);\r\n if (infos.length > 0) {\r\n const names = infos.map((info) => info.settings.name);\r\n return `Layer${names.length > 1 ? \"s\" : \"\"}: ${names.join(\", \")}`;\r\n }\r\n return \"\";\r\n }\r\n\r\n public override async filterHit(hit: HitDetail, _out?: LocateResponse): Promise<LocateFilterStatus> {\r\n return this.getMapLayerInfoFromHit(hit).length > 0 ? LocateFilterStatus.Accept : LocateFilterStatus.Reject;\r\n }\r\n\r\n public override async onDataButtonDown(\r\n ev: BeButtonEvent,\r\n ): Promise<EventHandled> {\r\n const hit = await IModelApp.locateManager.doLocate(\r\n new LocateResponse(),\r\n true,\r\n ev.point,\r\n ev.viewport,\r\n ev.inputSource,\r\n );\r\n if (hit !== undefined) {\r\n let mapInfo: MapFeatureInfo | undefined;\r\n\r\n const mapLayersHit = this.getMapLayerInfoFromHit(hit);\r\n if (mapLayersHit.length > 0) {\r\n this._state.activeMapLayers = mapLayersHit;\r\n IModelApp.toolAdmin.setCursor(\"wait\");\r\n try {\r\n const aperture = (hit.viewport.pixelsFromInches(IModelApp.locateManager.apertureInches) / 2.0) + 1.5;\r\n const pixelRadius = Math.floor(aperture + 0.5);\r\n mapInfo = await hit.viewport.getMapFeatureInfo(hit, {tolerance: pixelRadius});\r\n if (mapInfo) {\r\n this._decorator.setData({ hit, mapInfo });\r\n } else {\r\n IModelApp.toolAdmin.setCursor(undefined);\r\n }\r\n } catch {\r\n IModelApp.toolAdmin.setCursor(undefined);\r\n }\r\n }\r\n\r\n this.onInfoReady.raiseEvent({ hit, mapInfo });\r\n return EventHandled.Yes;\r\n }\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onResetButtonUp(\r\n _ev: BeButtonEvent,\r\n ): Promise<EventHandled> {\r\n this._state.activeMapLayers = undefined;\r\n /* Common reset behavior for primitive tools is calling onReinitialize to restart or exitTool to terminate. */\r\n await this.onReinitialize();\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onRestartTool() {\r\n const tool = new MapFeatureInfoTool();\r\n if (!(await tool.run()))\r\n return this.exitTool();\r\n }\r\n\r\n /** @internal */\r\n protected showPrompt(): void {\r\n\r\n const promptEnterPoint = IModelApp.localization.getLocalizedString(\"mapLayersFormats:tools.MapFeatureInfoTool.Prompts.EnterPoint\");\r\n const promptClickIdentify= IModelApp.localization.getLocalizedString(\"mapLayersFormats:tools.MapFeatureInfoTool.Prompts.clickToIdentify\");\r\n const promptClickClear = IModelApp.localization.getLocalizedString(\"mapLayersFormats:tools.MapFeatureInfoTool.Prompts.clickToClear\");\r\n\r\n // Mouse Instructions\r\n const mouseInstructions: ToolAssistanceInstruction[] = [];\r\n mouseInstructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.LeftClick, promptClickIdentify, false, ToolAssistanceInputMethod.Mouse));\r\n mouseInstructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.RightClick, promptClickClear, false, ToolAssistanceInputMethod.Mouse));\r\n const sections: ToolAssistanceSection[] = [];\r\n sections.push(ToolAssistance.createSection(mouseInstructions, ToolAssistance.inputsLabel));\r\n\r\n // Main Instruction\r\n const mainInstruction = ToolAssistance.createInstruction(this.iconSpec, promptEnterPoint);\r\n const instructions = ToolAssistance.createInstructions(mainInstruction, sections);\r\n\r\n IModelApp.notifications.setToolAssistance(instructions);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MapFeatureInfoTool.js","sourceRoot":"","sources":["../../../src/Tools/MapFeatureInfoTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6D;AAC7D,oDAA+G;AAC/G,wDAkB8B;AAC9B,4DAAsD;AACtD,6EAAuE;AAcvE,SAAS,eAAe,CAAI,GAAS;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,mBAAmB;IACf,gBAAgB,CAAuC;IAC/D,IAAW,eAAe,KAAK,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAA,CAAC;IAC7D,IAAW,eAAe,CAAC,MAA4C;QACrE,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAEnC,CAAC;IACM,SAAS,GAAY,IAAI,CAAC;IAC1B,SAAS,GAAY,IAAI,CAAC;IAC1B,oBAAoB,GAAY,IAAI,CAAC;IAE5C,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;I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AAC,CAAC;QACrJ,iBAAiB,CAAC,IAAI,CAAC,8BAAc,CAAC,iBAAiB,CAAC,mCAAmB,CAAC,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,yCAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;QACnJ,MAAM,QAAQ,GAA4B,EAAE,CAAC;QAC7C,QAAQ,CAAC,IAAI,CAAC,8BAAc,CAAC,aAAa,CAAC,iBAAiB,EAAE,8BAAc,CAAC,WAAW,CAAC,CAAC,CAAC;QAE3F,mBAAmB;QACnB,MAAM,eAAe,GAAG,8BAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC1F,MAAM,YAAY,GAAG,8BAAc,CAAC,kBAAkB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAElF,yBAAS,CAAC,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;;AAjNH,gDAkNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { BeEvent, expectDefined } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, MapImageryProps, MapImagerySettings, MapLayerProps } from \"@itwin/core-common\";\r\nimport {\r\n BeButtonEvent,\r\n EventHandled,\r\n HitDetail,\r\n IModelApp,\r\n LocateFilterStatus,\r\n LocateResponse,\r\n MapFeatureInfo,\r\n MapLayerInfoFromTileTree,\r\n MapLayerScaleRangeVisibility,\r\n MapTileTreeScaleRangeVisibility,\r\n PrimitiveTool,\r\n ToolAssistance,\r\n ToolAssistanceImage,\r\n ToolAssistanceInputMethod,\r\n ToolAssistanceInstruction,\r\n ToolAssistanceSection,\r\n Viewport,\r\n} from \"@itwin/core-frontend\";\r\nimport { mapInfoIcon } from \"../Icons/MapInfoIcon.js\";\r\nimport { MapFeatureInfoDecorator } from \"./MapFeatureInfoDecorator.js\";\r\n\r\n/**\r\n * Data provided every time [[MapFeatureInfoTool]] retrieves feature information.\r\n * @see [[MapFeatureInfoToolData]]\r\n * @beta\r\n */\r\nexport interface MapFeatureInfoToolData {\r\n hit: HitDetail;\r\n mapInfo?: MapFeatureInfo;\r\n}\r\n\r\ntype NonEmptyArray<T> = [T, ...T[]];\r\n\r\nfunction isNonEmptyArray<T>(arr?: T[]): arr is NonEmptyArray<T> {\r\n return !!arr && arr.length > 0;\r\n}\r\n\r\nclass ActiveMapLayerState {\r\n private _activeMapLayers: MapLayerInfoFromTileTree[]|undefined;\r\n public get activeMapLayers() {return this._activeMapLayers;}\r\n public set activeMapLayers(active: MapLayerInfoFromTileTree[]|undefined) {\r\n this._activeMapLayers = active;\r\n this.isVisible = true;\r\n this.isInRange = true;\r\n this.existsInDisplayStyle = true;\r\n\r\n }\r\n public isVisible: boolean = true;\r\n public isInRange: boolean = true;\r\n public existsInDisplayStyle: boolean = true;\r\n\r\n public get hasMapLayers() { return this.hasActiveMapLayers(); }\r\n\r\n public hasActiveMapLayers(): this is { activeMapLayers: NonEmptyArray<MapLayerInfoFromTileTree> } {\r\n return isNonEmptyArray(this.activeMapLayers);\r\n }\r\n\r\n public updateWithImagerySettings(imagery: MapImageryProps) {\r\n const result = {exists: false, hidden: false};\r\n this.existsInDisplayStyle = false;\r\n this.isVisible = false;\r\n if (this.hasActiveMapLayers()) {\r\n const oldMls = this.activeMapLayers[0]; // consider only first layer for now\r\n\r\n let newMls: MapLayerProps|undefined;\r\n if (oldMls.isBaseLayer) {\r\n if (typeof (imagery.backgroundBase) !== \"number\") {\r\n newMls = imagery.backgroundBase;\r\n }\r\n } else if (oldMls.index?.isOverlay && imagery.overlayLayers && imagery.overlayLayers.length > oldMls.index.index) {\r\n newMls = imagery.overlayLayers[oldMls.index.index];\r\n\r\n } else if ((oldMls.index !== undefined) && imagery.backgroundLayers && imagery.backgroundLayers.length > oldMls.index.index) {\r\n newMls = imagery.backgroundLayers[oldMls.index.index];\r\n }\r\n\r\n // We want to make sure that newMls and OldMls are the same (but ignoring the 'visible' flag).\r\n // by using the serialized JSON object\r\n let tmpNewMls = newMls;\r\n if (newMls && newMls.visible !== oldMls.settings.visible) {\r\n tmpNewMls = {...newMls, visible: oldMls.settings.visible};\r\n }\r\n const newJson = tmpNewMls ? JSON.stringify(tmpNewMls) : \"\";\r\n const oldJson = JSON.stringify(oldMls.settings.toJSON());\r\n\r\n if (newJson === oldJson) {\r\n // We consider newMls and OldMls to be the same mapLayer instance.\r\n this.existsInDisplayStyle = true;\r\n this.isVisible = expectDefined(newMls).visible ? true : false;\r\n }\r\n\r\n }\r\n return result;\r\n }\r\n\r\n public updateWithScaleRangeVisibility(layerIndexes: MapLayerScaleRangeVisibility[]) {\r\n if (this.hasActiveMapLayers()) {\r\n const currentMls = this.activeMapLayers[0]; // consider only first layer for now\r\n for (const scaleRangeVisibility of layerIndexes) {\r\n if (currentMls.index?.index === scaleRangeVisibility.index) {\r\n this.isInRange = scaleRangeVisibility.visibility === MapTileTreeScaleRangeVisibility.Visible || scaleRangeVisibility.visibility === MapTileTreeScaleRangeVisibility.Partial;\r\n }\r\n }\r\n }\r\n\r\n }\r\n}\r\n\r\n/** Tools that allow extracting feature information from map-layers.\r\n * Simulate feature highlight by drawing overlay decorations. It also\r\n * fire an event that provide further feature information meant to be displayed in a UI / Widget.\r\n * @see [[MapFeatureInfoToolData]]\r\n * @beta\r\n */\r\nexport class MapFeatureInfoTool extends PrimitiveTool {\r\n public readonly onInfoReady = new BeEvent<(data: MapFeatureInfoToolData) => void>();\r\n public readonly onInfoCleared = new BeEvent();\r\n\r\n public static override toolId = \"MapFeatureInfoTool\";\r\n public static override iconSpec = mapInfoIcon.dataUri;\r\n\r\n private _decorator: MapFeatureInfoDecorator = new MapFeatureInfoDecorator();\r\n private _layerSettingsCache = new Map<string, MapLayerInfoFromTileTree[]>();\r\n\r\n private _state: ActiveMapLayerState = new ActiveMapLayerState();\r\n private readonly _detachListeners: VoidFunction[] = [];\r\n private _detachOnMapImageryChanged: VoidFunction|undefined;\r\n\r\n public override requireWriteableTarget(): boolean {\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n protected setupAndPromptForNextAction(): void {\r\n this.showPrompt();\r\n }\r\n\r\n private updateDecorator(vp: Viewport) {\r\n if (this._state.existsInDisplayStyle) {\r\n if (this._state.isInRange) {\r\n this._decorator.hidden = !this._state.isVisible;\r\n }\r\n } else {\r\n // Flush existing decorations until a new selection is made\r\n this.onInfoCleared.raiseEvent();\r\n this._decorator.clearData();\r\n }\r\n vp.invalidateDecorations();\r\n }\r\n\r\n public override async onPostInstall() {\r\n await super.onPostInstall();\r\n\r\n this.setupAndPromptForNextAction();\r\n\r\n this.initLocateElements();\r\n IModelApp.locateManager.options.allowDecorations = true;\r\n\r\n this._layerSettingsCache.clear();\r\n\r\n // Listen of display style configuration changes, that way we don't have to restart the tool to be up to date.\r\n const vp = this.targetView;\r\n if (vp) {\r\n const mapImageryChangeHandler = (newImagery: Readonly<MapImagerySettings>) => {\r\n if (this._state.hasMapLayers) {\r\n this._state.updateWithImagerySettings(newImagery.toJSON());\r\n this.updateDecorator(vp);\r\n }\r\n this._layerSettingsCache.clear();\r\n };\r\n\r\n this._detachListeners.push(vp.onChangeView.addListener((viewport, _previousViewState) => {\r\n\r\n // When a saved view is loaded, 'onMapImageryChanged' events are no longer handled, we have to re-attach.\r\n if (this._detachOnMapImageryChanged) {\r\n this._detachOnMapImageryChanged();\r\n }\r\n this._detachOnMapImageryChanged = viewport.displayStyle.settings.onMapImageryChanged.addListener(mapImageryChangeHandler);\r\n\r\n if (this._state.hasMapLayers) {\r\n this._state.updateWithImagerySettings({\r\n backgroundBase: viewport.displayStyle.backgroundMapBase.toJSON(),\r\n backgroundLayers: viewport.displayStyle.getMapLayers(false).map((value) => value.toJSON()),\r\n overlayLayers: viewport.displayStyle.getMapLayers(true).map((value) => value.toJSON()),\r\n });\r\n this.updateDecorator(vp);\r\n }\r\n this._layerSettingsCache.clear();\r\n }));\r\n\r\n this._detachOnMapImageryChanged = vp.displayStyle.settings.onMapImageryChanged.addListener(mapImageryChangeHandler);\r\n\r\n // Every time a layer goes out of range it, its associated decoration should be hidden (and restore if enter again the range)\r\n this._detachListeners.push(vp.onMapLayerScaleRangeVisibilityChanged.addListener(((layerIndexes: MapLayerScaleRangeVisibility[]) => {\r\n if (this._state.hasMapLayers) {\r\n this._state.updateWithScaleRangeVisibility(layerIndexes);\r\n if (this._state.existsInDisplayStyle && this._state.isVisible) {\r\n this._decorator.hidden = !this._state.isInRange;\r\n vp.invalidateDecorations();\r\n }\r\n }\r\n this._layerSettingsCache.clear();\r\n })));\r\n\r\n }\r\n\r\n IModelApp.viewManager.addDecorator(this._decorator);\r\n\r\n }\r\n\r\n public override async onCleanup() {\r\n this._detachListeners.forEach((f) => f());\r\n this._detachListeners.length = 0;\r\n if (this._detachOnMapImageryChanged) {\r\n this._detachOnMapImageryChanged();\r\n }\r\n\r\n IModelApp.viewManager.dropDecorator(this._decorator);\r\n }\r\n\r\n /**\r\n * Get map layer information from a hit.\r\n * @param hit The hit to get info from.\r\n * @returns Returns a list of [[MapLayerInfoFromTileTree]]s.\r\n * @internal\r\n */\r\n private getMapLayerInfoFromHit(hit: HitDetail) {\r\n let mapLayerFromHit: MapLayerInfoFromTileTree[] = [];\r\n const fromCache = this._layerSettingsCache.get(hit.sourceId);\r\n if (fromCache) {\r\n mapLayerFromHit = fromCache;\r\n } else if (this.targetView) {\r\n mapLayerFromHit = this.targetView?.mapLayerFromHit(hit).filter(((info) => info.settings instanceof ImageMapLayerSettings && info.provider?.supportsMapFeatureInfo));\r\n this._layerSettingsCache.set(hit.sourceId, mapLayerFromHit);\r\n }\r\n\r\n return mapLayerFromHit;\r\n }\r\n\r\n public override async getToolTip(hit: HitDetail): Promise<HTMLElement | string> {\r\n const infos = this.getMapLayerInfoFromHit(hit);\r\n if (infos.length > 0) {\r\n const names = infos.map((info) => info.settings.name);\r\n return `Layer${names.length > 1 ? \"s\" : \"\"}: ${names.join(\", \")}`;\r\n }\r\n return \"\";\r\n }\r\n\r\n public override async filterHit(hit: HitDetail, _out?: LocateResponse): Promise<LocateFilterStatus> {\r\n return this.getMapLayerInfoFromHit(hit).length > 0 ? LocateFilterStatus.Accept : LocateFilterStatus.Reject;\r\n }\r\n\r\n public override async onDataButtonDown(\r\n ev: BeButtonEvent,\r\n ): Promise<EventHandled> {\r\n const hit = await IModelApp.locateManager.doLocate(\r\n new LocateResponse(),\r\n true,\r\n ev.point,\r\n ev.viewport,\r\n ev.inputSource,\r\n );\r\n if (hit !== undefined) {\r\n let mapInfo: MapFeatureInfo | undefined;\r\n\r\n const mapLayersHit = this.getMapLayerInfoFromHit(hit);\r\n if (mapLayersHit.length > 0) {\r\n this._state.activeMapLayers = mapLayersHit;\r\n IModelApp.toolAdmin.setCursor(\"wait\");\r\n try {\r\n const aperture = (hit.viewport.pixelsFromInches(IModelApp.locateManager.apertureInches) / 2.0) + 1.5;\r\n const pixelRadius = Math.floor(aperture + 0.5);\r\n mapInfo = await hit.viewport.getMapFeatureInfo(hit, {tolerance: pixelRadius});\r\n if (mapInfo) {\r\n this._decorator.setData({ hit, mapInfo });\r\n } else {\r\n IModelApp.toolAdmin.setCursor(undefined);\r\n }\r\n } catch {\r\n IModelApp.toolAdmin.setCursor(undefined);\r\n }\r\n }\r\n\r\n this.onInfoReady.raiseEvent({ hit, mapInfo });\r\n return EventHandled.Yes;\r\n }\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onResetButtonUp(\r\n _ev: BeButtonEvent,\r\n ): Promise<EventHandled> {\r\n this._state.activeMapLayers = undefined;\r\n /* Common reset behavior for primitive tools is calling onReinitialize to restart or exitTool to terminate. */\r\n await this.onReinitialize();\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onRestartTool() {\r\n const tool = new MapFeatureInfoTool();\r\n if (!(await tool.run()))\r\n return this.exitTool();\r\n }\r\n\r\n /** @internal */\r\n protected showPrompt(): void {\r\n\r\n const promptEnterPoint = IModelApp.localization.getLocalizedString(\"mapLayersFormats:tools.MapFeatureInfoTool.Prompts.EnterPoint\");\r\n const promptClickIdentify= IModelApp.localization.getLocalizedString(\"mapLayersFormats:tools.MapFeatureInfoTool.Prompts.clickToIdentify\");\r\n const promptClickClear = IModelApp.localization.getLocalizedString(\"mapLayersFormats:tools.MapFeatureInfoTool.Prompts.clickToClear\");\r\n\r\n // Mouse Instructions\r\n const mouseInstructions: ToolAssistanceInstruction[] = [];\r\n mouseInstructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.LeftClick, promptClickIdentify, false, ToolAssistanceInputMethod.Mouse));\r\n mouseInstructions.push(ToolAssistance.createInstruction(ToolAssistanceImage.RightClick, promptClickClear, false, ToolAssistanceInputMethod.Mouse));\r\n const sections: ToolAssistanceSection[] = [];\r\n sections.push(ToolAssistance.createSection(mouseInstructions, ToolAssistance.inputsLabel));\r\n\r\n // Main Instruction\r\n const mainInstruction = ToolAssistance.createInstruction(this.iconSpec, promptEnterPoint);\r\n const instructions = ToolAssistance.createInstructions(mainInstruction, sections);\r\n\r\n IModelApp.notifications.setToolAssistance(instructions);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsUtils.d.ts","sourceRoot":"","sources":["../../../src/internal/GoogleMapsUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAG3G,OAAO,EAAE,8BAA8B,EAAoE,MAAM,0BAA0B,CAAC;AAK5I,gBAAgB;AAEhB,eAAO,MAAM,eAAe;IAE1B;;;MAGE;;IAOF;;;;;IAKA;iCAC4B,MAAM,SAAwB,8BAA8B,KAAG,kBAAkB;IAW3G;;;;IAIA;+CACyC,8BAA8B,KAAG,0BAA0B;IA0BtG;;;;;MAKE;8CACwC,qBAAqB,KAAG,8BAA8B;
|
|
1
|
+
{"version":3,"file":"GoogleMapsUtils.d.ts","sourceRoot":"","sources":["../../../src/internal/GoogleMapsUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAG3G,OAAO,EAAE,8BAA8B,EAAoE,MAAM,0BAA0B,CAAC;AAK5I,gBAAgB;AAEhB,eAAO,MAAM,eAAe;IAE1B;;;MAGE;;IAOF;;;;;IAKA;iCAC4B,MAAM,SAAwB,8BAA8B,KAAG,kBAAkB;IAW3G;;;;IAIA;+CACyC,8BAA8B,KAAG,0BAA0B;IA0BtG;;;;;MAKE;8CACwC,qBAAqB,KAAG,8BAA8B;CAwCjG,CAAA"}
|
|
@@ -68,9 +68,14 @@ exports.GoogleMapsUtils = {
|
|
|
68
68
|
* @internal
|
|
69
69
|
*/
|
|
70
70
|
getSessionOptionsFromMapLayer: (settings) => {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
|
|
71
|
+
const properties = settings.properties;
|
|
72
|
+
if (properties === undefined) {
|
|
73
|
+
const msg = "Missing session options";
|
|
74
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
75
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
76
|
+
}
|
|
77
|
+
const layerPropertyKeys = Object.keys(properties);
|
|
78
|
+
if (!layerPropertyKeys.includes("mapType") ||
|
|
74
79
|
!layerPropertyKeys.includes("language") ||
|
|
75
80
|
!layerPropertyKeys.includes("region")) {
|
|
76
81
|
const msg = "Missing session options";
|
|
@@ -78,21 +83,21 @@ exports.GoogleMapsUtils = {
|
|
|
78
83
|
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
79
84
|
}
|
|
80
85
|
const createSessionOptions = {
|
|
81
|
-
mapType:
|
|
82
|
-
region:
|
|
83
|
-
language:
|
|
86
|
+
mapType: properties.mapType,
|
|
87
|
+
region: properties.region,
|
|
88
|
+
language: properties.language,
|
|
84
89
|
};
|
|
85
|
-
if (Array.isArray(
|
|
86
|
-
createSessionOptions.layerTypes =
|
|
90
|
+
if (Array.isArray(properties.layerTypes) && properties.layerTypes.length > 0) {
|
|
91
|
+
createSessionOptions.layerTypes = properties.layerTypes;
|
|
87
92
|
}
|
|
88
|
-
if (
|
|
89
|
-
createSessionOptions.scale =
|
|
93
|
+
if (properties.scale !== undefined) {
|
|
94
|
+
createSessionOptions.scale = properties.scale;
|
|
90
95
|
}
|
|
91
|
-
if (
|
|
92
|
-
createSessionOptions.overlay =
|
|
96
|
+
if (properties.overlay !== undefined) {
|
|
97
|
+
createSessionOptions.overlay = properties.overlay;
|
|
93
98
|
}
|
|
94
|
-
if (
|
|
95
|
-
createSessionOptions.apiOptions =
|
|
99
|
+
if (properties.apiOptions !== undefined) {
|
|
100
|
+
createSessionOptions.apiOptions = properties.apiOptions;
|
|
96
101
|
}
|
|
97
102
|
return createSessionOptions;
|
|
98
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsUtils.js","sourceRoot":"","sources":["../../../src/internal/GoogleMapsUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,wDAAiD;AACjD,yFAAoF;AAEpF,sDAA0E;AAE1E,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD,gBAAgB;AAChB,gEAAgE;AACnD,QAAA,eAAe,GAAG;IAE7B;;;MAGE;IACF,qBAAqB,EAAE,GAAG,EAAE;QAC1B,IAAI,CAAC,yBAAS,CAAC,sBAAsB,CAAC,YAAY,CAAC,qDAAwB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtF,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED;;;;;IAKA;IACA,mBAAmB,EAAE,CAAC,OAAe,YAAY,EAAE,IAAqC,EAAs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AAgB;YACnC,QAAQ,EAAE,UAAU,CAAC,QAAkB;SACxC,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7E,oBAAoB,CAAC,UAAU,GAAG,UAAU,CAAC,UAAoC,CAAC;QACpF,CAAC;QAED,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACnC,oBAAoB,CAAC,KAAK,GAAG,UAAU,CAAC,KAA+B,CAAC;QAC1E,CAAC;QAED,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACrC,oBAAoB,CAAC,OAAO,GAAG,UAAU,CAAC,OAAkB,CAAC;QAC/D,CAAC;QAED,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACxC,oBAAoB,CAAC,UAAU,GAAG,UAAU,CAAC,UAAsB,CAAC;QACtE,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;CACF,CAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { ImageMapLayerProps, ImageMapLayerSettings, MapLayerProviderProperties } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsMapLayerFormat } from \"../GoogleMaps/GoogleMapsImageryFormat.js\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors } from \"../map-layers-formats.js\";\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const GoogleMapsUtils = {\r\n\r\n /**\r\n * Register the google maps format if it is not already registered.\r\n * @internal\r\n */\r\n checkFormatRegistered: () => {\r\n if (!IModelApp.mapLayerFormatRegistry.isRegistered(GoogleMapsMapLayerFormat.formatId)) {\r\n throw new Error(`GoogleMaps format is not registered`);\r\n }\r\n },\r\n\r\n /**\r\n * Creates a Google Maps layer props.\r\n * @param name Name of the layer (Defaults to \"GoogleMaps\")\r\n * @param opts Options to create the session (Defaults to satellite map type, English language, US region, and roadmap layer type)\r\n * @internal\r\n*/\r\n createMapLayerProps: (name: string = \"GoogleMaps\", opts?: GoogleMapsCreateSessionOptions): ImageMapLayerProps => {\r\n GoogleMapsUtils.checkFormatRegistered();\r\n\r\n return {\r\n formatId: GoogleMapsMapLayerFormat.formatId,\r\n url: \"\",\r\n name,\r\n properties: GoogleMapsUtils.createPropertiesFromSessionOptions(opts ?? {mapType: \"satellite\", language: \"en-US\", region: \"US:\", layerTypes: [\"layerRoadmap\"]}),\r\n };\r\n },\r\n\r\n /**\r\n * Converts the session options to provider properties\r\n * @param opts Options to create the session\r\n * @internal\r\n */\r\n createPropertiesFromSessionOptions: (opts: GoogleMapsCreateSessionOptions): MapLayerProviderProperties => {\r\n const properties: MapLayerProviderProperties = {\r\n mapType: opts.mapType,\r\n language: opts.language,\r\n region: opts.region,\r\n }\r\n\r\n if (opts.layerTypes !== undefined) {\r\n properties.layerTypes = [...opts.layerTypes];\r\n }\r\n\r\n if (opts.scale !== undefined) {\r\n properties.scale = opts.scale;\r\n }\r\n\r\n if (opts.overlay !== undefined) {\r\n properties.overlay = opts.overlay;\r\n }\r\n\r\n if (opts.apiOptions !== undefined) {\r\n properties.apiOptions = [...opts.apiOptions];\r\n }\r\n\r\n return properties;\r\n },\r\n\r\n /**\r\n * Read the session options from the map layer settings.\r\n * @param settings Map layer settings\r\n * ```\r\n * @internal\r\n */\r\n getSessionOptionsFromMapLayer: (settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions => {\r\n const properties = settings.properties;\r\n if (properties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const layerPropertyKeys = Object.keys(properties);\r\n if (!layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: properties.mapType as GoogleMapsMapTypes,\r\n region: properties.region as string,\r\n language: properties.language as string,\r\n };\r\n\r\n if (Array.isArray(properties.layerTypes) && properties.layerTypes.length > 0) {\r\n createSessionOptions.layerTypes = properties.layerTypes as GoogleMapsLayerTypes[];\r\n }\r\n\r\n if (properties.scale !== undefined) {\r\n createSessionOptions.scale = properties.scale as GoogleMapsScaleFactors;\r\n }\r\n\r\n if (properties.overlay !== undefined) {\r\n createSessionOptions.overlay = properties.overlay as boolean;\r\n }\r\n\r\n if (properties.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = properties.apiOptions as string[];\r\n }\r\n return createSessionOptions;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAkC,iBAAiB,EAAE,uBAAuB,EAAwB,cAAc,EAAQ,MAAM,sBAAsB,CAAC;AAC/K,OAAO,EAAE,8BAA8B,
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"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,EAAE,gBAAgB,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA8BlG"}
|
|
@@ -28,12 +28,12 @@ export class GoogleMapsImageryProvider extends MapLayerImageryProvider {
|
|
|
28
28
|
}
|
|
29
29
|
get tileSize() { return this._tileSize; }
|
|
30
30
|
async initialize() {
|
|
31
|
-
|
|
31
|
+
const sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);
|
|
32
|
+
this._sessionOptions = sessionOptions;
|
|
32
33
|
this._sessionManager = await this.getSessionManager();
|
|
33
|
-
this._activeSession = await this._sessionManager.createSession(
|
|
34
|
-
;
|
|
34
|
+
this._activeSession = await this._sessionManager.createSession(sessionOptions);
|
|
35
35
|
this._tileSize = this._activeSession.getTileSize();
|
|
36
|
-
const isActivated = await this._decorator.activate(
|
|
36
|
+
const isActivated = await this._decorator.activate(sessionOptions.mapType);
|
|
37
37
|
if (!isActivated) {
|
|
38
38
|
const msg = `Failed to activate decorator`;
|
|
39
39
|
Logger.logError(loggerCategory, msg);
|
|
@@ -53,31 +53,42 @@ export class GoogleMapsImageryProvider extends MapLayerImageryProvider {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
createCreateSessionOptions(settings) {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
|
|
56
|
+
const requestedProperties = settings.properties;
|
|
57
|
+
if (requestedProperties === undefined) {
|
|
58
|
+
const msg = "Missing session options";
|
|
59
|
+
Logger.logError(loggerCategory, msg);
|
|
60
|
+
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
61
|
+
}
|
|
62
|
+
const layerPropertyKeys = Object.keys(requestedProperties);
|
|
63
|
+
if (!layerPropertyKeys.includes("mapType") ||
|
|
59
64
|
!layerPropertyKeys.includes("language") ||
|
|
60
65
|
!layerPropertyKeys.includes("region")) {
|
|
61
66
|
const msg = "Missing session options";
|
|
62
67
|
Logger.logError(loggerCategory, msg);
|
|
63
68
|
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
64
69
|
}
|
|
70
|
+
const properties = this._settings.properties;
|
|
71
|
+
if (properties === undefined) {
|
|
72
|
+
const msg = "Missing session options";
|
|
73
|
+
Logger.logError(loggerCategory, msg);
|
|
74
|
+
throw new BentleyError(BentleyStatus.ERROR, msg);
|
|
75
|
+
}
|
|
65
76
|
const createSessionOptions = {
|
|
66
|
-
mapType:
|
|
67
|
-
region:
|
|
68
|
-
language:
|
|
77
|
+
mapType: requestedProperties.mapType,
|
|
78
|
+
region: properties.region,
|
|
79
|
+
language: properties.language,
|
|
69
80
|
};
|
|
70
|
-
if (Array.isArray(
|
|
71
|
-
createSessionOptions.layerTypes =
|
|
81
|
+
if (Array.isArray(properties.layerTypes) && properties.layerTypes.length > 0) {
|
|
82
|
+
createSessionOptions.layerTypes = properties.layerTypes;
|
|
72
83
|
}
|
|
73
|
-
if (
|
|
74
|
-
createSessionOptions.scale =
|
|
84
|
+
if (properties.scale !== undefined) {
|
|
85
|
+
createSessionOptions.scale = properties.scale;
|
|
75
86
|
}
|
|
76
|
-
if (
|
|
77
|
-
createSessionOptions.overlay =
|
|
87
|
+
if (properties.overlay !== undefined) {
|
|
88
|
+
createSessionOptions.overlay = properties.overlay;
|
|
78
89
|
}
|
|
79
|
-
if (
|
|
80
|
-
createSessionOptions.apiOptions =
|
|
90
|
+
if (properties.apiOptions !== undefined) {
|
|
91
|
+
createSessionOptions.apiOptions = properties.apiOptions;
|
|
81
92
|
}
|
|
82
93
|
return createSessionOptions;
|
|
83
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAmB,mBAAmB,EAAE,SAAS,EA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,CAAC,SAAS,CAAC,YAAY,CAAC;YACvC,OAAO;YACP,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC,CAAC;IACN,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\r\nimport { DecorateContext, GoogleMapsDecorator, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\r\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\r\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\n\r\n/*\r\n* Google Maps imagery provider\r\n* @beta\r\n*/\r\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\r\n\r\n private _decorator: GoogleMapsDecorator;\r\n private _hadUnrecoverableError = false;\r\n private _tileSize = 256;\r\n private _sessionManager?: GoogleMapsSessionManager;\r\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\r\n private _activeSession?: GoogleMapsSession;\r\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\r\n super(settings, true);\r\n this._decorator = new GoogleMapsDecorator();\r\n this._sessionManager = sessionManager;\r\n }\r\n public override get tileSize(): number { return this._tileSize; }\r\n\r\n public override async initialize(): Promise<void> {\r\n this._sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\r\n this._sessionManager = await this.getSessionManager();\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);;\r\n this._tileSize = this._activeSession.getTileSize();\r\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\r\n if (!isActivated) {\r\n const msg = `Failed to activate decorator`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected async getSessionManager(): Promise<GoogleMapsSessionManager> {\r\n if (this._sessionManager)\r\n return this._sessionManager;\r\n\r\n if (this._settings.accessKey?.value) {\r\n return new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\r\n } else {\r\n const msg = `Missing GoogleMaps api key`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\r\n const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;\r\n if (layerPropertyKeys === undefined ||\r\n !layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: settings.properties!.mapType as GoogleMapsMapTypes,\r\n region: this._settings.properties!.region as string,\r\n language: this._settings.properties!.language as string,\r\n }\r\n\r\n if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {\r\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\r\n }\r\n\r\n if (this._settings.properties?.scale !== undefined) {\r\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\r\n }\r\n\r\n if (this._settings.properties?.overlay !== undefined) {\r\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\r\n }\r\n\r\n if (this._settings.properties?.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\r\n }\r\n return createSessionOptions;\r\n }\r\n\r\n // not used, see loadTile\r\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\r\n if (!this._activeSession) {\r\n Logger.logError(loggerCategory, `Session is not initialized`);\r\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\r\n }\r\n\r\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\r\n const request = new Request(req.url, {method: \"GET\"});\r\n if (req.authorization) {\r\n request.headers.set(\"Authorization\", req.authorization);\r\n }\r\n // Add the session token to the request\r\n const response = await fetch(request);\r\n if (!response.ok) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\r\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\r\n }\r\n return response.json() as Promise<ViewportInfo>;\r\n }\r\n\r\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\r\n const zooms = new Set<number>();\r\n const matchingAttributions: string[] = [];\r\n\r\n // Viewport info requests must be made for a specific zoom level\r\n tiles.forEach((tile) => zooms.add(tile.depth));\r\n\r\n for (const zoom of zooms) {\r\n let cartoRect: MapCartoRectangle|undefined;\r\n for (const tile of tiles) {\r\n if (tile.depth === zoom && tile instanceof MapTile) {\r\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\r\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\r\n if (cartoRect)\r\n cartoRect.union(rect);\r\n else\r\n cartoRect = rect;\r\n }\r\n }\r\n if (cartoRect && this._activeSession) {\r\n try {\r\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\r\n if (viewportInfo?.copyright) {\r\n matchingAttributions.push(viewportInfo.copyright);\r\n }\r\n } catch (error:any) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n }\r\n\r\n return matchingAttributions;\r\n }\r\n private async logJsonError(tileResponse: Response) {\r\n try {\r\n const error = await tileResponse.json();\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\r\n if (this._hadUnrecoverableError)\r\n return undefined;\r\n\r\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\r\n Logger.logError(loggerCategory, `Session manager is not initialized`);\r\n return undefined;\r\n }\r\n\r\n try {\r\n let tileRequest = this._activeSession.getTileRequest(tilePos);\r\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\r\n try {\r\n // Session might have expired, lets try to refresh it\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\r\n tileRequest = this._activeSession.getTileRequest(tilePos);\r\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n await this.logJsonError(tileResponse);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\r\n return undefined;\r\n }\r\n }\r\n catch {\r\n await this.logJsonError(tileResponse);\r\n }\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n return undefined;\r\n }\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error: any) {\r\n if (error?.code === 401) {\r\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\r\n }\r\n return undefined;\r\n }\r\n }\r\n\r\n public override decorate(context: DecorateContext): void {\r\n this._decorator.decorate(context);\r\n }\r\n\r\n private getSelectedTiles(vp: ScreenViewport) {\r\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected;\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n let copyrightMsg = \"\";\r\n const tiles = this.getSelectedTiles(vp);\r\n if (tiles) {\r\n try {\r\n const attrList = await this.fetchAttributions(tiles);\r\n for (const attr of attrList) {\r\n attr.split(\",\").forEach((line) => {\r\n // Attempt to reduce duplicates, since if there are multiple zoom levels sometimes the same info is returned\r\n if (!copyrightMsg.includes(line)) {\r\n copyrightMsg += `${copyrightMsg.length === 0 ? \"\": \"<br>\"}${line}`;\r\n }\r\n });\r\n }\r\n }\r\n catch (error: any) {\r\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n\r\n const iconSrc = document.createElement(\"img\");\r\n iconSrc.src = `${IModelApp.publicPath}images/GoogleMaps_Logo_Gray.svg`;\r\n iconSrc.style.padding = \"10px 10px 5px 10px\";\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc,\r\n heading: \"Google Maps\",\r\n notice: copyrightMsg\r\n }));\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA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qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,UAAU,iCAAiC,CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,oBAAoB,CAAC;QAE7C,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;YACvC,OAAO;YACP,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC,CAAC;IACN,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\r\nimport { DecorateContext, GoogleMapsDecorator, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\r\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\r\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\n\r\n/*\r\n* Google Maps imagery provider\r\n* @beta\r\n*/\r\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\r\n\r\n private _decorator: GoogleMapsDecorator;\r\n private _hadUnrecoverableError = false;\r\n private _tileSize = 256;\r\n private _sessionManager?: GoogleMapsSessionManager;\r\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\r\n private _activeSession?: GoogleMapsSession;\r\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\r\n super(settings, true);\r\n this._decorator = new GoogleMapsDecorator();\r\n this._sessionManager = sessionManager;\r\n }\r\n public override get tileSize(): number { return this._tileSize; }\r\n\r\n public override async initialize(): Promise<void> {\r\n const sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\r\n this._sessionOptions = sessionOptions;\r\n this._sessionManager = await this.getSessionManager();\r\n this._activeSession = await this._sessionManager.createSession(sessionOptions);\r\n this._tileSize = this._activeSession.getTileSize();\r\n const isActivated = await this._decorator.activate(sessionOptions.mapType);\r\n if (!isActivated) {\r\n const msg = `Failed to activate decorator`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected async getSessionManager(): Promise<GoogleMapsSessionManager> {\r\n if (this._sessionManager)\r\n return this._sessionManager;\r\n\r\n if (this._settings.accessKey?.value) {\r\n return new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\r\n } else {\r\n const msg = `Missing GoogleMaps api key`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\r\n const requestedProperties = settings.properties;\r\n if (requestedProperties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const layerPropertyKeys = Object.keys(requestedProperties);\r\n if (!layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const properties = this._settings.properties;\r\n if (properties === undefined) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: requestedProperties.mapType as GoogleMapsCreateSessionOptions[\"mapType\"],\r\n region: properties.region as string,\r\n language: properties.language as string,\r\n };\r\n\r\n if (Array.isArray(properties.layerTypes) && properties.layerTypes.length > 0) {\r\n createSessionOptions.layerTypes = properties.layerTypes as GoogleMapsCreateSessionOptions[\"layerTypes\"];\r\n }\r\n\r\n if (properties.scale !== undefined) {\r\n createSessionOptions.scale = properties.scale as GoogleMapsCreateSessionOptions[\"scale\"];\r\n }\r\n\r\n if (properties.overlay !== undefined) {\r\n createSessionOptions.overlay = properties.overlay as boolean;\r\n }\r\n\r\n if (properties.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = properties.apiOptions as string[];\r\n }\r\n\r\n return createSessionOptions;\r\n }\r\n\r\n // not used, see loadTile\r\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\r\n if (!this._activeSession) {\r\n Logger.logError(loggerCategory, `Session is not initialized`);\r\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\r\n }\r\n\r\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\r\n const request = new Request(req.url, {method: \"GET\"});\r\n if (req.authorization) {\r\n request.headers.set(\"Authorization\", req.authorization);\r\n }\r\n // Add the session token to the request\r\n const response = await fetch(request);\r\n if (!response.ok) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\r\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\r\n }\r\n return response.json() as Promise<ViewportInfo>;\r\n }\r\n\r\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\r\n const zooms = new Set<number>();\r\n const matchingAttributions: string[] = [];\r\n\r\n // Viewport info requests must be made for a specific zoom level\r\n tiles.forEach((tile) => zooms.add(tile.depth));\r\n\r\n for (const zoom of zooms) {\r\n let cartoRect: MapCartoRectangle|undefined;\r\n for (const tile of tiles) {\r\n if (tile.depth === zoom && tile instanceof MapTile) {\r\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\r\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\r\n if (cartoRect)\r\n cartoRect.union(rect);\r\n else\r\n cartoRect = rect;\r\n }\r\n }\r\n if (cartoRect && this._activeSession) {\r\n try {\r\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\r\n if (viewportInfo?.copyright) {\r\n matchingAttributions.push(viewportInfo.copyright);\r\n }\r\n } catch (error:any) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n }\r\n\r\n return matchingAttributions;\r\n }\r\n private async logJsonError(tileResponse: Response) {\r\n try {\r\n const error = await tileResponse.json();\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\r\n if (this._hadUnrecoverableError)\r\n return undefined;\r\n\r\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\r\n Logger.logError(loggerCategory, `Session manager is not initialized`);\r\n return undefined;\r\n }\r\n\r\n try {\r\n let tileRequest = this._activeSession.getTileRequest(tilePos);\r\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\r\n try {\r\n // Session might have expired, lets try to refresh it\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\r\n tileRequest = this._activeSession.getTileRequest(tilePos);\r\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n await this.logJsonError(tileResponse);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\r\n return undefined;\r\n }\r\n }\r\n catch {\r\n await this.logJsonError(tileResponse);\r\n }\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n return undefined;\r\n }\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error: any) {\r\n if (error?.code === 401) {\r\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\r\n }\r\n return undefined;\r\n }\r\n }\r\n\r\n public override decorate(context: DecorateContext): void {\r\n this._decorator.decorate(context);\r\n }\r\n\r\n private getSelectedTiles(vp: ScreenViewport) {\r\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected;\r\n }\r\n\r\n public override async addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n let copyrightMsg = \"\";\r\n const tiles = this.getSelectedTiles(vp);\r\n if (tiles) {\r\n try {\r\n const attrList = await this.fetchAttributions(tiles);\r\n for (const attr of attrList) {\r\n attr.split(\",\").forEach((line) => {\r\n // Attempt to reduce duplicates, since if there are multiple zoom levels sometimes the same info is returned\r\n if (!copyrightMsg.includes(line)) {\r\n copyrightMsg += `${copyrightMsg.length === 0 ? \"\": \"<br>\"}${line}`;\r\n }\r\n });\r\n }\r\n }\r\n catch (error: any) {\r\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n\r\n const iconSrc = document.createElement(\"img\");\r\n iconSrc.src = `${IModelApp.publicPath}images/GoogleMaps_Logo_Gray.svg`;\r\n iconSrc.style.padding = \"10px 10px 5px 10px\";\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc,\r\n heading: \"Google Maps\",\r\n notice: copyrightMsg\r\n }));\r\n }\r\n}\r\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { base64StringToUint8Array, IModelStatus, Logger } from "@itwin/core-bentley";
|
|
5
|
+
import { base64StringToUint8Array, expectDefined, IModelStatus, Logger } from "@itwin/core-bentley";
|
|
6
6
|
import { ColorDef, ImageSource, ImageSourceFormat, ServerError } from "@itwin/core-common";
|
|
7
7
|
import { FeatureGraphicsRenderer, MapCartoRectangle, MapLayerImageryProvider } from "@itwin/core-frontend";
|
|
8
8
|
import { Matrix4d, Point3d, Range2d } from "@itwin/core-geometry";
|
|
@@ -367,7 +367,7 @@ export class OgcApiFeaturesProvider extends MapLayerImageryProvider {
|
|
|
367
367
|
// Static data mode
|
|
368
368
|
const filteredData = { type: "FeatureCollection", features: [] };
|
|
369
369
|
this._spatialIdx?.search(extent4326.longitudeLeft, extent4326.latitudeBottom, extent4326.longitudeRight, extent4326.latitudeTop, (index) => {
|
|
370
|
-
filteredData.features.push(this._staticData.features[index]);
|
|
370
|
+
filteredData.features.push(expectDefined(this._staticData).features[index]);
|
|
371
371
|
return true;
|
|
372
372
|
});
|
|
373
373
|
data = filteredData;
|