@itwin/map-layers-formats 5.0.0-dev.99 → 5.0.1

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 (72) hide show
  1. package/CHANGELOG.md +58 -1
  2. package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts +1 -1
  3. package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts.map +1 -1
  4. package/lib/cjs/GoogleMaps/GoogleMapDecorator.js.map +1 -1
  5. package/lib/cjs/GoogleMaps/GoogleMaps.d.ts +8 -125
  6. package/lib/cjs/GoogleMaps/GoogleMaps.d.ts.map +1 -1
  7. package/lib/cjs/GoogleMaps/GoogleMaps.js +10 -3
  8. package/lib/cjs/GoogleMaps/GoogleMaps.js.map +1 -1
  9. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts +8 -0
  10. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -1
  11. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js +10 -1
  12. package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -1
  13. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts +10 -7
  14. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
  15. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +65 -67
  16. package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
  17. package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts +152 -0
  18. package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts.map +1 -0
  19. package/lib/cjs/GoogleMaps/GoogleMapsSession.js +33 -0
  20. package/lib/cjs/GoogleMaps/GoogleMapsSession.js.map +1 -0
  21. package/lib/cjs/internal/GoogleMapsUtils.d.ts +9 -16
  22. package/lib/cjs/internal/GoogleMapsUtils.d.ts.map +1 -1
  23. package/lib/cjs/internal/GoogleMapsUtils.js +36 -40
  24. package/lib/cjs/internal/GoogleMapsUtils.js.map +1 -1
  25. package/lib/cjs/internal/NativeGoogleMapsSession.d.ts +29 -0
  26. package/lib/cjs/internal/NativeGoogleMapsSession.d.ts.map +1 -0
  27. package/lib/cjs/internal/NativeGoogleMapsSession.js +83 -0
  28. package/lib/cjs/internal/NativeGoogleMapsSession.js.map +1 -0
  29. package/lib/cjs/map-layers-formats.d.ts +2 -0
  30. package/lib/cjs/map-layers-formats.d.ts.map +1 -1
  31. package/lib/cjs/map-layers-formats.js +2 -0
  32. package/lib/cjs/map-layers-formats.js.map +1 -1
  33. package/lib/cjs/mapLayersFormats.d.ts +10 -0
  34. package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
  35. package/lib/cjs/mapLayersFormats.js +5 -0
  36. package/lib/cjs/mapLayersFormats.js.map +1 -1
  37. package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts +1 -1
  38. package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts.map +1 -1
  39. package/lib/esm/GoogleMaps/GoogleMapDecorator.js.map +1 -1
  40. package/lib/esm/GoogleMaps/GoogleMaps.d.ts +8 -125
  41. package/lib/esm/GoogleMaps/GoogleMaps.d.ts.map +1 -1
  42. package/lib/esm/GoogleMaps/GoogleMaps.js +10 -3
  43. package/lib/esm/GoogleMaps/GoogleMaps.js.map +1 -1
  44. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts +8 -0
  45. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -1
  46. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js +10 -1
  47. package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -1
  48. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts +10 -7
  49. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
  50. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +66 -68
  51. package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
  52. package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts +152 -0
  53. package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts.map +1 -0
  54. package/lib/esm/GoogleMaps/GoogleMapsSession.js +28 -0
  55. package/lib/esm/GoogleMaps/GoogleMapsSession.js.map +1 -0
  56. package/lib/esm/internal/GoogleMapsUtils.d.ts +9 -16
  57. package/lib/esm/internal/GoogleMapsUtils.d.ts.map +1 -1
  58. package/lib/esm/internal/GoogleMapsUtils.js +36 -40
  59. package/lib/esm/internal/GoogleMapsUtils.js.map +1 -1
  60. package/lib/esm/internal/NativeGoogleMapsSession.d.ts +29 -0
  61. package/lib/esm/internal/NativeGoogleMapsSession.d.ts.map +1 -0
  62. package/lib/esm/internal/NativeGoogleMapsSession.js +78 -0
  63. package/lib/esm/internal/NativeGoogleMapsSession.js.map +1 -0
  64. package/lib/esm/map-layers-formats.d.ts +2 -0
  65. package/lib/esm/map-layers-formats.d.ts.map +1 -1
  66. package/lib/esm/map-layers-formats.js +2 -0
  67. package/lib/esm/map-layers-formats.js.map +1 -1
  68. package/lib/esm/mapLayersFormats.d.ts +10 -0
  69. package/lib/esm/mapLayersFormats.d.ts.map +1 -1
  70. package/lib/esm/mapLayersFormats.js +5 -0
  71. package/lib/esm/mapLayersFormats.js.map +1 -1
  72. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,6 +1,63 @@
1
1
  # Change Log - @itwin/map-layers-formats
2
2
 
3
- This log was last generated on Wed, 02 Apr 2025 19:38:36 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 17 Jun 2025 18:33:52 GMT and should not be manually modified.
4
+
5
+ ## 5.0.1
6
+ Tue, 17 Jun 2025 18:33:52 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.0.0
11
+ Fri, 13 Jun 2025 20:25:38 GMT
12
+
13
+ ### Updates
14
+
15
+ - Bug fix: Google Maps would only use the supplied session manager if an API key was also configured.
16
+ - Exposed some missing Google maps sessions structures.
17
+ - Added Google Maps 2D tiles support.
18
+ - Revisted the Google Maps 2D tiles support to allow a custom session manager to be passed.
19
+ - Upgrade compile target to ES2023 and module to ES2022
20
+ - change map-layers-formats to pure esm
21
+
22
+ ## 4.11.6
23
+ Mon, 16 Jun 2025 15:00:15 GMT
24
+
25
+ _Version update only_
26
+
27
+ ## 4.11.5
28
+ Fri, 06 Jun 2025 13:41:18 GMT
29
+
30
+ _Version update only_
31
+
32
+ ## 4.11.4
33
+ Tue, 03 Jun 2025 16:15:19 GMT
34
+
35
+ _Version update only_
36
+
37
+ ## 4.11.3
38
+ Wed, 28 May 2025 13:56:23 GMT
39
+
40
+ _Version update only_
41
+
42
+ ## 4.11.2
43
+ Tue, 20 May 2025 20:14:46 GMT
44
+
45
+ _Version update only_
46
+
47
+ ## 4.11.1
48
+ Wed, 30 Apr 2025 13:13:21 GMT
49
+
50
+ _Version update only_
51
+
52
+ ## 4.11.0
53
+ Wed, 16 Apr 2025 15:50:28 GMT
54
+
55
+ _Version update only_
56
+
57
+ ## 4.10.13
58
+ Thu, 10 Apr 2025 17:47:21 GMT
59
+
60
+ _Version update only_
4
61
 
5
62
  ## 4.10.12
6
63
  Wed, 02 Apr 2025 19:35:47 GMT
@@ -1,6 +1,6 @@
1
1
  import { CanvasDecoration, DecorateContext, Decorator, Sprite } from "@itwin/core-frontend";
2
2
  import { Point3d } from "@itwin/core-geometry";
3
- import { GoogleMapsMapTypes } from "./GoogleMaps.js";
3
+ import { GoogleMapsMapTypes } from "./GoogleMapsSession.js";
4
4
  /** A simple decorator that show logo at the a given screen position.
5
5
  * @internal
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapDecorator.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapDecorator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAA0B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,OAAO,EAAE,MAAM,sBA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I,CAAC,CAAC;IACpC,CAAC;CACF;AA1DD,wCA0DC;AAED;;EAEE;AACF,MAAa,mBAAmB;IACd,IAAI,GAAG,IAAI,cAAc,EAAE,CAAC;IAE5C,qDAAqD;IAC9C,KAAK,CAAC,QAAQ,CAAC,OAA2B;QAC/C,+DAA+D;QAC/D,MAAM,SAAS,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC;YACzC,iBAAiB,CAAC,CAAC;YACnB,qBAAqB,CAAC;QAEtB,yDAAyD;QACzD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,2BAAW,CAAC,gBAAgB,CAAC,GAAG,yBAAS,CAAC,UAAU,UAAU,SAAS,MAAM,CAAC,CAAC,CAAC;IAC5G,CAAC;IAAA,CAAC;IAEF,8BAA8B;IACvB,QAAQ,GAAG,CAAC,OAAwB,EAAE,EAAE;QAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;YACrB,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC;CACH;AAvBD,kDAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CanvasDecoration, DecorateContext, Decorator, IconSprites, IModelApp, Sprite } from \"@itwin/core-frontend\";\nimport { Point3d } from \"@itwin/core-geometry\";\nimport { GoogleMapsMapTypes } from \"./GoogleMaps.js\";\n\n\n/** A simple decorator that show logo at the a given screen position.\n * @internal\n */\nexport class LogoDecoration implements CanvasDecoration {\n private _sprite?: Sprite;\n\n /** The current position of the logo in view coordinates. */\n public readonly position = new Point3d();\n\n private _offset: Point3d|undefined;\n\n public set offset(offset: Point3d|undefined) {\n this._offset = offset;\n }\n\n /** The logo offset in view coordinates.*/\n public get offset() {\n return this._offset;\n }\n\n /** Move the logo to the lower left corner of the screen. */\n public moveToLowerLeftCorner(context: DecorateContext) : boolean{\n if (!this._sprite || !this._sprite.isLoaded)\n return false;\n\n this.position.x = this._offset?.x ?? 0;\n this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;\n if (this._offset?.y)\n this.position.y -= this._offset.y;\n return true;\n }\n\n /* TODO: Add other move methods as needed */\n\n /** Indicate if the logo is loaded and ready to be drawn. */\n public get isLoaded() { return this._sprite?.isLoaded ?? false; }\n\n public async activate(sprite: Sprite): Promise<boolean> {\n this._sprite = sprite;\n return new Promise<boolean>((resolve, _reject) => {\n sprite.loadPromise.then(() => {\n resolve(true);\n }).catch(() => {\n resolve (false);\n });\n });\n }\n\n /** Draw this sprite onto the supplied canvas.\n * @see [[CanvasDecoration.drawDecoration]]\n */\n public drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (this.isLoaded) {\n // Draw image with an origin at the top left corner\n ctx.drawImage(this._sprite!.image!, 0, 0);\n }\n }\n\n public decorate(context: DecorateContext) {\n context.addCanvasDecoration(this);\n }\n}\n\n/** A decorator that adds the Google Maps logo to the lower left corner of the screen.\n * @internal\n*/\nexport class GoogleMapsDecorator implements Decorator {\n public readonly logo = new LogoDecoration();\n\n /** Activate the logo based on the given map type. */\n public async activate(mapType: GoogleMapsMapTypes): Promise<boolean> {\n // Pick the logo that is the most visible on the background map\n const imageName = mapType === \"roadmap\" ?\n \"google_on_white\" :\n \"google_on_non_white\";\n\n // We need to move the logo right after the 'i.js' button\n this.logo.offset = new Point3d(45, 10);\n\n return this.logo.activate(IconSprites.getSpriteFromUrl(`${IModelApp.publicPath}images/${imageName}.png`));\n };\n\n /** Decorate implementation */\n public decorate = (context: DecorateContext) => {\n if (!this.logo.isLoaded)\n return;\n this.logo.moveToLowerLeftCorner(context);\n this.logo.decorate(context);\n };\n}\n"]}
1
+ {"version":3,"file":"GoogleMapDecorator.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapDecorator.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,wDAAoH;AACpH,wDAA+C;AAI/C;;GAEG;AACH,MAAa,cAAc;IACjB,OAAO,CAAU;IAEzB,4DAA4D;IAC5C,QAAQ,GAAG,IAAI,uBAAO,EAAE,CAAC;IAEjC,OAAO,CAAoB;IAEnC,IAAW,MAAM,CAAC,MAAyB;QACvC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEH,0CAA0C;IAC1C,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,4DAA4D;IACrD,qBAAqB,CAAC,OAAwB;QACnD,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ;YACzC,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACjF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4CAA4C;IAE5C,4DAA4D;IAC5D,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC;IAE1D,KAAK,CAAC,QAAQ,CAAC,MAAc;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,OAAO,IA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,QAAQ;YACrB,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC;CACH;AAvBD,kDAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CanvasDecoration, DecorateContext, Decorator, IconSprites, IModelApp, Sprite } from \"@itwin/core-frontend\";\nimport { Point3d } from \"@itwin/core-geometry\";\nimport { GoogleMapsMapTypes } from \"./GoogleMapsSession.js\";\n\n\n/** A simple decorator that show logo at the a given screen position.\n * @internal\n */\nexport class LogoDecoration implements CanvasDecoration {\n private _sprite?: Sprite;\n\n /** The current position of the logo in view coordinates. */\n public readonly position = new Point3d();\n\n private _offset: Point3d|undefined;\n\n public set offset(offset: Point3d|undefined) {\n this._offset = offset;\n }\n\n /** The logo offset in view coordinates.*/\n public get offset() {\n return this._offset;\n }\n\n /** Move the logo to the lower left corner of the screen. */\n public moveToLowerLeftCorner(context: DecorateContext) : boolean{\n if (!this._sprite || !this._sprite.isLoaded)\n return false;\n\n this.position.x = this._offset?.x ?? 0;\n this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;\n if (this._offset?.y)\n this.position.y -= this._offset.y;\n return true;\n }\n\n /* TODO: Add other move methods as needed */\n\n /** Indicate if the logo is loaded and ready to be drawn. */\n public get isLoaded() { return this._sprite?.isLoaded ?? false; }\n\n public async activate(sprite: Sprite): Promise<boolean> {\n this._sprite = sprite;\n return new Promise<boolean>((resolve, _reject) => {\n sprite.loadPromise.then(() => {\n resolve(true);\n }).catch(() => {\n resolve (false);\n });\n });\n }\n\n /** Draw this sprite onto the supplied canvas.\n * @see [[CanvasDecoration.drawDecoration]]\n */\n public drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (this.isLoaded) {\n // Draw image with an origin at the top left corner\n ctx.drawImage(this._sprite!.image!, 0, 0);\n }\n }\n\n public decorate(context: DecorateContext) {\n context.addCanvasDecoration(this);\n }\n}\n\n/** A decorator that adds the Google Maps logo to the lower left corner of the screen.\n * @internal\n*/\nexport class GoogleMapsDecorator implements Decorator {\n public readonly logo = new LogoDecoration();\n\n /** Activate the logo based on the given map type. */\n public async activate(mapType: GoogleMapsMapTypes): Promise<boolean> {\n // Pick the logo that is the most visible on the background map\n const imageName = mapType === \"roadmap\" ?\n \"google_on_white\" :\n \"google_on_non_white\";\n\n // We need to move the logo right after the 'i.js' button\n this.logo.offset = new Point3d(45, 10);\n\n return this.logo.activate(IconSprites.getSpriteFromUrl(`${IModelApp.publicPath}images/${imageName}.png`));\n };\n\n /** Decorate implementation */\n public decorate = (context: DecorateContext) => {\n if (!this.logo.isLoaded)\n return;\n this.logo.moveToLowerLeftCorner(context);\n this.logo.decorate(context);\n };\n}\n"]}
@@ -2,131 +2,7 @@
2
2
  * @module MapLayersFormats
3
3
  */
4
4
  import { BaseMapLayerSettings, ImageMapLayerSettings } from "@itwin/core-common";
5
- import { MapCartoRectangle } from "@itwin/core-frontend";
6
- /**
7
- * The type of base map.
8
- * @beta*/
9
- export type GoogleMapsLayerTypes = "layerRoadmap" | "layerStreetview";
10
- /**
11
- * Layer types that can be added to the map.
12
- * @beta
13
- * */
14
- export type GoogleMapsMapTypes = "roadmap" | "satellite" | "terrain";
15
- /**
16
- * Scale factors that can be applied to labels and objects in the map.
17
- * @beta
18
- * */
19
- export type GoogleMapsScaleFactors = "scaleFactor1x" | "scaleFactor2x" | "scaleFactor4x";
20
- /**
21
- * Represents the options to create a Google Maps session.
22
- * @beta
23
- */
24
- export interface GoogleMapsCreateSessionOptions {
25
- /**
26
- * The type of base map.
27
- *
28
- * `roadmap`: The standard Google Maps painted map tiles.
29
- *
30
- * `satellite`: Satellite imagery.
31
- *
32
- * `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.
33
- * @beta
34
- * */
35
- mapType: GoogleMapsMapTypes;
36
- /**
37
- * 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.
38
- */
39
- language: string;
40
- /**
41
- * 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`.
42
- */
43
- region: string;
44
- /**
45
- * An array of values that specifies the layer types added to the map.
46
- *
47
- * `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.
48
- *
49
- * `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.
50
- *
51
- * @beta
52
- * */
53
- layerTypes?: GoogleMapsLayerTypes[];
54
- /**
55
- * Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.
56
- * Increasing the scale also reduces the number of labels on the map, which reduces clutter.
57
- *
58
- * `scaleFactor1x`: The default.
59
- *
60
- * `scaleFactor2x`: Doubles label size and removes minor feature labels.
61
- *
62
- * `scaleFactor4x`: Quadruples label size and removes minor feature labels.
63
- * @beta
64
- * */
65
- scale?: GoogleMapsScaleFactors;
66
- /**
67
- * A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.
68
- * When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.
69
- * Default is false.
70
- * @beta
71
- * */
72
- overlay?: boolean;
73
- /**
74
- * An array of values specifying additional options to apply.
75
- * @beta
76
- * */
77
- apiOptions?: string[];
78
- }
79
- /**
80
- * Structure representing a Google Maps session.
81
- * @beta
82
- */
83
- export interface GoogleMapsSession {
84
- /** A session token value that you must include in all of your Map Tiles API requests. */
85
- session: string;
86
- /** 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. */
87
- expiry: number;
88
- /** The width of the tiles measured in pixels. */
89
- tileWidth: number;
90
- /** he height of the tiles measured in pixels. */
91
- tileHeight: number;
92
- /** The image format, which can be either `png` or `jpeg`. */
93
- imageFormat: string;
94
- }
95
- /**
96
- * Represents the maximum zoom level available within a bounding rectangle.
97
- * @beta
98
- */
99
- export interface MaxZoomRectangle {
100
- maxZoom: number;
101
- north: number;
102
- south: number;
103
- east: number;
104
- west: number;
105
- }
106
- /**
107
- * Indicate which areas of given viewport have imagery, and at which zoom levels.
108
- * @beta
109
- */
110
- export interface ViewportInfo {
111
- /** Attribution string that you must display on your map when you display roadmap and satellite tiles. */
112
- copyright: string;
113
- /** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */
114
- maxZoomRects: MaxZoomRectangle[];
115
- }
116
- /**
117
- * Request parameters for the getViewportInfo method.
118
- * @beta
119
- */
120
- export interface ViewportInfoRequestParams {
121
- /** Bounding rectangle */
122
- rectangle: MapCartoRectangle;
123
- /** Session token */
124
- session: string;
125
- /** The Google Cloud API key */
126
- key: string;
127
- /** Zoom level of the viewport */
128
- zoom: number;
129
- }
5
+ import { GoogleMapsCreateSessionOptions } from "./GoogleMapsSession.js";
130
6
  /**
131
7
  * Google Maps API
132
8
  * @beta
@@ -162,5 +38,12 @@ export declare const GoogleMaps: {
162
38
  * @beta
163
39
  */
164
40
  createBaseLayerSettings: (opts?: GoogleMapsCreateSessionOptions) => BaseMapLayerSettings;
41
+ /**
42
+ * Read the session options from the map layer settings.
43
+ * @param settings Map layer settings
44
+ * ```
45
+ * @beta
46
+ */
47
+ getMapLayerSessionOptions: (settings: ImageMapLayerSettings) => GoogleMapsCreateSessionOptions;
165
48
  };
166
49
  //# sourceMappingURL=GoogleMaps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMaps.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMaps.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,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,MAAM,CAAC;IAElB,kJAAkJ;IAClJ,YAAY,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAED;;;EAGE;AACF,MAAM,WAAW,yBAAyB;IACxC,yBAAyB;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAE7B,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAEhB,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IAEZ,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;EAGE;AAEF,eAAO,MAAM,UAAU;IACvB;;;;;;;;;;;;;MAaE;oCACgC,MAAM,SAAS,8BAA8B;IAI/E;;;;;;;;;;;;;MAaE;qCACiC,8BAA8B;CAGhE,CAAC"}
1
+ {"version":3,"file":"GoogleMaps.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMaps.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAIxE;;;EAGE;AAEF,eAAO,MAAM,UAAU;IACrB;;;;;;;;;;;;;MAaE;oCAC8B,MAAM,SAAS,8BAA8B;IAI7E;;;;;;;;;;;;;MAaE;qCAC+B,8BAA8B;IAI/D;;;;;MAKE;0CACoC,qBAAqB;CAG5D,CAAC"}
@@ -10,8 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.GoogleMaps = void 0;
11
11
  const core_common_1 = require("@itwin/core-common");
12
12
  const GoogleMapsUtils_js_1 = require("../internal/GoogleMapsUtils.js");
13
- ;
14
- ;
15
13
  /**
16
14
  * Google Maps API
17
15
  * @beta
@@ -51,6 +49,15 @@ exports.GoogleMaps = {
51
49
  */
52
50
  createBaseLayerSettings: (opts) => {
53
51
  return core_common_1.BaseMapLayerSettings.fromJSON(GoogleMapsUtils_js_1.GoogleMapsUtils.createMapLayerProps("GoogleMaps", opts));
54
- }
52
+ },
53
+ /**
54
+ * Read the session options from the map layer settings.
55
+ * @param settings Map layer settings
56
+ * ```
57
+ * @beta
58
+ */
59
+ getMapLayerSessionOptions: (settings) => {
60
+ return GoogleMapsUtils_js_1.GoogleMapsUtils.getSessionOptionsFromMapLayer(settings);
61
+ },
55
62
  };
56
63
  //# sourceMappingURL=GoogleMaps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMaps.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMaps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiF;AAEjF,uEAAiE;AAkFhE,CAAC;AAqBD,CAAC;AA4CF;;;EAGE;AACF,gEAAgE;AACnD,QAAA,UAAU,GAAG;IAC1B;;;;;;;;;;;;;MAaE;IACA,sBAAsB,EAAE,CAAC,IAAa,EAAE,IAAqC,EAAE,EAAE;QAC/E,OAAO,mCAAqB,CAAC,QAAQ,CAAC,oCAAe,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACzF,CAAC;IAEH;;;;;;;;;;;;;MAaE;IACA,uBAAuB,EAAE,CAAC,IAAqC,EAAE,EAAE;QACjE,OAAO,kCAAoB,CAAC,QAAQ,CAAC,oCAAe,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAChG,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BaseMapLayerSettings, ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { MapCartoRectangle } from \"@itwin/core-frontend\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\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* Structure representing a Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsSession {\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 * Represents the 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 * Request parameters for the getViewportInfo method.\n * @beta\n*/\nexport interface ViewportInfoRequestParams {\n /** Bounding rectangle */\n rectangle: MapCartoRectangle;\n\n /** Session token */\n session: string;\n\n /** The Google Cloud API key */\n key: string;\n\n /** Zoom level of the viewport */\n zoom: number;\n}\n\n/**\n * Google Maps API\n * @beta\n*/\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const GoogleMaps = {\n/**\n * Creates Google Maps map-layer settings.\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 *\n * The following examples illustrates how a Googles Map layer can be attached to a viewport:\n * ```ts\n * [[include:GoogleMaps_AttachMapLayerSimple]]\n * ```\n * ```ts\n * [[include:GoogleMaps_AttachMapLayerOpts]]\n * ```\n * @beta\n*/\n createMapLayerSettings: (name?: string, opts?: GoogleMapsCreateSessionOptions) => {\n return ImageMapLayerSettings.fromJSON(GoogleMapsUtils.createMapLayerProps(name, opts));\n },\n\n/**\n * Creates Google Maps base layer settings.\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 *\n * The following examples illustrates how a Google Maps base layer can be set on a viewport:\n * ```ts\n * [[include:GoogleMaps_BaseMapSimple]]\n * ```\n * ```ts\n * [[include:GoogleMaps_BaseMapOpts]]\n * ```\n * @beta\n*/\n createBaseLayerSettings: (opts?: GoogleMapsCreateSessionOptions) => {\n return BaseMapLayerSettings.fromJSON(GoogleMapsUtils.createMapLayerProps(\"GoogleMaps\", opts));\n }\n};"]}
1
+ {"version":3,"file":"GoogleMaps.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMaps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiF;AAEjF,uEAAiE;AAGjE;;;EAGE;AACF,gEAAgE;AACnD,QAAA,UAAU,GAAG;IACxB;;;;;;;;;;;;;MAaE;IACF,sBAAsB,EAAE,CAAC,IAAa,EAAE,IAAqC,EAAE,EAAE;QAC/E,OAAO,mCAAqB,CAAC,QAAQ,CAAC,oCAAe,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACzF,CAAC;IAED;;;;;;;;;;;;;MAaE;IACF,uBAAuB,EAAE,CAAC,IAAqC,EAAE,EAAE;QACjE,OAAO,kCAAoB,CAAC,QAAQ,CAAC,oCAAe,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAChG,CAAC;IAED;;;;;MAKE;IACF,yBAAyB,EAAE,CAAC,QAA+B,EAAE,EAAE;QAC7D,OAAO,oCAAe,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BaseMapLayerSettings, ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { GoogleMapsCreateSessionOptions } from \"./GoogleMapsSession.js\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\n\n\n/**\n * Google Maps API\n * @beta\n*/\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const GoogleMaps = {\n /**\n * Creates Google Maps map-layer settings.\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 *\n * The following examples illustrates how a Googles Map layer can be attached to a viewport:\n * ```ts\n * [[include:GoogleMaps_AttachMapLayerSimple]]\n * ```\n * ```ts\n * [[include:GoogleMaps_AttachMapLayerOpts]]\n * ```\n * @beta\n */\n createMapLayerSettings: (name?: string, opts?: GoogleMapsCreateSessionOptions) => {\n return ImageMapLayerSettings.fromJSON(GoogleMapsUtils.createMapLayerProps(name, opts));\n },\n\n /**\n * Creates Google Maps base layer settings.\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 *\n * The following examples illustrates how a Google Maps base layer can be set on a viewport:\n * ```ts\n * [[include:GoogleMaps_BaseMapSimple]]\n * ```\n * ```ts\n * [[include:GoogleMaps_BaseMapOpts]]\n * ```\n * @beta\n */\n createBaseLayerSettings: (opts?: GoogleMapsCreateSessionOptions) => {\n return BaseMapLayerSettings.fromJSON(GoogleMapsUtils.createMapLayerProps(\"GoogleMaps\", opts));\n },\n\n /**\n * Read the session options from the map layer settings.\n * @param settings Map layer settings\n * ```\n * @beta\n */\n getMapLayerSessionOptions: (settings: ImageMapLayerSettings) => {\n return GoogleMapsUtils.getSessionOptionsFromMapLayer(settings);\n },\n};\n"]}
@@ -3,8 +3,16 @@
3
3
  */
4
4
  import { ImageMapLayerSettings } from "@itwin/core-common";
5
5
  import { ImageryMapLayerFormat, MapLayerImageryProvider } from "@itwin/core-frontend";
6
+ /**
7
+ * Google Maps imagery layer format.
8
+ * @public
9
+ */
6
10
  export declare class GoogleMapsMapLayerFormat extends ImageryMapLayerFormat {
11
+ /** Google Maps imagery layer format.
12
+ * @public
13
+ */
7
14
  static formatId: string;
15
+ /** @internal */
8
16
  static createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined;
9
17
  }
10
18
  //# sourceMappingURL=GoogleMapsImageryFormat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsImageryFormat.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGtF,qBAAa,wBAAyB,SAAQ,qBAAqB;IACjE,OAAuB,QAAQ,SAAgB;WACxB,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,GAAG,SAAS;CAGnH"}
1
+ {"version":3,"file":"GoogleMapsImageryFormat.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAItF;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,qBAAqB;IACjE;;OAEG;IACH,OAAuB,QAAQ,SAAgB;IAE/C,gBAAgB;WACO,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,GAAG,SAAS;CAGnH"}
@@ -10,10 +10,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.GoogleMapsMapLayerFormat = void 0;
11
11
  const core_frontend_1 = require("@itwin/core-frontend");
12
12
  const GoogleMapsImageryProvider_js_1 = require("./GoogleMapsImageryProvider.js");
13
+ const mapLayersFormats_js_1 = require("../mapLayersFormats.js");
14
+ /**
15
+ * Google Maps imagery layer format.
16
+ * @public
17
+ */
13
18
  class GoogleMapsMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat {
19
+ /** Google Maps imagery layer format.
20
+ * @public
21
+ */
14
22
  static formatId = "GoogleMaps";
23
+ /** @internal */
15
24
  static createImageryProvider(settings) {
16
- return new GoogleMapsImageryProvider_js_1.GoogleMapsImageryProvider(settings);
25
+ return new GoogleMapsImageryProvider_js_1.GoogleMapsImageryProvider(settings, mapLayersFormats_js_1.MapLayersFormats.googleMapsOpts?.sessionManager);
17
26
  }
18
27
  }
19
28
  exports.GoogleMapsMapLayerFormat = GoogleMapsMapLayerFormat;
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsImageryFormat.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAAsF;AACtF,iFAA2E;AAE3E,MAAa,wBAAyB,SAAQ,qCAAqB;IAC1D,MAAM,CAAU,QAAQ,GAAG,YAAY,CAAC;IACxC,MAAM,CAAU,qBAAqB,CAAC,QAA+B;QAC1E,OAAO,IAAI,wDAAyB,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;;AAJH,4DAKC","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 { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { ImageryMapLayerFormat, MapLayerImageryProvider } from \"@itwin/core-frontend\";\nimport { GoogleMapsImageryProvider } from \"./GoogleMapsImageryProvider.js\";\n\nexport class GoogleMapsMapLayerFormat extends ImageryMapLayerFormat {\n public static override formatId = \"GoogleMaps\";\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined {\n return new GoogleMapsImageryProvider(settings);\n }\n}\n"]}
1
+ {"version":3,"file":"GoogleMapsImageryFormat.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAAsF;AACtF,iFAA2E;AAC3E,gEAA0D;AAE1D;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,qCAAqB;IACjE;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAG,YAAY,CAAC;IAE/C,gBAAgB;IACT,MAAM,CAAU,qBAAqB,CAAC,QAA+B;QAC1E,OAAO,IAAI,wDAAyB,CAAC,QAAQ,EAAE,sCAAgB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAClG,CAAC;;AATH,4DAUC","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 { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { ImageryMapLayerFormat, MapLayerImageryProvider } from \"@itwin/core-frontend\";\nimport { GoogleMapsImageryProvider } from \"./GoogleMapsImageryProvider.js\";\nimport { MapLayersFormats } from \"../mapLayersFormats.js\";\n\n/**\n * Google Maps imagery layer format.\n * @public\n */\nexport class GoogleMapsMapLayerFormat extends ImageryMapLayerFormat {\n /** Google Maps imagery layer format.\n * @public\n */\n public static override formatId = \"GoogleMaps\";\n\n /** @internal */\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined {\n return new GoogleMapsImageryProvider(settings, MapLayersFormats.googleMapsOpts?.sessionManager);\n }\n}\n"]}
@@ -2,19 +2,22 @@
2
2
  * @module MapLayersFormats
3
3
  */
4
4
  import { ImageMapLayerSettings, ImageSource } from "@itwin/core-common";
5
- import { DecorateContext, MapLayerImageryProvider, MapLayerSourceValidation, ScreenViewport } from "@itwin/core-frontend";
6
- import { GoogleMapsSession } from "./GoogleMaps.js";
5
+ import { DecorateContext, MapCartoRectangle, MapLayerImageryProvider, ScreenViewport } from "@itwin/core-frontend";
6
+ import { GoogleMapsCreateSessionOptions, GoogleMapsSessionManager, ViewportInfo } from "./GoogleMapsSession.js";
7
7
  export declare class GoogleMapsImageryProvider extends MapLayerImageryProvider {
8
8
  private _decorator;
9
9
  private _hadUnrecoverableError;
10
10
  private _tileSize;
11
- constructor(settings: ImageMapLayerSettings);
12
- static validateUrlTemplate(template: string): MapLayerSourceValidation;
13
- protected createSession(): Promise<GoogleMapsSession | undefined>;
11
+ private _sessionManager?;
12
+ private _sessionOptions;
13
+ private _activeSession?;
14
+ constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager);
14
15
  get tileSize(): number;
15
16
  initialize(): Promise<void>;
16
- private createCreateSessionOptions;
17
- constructUrl(row: number, column: number, level: number): Promise<string>;
17
+ protected getSessionManager(): Promise<GoogleMapsSessionManager>;
18
+ protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions;
19
+ constructUrl(_row: number, _column: number, _level: number): Promise<string>;
20
+ fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo>;
18
21
  private fetchAttributions;
19
22
  private logJsonError;
20
23
  loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined>;
@@ -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,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ule", { value: true });
10
10
  exports.GoogleMapsImageryProvider = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_frontend_1 = require("@itwin/core-frontend");
13
- const GoogleMapsUtils_js_1 = require("../internal/GoogleMapsUtils.js");
14
13
  const GoogleMapDecorator_js_1 = require("./GoogleMapDecorator.js");
14
+ const NativeGoogleMapsSession_js_1 = require("../internal/NativeGoogleMapsSession.js");
15
+ const GoogleMapsUtils_js_1 = require("../internal/GoogleMapsUtils.js");
15
16
  const loggerCategory = "MapLayersFormats.GoogleMaps";
16
- const levelToken = "{level}";
17
- const rowToken = "{row}";
18
- const columnToken = "{column}";
19
- const urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;
20
17
  /*
21
18
  * Google Maps imagery provider
22
- * @internal
19
+ * @beta
23
20
  */
24
21
  class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider {
25
22
  _decorator;
26
23
  _hadUnrecoverableError = false;
27
24
  _tileSize = 256;
28
- constructor(settings) {
25
+ _sessionManager;
26
+ _sessionOptions;
27
+ _activeSession;
28
+ constructor(settings, sessionManager) {
29
29
  super(settings, true);
30
30
  this._decorator = new GoogleMapDecorator_js_1.GoogleMapsDecorator();
31
- }
32
- static validateUrlTemplate(template) {
33
- return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? core_frontend_1.MapLayerSourceStatus.Valid : core_frontend_1.MapLayerSourceStatus.InvalidUrl };
34
- }
35
- async createSession() {
36
- const sessionOptions = this.createCreateSessionOptions();
37
- if (this._settings.accessKey) {
38
- // Create session and store in query parameters
39
- const sessionObj = await GoogleMapsUtils_js_1.GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);
40
- this._settings.unsavedQueryParams = { session: sessionObj.session };
41
- return sessionObj;
42
- }
43
- else {
44
- core_bentley_1.Logger.logError(loggerCategory, `Missing GoogleMaps api key`);
45
- return undefined;
46
- }
31
+ this._sessionManager = sessionManager;
47
32
  }
48
33
  get tileSize() { return this._tileSize; }
49
34
  async initialize() {
50
- const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
51
- if (layerPropertyKeys === undefined ||
52
- !layerPropertyKeys.includes("mapType") ||
53
- !layerPropertyKeys.includes("language") ||
54
- !layerPropertyKeys.includes("region")) {
55
- const msg = "Missing session options";
35
+ this._sessionOptions = GoogleMapsUtils_js_1.GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);
36
+ this._sessionManager = await this.getSessionManager();
37
+ this._activeSession = await this._sessionManager.createSession(this._sessionOptions);
38
+ ;
39
+ this._tileSize = this._activeSession.getTileSize();
40
+ const isActivated = await this._decorator.activate(this._settings.properties.mapType);
41
+ if (!isActivated) {
42
+ const msg = `Failed to activate decorator`;
56
43
  core_bentley_1.Logger.logError(loggerCategory, msg);
57
44
  throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
58
45
  }
59
- const session = await this.createSession();
60
- if (!session) {
61
- const msg = `Failed to create session`;
62
- core_bentley_1.Logger.logError(loggerCategory, msg);
63
- throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
46
+ }
47
+ async getSessionManager() {
48
+ if (this._sessionManager)
49
+ return this._sessionManager;
50
+ if (this._settings.accessKey?.value) {
51
+ return new NativeGoogleMapsSession_js_1.NativeGoogleMapsSessionManager(this._settings.accessKey.value);
64
52
  }
65
- this._tileSize = session.tileWidth; // assuming here tiles are square
66
- const isActivated = await this._decorator.activate(this._settings.properties.mapType);
67
- if (!isActivated) {
68
- const msg = `Failed to activate decorator`;
53
+ else {
54
+ const msg = `Missing GoogleMaps api key`;
69
55
  core_bentley_1.Logger.logError(loggerCategory, msg);
70
56
  throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
71
57
  }
72
58
  }
73
- createCreateSessionOptions() {
74
- const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
59
+ createCreateSessionOptions(settings) {
60
+ const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;
75
61
  if (layerPropertyKeys === undefined ||
76
62
  !layerPropertyKeys.includes("mapType") ||
77
63
  !layerPropertyKeys.includes("language") ||
@@ -81,11 +67,11 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
81
67
  throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
82
68
  }
83
69
  const createSessionOptions = {
84
- mapType: this._settings.properties.mapType,
70
+ mapType: settings.properties.mapType,
85
71
  region: this._settings.properties.region,
86
72
  language: this._settings.properties.language,
87
73
  };
88
- if (this._settings.properties?.layerTypes !== undefined) {
74
+ if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {
89
75
  createSessionOptions.layerTypes = this._settings.properties.layerTypes;
90
76
  }
91
77
  if (this._settings.properties?.scale !== undefined) {
@@ -99,15 +85,27 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
99
85
  }
100
86
  return createSessionOptions;
101
87
  }
102
- // construct the Url from the desired Tile
103
- async constructUrl(row, column, level) {
104
- const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());
105
- const obj = new URL(tmpUrl);
106
- if (this._settings.accessKey) {
107
- obj.searchParams.append("key", this._settings.accessKey.value);
108
- }
109
- // We assume the 'session' param to be already part of the query parameters (checked in initialize)
110
- return this.appendCustomParams(obj.toString());
88
+ // not used, see loadTile
89
+ async constructUrl(_row, _column, _level) {
90
+ return "";
91
+ }
92
+ async fetchViewportInfo(rectangle, zoomLevel) {
93
+ if (!this._activeSession) {
94
+ core_bentley_1.Logger.logError(loggerCategory, `Session is not initialized`);
95
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Session is not initialized");
96
+ }
97
+ const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);
98
+ const request = new Request(req.url, { method: "GET" });
99
+ if (req.authorization) {
100
+ request.headers.set("Authorization", req.authorization);
101
+ }
102
+ // Add the session token to the request
103
+ const response = await fetch(request);
104
+ if (!response.ok) {
105
+ core_bentley_1.Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);
106
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);
107
+ }
108
+ return response.json();
111
109
  }
112
110
  async fetchAttributions(tiles) {
113
111
  const zooms = new Set();
@@ -126,14 +124,9 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
126
124
  cartoRect = rect;
127
125
  }
128
126
  }
129
- if (cartoRect) {
127
+ if (cartoRect && this._activeSession) {
130
128
  try {
131
- const viewportInfo = await GoogleMapsUtils_js_1.GoogleMapsUtils.getViewportInfo({
132
- rectangle: cartoRect,
133
- session: this._settings.collectQueryParams().session,
134
- key: this._settings.accessKey.value,
135
- zoom
136
- });
129
+ const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);
137
130
  if (viewportInfo?.copyright) {
138
131
  matchingAttributions.push(viewportInfo.copyright);
139
132
  }
@@ -155,18 +148,23 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
155
148
  }
156
149
  }
157
150
  async loadTile(row, column, zoomLevel) {
151
+ const tilePos = { row, column, level: zoomLevel };
158
152
  if (this._hadUnrecoverableError)
159
153
  return undefined;
154
+ if (this._activeSession === undefined || this._sessionOptions === undefined) {
155
+ core_bentley_1.Logger.logError(loggerCategory, `Session manager is not initialized`);
156
+ return undefined;
157
+ }
160
158
  try {
161
- let tileUrl = await this.constructUrl(row, column, zoomLevel);
162
- let tileResponse = await this.makeTileRequest(tileUrl);
159
+ let tileRequest = this._activeSession.getTileRequest(tilePos);
160
+ let tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);
163
161
  if (!tileResponse.ok) {
164
- if (tileResponse.headers.get("content-type")?.includes("application/json")) {
165
- // Session might have expired, lets try to re-new it.
166
- const isSessionCreated = await this.createSession();
167
- if (isSessionCreated) {
168
- tileUrl = await this.constructUrl(row, column, zoomLevel);
169
- tileResponse = await this.makeTileRequest(tileUrl);
162
+ if (tileResponse.headers.get("content-type")?.includes("application/json") && this._sessionManager) {
163
+ try {
164
+ // Session might have expired, lets try to refresh it
165
+ this._activeSession = await this._sessionManager.createSession(this._sessionOptions);
166
+ tileRequest = this._activeSession.getTileRequest(tilePos);
167
+ tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);
170
168
  if (!tileResponse.ok) {
171
169
  if (tileResponse.headers.get("content-type")?.includes("application/json")) {
172
170
  await this.logJsonError(tileResponse);
@@ -178,7 +176,7 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
178
176
  return undefined;
179
177
  }
180
178
  }
181
- else {
179
+ catch {
182
180
  await this.logJsonError(tileResponse);
183
181
  }
184
182
  }