@itwin/map-layers-formats 5.1.0-dev.10 → 5.1.0-dev.13
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.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts +3 -4
- package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsSession.js +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsSession.js.map +1 -1
- package/lib/cjs/internal/NativeGoogleMapsSession.d.ts +1 -2
- package/lib/cjs/internal/NativeGoogleMapsSession.d.ts.map +1 -1
- package/lib/cjs/internal/NativeGoogleMapsSession.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts +3 -4
- package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsSession.js +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsSession.js.map +1 -1
- package/lib/esm/internal/NativeGoogleMapsSession.d.ts +1 -2
- package/lib/esm/internal/NativeGoogleMapsSession.d.ts.map +1 -1
- package/lib/esm/internal/NativeGoogleMapsSession.js.map +1 -1
- package/package.json +12 -12
|
@@ -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,EAAa,iBAAiB,EAAE,uBAAuB,
|
|
1
|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BAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AA5ND,8DA4NC","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator.js\";\nimport { QuadIdProps } from \"@itwin/core-frontend/lib/cjs/tile/internal.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/*\n* Google Maps imagery provider\n* @beta\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256;\n private _sessionManager?: GoogleMapsSessionManager;\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\n private _activeSession?: GoogleMapsSession;\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n this._sessionManager = sessionManager;\n\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n this._sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\n this._sessionManager = await this.getSessionManager();\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);;\n this._tileSize = this._activeSession.getTileSize();\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\n if (!isActivated) {\n const msg = `Failed to activate decorator`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected async getSessionManager (): Promise<GoogleMapsSessionManager> {\n if (this._settings.accessKey?.value) {\n return this._sessionManager ?? new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\n } else {\n const msg = `Missing GoogleMaps api key`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\n mapType: settings.properties!.mapType as GoogleMapsMapTypes,\n region: this._settings.properties!.region as string,\n language: this._settings.properties!.language as string,\n }\n\n if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (this._settings.properties?.scale !== undefined) {\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (this._settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\n }\n\n if (this._settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n\n // not used, see loadTile\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\n return \"\";\n }\n\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\n if (!this._activeSession) {\n Logger.logError(loggerCategory, `Session is not initialized`);\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\n }\n\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\n const request = new Request(req.url, {method: \"GET\"});\n if (req.authorization) {\n request.headers.set(\"Authorization\", req.authorization);\n }\n // Add the session token to the request\n const response = await fetch(request);\n if (!response.ok) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\n }\n return response.json() as Promise<ViewportInfo>;\n }\n\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\n const zooms = new Set<number>();\n const matchingAttributions: string[] = [];\n\n // Viewport info requests must be made for a specific zoom level\n tiles.forEach((tile) => zooms.add(tile.depth));\n\n for (const zoom of zooms) {\n let cartoRect: MapCartoRectangle|undefined;\n for (const tile of tiles) {\n if (tile.depth === zoom && tile instanceof MapTile) {\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\n if (cartoRect)\n cartoRect.union(rect);\n else\n cartoRect = rect;\n }\n }\n if (cartoRect && this._activeSession) {\n try {\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\n if (viewportInfo?.copyright) {\n matchingAttributions.push(viewportInfo.copyright);\n }\n } catch (error:any) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\n }\n }\n }\n\n return matchingAttributions;\n }\n private async logJsonError(tileResponse: Response) {\n try {\n const error = await tileResponse.json();\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\n } catch {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\n if (this._hadUnrecoverableError)\n return undefined;\n\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\n Logger.logError(loggerCategory, `Session manager is not initialized`);\n return undefined;\n }\n\n try {\n let tileRequest = this._activeSession.getTileRequest(tilePos);\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\n try {\n // Session might have expired, lets try to refresh it\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\n tileRequest = this._activeSession.getTileRequest(tilePos);\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await this.logJsonError(tileResponse);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\n return undefined;\n }\n }\n catch {\n await this.logJsonError(tileResponse);\n }\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n return undefined;\n }\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error: any) {\n if (error?.code === 401) {\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\n }\n return undefined;\n }\n }\n\n public override decorate(context: DecorateContext): void {\n this._decorator.decorate(context);\n }\n\n private getSelectedTiles(vp: ScreenViewport) {\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\n }\n\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\n let copyrightMsg = \"\";\n const tiles = this.getSelectedTiles(vp);\n if (tiles) {\n try {\n const attrList = await this.fetchAttributions(tiles);\n for (const attr of attrList) {\n attr.split(\",\").forEach((line) => {\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\n });\n }\n }\n catch (error: any) {\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\n }\n }\n\n cards.appendChild(IModelApp.makeLogoCard({\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\n heading: \"Google Maps\",\n notice: copyrightMsg }));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0E;AAE1E,wDAA0J;AAC1J,mEAA8D;AAE9D,uFAAwF;AACxF,uEAAiE;AAEjE,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAa,yBAA0B,SAAQ,uCAAuB;IAE5D,UAAU,CAAsB;IAChC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,SAAS,GAAG,GAAG,CAAC;IAChB,eAAe,CAA4B;IAC3C,eAAe,CAA2C;IAC1D,cAAc,CAAqB;IAC3C,YAAY,QAA+B,EAAE,cAAyC;QACpF,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,2CAAmB,EAAE,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IAExC,CAAC;IACD,IAAoB,QAAQ,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAEjD,KAAK,CAAC,UAAU;QAC9B,IAAI,CAAC,eAAe,GAAG,oCAAe,CAAC,6BAA6B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrF,IAAI,CAAC,eAAe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C,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,yBAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AA5ND,8DA4NC","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/*\n* Google Maps imagery provider\n* @beta\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256;\n private _sessionManager?: GoogleMapsSessionManager;\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\n private _activeSession?: GoogleMapsSession;\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n this._sessionManager = sessionManager;\n\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n this._sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\n this._sessionManager = await this.getSessionManager();\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);;\n this._tileSize = this._activeSession.getTileSize();\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\n if (!isActivated) {\n const msg = `Failed to activate decorator`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected async getSessionManager (): Promise<GoogleMapsSessionManager> {\n if (this._settings.accessKey?.value) {\n return this._sessionManager ?? new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\n } else {\n const msg = `Missing GoogleMaps api key`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\n mapType: settings.properties!.mapType as GoogleMapsMapTypes,\n region: this._settings.properties!.region as string,\n language: this._settings.properties!.language as string,\n }\n\n if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (this._settings.properties?.scale !== undefined) {\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (this._settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\n }\n\n if (this._settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n\n // not used, see loadTile\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\n return \"\";\n }\n\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\n if (!this._activeSession) {\n Logger.logError(loggerCategory, `Session is not initialized`);\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\n }\n\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\n const request = new Request(req.url, {method: \"GET\"});\n if (req.authorization) {\n request.headers.set(\"Authorization\", req.authorization);\n }\n // Add the session token to the request\n const response = await fetch(request);\n if (!response.ok) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\n }\n return response.json() as Promise<ViewportInfo>;\n }\n\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\n const zooms = new Set<number>();\n const matchingAttributions: string[] = [];\n\n // Viewport info requests must be made for a specific zoom level\n tiles.forEach((tile) => zooms.add(tile.depth));\n\n for (const zoom of zooms) {\n let cartoRect: MapCartoRectangle|undefined;\n for (const tile of tiles) {\n if (tile.depth === zoom && tile instanceof MapTile) {\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\n if (cartoRect)\n cartoRect.union(rect);\n else\n cartoRect = rect;\n }\n }\n if (cartoRect && this._activeSession) {\n try {\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\n if (viewportInfo?.copyright) {\n matchingAttributions.push(viewportInfo.copyright);\n }\n } catch (error:any) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\n }\n }\n }\n\n return matchingAttributions;\n }\n private async logJsonError(tileResponse: Response) {\n try {\n const error = await tileResponse.json();\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\n } catch {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\n if (this._hadUnrecoverableError)\n return undefined;\n\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\n Logger.logError(loggerCategory, `Session manager is not initialized`);\n return undefined;\n }\n\n try {\n let tileRequest = this._activeSession.getTileRequest(tilePos);\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\n try {\n // Session might have expired, lets try to refresh it\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\n tileRequest = this._activeSession.getTileRequest(tilePos);\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await this.logJsonError(tileResponse);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\n return undefined;\n }\n }\n catch {\n await this.logJsonError(tileResponse);\n }\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n return undefined;\n }\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error: any) {\n if (error?.code === 401) {\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\n }\n return undefined;\n }\n }\n\n public override decorate(context: DecorateContext): void {\n this._decorator.decorate(context);\n }\n\n private getSelectedTiles(vp: ScreenViewport) {\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\n }\n\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\n let copyrightMsg = \"\";\n const tiles = this.getSelectedTiles(vp);\n if (tiles) {\n try {\n const attrList = await this.fetchAttributions(tiles);\n for (const attr of attrList) {\n attr.split(\",\").forEach((line) => {\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\n });\n }\n }\n catch (error: any) {\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\n }\n }\n\n cards.appendChild(IModelApp.makeLogoCard({\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\n heading: \"Google Maps\",\n notice: copyrightMsg }));\n }\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module MapLayersFormats
|
|
3
3
|
*/
|
|
4
|
-
import { MapCartoRectangle } from "@itwin/core-frontend";
|
|
5
|
-
import { QuadIdProps } from "@itwin/core-frontend/lib/cjs/tile/internal.js";
|
|
4
|
+
import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
|
|
6
5
|
/**
|
|
7
|
-
* The type of base map.
|
|
6
|
+
* The type of base map .
|
|
8
7
|
* @beta*/
|
|
9
8
|
export type GoogleMapsLayerTypes = "layerRoadmap" | "layerStreetview";
|
|
10
9
|
/**
|
|
@@ -133,7 +132,7 @@ export interface GoogleMapsSession {
|
|
|
133
132
|
}
|
|
134
133
|
/**
|
|
135
134
|
* Base implementation of Google Maps session.
|
|
136
|
-
* @
|
|
135
|
+
* @beta
|
|
137
136
|
*/
|
|
138
137
|
export declare abstract class BaseGoogleMapsSession implements GoogleMapsSession {
|
|
139
138
|
protected abstract getTileApiBaseUrl(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"GoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAGrE;;UAEU;AACV,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAEtE;;;KAGK;AACL,MAAM,MAAM,kBAAkB,GAAI,SAAS,GAAC,WAAW,GAAC,SAAS,CAAC;AAElE;;;KAGK;AACL,MAAM,MAAM,sBAAsB,GAAI,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;AAE1F;;;EAGE;AACF,MAAM,WAAW,8BAA8B;IAC3C;;;;;;;;;OASG;IACL,OAAO,EAAE,kBAAkB,CAAC;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACf;;MAEE;IACJ,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;;;SAQK;IACL,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAEpC;;;;;;;;;;SAUK;IACL,KAAK,CAAC,EAAE,sBAAsB,CAAA;IAE9B;;;;;SAKK;IACH,OAAO,CAAC,EAAG,OAAO,CAAC;IAEnB;;;SAGK;IACL,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAGD;;;EAGE;AACF,MAAM,WAAW,qBAAqB;IACpC,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;IAEhB,0MAA0M;IAC1M,MAAM,EAAE,MAAM,CAAC;IAEf,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAElB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IAEnB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;EAGE;AACF,MAAM,WAAW,gBA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"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"GoogleMapsSession.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAoFF,CAAC;AAsBD,CAAC;AAsDF;;;EAGE;AACF,MAAsB,qBAAqB;IAG/B,kBAAkB,CAAC,QAAqB;QAChD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,GAAG,OAAO,IAAI,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;QACjF,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CAKF;AAZD,sDAYC;AAED;;;EAGE;AACF,MAAsB,wBAAwB;IAC5B,IAAI,GAAG,0BAA0B,CAAC;CAEnD;AAHD,4DAGC","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { MapCartoRectangle, QuadIdProps} from \"@itwin/core-frontend\";\n\n\n/**\n * The type of base map .\n * @beta*/\nexport type GoogleMapsLayerTypes = \"layerRoadmap\" | \"layerStreetview\";\n\n/**\n * Layer types that can be added to the map.\n * @beta\n * */\nexport type GoogleMapsMapTypes = \"roadmap\"|\"satellite\"|\"terrain\";\n\n/**\n * Scale factors that can be applied to labels and objects in the map.\n * @beta\n * */\nexport type GoogleMapsScaleFactors = \"scaleFactor1x\" | \"scaleFactor2x\" | \"scaleFactor4x\";\n\n/**\n* Represents the options to create a Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsCreateSessionOptions {\n /**\n * The type of base map.\n *\n * `roadmap`: The standard Google Maps painted map tiles.\n *\n * `satellite`: Satellite imagery.\n *\n * `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.\n * @beta\n * */\n mapType: GoogleMapsMapTypes,\n /**\n * An {@link https://en.wikipedia.org/wiki/IETF_language_tag | IETF language tag} that specifies the language used to display information on the tiles. For example, `en-US` specifies the English language as spoken in the United States.\n */\n language: string;\n /**\n * A {@link https://cldr.unicode.org/ | Common Locale Data Repository} region identifier (two uppercase letters) that represents the physical location of the user. For example, `US`.\n */\n region: string;\n\n /**\n * An array of values that specifies the layer types added to the map.\n *\n * `layerRoadmap`: Required if you specify terrain as the map type. Can also be optionally overlaid on the satellite map type. Has no effect on roadmap tiles.\n *\n * `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.\n *\n * @beta\n * */\n layerTypes?: GoogleMapsLayerTypes[];\n\n /**\n * Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.\n * Increasing the scale also reduces the number of labels on the map, which reduces clutter.\n *\n * `scaleFactor1x`: The default.\n *\n * `scaleFactor2x`: Doubles label size and removes minor feature labels.\n *\n * `scaleFactor4x`: Quadruples label size and removes minor feature labels.\n * @beta\n * */\n scale?: GoogleMapsScaleFactors\n\n /**\n * A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.\n * When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.\n * Default is false.\n * @beta\n * */\n overlay? : boolean;\n\n /**\n * An array of values specifying additional options to apply.\n * @beta\n * */\n apiOptions?: string[];\n};\n\n\n/**\n* Session data returned by the Google Maps API.\n* @beta\n*/\nexport interface GoogleMapsSessionData {\n /** A session token value that you must include in all of your Map Tiles API requests. */\n session: string;\n\n /** string that contains the time (in seconds since the epoch) at which the token expires. A session token is valid for two weeks from its creation time, but this policy might change without notice. */\n expiry: number;\n\n /** The width of the tiles measured in pixels. */\n tileWidth: number;\n\n /** he height of the tiles measured in pixels. */\n tileHeight: number;\n\n /** The image format, which can be either `png` or `jpeg`. */\n imageFormat: string;\n};\n\n/**\n * Maximum zoom level available within a bounding rectangle.\n* @beta\n*/\nexport interface MaxZoomRectangle {\n maxZoom: number;\n north: number;\n south: number;\n east: number;\n west: number;\n}\n\n/**\n * Indicate which areas of given viewport have imagery, and at which zoom levels.\n * @beta\n*/\nexport interface ViewportInfo {\n /** Attribution string that you must display on your map when you display roadmap and satellite tiles. */\n copyright: string;\n\n /** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */\n maxZoomRects: MaxZoomRectangle[];\n}\n\n\n/**\n* Google Maps Request\n* @beta\n*/\nexport interface GoogleMapsRequest {\n /** The URL of the request */\n url: URL;\n\n /* Authorization header for the request */\n authorization?: string;\n}\n\n/**\n* Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsSession {\n /* Tile size in pixels */\n getTileSize: () => number;\n\n /* Tile URL for the given tile position */\n getTileRequest: (position: QuadIdProps) => GoogleMapsRequest;\n\n /* Viewport information request */\n getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest\n}\n\n/**\n* Base implementation of Google Maps session.\n* @beta\n*/\nexport abstract class BaseGoogleMapsSession implements GoogleMapsSession {\n protected abstract getTileApiBaseUrl(): string;\n\n protected getTilePositionUrl(position: QuadIdProps) {\n const baseUrl = this.getTileApiBaseUrl();\n const tmpUrl = `${baseUrl}/${position.level}/${position.column}/${position.row}`;\n return new URL(tmpUrl);\n }\n\n public abstract getTileSize(): number;\n public abstract getTileRequest(position: QuadIdProps): GoogleMapsRequest;\n public abstract getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest\n}\n\n/**\n* Google Maps session manager interface.\n* @beta\n*/\nexport abstract class GoogleMapsSessionManager {\n public readonly type = \"GoogleMapsSessionManager\";\n public abstract createSession (sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession>;\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module MapLayersFormats
|
|
3
3
|
*/
|
|
4
|
-
import { MapCartoRectangle } from "@itwin/core-frontend";
|
|
5
|
-
import { QuadIdProps } from "@itwin/core-frontend/lib/cjs/tile/internal.js";
|
|
4
|
+
import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
|
|
6
5
|
import { BaseGoogleMapsSession, GoogleMapsCreateSessionOptions, GoogleMapsRequest, GoogleMapsSession, GoogleMapsSessionData, GoogleMapsSessionManager } from "../GoogleMaps/GoogleMapsSession.js";
|
|
7
6
|
export declare class NativeGoogleMapsSession extends BaseGoogleMapsSession {
|
|
8
7
|
static getTileApiBaseUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeGoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"NativeGoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AASlM,qBAAa,uBAAwB,SAAQ,qBAAqB;IAChE,OAAc,iBAAiB,SAA4C;IAC3E,OAAc,kBAAkB,SAAiD;IACjF,SAAgB,IAAI,EAAE,qBAAqB,CAAC;IAC5C,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM;IAM9D,SAAS,CAAC,iBAAiB;IAIpB,WAAW,IAAI,MAAM;IAIrB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB;IAOxD,sBAAsB,CAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB;IAYhG;;;;;MAKE;WACkB,MAAM,CAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAUpH;AAMD,qBAAa,8BAA+B,SAAQ,wBAAwB;IAC1E,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,MAAM,EAAE,MAAM;IAKb,aAAa,CAAC,cAAc,EAAE,8BAA8B,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAKvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeGoogleMapsSession.js","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;
|
|
1
|
+
{"version":3,"file":"NativeGoogleMapsSession.js","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,6EAAkM;AAGlM,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAa,uBAAwB,SAAQ,4CAAqB;IACzD,MAAM,CAAC,iBAAiB,GAAG,wCAAwC,CAAC;IACpE,MAAM,CAAC,kBAAkB,GAAG,8CAA8C,CAAA;IACjE,IAAI,CAAwB;IAC5B,MAAM,CAAS;IAE/B,YAAmB,IAA2B,EAAE,MAAc;QAC5D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAES,iBAAiB;QACzB,OAAO,uBAAuB,CAAC,iBAAiB,CAAC;IACnD,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAC/B,CAAC;I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,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAC/F,CAAC;QACD,qBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,8BAA8B,CAAC,CAAC;QAC/D,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;;AAtDL,0DAuDC;AAED;;;EAGE;AACF,MAAa,8BAA+B,SAAQ,+CAAwB;IAC1D,MAAM,CAAS;IAE/B,YAAY,MAAc;QACxB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,cAA8C;QACvE,MAAM,IAAI,GAAG,MAAM,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC/E,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CAEF;AAbD,wEAaC","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { MapCartoRectangle, QuadIdProps } from \"@itwin/core-frontend\";\nimport { BaseGoogleMapsSession, GoogleMapsCreateSessionOptions, GoogleMapsRequest, GoogleMapsSession, GoogleMapsSessionData, GoogleMapsSessionManager } from \"../GoogleMaps/GoogleMapsSession.js\";\n\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/*\n* Google Maps session\n* @internal\n*/\nexport class NativeGoogleMapsSession extends BaseGoogleMapsSession {\n public static getTileApiBaseUrl = \"https://tile.googleapis.com/v1/2dtiles\";\n public static viewportApiBaseUrl = `https://tile.googleapis.com/tile/v1/viewport`\n public readonly json: GoogleMapsSessionData;\n public readonly apiKey: string;\n\n public constructor(json: GoogleMapsSessionData, apiKey: string) {\n super();\n this.json = json;\n this.apiKey = apiKey;\n }\n\n protected getTileApiBaseUrl() {\n return NativeGoogleMapsSession.getTileApiBaseUrl;\n }\n\n public getTileSize(): number {\n return this.json.tileWidth;\n }\n\n public getTileRequest(position: QuadIdProps): GoogleMapsRequest {\n const url = this.getTilePositionUrl(position);\n url.searchParams.append(\"key\", this.apiKey);\n url.searchParams.append(\"session\", this.json.session);\n return {url};\n }\n\n public getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest {\n const degrees = rectangle.toDegrees();\n const url = new URL(\n `${this.getTileApiBaseUrl()}\\\n zoom=${zoomLevel}\\\n &north=${degrees.north}&south=${degrees.south}&east=${degrees.east}&west=${degrees.west}`\n );\n url.searchParams.append(\"key\", this.apiKey);\n url.searchParams.append(\"session\", this.json.session);\n return {url};\n }\n\n /**\n * Creates a Google Maps session.\n * @param apiKey Google Cloud API key\n * @param opts Options to create the session\n * @internal\n */\n public static async create (apiKey: string, opts: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSessionData> {\n const url = `https://tile.googleapis.com/v1/createSession?key=${apiKey}`;\n const request = new Request(url, {method: \"POST\", body: JSON.stringify(opts)});\n const response = await fetch (request);\n if (!response.ok) {\n throw new Error(`CreateSession request failed: ${response.status} - ${response.statusText}`);\n }\n Logger.logInfo(loggerCategory, `Session created successfully`);\n return response.json();\n }\n}\n\n/*\n* Google Maps session manager that uses standard API key to create a session.\n* @beta\n*/\nexport class NativeGoogleMapsSessionManager extends GoogleMapsSessionManager {\n public readonly apiKey: string;\n\n constructor(apiKey: string) {\n super();\n this.apiKey = apiKey;\n }\n\n public async createSession(sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession> {\n const json = await NativeGoogleMapsSession.create(this.apiKey, sessionOptions);\n return new NativeGoogleMapsSession(json, this.apiKey);\n }\n\n}\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,EAAa,iBAAiB,EAAE,uBAAuB,
|
|
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,EAAa,iBAAiB,EAAE,uBAAuB,EAAwB,cAAc,EAAQ,MAAM,sBAAsB,CAAC;AAE1J,OAAO,EAAG,8BAA8B,EAAuF,wBAAwB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAUtM,qBAAa,yBAA0B,SAAQ,uBAAuB;IAEpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,eAAe,CAAC,CAA2B;IACnD,OAAO,CAAC,eAAe,CAA2C;IAClE,OAAO,CAAC,cAAc,CAAC,CAAoB;gBAC/B,QAAQ,EAAE,qBAAqB,EAAE,cAAc,CAAC,EAAE,wBAAwB;IAMtF,IAAoB,QAAQ,IAAI,MAAM,CAA2B;IAE3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAajC,iBAAiB,IAAK,OAAO,CAAC,wBAAwB,CAAC;IAUvE,SAAS,CAAC,0BAA0B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,8BAA8B;IAoCxF,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OA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C;oBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,YAAY,IAAI,GAAG,YAAY,CAAC,MAAM,KAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,KAAU,EAAE,CAAC;gBAClB,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,SAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator.js\";\nimport { QuadIdProps } from \"@itwin/core-frontend/lib/cjs/tile/internal.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/*\n* Google Maps imagery provider\n* @beta\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256;\n private _sessionManager?: GoogleMapsSessionManager;\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\n private _activeSession?: GoogleMapsSession;\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n this._sessionManager = sessionManager;\n\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n this._sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\n this._sessionManager = await this.getSessionManager();\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);;\n this._tileSize = this._activeSession.getTileSize();\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\n if (!isActivated) {\n const msg = `Failed to activate decorator`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected async getSessionManager (): Promise<GoogleMapsSessionManager> {\n if (this._settings.accessKey?.value) {\n return this._sessionManager ?? new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\n } else {\n const msg = `Missing GoogleMaps api key`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\n mapType: settings.properties!.mapType as GoogleMapsMapTypes,\n region: this._settings.properties!.region as string,\n language: this._settings.properties!.language as string,\n }\n\n if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (this._settings.properties?.scale !== undefined) {\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (this._settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\n }\n\n if (this._settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n\n // not used, see loadTile\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\n return \"\";\n }\n\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\n if (!this._activeSession) {\n Logger.logError(loggerCategory, `Session is not initialized`);\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\n }\n\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\n const request = new Request(req.url, {method: \"GET\"});\n if (req.authorization) {\n request.headers.set(\"Authorization\", req.authorization);\n }\n // Add the session token to the request\n const response = await fetch(request);\n if (!response.ok) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\n }\n return response.json() as Promise<ViewportInfo>;\n }\n\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\n const zooms = new Set<number>();\n const matchingAttributions: string[] = [];\n\n // Viewport info requests must be made for a specific zoom level\n tiles.forEach((tile) => zooms.add(tile.depth));\n\n for (const zoom of zooms) {\n let cartoRect: MapCartoRectangle|undefined;\n for (const tile of tiles) {\n if (tile.depth === zoom && tile instanceof MapTile) {\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\n if (cartoRect)\n cartoRect.union(rect);\n else\n cartoRect = rect;\n }\n }\n if (cartoRect && this._activeSession) {\n try {\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\n if (viewportInfo?.copyright) {\n matchingAttributions.push(viewportInfo.copyright);\n }\n } catch (error:any) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\n }\n }\n }\n\n return matchingAttributions;\n }\n private async logJsonError(tileResponse: Response) {\n try {\n const error = await tileResponse.json();\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\n } catch {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\n if (this._hadUnrecoverableError)\n return undefined;\n\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\n Logger.logError(loggerCategory, `Session manager is not initialized`);\n return undefined;\n }\n\n try {\n let tileRequest = this._activeSession.getTileRequest(tilePos);\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\n try {\n // Session might have expired, lets try to refresh it\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\n tileRequest = this._activeSession.getTileRequest(tilePos);\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await this.logJsonError(tileResponse);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\n return undefined;\n }\n }\n catch {\n await this.logJsonError(tileResponse);\n }\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n return undefined;\n }\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error: any) {\n if (error?.code === 401) {\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\n }\n return undefined;\n }\n }\n\n public override decorate(context: DecorateContext): void {\n this._decorator.decorate(context);\n }\n\n private getSelectedTiles(vp: ScreenViewport) {\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\n }\n\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\n let copyrightMsg = \"\";\n const tiles = this.getSelectedTiles(vp);\n if (tiles) {\n try {\n const attrList = await this.fetchAttributions(tiles);\n for (const attr of attrList) {\n attr.split(\",\").forEach((line) => {\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\n });\n }\n }\n catch (error: any) {\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\n }\n }\n\n cards.appendChild(IModelApp.makeLogoCard({\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\n heading: \"Google Maps\",\n notice: copyrightMsg }));\n }\n}\n"]}
|
|
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,SAAS,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,OAAO,EAAqC,MAAM,sBAAsB,CAAC;AAC1J,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D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Ae,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAA;IAC1D,CAAC;IAEe,KAAK,CAAC,eAAe,CAAE,KAAuB,EAAE,EAAkB;QAChF,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBACrD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,YAAY,IAAI,GAAG,YAAY,CAAC,MAAM,KAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,KAAU,EAAE,CAAC;gBAClB,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,SAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/*\n* Google Maps imagery provider\n* @beta\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256;\n private _sessionManager?: GoogleMapsSessionManager;\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\n private _activeSession?: GoogleMapsSession;\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n this._sessionManager = sessionManager;\n\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n this._sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\n this._sessionManager = await this.getSessionManager();\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);;\n this._tileSize = this._activeSession.getTileSize();\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\n if (!isActivated) {\n const msg = `Failed to activate decorator`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected async getSessionManager (): Promise<GoogleMapsSessionManager> {\n if (this._settings.accessKey?.value) {\n return this._sessionManager ?? new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\n } else {\n const msg = `Missing GoogleMaps api key`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\n mapType: settings.properties!.mapType as GoogleMapsMapTypes,\n region: this._settings.properties!.region as string,\n language: this._settings.properties!.language as string,\n }\n\n if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (this._settings.properties?.scale !== undefined) {\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (this._settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\n }\n\n if (this._settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n\n // not used, see loadTile\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\n return \"\";\n }\n\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\n if (!this._activeSession) {\n Logger.logError(loggerCategory, `Session is not initialized`);\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\n }\n\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\n const request = new Request(req.url, {method: \"GET\"});\n if (req.authorization) {\n request.headers.set(\"Authorization\", req.authorization);\n }\n // Add the session token to the request\n const response = await fetch(request);\n if (!response.ok) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\n }\n return response.json() as Promise<ViewportInfo>;\n }\n\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\n const zooms = new Set<number>();\n const matchingAttributions: string[] = [];\n\n // Viewport info requests must be made for a specific zoom level\n tiles.forEach((tile) => zooms.add(tile.depth));\n\n for (const zoom of zooms) {\n let cartoRect: MapCartoRectangle|undefined;\n for (const tile of tiles) {\n if (tile.depth === zoom && tile instanceof MapTile) {\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\n if (cartoRect)\n cartoRect.union(rect);\n else\n cartoRect = rect;\n }\n }\n if (cartoRect && this._activeSession) {\n try {\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\n if (viewportInfo?.copyright) {\n matchingAttributions.push(viewportInfo.copyright);\n }\n } catch (error:any) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\n }\n }\n }\n\n return matchingAttributions;\n }\n private async logJsonError(tileResponse: Response) {\n try {\n const error = await tileResponse.json();\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\n } catch {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\n if (this._hadUnrecoverableError)\n return undefined;\n\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\n Logger.logError(loggerCategory, `Session manager is not initialized`);\n return undefined;\n }\n\n try {\n let tileRequest = this._activeSession.getTileRequest(tilePos);\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\n try {\n // Session might have expired, lets try to refresh it\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\n tileRequest = this._activeSession.getTileRequest(tilePos);\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await this.logJsonError(tileResponse);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\n return undefined;\n }\n }\n catch {\n await this.logJsonError(tileResponse);\n }\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n return undefined;\n }\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error: any) {\n if (error?.code === 401) {\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\n }\n return undefined;\n }\n }\n\n public override decorate(context: DecorateContext): void {\n this._decorator.decorate(context);\n }\n\n private getSelectedTiles(vp: ScreenViewport) {\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\n }\n\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\n let copyrightMsg = \"\";\n const tiles = this.getSelectedTiles(vp);\n if (tiles) {\n try {\n const attrList = await this.fetchAttributions(tiles);\n for (const attr of attrList) {\n attr.split(\",\").forEach((line) => {\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\n });\n }\n }\n catch (error: any) {\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\n }\n }\n\n cards.appendChild(IModelApp.makeLogoCard({\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\n heading: \"Google Maps\",\n notice: copyrightMsg }));\n }\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module MapLayersFormats
|
|
3
3
|
*/
|
|
4
|
-
import { MapCartoRectangle } from "@itwin/core-frontend";
|
|
5
|
-
import { QuadIdProps } from "@itwin/core-frontend/lib/cjs/tile/internal.js";
|
|
4
|
+
import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
|
|
6
5
|
/**
|
|
7
|
-
* The type of base map.
|
|
6
|
+
* The type of base map .
|
|
8
7
|
* @beta*/
|
|
9
8
|
export type GoogleMapsLayerTypes = "layerRoadmap" | "layerStreetview";
|
|
10
9
|
/**
|
|
@@ -133,7 +132,7 @@ export interface GoogleMapsSession {
|
|
|
133
132
|
}
|
|
134
133
|
/**
|
|
135
134
|
* Base implementation of Google Maps session.
|
|
136
|
-
* @
|
|
135
|
+
* @beta
|
|
137
136
|
*/
|
|
138
137
|
export declare abstract class BaseGoogleMapsSession implements GoogleMapsSession {
|
|
139
138
|
protected abstract getTileApiBaseUrl(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"GoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAGrE;;UAEU;AACV,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAEtE;;;KAGK;AACL,MAAM,MAAM,kBAAkB,GAAI,SAAS,GAAC,WAAW,GAAC,SAAS,CAAC;AAElE;;;KAGK;AACL,MAAM,MAAM,sBAAsB,GAAI,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;AAE1F;;;EAGE;AACF,MAAM,WAAW,8BAA8B;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AAW,KAAK,iBAAiB,CAAC;IAG7D,sBAAsB,CAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAC5F;AAED;;;EAGE;AACF,8BAAsB,qBAAsB,YAAW,iBAAiB;IACtE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,IAAI,MAAM;IAE9C,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,WAAW;aAMlC,WAAW,IAAI,MAAM;aACrB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB;aACxD,sBAAsB,CAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB;CAC5G;AAED;;;EAGE;AACF,8BAAsB,wBAAwB;IAC5C,SAAgB,IAAI,8BAA8B;aAClC,aAAa,CAAE,cAAc,EAAE,8BAA8B,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAC3G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsSession.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;
|
|
1
|
+
{"version":3,"file":"GoogleMapsSession.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAoFF,CAAC;AAsBD,CAAC;AAsDF;;;EAGE;AACF,MAAM,OAAgB,qBAAqB;IAG/B,kBAAkB,CAAC,QAAqB;QAChD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,GAAG,OAAO,IAAI,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;QACjF,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CAKF;AAED;;;EAGE;AACF,MAAM,OAAgB,wBAAwB;IAC5B,IAAI,GAAG,0BAA0B,CAAC;CAEnD","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { MapCartoRectangle, QuadIdProps} from \"@itwin/core-frontend\";\n\n\n/**\n * The type of base map .\n * @beta*/\nexport type GoogleMapsLayerTypes = \"layerRoadmap\" | \"layerStreetview\";\n\n/**\n * Layer types that can be added to the map.\n * @beta\n * */\nexport type GoogleMapsMapTypes = \"roadmap\"|\"satellite\"|\"terrain\";\n\n/**\n * Scale factors that can be applied to labels and objects in the map.\n * @beta\n * */\nexport type GoogleMapsScaleFactors = \"scaleFactor1x\" | \"scaleFactor2x\" | \"scaleFactor4x\";\n\n/**\n* Represents the options to create a Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsCreateSessionOptions {\n /**\n * The type of base map.\n *\n * `roadmap`: The standard Google Maps painted map tiles.\n *\n * `satellite`: Satellite imagery.\n *\n * `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.\n * @beta\n * */\n mapType: GoogleMapsMapTypes,\n /**\n * An {@link https://en.wikipedia.org/wiki/IETF_language_tag | IETF language tag} that specifies the language used to display information on the tiles. For example, `en-US` specifies the English language as spoken in the United States.\n */\n language: string;\n /**\n * A {@link https://cldr.unicode.org/ | Common Locale Data Repository} region identifier (two uppercase letters) that represents the physical location of the user. For example, `US`.\n */\n region: string;\n\n /**\n * An array of values that specifies the layer types added to the map.\n *\n * `layerRoadmap`: Required if you specify terrain as the map type. Can also be optionally overlaid on the satellite map type. Has no effect on roadmap tiles.\n *\n * `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.\n *\n * @beta\n * */\n layerTypes?: GoogleMapsLayerTypes[];\n\n /**\n * Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.\n * Increasing the scale also reduces the number of labels on the map, which reduces clutter.\n *\n * `scaleFactor1x`: The default.\n *\n * `scaleFactor2x`: Doubles label size and removes minor feature labels.\n *\n * `scaleFactor4x`: Quadruples label size and removes minor feature labels.\n * @beta\n * */\n scale?: GoogleMapsScaleFactors\n\n /**\n * A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.\n * When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.\n * Default is false.\n * @beta\n * */\n overlay? : boolean;\n\n /**\n * An array of values specifying additional options to apply.\n * @beta\n * */\n apiOptions?: string[];\n};\n\n\n/**\n* Session data returned by the Google Maps API.\n* @beta\n*/\nexport interface GoogleMapsSessionData {\n /** A session token value that you must include in all of your Map Tiles API requests. */\n session: string;\n\n /** string that contains the time (in seconds since the epoch) at which the token expires. A session token is valid for two weeks from its creation time, but this policy might change without notice. */\n expiry: number;\n\n /** The width of the tiles measured in pixels. */\n tileWidth: number;\n\n /** he height of the tiles measured in pixels. */\n tileHeight: number;\n\n /** The image format, which can be either `png` or `jpeg`. */\n imageFormat: string;\n};\n\n/**\n * Maximum zoom level available within a bounding rectangle.\n* @beta\n*/\nexport interface MaxZoomRectangle {\n maxZoom: number;\n north: number;\n south: number;\n east: number;\n west: number;\n}\n\n/**\n * Indicate which areas of given viewport have imagery, and at which zoom levels.\n * @beta\n*/\nexport interface ViewportInfo {\n /** Attribution string that you must display on your map when you display roadmap and satellite tiles. */\n copyright: string;\n\n /** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */\n maxZoomRects: MaxZoomRectangle[];\n}\n\n\n/**\n* Google Maps Request\n* @beta\n*/\nexport interface GoogleMapsRequest {\n /** The URL of the request */\n url: URL;\n\n /* Authorization header for the request */\n authorization?: string;\n}\n\n/**\n* Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsSession {\n /* Tile size in pixels */\n getTileSize: () => number;\n\n /* Tile URL for the given tile position */\n getTileRequest: (position: QuadIdProps) => GoogleMapsRequest;\n\n /* Viewport information request */\n getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest\n}\n\n/**\n* Base implementation of Google Maps session.\n* @beta\n*/\nexport abstract class BaseGoogleMapsSession implements GoogleMapsSession {\n protected abstract getTileApiBaseUrl(): string;\n\n protected getTilePositionUrl(position: QuadIdProps) {\n const baseUrl = this.getTileApiBaseUrl();\n const tmpUrl = `${baseUrl}/${position.level}/${position.column}/${position.row}`;\n return new URL(tmpUrl);\n }\n\n public abstract getTileSize(): number;\n public abstract getTileRequest(position: QuadIdProps): GoogleMapsRequest;\n public abstract getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest\n}\n\n/**\n* Google Maps session manager interface.\n* @beta\n*/\nexport abstract class GoogleMapsSessionManager {\n public readonly type = \"GoogleMapsSessionManager\";\n public abstract createSession (sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession>;\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module MapLayersFormats
|
|
3
3
|
*/
|
|
4
|
-
import { MapCartoRectangle } from "@itwin/core-frontend";
|
|
5
|
-
import { QuadIdProps } from "@itwin/core-frontend/lib/cjs/tile/internal.js";
|
|
4
|
+
import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
|
|
6
5
|
import { BaseGoogleMapsSession, GoogleMapsCreateSessionOptions, GoogleMapsRequest, GoogleMapsSession, GoogleMapsSessionData, GoogleMapsSessionManager } from "../GoogleMaps/GoogleMapsSession.js";
|
|
7
6
|
export declare class NativeGoogleMapsSession extends BaseGoogleMapsSession {
|
|
8
7
|
static getTileApiBaseUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeGoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"NativeGoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AASlM,qBAAa,uBAAwB,SAAQ,qBAAqB;IAChE,OAAc,iBAAiB,SAA4C;IAC3E,OAAc,kBAAkB,SAAiD;IACjF,SAAgB,IAAI,EAAE,qBAAqB,CAAC;IAC5C,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM;IAM9D,SAAS,CAAC,iBAAiB;IAIpB,WAAW,IAAI,MAAM;IAIrB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB;IAOxD,sBAAsB,CAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB;IAYhG;;;;;MAKE;WACkB,MAAM,CAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAUpH;AAMD,qBAAa,8BAA+B,SAAQ,wBAAwB;IAC1E,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,MAAM,EAAE,MAAM;IAKb,aAAa,CAAC,cAAc,EAAE,8BAA8B,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAKvG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeGoogleMapsSession.js","sourceRoot":"","sources":["../../../src/internal/NativeGoogleMapsSession.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,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AAC,cAA8C;QACvE,MAAM,IAAI,GAAG,MAAM,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC/E,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CAEF","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/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { MapCartoRectangle, QuadIdProps } from \"@itwin/core-frontend\";\nimport { BaseGoogleMapsSession, GoogleMapsCreateSessionOptions, GoogleMapsRequest, GoogleMapsSession, GoogleMapsSessionData, GoogleMapsSessionManager } from \"../GoogleMaps/GoogleMapsSession.js\";\n\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/*\n* Google Maps session\n* @internal\n*/\nexport class NativeGoogleMapsSession extends BaseGoogleMapsSession {\n public static getTileApiBaseUrl = \"https://tile.googleapis.com/v1/2dtiles\";\n public static viewportApiBaseUrl = `https://tile.googleapis.com/tile/v1/viewport`\n public readonly json: GoogleMapsSessionData;\n public readonly apiKey: string;\n\n public constructor(json: GoogleMapsSessionData, apiKey: string) {\n super();\n this.json = json;\n this.apiKey = apiKey;\n }\n\n protected getTileApiBaseUrl() {\n return NativeGoogleMapsSession.getTileApiBaseUrl;\n }\n\n public getTileSize(): number {\n return this.json.tileWidth;\n }\n\n public getTileRequest(position: QuadIdProps): GoogleMapsRequest {\n const url = this.getTilePositionUrl(position);\n url.searchParams.append(\"key\", this.apiKey);\n url.searchParams.append(\"session\", this.json.session);\n return {url};\n }\n\n public getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest {\n const degrees = rectangle.toDegrees();\n const url = new URL(\n `${this.getTileApiBaseUrl()}\\\n zoom=${zoomLevel}\\\n &north=${degrees.north}&south=${degrees.south}&east=${degrees.east}&west=${degrees.west}`\n );\n url.searchParams.append(\"key\", this.apiKey);\n url.searchParams.append(\"session\", this.json.session);\n return {url};\n }\n\n /**\n * Creates a Google Maps session.\n * @param apiKey Google Cloud API key\n * @param opts Options to create the session\n * @internal\n */\n public static async create (apiKey: string, opts: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSessionData> {\n const url = `https://tile.googleapis.com/v1/createSession?key=${apiKey}`;\n const request = new Request(url, {method: \"POST\", body: JSON.stringify(opts)});\n const response = await fetch (request);\n if (!response.ok) {\n throw new Error(`CreateSession request failed: ${response.status} - ${response.statusText}`);\n }\n Logger.logInfo(loggerCategory, `Session created successfully`);\n return response.json();\n }\n}\n\n/*\n* Google Maps session manager that uses standard API key to create a session.\n* @beta\n*/\nexport class NativeGoogleMapsSessionManager extends GoogleMapsSessionManager {\n public readonly apiKey: string;\n\n constructor(apiKey: string) {\n super();\n this.apiKey = apiKey;\n }\n\n public async createSession(sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession> {\n const json = await NativeGoogleMapsSession.create(this.apiKey, sessionOptions);\n return new NativeGoogleMapsSession(json, this.apiKey);\n }\n\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/map-layers-formats",
|
|
3
|
-
"version": "5.1.0-dev.
|
|
3
|
+
"version": "5.1.0-dev.13",
|
|
4
4
|
"description": "Enables additional map-layers formats in iTwin.js",
|
|
5
5
|
"main": "lib/cjs/map-layers-formats.js",
|
|
6
6
|
"module": "lib/esm/map-layers-formats.js",
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
"typemoq": "^2.1.0",
|
|
53
53
|
"typescript": "~5.6.2",
|
|
54
54
|
"fetch-mock": "~11.1.3",
|
|
55
|
-
"@itwin/appui-abstract": "5.1.0-dev.
|
|
56
|
-
"@itwin/
|
|
57
|
-
"@itwin/
|
|
58
|
-
"@itwin/core-common": "5.1.0-dev.
|
|
59
|
-
"@itwin/core-geometry": "5.1.0-dev.
|
|
60
|
-
"@itwin/core-
|
|
55
|
+
"@itwin/appui-abstract": "5.1.0-dev.13",
|
|
56
|
+
"@itwin/core-frontend": "5.1.0-dev.13",
|
|
57
|
+
"@itwin/build-tools": "5.1.0-dev.13",
|
|
58
|
+
"@itwin/core-common": "5.1.0-dev.13",
|
|
59
|
+
"@itwin/core-geometry": "5.1.0-dev.13",
|
|
60
|
+
"@itwin/core-bentley": "5.1.0-dev.13",
|
|
61
61
|
"internal-tools": "3.0.0-dev.69"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@itwin/appui-abstract": "5.1.0-dev.
|
|
65
|
-
"@itwin/core-
|
|
66
|
-
"@itwin/core-
|
|
67
|
-
"@itwin/core-bentley": "5.1.0-dev.
|
|
68
|
-
"@itwin/core-geometry": "5.1.0-dev.
|
|
64
|
+
"@itwin/appui-abstract": "5.1.0-dev.13",
|
|
65
|
+
"@itwin/core-common": "5.1.0-dev.13",
|
|
66
|
+
"@itwin/core-frontend": "5.1.0-dev.13",
|
|
67
|
+
"@itwin/core-bentley": "5.1.0-dev.13",
|
|
68
|
+
"@itwin/core-geometry": "5.1.0-dev.13"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"google-protobuf": "~3.20.1",
|