@itwin/map-layers-formats 5.1.0-dev.9 → 5.2.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +65 -1
  2. package/lib/cjs/GoogleMaps/GoogleMaps.d.ts +8 -125
  3. package/lib/cjs/GoogleMaps/GoogleMaps.d.ts.map +1 -1
  4. package/lib/cjs/GoogleMaps/GoogleMaps.js +10 -3
  5. package/lib/cjs/GoogleMaps/GoogleMaps.js.map +1 -1
  6. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts +8 -0
  7. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -1
  8. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js +10 -1
  9. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -1
  10. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts +10 -7
  11. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
  12. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +65 -68
  13. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
  14. package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts +152 -0
  15. package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts.map +1 -0
  16. package/lib/cjs/GoogleMaps/GoogleMapsSession.js +33 -0
  17. package/lib/cjs/GoogleMaps/GoogleMapsSession.js.map +1 -0
  18. package/lib/cjs/internal/GoogleMapsUtils.d.ts +9 -16
  19. package/lib/cjs/internal/GoogleMapsUtils.d.ts.map +1 -1
  20. package/lib/cjs/internal/GoogleMapsUtils.js +36 -40
  21. package/lib/cjs/internal/GoogleMapsUtils.js.map +1 -1
  22. package/lib/cjs/internal/NativeGoogleMapsSession.d.ts +29 -0
  23. package/lib/cjs/internal/NativeGoogleMapsSession.d.ts.map +1 -0
  24. package/lib/cjs/internal/NativeGoogleMapsSession.js +83 -0
  25. package/lib/cjs/internal/NativeGoogleMapsSession.js.map +1 -0
  26. package/lib/cjs/map-layers-formats.d.ts +2 -0
  27. package/lib/cjs/map-layers-formats.d.ts.map +1 -1
  28. package/lib/cjs/map-layers-formats.js +2 -0
  29. package/lib/cjs/map-layers-formats.js.map +1 -1
  30. package/lib/cjs/mapLayersFormats.d.ts +10 -0
  31. package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
  32. package/lib/cjs/mapLayersFormats.js +5 -0
  33. package/lib/cjs/mapLayersFormats.js.map +1 -1
  34. package/lib/esm/GoogleMaps/GoogleMaps.d.ts +8 -125
  35. package/lib/esm/GoogleMaps/GoogleMaps.d.ts.map +1 -1
  36. package/lib/esm/GoogleMaps/GoogleMaps.js +10 -3
  37. package/lib/esm/GoogleMaps/GoogleMaps.js.map +1 -1
  38. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts +8 -0
  39. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -1
  40. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js +10 -1
  41. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -1
  42. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts +10 -7
  43. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
  44. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +65 -68
  45. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
  46. package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts +152 -0
  47. package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts.map +1 -0
  48. package/lib/esm/GoogleMaps/GoogleMapsSession.js +28 -0
  49. package/lib/esm/GoogleMaps/GoogleMapsSession.js.map +1 -0
  50. package/lib/esm/internal/GoogleMapsUtils.d.ts +9 -16
  51. package/lib/esm/internal/GoogleMapsUtils.d.ts.map +1 -1
  52. package/lib/esm/internal/GoogleMapsUtils.js +36 -40
  53. package/lib/esm/internal/GoogleMapsUtils.js.map +1 -1
  54. package/lib/esm/internal/NativeGoogleMapsSession.d.ts +29 -0
  55. package/lib/esm/internal/NativeGoogleMapsSession.d.ts.map +1 -0
  56. package/lib/esm/internal/NativeGoogleMapsSession.js +78 -0
  57. package/lib/esm/internal/NativeGoogleMapsSession.js.map +1 -0
  58. package/lib/esm/map-layers-formats.d.ts +2 -0
  59. package/lib/esm/map-layers-formats.d.ts.map +1 -1
  60. package/lib/esm/map-layers-formats.js +2 -0
  61. package/lib/esm/map-layers-formats.js.map +1 -1
  62. package/lib/esm/mapLayersFormats.d.ts +10 -0
  63. package/lib/esm/mapLayersFormats.d.ts.map +1 -1
  64. package/lib/esm/mapLayersFormats.js +5 -0
  65. package/lib/esm/mapLayersFormats.js.map +1 -1
  66. package/package.json +17 -15
  67. package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts +0 -36
  68. package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts.map +0 -1
  69. package/lib/cjs/GoogleMaps/GoogleMapDecorator.js +0 -87
  70. package/lib/cjs/GoogleMaps/GoogleMapDecorator.js.map +0 -1
  71. package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts +0 -36
  72. package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts.map +0 -1
  73. package/lib/esm/GoogleMaps/GoogleMapDecorator.js +0 -82
  74. package/lib/esm/GoogleMaps/GoogleMapDecorator.js.map +0 -1
@@ -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,SAAS,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,oBAAoB,EAA4B,OAAO,EAAw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E,CAAC,CAAC,CAAC;IAC7B,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 { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession } from \"./GoogleMaps.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\nconst levelToken = \"{level}\";\nconst rowToken = \"{row}\";\nconst columnToken = \"{column}\";\n\nconst urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;\n\n/*\n* Google Maps imagery provider\n* @internal\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256\n constructor(settings: ImageMapLayerSettings) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n }\n public static validateUrlTemplate(template: string): MapLayerSourceValidation {\n return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl };\n }\n\n protected async createSession() : Promise<GoogleMapsSession|undefined> {\n const sessionOptions = this.createCreateSessionOptions();\n if (this._settings.accessKey ) {\n // Create session and store in query parameters\n const sessionObj = await GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);\n this._settings.unsavedQueryParams = {session: sessionObj.session};\n return sessionObj;\n } else {\n Logger.logError(loggerCategory, `Missing GoogleMaps api key`);\n return undefined;\n }\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._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 session = await this.createSession();\n if (!session) {\n const msg = `Failed to create session`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n this._tileSize = session.tileWidth; // assuming here tiles are square\n\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 private createCreateSessionOptions(): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._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: this._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 (this._settings.properties?.layerTypes !== undefined) {\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 // construct the Url from the desired Tile\n public async constructUrl(row: number, column: number, level: number): Promise<string> {\n const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());\n const obj = new URL(tmpUrl);\n if (this._settings.accessKey ) {\n obj.searchParams.append(\"key\", this._settings.accessKey.value);\n }\n\n // We assume the 'session' param to be already part of the query parameters (checked in initialize)\n return this.appendCustomParams(obj.toString());\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) {\n try {\n const viewportInfo = await GoogleMapsUtils.getViewportInfo({\n rectangle: cartoRect,\n session: this._settings.collectQueryParams().session,\n key: this._settings.accessKey!.value,\n 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 if (this._hadUnrecoverableError)\n return undefined;\n\n try {\n let tileUrl: string = await this.constructUrl(row, column, zoomLevel);\n let tileResponse: Response = await this.makeTileRequest(tileUrl);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n // Session might have expired, lets try to re-new it.\n const isSessionCreated = await this.createSession();\n if (isSessionCreated) {\n tileUrl = await this.constructUrl(row, column, zoomLevel);\n tileResponse = await this.makeTileRequest(tileUrl);\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 } else {\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}\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,mBAAmB,EAAE,SAAS,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,OAAO,EAAqC,MAAM,sBAAsB,CAAC;AAE/K,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;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,mBAAmB,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,eAAe,CAAC,6BAA6B,CAAC,IAAI,CAAC,SAAS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,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, GoogleMapsDecorator, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\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._sessionManager)\n return this._sessionManager;\n\n if (this._settings.accessKey?.value) {\n return 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"]}
@@ -0,0 +1,152 @@
1
+ /** @packageDocumentation
2
+ * @module MapLayersFormats
3
+ */
4
+ import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
5
+ /**
6
+ * The type of base map .
7
+ * @beta*/
8
+ export type GoogleMapsLayerTypes = "layerRoadmap" | "layerStreetview";
9
+ /**
10
+ * Layer types that can be added to the map.
11
+ * @beta
12
+ * */
13
+ export type GoogleMapsMapTypes = "roadmap" | "satellite" | "terrain";
14
+ /**
15
+ * Scale factors that can be applied to labels and objects in the map.
16
+ * @beta
17
+ * */
18
+ export type GoogleMapsScaleFactors = "scaleFactor1x" | "scaleFactor2x" | "scaleFactor4x";
19
+ /**
20
+ * Represents the options to create a Google Maps session.
21
+ * @beta
22
+ */
23
+ export interface GoogleMapsCreateSessionOptions {
24
+ /**
25
+ * The type of base map.
26
+ *
27
+ * `roadmap`: The standard Google Maps painted map tiles.
28
+ *
29
+ * `satellite`: Satellite imagery.
30
+ *
31
+ * `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.
32
+ * @beta
33
+ * */
34
+ mapType: GoogleMapsMapTypes;
35
+ /**
36
+ * 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.
37
+ */
38
+ language: string;
39
+ /**
40
+ * 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`.
41
+ */
42
+ region: string;
43
+ /**
44
+ * An array of values that specifies the layer types added to the map.
45
+ *
46
+ * `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.
47
+ *
48
+ * `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.
49
+ *
50
+ * @beta
51
+ * */
52
+ layerTypes?: GoogleMapsLayerTypes[];
53
+ /**
54
+ * Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.
55
+ * Increasing the scale also reduces the number of labels on the map, which reduces clutter.
56
+ *
57
+ * `scaleFactor1x`: The default.
58
+ *
59
+ * `scaleFactor2x`: Doubles label size and removes minor feature labels.
60
+ *
61
+ * `scaleFactor4x`: Quadruples label size and removes minor feature labels.
62
+ * @beta
63
+ * */
64
+ scale?: GoogleMapsScaleFactors;
65
+ /**
66
+ * A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.
67
+ * When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.
68
+ * Default is false.
69
+ * @beta
70
+ * */
71
+ overlay?: boolean;
72
+ /**
73
+ * An array of values specifying additional options to apply.
74
+ * @beta
75
+ * */
76
+ apiOptions?: string[];
77
+ }
78
+ /**
79
+ * Session data returned by the Google Maps API.
80
+ * @beta
81
+ */
82
+ export interface GoogleMapsSessionData {
83
+ /** A session token value that you must include in all of your Map Tiles API requests. */
84
+ session: string;
85
+ /** 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. */
86
+ expiry: number;
87
+ /** The width of the tiles measured in pixels. */
88
+ tileWidth: number;
89
+ /** he height of the tiles measured in pixels. */
90
+ tileHeight: number;
91
+ /** The image format, which can be either `png` or `jpeg`. */
92
+ imageFormat: string;
93
+ }
94
+ /**
95
+ * Maximum zoom level available within a bounding rectangle.
96
+ * @beta
97
+ */
98
+ export interface MaxZoomRectangle {
99
+ maxZoom: number;
100
+ north: number;
101
+ south: number;
102
+ east: number;
103
+ west: number;
104
+ }
105
+ /**
106
+ * Indicate which areas of given viewport have imagery, and at which zoom levels.
107
+ * @beta
108
+ */
109
+ export interface ViewportInfo {
110
+ /** Attribution string that you must display on your map when you display roadmap and satellite tiles. */
111
+ copyright: string;
112
+ /** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */
113
+ maxZoomRects: MaxZoomRectangle[];
114
+ }
115
+ /**
116
+ * Google Maps Request
117
+ * @beta
118
+ */
119
+ export interface GoogleMapsRequest {
120
+ /** The URL of the request */
121
+ url: URL;
122
+ authorization?: string;
123
+ }
124
+ /**
125
+ * Google Maps session.
126
+ * @beta
127
+ */
128
+ export interface GoogleMapsSession {
129
+ getTileSize: () => number;
130
+ getTileRequest: (position: QuadIdProps) => GoogleMapsRequest;
131
+ getViewportInfoRequest(rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest;
132
+ }
133
+ /**
134
+ * Base implementation of Google Maps session.
135
+ * @beta
136
+ */
137
+ export declare abstract class BaseGoogleMapsSession implements GoogleMapsSession {
138
+ protected abstract getTileApiBaseUrl(): string;
139
+ protected getTilePositionUrl(position: QuadIdProps): URL;
140
+ abstract getTileSize(): number;
141
+ abstract getTileRequest(position: QuadIdProps): GoogleMapsRequest;
142
+ abstract getViewportInfoRequest(rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest;
143
+ }
144
+ /**
145
+ * Google Maps session manager interface.
146
+ * @beta
147
+ */
148
+ export declare abstract class GoogleMapsSessionManager {
149
+ readonly type = "GoogleMapsSessionManager";
150
+ abstract createSession(sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession>;
151
+ }
152
+ //# sourceMappingURL=GoogleMapsSession.d.ts.map
@@ -0,0 +1 @@
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,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;EAGE;AACF,MAAM,WAAW,YAAY;IAC3B,0GAA0G;IAC1G,SAAS,EAAE,MAAM,CAAC;IAElB,kJAAkJ;IAClJ,YAAY,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAGD;;;EAGE;AACF,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,GAAG,EAAE,GAAG,CAAC;IAGT,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;EAGE;AACF,MAAM,WAAW,iBAAiB;IAEhC,WAAW,EAAE,MAAM,MAAM,CAAC;IAG1B,cAAc,EAAE,CAAC,QAAQ,EAAE,WAAW,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"}
@@ -0,0 +1,28 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module MapLayersFormats
7
+ */
8
+ ;
9
+ ;
10
+ /**
11
+ * Base implementation of Google Maps session.
12
+ * @beta
13
+ */
14
+ export class BaseGoogleMapsSession {
15
+ getTilePositionUrl(position) {
16
+ const baseUrl = this.getTileApiBaseUrl();
17
+ const tmpUrl = `${baseUrl}/${position.level}/${position.column}/${position.row}`;
18
+ return new URL(tmpUrl);
19
+ }
20
+ }
21
+ /**
22
+ * Google Maps session manager interface.
23
+ * @beta
24
+ */
25
+ export class GoogleMapsSessionManager {
26
+ type = "GoogleMapsSessionManager";
27
+ }
28
+ //# sourceMappingURL=GoogleMapsSession.js.map
@@ -0,0 +1 @@
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,14 +1,7 @@
1
- import { ImageMapLayerProps, MapLayerProviderProperties } from "@itwin/core-common";
2
- import { GoogleMapsCreateSessionOptions, GoogleMapsSession, ViewportInfo, ViewportInfoRequestParams } from "../GoogleMaps/GoogleMaps.js";
1
+ import { ImageMapLayerProps, ImageMapLayerSettings, MapLayerProviderProperties } from "@itwin/core-common";
2
+ import { GoogleMapsCreateSessionOptions } from "../map-layers-formats.js";
3
3
  /** @internal */
4
4
  export declare const GoogleMapsUtils: {
5
- /**
6
- * Creates a Google Maps session.
7
- * @param apiKey Google Cloud API key
8
- * @param opts Options to create the session
9
- * @internal
10
- */
11
- createSession: (apiKey: string, opts: GoogleMapsCreateSessionOptions) => Promise<GoogleMapsSession>;
12
5
  /**
13
6
  * Register the google maps format if it is not already registered.
14
7
  * @internal
@@ -22,17 +15,17 @@ export declare const GoogleMapsUtils: {
22
15
  */
23
16
  createMapLayerProps: (name?: string, opts?: GoogleMapsCreateSessionOptions) => ImageMapLayerProps;
24
17
  /**
25
- * Retrieves the maximum zoom level available within a bounding rectangle.
26
- * @param rectangle The bounding rectangle
27
- * @returns The maximum zoom level available within the bounding rectangle.
28
- * @internal
29
- */
30
- getViewportInfo: (params: ViewportInfoRequestParams) => Promise<ViewportInfo | undefined>;
31
- /**
32
18
  * Converts the session options to provider properties
33
19
  * @param opts Options to create the session
34
20
  * @internal
35
21
  */
36
22
  createPropertiesFromSessionOptions: (opts: GoogleMapsCreateSessionOptions) => MapLayerProviderProperties;
23
+ /**
24
+ * Read the session options from the map layer settings.
25
+ * @param settings Map layer settings
26
+ * ```
27
+ * @internal
28
+ */
29
+ getSessionOptionsFromMapLayer: (settings: ImageMapLayerSettings) => GoogleMapsCreateSessionOptions;
37
30
  };
38
31
  //# sourceMappingURL=GoogleMapsUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsUtils.d.ts","sourceRoot":"","sources":["../../../src/internal/GoogleMapsUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAKzI,gBAAgB;AAEhB,eAAO,MAAM,eAAe;IAC1B;;;;;MAKE;4BAC4B,MAAM,QAAQ,8BAA8B,KAAG,OAAO,CAAC,iBAAiB,CAAC;IAWvG;;;MAGE;;IAOF;;;;;IAKA;iCAC4B,MAAM,SAAwB,8BAA8B,KAAG,kBAAkB;IAW7G;;;;;MAKE;8BAC8B,yBAAyB,KAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAgB3F;;;;IAIA;+CACyC,8BAA8B,KAAG,0BAA0B;CAyBvG,CAAA"}
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;CAkCjG,CAAA"}
@@ -2,30 +2,13 @@
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 { Logger } from "@itwin/core-bentley";
6
5
  import { IModelApp } from "@itwin/core-frontend";
7
- import { Angle } from "@itwin/core-geometry";
8
6
  import { GoogleMapsMapLayerFormat } from "../GoogleMaps/GoogleMapsImageryFormat.js";
7
+ import { BentleyError, BentleyStatus, Logger } from "@itwin/core-bentley";
9
8
  const loggerCategory = "MapLayersFormats.GoogleMaps";
10
9
  /** @internal */
11
10
  // eslint-disable-next-line @typescript-eslint/naming-convention
12
11
  export const GoogleMapsUtils = {
13
- /**
14
- * Creates a Google Maps session.
15
- * @param apiKey Google Cloud API key
16
- * @param opts Options to create the session
17
- * @internal
18
- */
19
- createSession: async (apiKey, opts) => {
20
- const url = `https://tile.googleapis.com/v1/createSession?key=${apiKey}`;
21
- const request = new Request(url, { method: "POST", body: JSON.stringify(opts) });
22
- const response = await fetch(request);
23
- if (!response.ok) {
24
- throw new Error(`CreateSession request failed: ${response.status} - ${response.statusText}`);
25
- }
26
- Logger.logInfo(loggerCategory, `Session created successfully`);
27
- return response.json();
28
- },
29
12
  /**
30
13
  * Register the google maps format if it is not already registered.
31
14
  * @internal
@@ -51,28 +34,6 @@ export const GoogleMapsUtils = {
51
34
  };
52
35
  },
53
36
  /**
54
- * Retrieves the maximum zoom level available within a bounding rectangle.
55
- * @param rectangle The bounding rectangle
56
- * @returns The maximum zoom level available within the bounding rectangle.
57
- * @internal
58
- */
59
- getViewportInfo: async (params) => {
60
- const { rectangle, session, key, zoom } = params;
61
- const north = Angle.radiansToDegrees(rectangle.north);
62
- const south = Angle.radiansToDegrees(rectangle.south);
63
- const east = Angle.radiansToDegrees(rectangle.east);
64
- const west = Angle.radiansToDegrees(rectangle.west);
65
- const url = `https://tile.googleapis.com/tile/v1/viewport?session=${session}&key=${key}&zoom=${zoom}&north=${north}&south=${south}&east=${east}&west=${west}`;
66
- const request = new Request(url, { method: "GET" });
67
- const response = await fetch(request);
68
- if (!response.ok) {
69
- return undefined;
70
- }
71
- const json = await response.json();
72
- return json;
73
- ;
74
- },
75
- /**
76
37
  * Converts the session options to provider properties
77
38
  * @param opts Options to create the session
78
39
  * @internal
@@ -97,5 +58,40 @@ export const GoogleMapsUtils = {
97
58
  }
98
59
  return properties;
99
60
  },
61
+ /**
62
+ * Read the session options from the map layer settings.
63
+ * @param settings Map layer settings
64
+ * ```
65
+ * @internal
66
+ */
67
+ getSessionOptionsFromMapLayer: (settings) => {
68
+ const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;
69
+ if (layerPropertyKeys === undefined ||
70
+ !layerPropertyKeys.includes("mapType") ||
71
+ !layerPropertyKeys.includes("language") ||
72
+ !layerPropertyKeys.includes("region")) {
73
+ const msg = "Missing session options";
74
+ Logger.logError(loggerCategory, msg);
75
+ throw new BentleyError(BentleyStatus.ERROR, msg);
76
+ }
77
+ const createSessionOptions = {
78
+ mapType: settings.properties.mapType,
79
+ region: settings.properties.region,
80
+ language: settings.properties.language,
81
+ };
82
+ if (Array.isArray(settings.properties?.layerTypes) && settings.properties.layerTypes.length > 0) {
83
+ createSessionOptions.layerTypes = settings.properties.layerTypes;
84
+ }
85
+ if (settings.properties?.scale !== undefined) {
86
+ createSessionOptions.scale = settings.properties.scale;
87
+ }
88
+ if (settings.properties?.overlay !== undefined) {
89
+ createSessionOptions.overlay = settings.properties.overlay;
90
+ }
91
+ if (settings.properties?.apiOptions !== undefined) {
92
+ createSessionOptions.apiOptions = settings.properties.apiOptions;
93
+ }
94
+ return createSessionOptions;
95
+ }
100
96
  };
101
97
  //# sourceMappingURL=GoogleMapsUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsUtils.js","sourceRoot":"","sources":["../../../src/internal/GoogleMapsUtils.ts"],"names":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Q,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,IAAoB,CAAC;QAAA,CAAC;IAC/B,CAAC;IAEC;;;;IAIA;IACF,kCAAkC,EAAE,CAAC,IAAoC,EAA8B,EAAE;QACvG,MAAM,UAAU,GAA+B;YAC7C,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAA;QAED,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAClC,UAAU,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC/B,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QACpC,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAClC,UAAU,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF,CAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerProps, MapLayerProviderProperties } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Angle } from \"@itwin/core-geometry\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsSession, ViewportInfo, ViewportInfoRequestParams } from \"../GoogleMaps/GoogleMaps.js\";\nimport { GoogleMapsMapLayerFormat } from \"../GoogleMaps/GoogleMapsImageryFormat.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const GoogleMapsUtils = {\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 createSession: async (apiKey: string, opts: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession> => {\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 * Register the google maps format if it is not already registered.\n * @internal\n */\n checkFormatRegistered: () => {\n if (!IModelApp.mapLayerFormatRegistry.isRegistered(GoogleMapsMapLayerFormat.formatId)) {\n throw new Error(`GoogleMaps format is not registered`);\n }\n },\n\n /**\n * Creates a Google Maps layer props.\n * @param name Name of the layer (Defaults to \"GoogleMaps\")\n * @param opts Options to create the session (Defaults to satellite map type, English language, US region, and roadmap layer type)\n * @internal\n*/\n createMapLayerProps: (name: string = \"GoogleMaps\", opts?: GoogleMapsCreateSessionOptions): ImageMapLayerProps => {\n GoogleMapsUtils.checkFormatRegistered();\n\n return {\n formatId: GoogleMapsMapLayerFormat.formatId,\n url: \"\",\n name,\n properties: GoogleMapsUtils.createPropertiesFromSessionOptions(opts ?? {mapType: \"satellite\", language: \"en-US\", region: \"US:\", layerTypes: [\"layerRoadmap\"]}),\n };\n },\n\n /**\n * Retrieves the maximum zoom level available within a bounding rectangle.\n * @param rectangle The bounding rectangle\n * @returns The maximum zoom level available within the bounding rectangle.\n * @internal\n */\n getViewportInfo: async (params: ViewportInfoRequestParams): Promise<ViewportInfo | undefined>=> {\n const {rectangle, session, key, zoom} = params;\n const north = Angle.radiansToDegrees(rectangle.north);\n const south = Angle.radiansToDegrees(rectangle.south);\n const east = Angle.radiansToDegrees(rectangle.east);\n const west = Angle.radiansToDegrees(rectangle.west);\n const url = `https://tile.googleapis.com/tile/v1/viewport?session=${session}&key=${key}&zoom=${zoom}&north=${north}&south=${south}&east=${east}&west=${west}`;\n const request = new Request(url, {method: \"GET\"});\n const response = await fetch (request);\n if (!response.ok) {\n return undefined;\n }\n const json = await response.json();\n return json as ViewportInfo;;\n },\n\n /**\n * Converts the session options to provider properties\n * @param opts Options to create the session\n * @internal\n */\n createPropertiesFromSessionOptions: (opts: GoogleMapsCreateSessionOptions): MapLayerProviderProperties => {\n const properties: MapLayerProviderProperties = {\n mapType: opts.mapType,\n language: opts.language,\n region: opts.region,\n }\n\n if (opts.layerTypes !== undefined) {\n properties.layerTypes = [...opts.layerTypes];\n }\n\n if (opts.scale !== undefined) {\n properties.scale = opts.scale;\n }\n\n if (opts.overlay !== undefined) {\n properties.overlay = opts.overlay;\n }\n\n if (opts.apiOptions !== undefined) {\n properties.apiOptions = [...opts.apiOptions];\n }\n\n return properties;\n },\n}\n"]}
1
+ {"version":3,"file":"GoogleMapsUtils.js","sourceRoot":"","sources":["../../../src/internal/GoogleMapsUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAG/F,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE1E,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG;IAE7B;;;MAGE;IACF,qBAAqB,EAAE,GAAG,EAAE;QAC1B,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,YAAY,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtF,MAAM,IAAI,KAAK,CAA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AoB,CAAC,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAkB,CAAC;QACxE,CAAC;QAED,IAAI,QAAQ,CAAC,UAAU,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;YAClD,oBAAoB,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,UAAsB,CAAC;QAC/E,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;CACF,CAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { ImageMapLayerProps, ImageMapLayerSettings, MapLayerProviderProperties } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { GoogleMapsMapLayerFormat } from \"../GoogleMaps/GoogleMapsImageryFormat.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors } from \"../map-layers-formats.js\";\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const GoogleMapsUtils = {\n\n /**\n * Register the google maps format if it is not already registered.\n * @internal\n */\n checkFormatRegistered: () => {\n if (!IModelApp.mapLayerFormatRegistry.isRegistered(GoogleMapsMapLayerFormat.formatId)) {\n throw new Error(`GoogleMaps format is not registered`);\n }\n },\n\n /**\n * Creates a Google Maps layer props.\n * @param name Name of the layer (Defaults to \"GoogleMaps\")\n * @param opts Options to create the session (Defaults to satellite map type, English language, US region, and roadmap layer type)\n * @internal\n*/\n createMapLayerProps: (name: string = \"GoogleMaps\", opts?: GoogleMapsCreateSessionOptions): ImageMapLayerProps => {\n GoogleMapsUtils.checkFormatRegistered();\n\n return {\n formatId: GoogleMapsMapLayerFormat.formatId,\n url: \"\",\n name,\n properties: GoogleMapsUtils.createPropertiesFromSessionOptions(opts ?? {mapType: \"satellite\", language: \"en-US\", region: \"US:\", layerTypes: [\"layerRoadmap\"]}),\n };\n },\n\n /**\n * Converts the session options to provider properties\n * @param opts Options to create the session\n * @internal\n */\n createPropertiesFromSessionOptions: (opts: GoogleMapsCreateSessionOptions): MapLayerProviderProperties => {\n const properties: MapLayerProviderProperties = {\n mapType: opts.mapType,\n language: opts.language,\n region: opts.region,\n }\n\n if (opts.layerTypes !== undefined) {\n properties.layerTypes = [...opts.layerTypes];\n }\n\n if (opts.scale !== undefined) {\n properties.scale = opts.scale;\n }\n\n if (opts.overlay !== undefined) {\n properties.overlay = opts.overlay;\n }\n\n if (opts.apiOptions !== undefined) {\n properties.apiOptions = [...opts.apiOptions];\n }\n\n return properties;\n },\n\n /**\n * Read the session options from the map layer settings.\n * @param settings Map layer settings\n * ```\n * @internal\n */\n getSessionOptionsFromMapLayer: (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: settings.properties!.region as string,\n language: settings.properties!.language as string,\n }\n\n if (Array.isArray(settings.properties?.layerTypes) && settings.properties.layerTypes.length > 0) {\n createSessionOptions.layerTypes = settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (settings.properties?.scale !== undefined) {\n createSessionOptions.scale = settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = settings.properties.overlay as boolean;\n }\n\n if (settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ /** @packageDocumentation
2
+ * @module MapLayersFormats
3
+ */
4
+ import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
5
+ import { BaseGoogleMapsSession, GoogleMapsCreateSessionOptions, GoogleMapsRequest, GoogleMapsSession, GoogleMapsSessionData, GoogleMapsSessionManager } from "../GoogleMaps/GoogleMapsSession.js";
6
+ export declare class NativeGoogleMapsSession extends BaseGoogleMapsSession {
7
+ static getTileApiBaseUrl: string;
8
+ static viewportApiBaseUrl: string;
9
+ readonly json: GoogleMapsSessionData;
10
+ readonly apiKey: string;
11
+ constructor(json: GoogleMapsSessionData, apiKey: string);
12
+ protected getTileApiBaseUrl(): string;
13
+ getTileSize(): number;
14
+ getTileRequest(position: QuadIdProps): GoogleMapsRequest;
15
+ getViewportInfoRequest(rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest;
16
+ /**
17
+ * Creates a Google Maps session.
18
+ * @param apiKey Google Cloud API key
19
+ * @param opts Options to create the session
20
+ * @internal
21
+ */
22
+ static create(apiKey: string, opts: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSessionData>;
23
+ }
24
+ export declare class NativeGoogleMapsSessionManager extends GoogleMapsSessionManager {
25
+ readonly apiKey: string;
26
+ constructor(apiKey: string);
27
+ createSession(sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession>;
28
+ }
29
+ //# sourceMappingURL=NativeGoogleMapsSession.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,78 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module MapLayersFormats
7
+ */
8
+ import { Logger } from "@itwin/core-bentley";
9
+ import { BaseGoogleMapsSession, GoogleMapsSessionManager } from "../GoogleMaps/GoogleMapsSession.js";
10
+ const loggerCategory = "MapLayersFormats.GoogleMaps";
11
+ /*
12
+ * Google Maps session
13
+ * @internal
14
+ */
15
+ export class NativeGoogleMapsSession extends BaseGoogleMapsSession {
16
+ static getTileApiBaseUrl = "https://tile.googleapis.com/v1/2dtiles";
17
+ static viewportApiBaseUrl = `https://tile.googleapis.com/tile/v1/viewport`;
18
+ json;
19
+ apiKey;
20
+ constructor(json, apiKey) {
21
+ super();
22
+ this.json = json;
23
+ this.apiKey = apiKey;
24
+ }
25
+ getTileApiBaseUrl() {
26
+ return NativeGoogleMapsSession.getTileApiBaseUrl;
27
+ }
28
+ getTileSize() {
29
+ return this.json.tileWidth;
30
+ }
31
+ getTileRequest(position) {
32
+ const url = this.getTilePositionUrl(position);
33
+ url.searchParams.append("key", this.apiKey);
34
+ url.searchParams.append("session", this.json.session);
35
+ return { url };
36
+ }
37
+ getViewportInfoRequest(rectangle, zoomLevel) {
38
+ const degrees = rectangle.toDegrees();
39
+ const url = new URL(`${this.getTileApiBaseUrl()}\
40
+ zoom=${zoomLevel}\
41
+ &north=${degrees.north}&south=${degrees.south}&east=${degrees.east}&west=${degrees.west}`);
42
+ url.searchParams.append("key", this.apiKey);
43
+ url.searchParams.append("session", this.json.session);
44
+ return { url };
45
+ }
46
+ /**
47
+ * Creates a Google Maps session.
48
+ * @param apiKey Google Cloud API key
49
+ * @param opts Options to create the session
50
+ * @internal
51
+ */
52
+ static async create(apiKey, opts) {
53
+ const url = `https://tile.googleapis.com/v1/createSession?key=${apiKey}`;
54
+ const request = new Request(url, { method: "POST", body: JSON.stringify(opts) });
55
+ const response = await fetch(request);
56
+ if (!response.ok) {
57
+ throw new Error(`CreateSession request failed: ${response.status} - ${response.statusText}`);
58
+ }
59
+ Logger.logInfo(loggerCategory, `Session created successfully`);
60
+ return response.json();
61
+ }
62
+ }
63
+ /*
64
+ * Google Maps session manager that uses standard API key to create a session.
65
+ * @beta
66
+ */
67
+ export class NativeGoogleMapsSessionManager extends GoogleMapsSessionManager {
68
+ apiKey;
69
+ constructor(apiKey) {
70
+ super();
71
+ this.apiKey = apiKey;
72
+ }
73
+ async createSession(sessionOptions) {
74
+ const json = await NativeGoogleMapsSession.create(this.apiKey, sessionOptions);
75
+ return new NativeGoogleMapsSession(json, this.apiKey);
76
+ }
77
+ }
78
+ //# sourceMappingURL=NativeGoogleMapsSession.js.map
@@ -0,0 +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,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAA+F,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAGlM,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAM,OAAO,uBAAwB,SAAQ,qBAAqB;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;IAEM,cAAc,CAAC,QAAqB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC9C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,OAAO,EAAC,GAAG,EAAC,CAAC;IACf,CAAC;IAEM,sBAAsB,CAAE,SAA4B,EAAE,SAAiB;QAC5E,MAAM,OAAO,GA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,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","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,5 +1,7 @@
1
1
  export * from "./ArcGisFeature/ArcGisFeatureProvider.js";
2
2
  export * from "./GoogleMaps/GoogleMaps.js";
3
+ export * from "./GoogleMaps/GoogleMapsSession.js";
4
+ export * from "./GoogleMaps/GoogleMapsImageryFormat.js";
3
5
  export * from "./mapLayersFormats.js";
4
6
  export * from "./Tools/MapFeatureInfoTool.js";
5
7
  /** @docs-package-description