@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
package/CHANGELOG.md CHANGED
@@ -1,6 +1,70 @@
1
1
  # Change Log - @itwin/map-layers-formats
2
2
 
3
- This log was last generated on Wed, 30 Apr 2025 13:16:15 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 06 Aug 2025 15:37:23 GMT and should not be manually modified.
4
+
5
+ ## 5.0.5
6
+ Wed, 06 Aug 2025 15:34:16 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.0.4
11
+ Wed, 16 Jul 2025 14:59:59 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 5.0.3
16
+ Fri, 11 Jul 2025 00:56:56 GMT
17
+
18
+ ### Updates
19
+
20
+ - `package.json` added to exports map
21
+
22
+ ## 5.0.2
23
+ Thu, 26 Jun 2025 22:16:01 GMT
24
+
25
+ _Version update only_
26
+
27
+ ## 5.0.1
28
+ Tue, 17 Jun 2025 18:33:52 GMT
29
+
30
+ _Version update only_
31
+
32
+ ## 5.0.0
33
+ Fri, 13 Jun 2025 20:25:38 GMT
34
+
35
+ ### Updates
36
+
37
+ - Bug fix: Google Maps would only use the supplied session manager if an API key was also configured.
38
+ - Exposed some missing Google maps sessions structures.
39
+ - Added Google Maps 2D tiles support.
40
+ - Revisted the Google Maps 2D tiles support to allow a custom session manager to be passed.
41
+ - Upgrade compile target to ES2023 and module to ES2022
42
+ - change map-layers-formats to pure esm
43
+
44
+ ## 4.11.6
45
+ Mon, 16 Jun 2025 15:00:15 GMT
46
+
47
+ _Version update only_
48
+
49
+ ## 4.11.5
50
+ Fri, 06 Jun 2025 13:41:18 GMT
51
+
52
+ _Version update only_
53
+
54
+ ## 4.11.4
55
+ Tue, 03 Jun 2025 16:15:19 GMT
56
+
57
+ _Version update only_
58
+
59
+ ## 4.11.3
60
+ Wed, 28 May 2025 13:56:23 GMT
61
+
62
+ _Version update only_
63
+
64
+ ## 4.11.2
65
+ Tue, 20 May 2025 20:14:46 GMT
66
+
67
+ _Version update only_
4
68
 
5
69
  ## 4.11.1
6
70
  Wed, 30 Apr 2025 13:13:21 GMT
@@ -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,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD;;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;AAED;;;EAGE;AACF,MAAM,WAAW,iBAAiB;IAChC,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;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,oBAAoB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAgC,uBAAuB,EAAwB,wBAAwB,EAAW,cAAc,EAAQ,MAAM,sBAAsB,CAAC;AAG7L,OAAO,EAAoG,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAatJ,qBAAa,yBAA0B,SAAQ,uBAAuB;IAEpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,SAAS,CAAM;gBACX,QAAQ,EAAE,qBAAqB;WAI7B,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB;cAI7D,aAAa,IAAK,OAAO,CAAC,iBAAiB,GAAC,SAAS,CAAC;IAYtE,IAAoB,QAAQ,IAAI,MAAM,CAA2B;IAE3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BjD,OAAO,CAAC,0BAA0B;IAoCrB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAWxE,iBAAiB;YAqCjB,YAAY;IASJ,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IA0ChG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIxD,OAAO,CAAC,gBAAgB;IAIF,eAAe,CAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBnG"}
1
+ {"version":3,"file":"GoogleMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAkC,iBAAiB,EAAE,uBAAuB,EAAwB,cAAc,EAAQ,MAAM,sBAAsB,CAAC;AAC/K,OAAO,EAAE,8BAA8B,EAAuF,wBAAwB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAUrM,qBAAa,yBAA0B,SAAQ,uBAAuB;IAEpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,eAAe,CAAC,CAA2B;IACnD,OAAO,CAAC,eAAe,CAA2C;IAClE,OAAO,CAAC,cAAc,CAAC,CAAoB;gBAC/B,QAAQ,EAAE,qBAAqB,EAAE,cAAc,CAAC,EAAE,wBAAwB;IAMtF,IAAoB,QAAQ,IAAI,MAAM,CAA2B;IAE3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAajC,iBAAiB,IAAK,OAAO,CAAC,wBAAwB,CAAC;IAavE,SAAS,CAAC,0BAA0B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,8BAA8B;IAoCxF,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI5E,iBAAiB,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;YAoBxF,iBAAiB;YAiCjB,YAAY;IASJ,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAiDhG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIxD,OAAO,CAAC,gBAAgB;IAIF,eAAe,CAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBnG"}
@@ -10,68 +10,53 @@ Object.defineProperty(exports, "__esModule", { 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 NativeGoogleMapsSession_js_1 = require("../internal/NativeGoogleMapsSession.js");
13
14
  const GoogleMapsUtils_js_1 = require("../internal/GoogleMapsUtils.js");
14
- const GoogleMapDecorator_js_1 = require("./GoogleMapDecorator.js");
15
15
  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
16
  /*
21
17
  * Google Maps imagery provider
22
- * @internal
18
+ * @beta
23
19
  */
24
20
  class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider {
25
21
  _decorator;
26
22
  _hadUnrecoverableError = false;
27
23
  _tileSize = 256;
28
- constructor(settings) {
24
+ _sessionManager;
25
+ _sessionOptions;
26
+ _activeSession;
27
+ constructor(settings, sessionManager) {
29
28
  super(settings, true);
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
- }
29
+ this._decorator = new core_frontend_1.GoogleMapsDecorator();
30
+ this._sessionManager = sessionManager;
47
31
  }
48
32
  get tileSize() { return this._tileSize; }
49
33
  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";
34
+ this._sessionOptions = GoogleMapsUtils_js_1.GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);
35
+ this._sessionManager = await this.getSessionManager();
36
+ this._activeSession = await this._sessionManager.createSession(this._sessionOptions);
37
+ ;
38
+ this._tileSize = this._activeSession.getTileSize();
39
+ const isActivated = await this._decorator.activate(this._settings.properties.mapType);
40
+ if (!isActivated) {
41
+ const msg = `Failed to activate decorator`;
56
42
  core_bentley_1.Logger.logError(loggerCategory, msg);
57
43
  throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
58
44
  }
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);
45
+ }
46
+ async getSessionManager() {
47
+ if (this._sessionManager)
48
+ return this._sessionManager;
49
+ if (this._settings.accessKey?.value) {
50
+ return new NativeGoogleMapsSession_js_1.NativeGoogleMapsSessionManager(this._settings.accessKey.value);
64
51
  }
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`;
52
+ else {
53
+ const msg = `Missing GoogleMaps api key`;
69
54
  core_bentley_1.Logger.logError(loggerCategory, msg);
70
55
  throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
71
56
  }
72
57
  }
73
- createCreateSessionOptions() {
74
- const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
58
+ createCreateSessionOptions(settings) {
59
+ const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;
75
60
  if (layerPropertyKeys === undefined ||
76
61
  !layerPropertyKeys.includes("mapType") ||
77
62
  !layerPropertyKeys.includes("language") ||
@@ -81,11 +66,11 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
81
66
  throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
82
67
  }
83
68
  const createSessionOptions = {
84
- mapType: this._settings.properties.mapType,
69
+ mapType: settings.properties.mapType,
85
70
  region: this._settings.properties.region,
86
71
  language: this._settings.properties.language,
87
72
  };
88
- if (this._settings.properties?.layerTypes !== undefined) {
73
+ if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {
89
74
  createSessionOptions.layerTypes = this._settings.properties.layerTypes;
90
75
  }
91
76
  if (this._settings.properties?.scale !== undefined) {
@@ -99,15 +84,27 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
99
84
  }
100
85
  return createSessionOptions;
101
86
  }
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());
87
+ // not used, see loadTile
88
+ async constructUrl(_row, _column, _level) {
89
+ return "";
90
+ }
91
+ async fetchViewportInfo(rectangle, zoomLevel) {
92
+ if (!this._activeSession) {
93
+ core_bentley_1.Logger.logError(loggerCategory, `Session is not initialized`);
94
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, "Session is not initialized");
95
+ }
96
+ const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);
97
+ const request = new Request(req.url, { method: "GET" });
98
+ if (req.authorization) {
99
+ request.headers.set("Authorization", req.authorization);
100
+ }
101
+ // Add the session token to the request
102
+ const response = await fetch(request);
103
+ if (!response.ok) {
104
+ core_bentley_1.Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);
105
+ throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);
106
+ }
107
+ return response.json();
111
108
  }
112
109
  async fetchAttributions(tiles) {
113
110
  const zooms = new Set();
@@ -126,14 +123,9 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
126
123
  cartoRect = rect;
127
124
  }
128
125
  }
129
- if (cartoRect) {
126
+ if (cartoRect && this._activeSession) {
130
127
  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
- });
128
+ const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);
137
129
  if (viewportInfo?.copyright) {
138
130
  matchingAttributions.push(viewportInfo.copyright);
139
131
  }
@@ -155,18 +147,23 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
155
147
  }
156
148
  }
157
149
  async loadTile(row, column, zoomLevel) {
150
+ const tilePos = { row, column, level: zoomLevel };
158
151
  if (this._hadUnrecoverableError)
159
152
  return undefined;
153
+ if (this._activeSession === undefined || this._sessionOptions === undefined) {
154
+ core_bentley_1.Logger.logError(loggerCategory, `Session manager is not initialized`);
155
+ return undefined;
156
+ }
160
157
  try {
161
- let tileUrl = await this.constructUrl(row, column, zoomLevel);
162
- let tileResponse = await this.makeTileRequest(tileUrl);
158
+ let tileRequest = this._activeSession.getTileRequest(tilePos);
159
+ let tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);
163
160
  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);
161
+ if (tileResponse.headers.get("content-type")?.includes("application/json") && this._sessionManager) {
162
+ try {
163
+ // Session might have expired, lets try to refresh it
164
+ this._activeSession = await this._sessionManager.createSession(this._sessionOptions);
165
+ tileRequest = this._activeSession.getTileRequest(tilePos);
166
+ tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);
170
167
  if (!tileResponse.ok) {
171
168
  if (tileResponse.headers.get("content-type")?.includes("application/json")) {
172
169
  await this.logJsonError(tileResponse);
@@ -178,7 +175,7 @@ class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider
178
175
  return undefined;
179
176
  }
180
177
  }
181
- else {
178
+ catch {
182
179
  await this.logJsonError(tileResponse);
183
180
  }
184
181
  }