@itwin/map-layers-formats 5.1.0-dev.9 → 5.1.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.
- package/CHANGELOG.md +80 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
- package/lib/cjs/ArcGisFeature/EsriSymbology.js.map +1 -1
- package/lib/cjs/ArcGisFeature/esriPBuffer.gen.js.map +1 -1
- package/lib/cjs/Feature/DefaultMarkerIcon.js +9 -9
- package/lib/cjs/Feature/DefaultMarkerIcon.js.map +1 -1
- package/lib/cjs/Feature/FeatureCanvasRenderer.js.map +1 -1
- package/lib/cjs/Feature/FeatureInfoReader.js.map +1 -1
- package/lib/cjs/Feature/FeatureSymbology.js.map +1 -1
- package/lib/cjs/Feature/RandomMapColor.js.map +1 -1
- package/lib/cjs/GeoJSON/GeoJSONGeometry.js.map +1 -1
- package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMaps.d.ts +8 -125
- package/lib/cjs/GoogleMaps/GoogleMaps.d.ts.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMaps.js +10 -3
- package/lib/cjs/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts +8 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js +10 -1
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts +10 -7
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +65 -68
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts +152 -0
- package/lib/cjs/GoogleMaps/GoogleMapsSession.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsSession.js +33 -0
- package/lib/cjs/GoogleMaps/GoogleMapsSession.js.map +1 -0
- package/lib/cjs/Icons/MapInfoIcon.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/cjs/internal/GoogleMapsUtils.d.ts +9 -16
- package/lib/cjs/internal/GoogleMapsUtils.d.ts.map +1 -1
- package/lib/cjs/internal/GoogleMapsUtils.js +36 -40
- package/lib/cjs/internal/GoogleMapsUtils.js.map +1 -1
- package/lib/cjs/internal/NativeGoogleMapsSession.d.ts +29 -0
- package/lib/cjs/internal/NativeGoogleMapsSession.d.ts.map +1 -0
- package/lib/cjs/internal/NativeGoogleMapsSession.js +83 -0
- package/lib/cjs/internal/NativeGoogleMapsSession.js.map +1 -0
- package/lib/cjs/map-layers-formats.d.ts +2 -0
- package/lib/cjs/map-layers-formats.d.ts.map +1 -1
- package/lib/cjs/map-layers-formats.js +2 -0
- package/lib/cjs/map-layers-formats.js.map +1 -1
- package/lib/cjs/mapLayersFormats.d.ts +10 -0
- package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
- package/lib/cjs/mapLayersFormats.js +5 -0
- package/lib/cjs/mapLayersFormats.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
- package/lib/esm/ArcGisFeature/EsriSymbology.js.map +1 -1
- package/lib/esm/ArcGisFeature/esriPBuffer.gen.js.map +1 -1
- package/lib/esm/Feature/DefaultMarkerIcon.js +9 -9
- package/lib/esm/Feature/DefaultMarkerIcon.js.map +1 -1
- package/lib/esm/Feature/FeatureCanvasRenderer.js.map +1 -1
- package/lib/esm/Feature/FeatureInfoReader.js.map +1 -1
- package/lib/esm/Feature/FeatureSymbology.js.map +1 -1
- package/lib/esm/Feature/RandomMapColor.js.map +1 -1
- package/lib/esm/GeoJSON/GeoJSONGeometry.js.map +1 -1
- package/lib/esm/GeoJSON/GeoJSONGeometryReader.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMaps.d.ts +8 -125
- package/lib/esm/GoogleMaps/GoogleMaps.d.ts.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMaps.js +10 -3
- package/lib/esm/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts +8 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js +10 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts +10 -7
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +65 -68
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts +152 -0
- package/lib/esm/GoogleMaps/GoogleMapsSession.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsSession.js +28 -0
- package/lib/esm/GoogleMaps/GoogleMapsSession.js.map +1 -0
- package/lib/esm/Icons/MapInfoIcon.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/esm/internal/GoogleMapsUtils.d.ts +9 -16
- package/lib/esm/internal/GoogleMapsUtils.d.ts.map +1 -1
- package/lib/esm/internal/GoogleMapsUtils.js +36 -40
- package/lib/esm/internal/GoogleMapsUtils.js.map +1 -1
- package/lib/esm/internal/NativeGoogleMapsSession.d.ts +29 -0
- package/lib/esm/internal/NativeGoogleMapsSession.d.ts.map +1 -0
- package/lib/esm/internal/NativeGoogleMapsSession.js +78 -0
- package/lib/esm/internal/NativeGoogleMapsSession.js.map +1 -0
- package/lib/esm/map-layers-formats.d.ts +2 -0
- package/lib/esm/map-layers-formats.d.ts.map +1 -1
- package/lib/esm/map-layers-formats.js +2 -0
- package/lib/esm/map-layers-formats.js.map +1 -1
- package/lib/esm/mapLayersFormats.d.ts +10 -0
- package/lib/esm/mapLayersFormats.d.ts.map +1 -1
- package/lib/esm/mapLayersFormats.js +5 -0
- package/lib/esm/mapLayersFormats.js.map +1 -1
- package/lib/public/locales/en/mapLayersFormats.json +18 -18
- package/package.json +17 -15
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts +0 -36
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts.map +0 -1
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.js +0 -87
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.js.map +0 -1
- package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts +0 -36
- package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts.map +0 -1
- package/lib/esm/GoogleMaps/GoogleMapDecorator.js +0 -82
- package/lib/esm/GoogleMaps/GoogleMapDecorator.js.map +0 -1
|
@@ -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
|
-
* @
|
|
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
|
-
|
|
24
|
+
_sessionManager;
|
|
25
|
+
_sessionOptions;
|
|
26
|
+
_activeSession;
|
|
27
|
+
constructor(settings, sessionManager) {
|
|
29
28
|
super(settings, true);
|
|
30
|
-
this._decorator = new
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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 =
|
|
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:
|
|
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
|
|
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
|
-
//
|
|
103
|
-
async constructUrl(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
|
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
|
|
162
|
-
let tileResponse = await this.makeTileRequest(
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
tileResponse = await this.makeTileRequest(
|
|
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
|
-
|
|
178
|
+
catch {
|
|
182
179
|
await this.logJsonError(tileResponse);
|
|
183
180
|
}
|
|
184
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0E;AAE1E,wDAA6L;AAC7L,uEAAiE;AACjE,mEAA8D;AAG9D,MAAM,cAAc,GAAG,6BAA6B,CAAC;AACrD,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC;AACzB,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B,MAAM,WAAW,GAAG,0CAA0C,UAAU,IAAI,WAAW,IAAI,QAAQ,EAAE,CAAC;AAEtG;;;EAGE;AACF,MAAa,yBAA0B,SAAQ,uCAAuB;IAE5D,UAAU,CAAsB;IAChC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,SAAS,GAAG,GAAG,CAAA;IACvB,YAAY,QAA+B;QACzC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAA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gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBACrD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,YAAY,IAAI,GAAG,YAAY,CAAC,MAAM,KAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,KAAU,EAAE,CAAC;gBAClB,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,yBAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CAEF;AA7ND,8DA6NC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator.js\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession } from \"./GoogleMaps.js\";\n\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\nconst levelToken = \"{level}\";\nconst rowToken = \"{row}\";\nconst columnToken = \"{column}\";\n\nconst urlTemplate = `https://tile.googleapis.com/v1/2dtiles/${levelToken}/${columnToken}/${rowToken}`;\n\n/*\n* Google Maps imagery provider\n* @internal\n*/\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\n\n private _decorator: GoogleMapsDecorator;\n private _hadUnrecoverableError = false;\n private _tileSize = 256\n constructor(settings: ImageMapLayerSettings) {\n super(settings, true);\n this._decorator = new GoogleMapsDecorator();\n }\n public static validateUrlTemplate(template: string): MapLayerSourceValidation {\n return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? MapLayerSourceStatus.Valid : MapLayerSourceStatus.InvalidUrl };\n }\n\n protected async createSession() : Promise<GoogleMapsSession|undefined> {\n const sessionOptions = this.createCreateSessionOptions();\n if (this._settings.accessKey ) {\n // Create session and store in query parameters\n const sessionObj = await GoogleMapsUtils.createSession(this._settings.accessKey.value, sessionOptions);\n this._settings.unsavedQueryParams = {session: sessionObj.session};\n return sessionObj;\n } else {\n Logger.logError(loggerCategory, `Missing GoogleMaps api key`);\n return undefined;\n }\n }\n public override get tileSize(): number { return this._tileSize; }\n\n public override async initialize(): Promise<void> {\n\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const session = await this.createSession();\n if (!session) {\n const msg = `Failed to create session`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n this._tileSize = session.tileWidth; // assuming here tiles are square\n\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\n if (!isActivated) {\n const msg = `Failed to activate decorator`;\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n }\n\n private createCreateSessionOptions(): GoogleMapsCreateSessionOptions {\n const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;\n if (layerPropertyKeys === undefined ||\n !layerPropertyKeys.includes(\"mapType\") ||\n !layerPropertyKeys.includes(\"language\") ||\n !layerPropertyKeys.includes(\"region\")) {\n const msg = \"Missing session options\";\n Logger.logError(loggerCategory, msg);\n throw new BentleyError(BentleyStatus.ERROR, msg);\n }\n\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\n mapType: this._settings.properties!.mapType as GoogleMapsMapTypes,\n region: this._settings.properties!.region as string,\n language: this._settings.properties!.language as string,\n }\n\n if (this._settings.properties?.layerTypes !== undefined) {\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\n }\n\n if (this._settings.properties?.scale !== undefined) {\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\n }\n\n if (this._settings.properties?.overlay !== undefined) {\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\n }\n\n if (this._settings.properties?.apiOptions !== undefined) {\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\n }\n return createSessionOptions;\n }\n\n // construct the Url from the desired Tile\n public async constructUrl(row: number, column: number, level: number): Promise<string> {\n const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());\n const obj = new URL(tmpUrl);\n if (this._settings.accessKey ) {\n obj.searchParams.append(\"key\", this._settings.accessKey.value);\n }\n\n // We assume the 'session' param to be already part of the query parameters (checked in initialize)\n return this.appendCustomParams(obj.toString());\n }\n\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\n const zooms = new Set<number>();\n const matchingAttributions: string[] = [];\n\n // Viewport info requests must be made for a specific zoom level\n tiles.forEach((tile) => zooms.add(tile.depth));\n\n for (const zoom of zooms) {\n let cartoRect: MapCartoRectangle|undefined;\n for (const tile of tiles) {\n if (tile.depth === zoom && tile instanceof MapTile) {\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\n if (cartoRect)\n cartoRect.union(rect);\n else\n cartoRect = rect;\n }\n }\n if (cartoRect) {\n try {\n const viewportInfo = await GoogleMapsUtils.getViewportInfo({\n rectangle: cartoRect,\n session: this._settings.collectQueryParams().session,\n key: this._settings.accessKey!.value,\n zoom});\n if (viewportInfo?.copyright) {\n matchingAttributions.push(viewportInfo.copyright);\n }\n } catch (error:any) {\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\n }\n }\n }\n\n return matchingAttributions;\n }\n private async logJsonError(tileResponse: Response) {\n try {\n const error = await tileResponse.json();\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\n } catch {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n }\n\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\n if (this._hadUnrecoverableError)\n return undefined;\n\n try {\n let tileUrl: string = await this.constructUrl(row, column, zoomLevel);\n let tileResponse: Response = await this.makeTileRequest(tileUrl);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n // Session might have expired, lets try to re-new it.\n const isSessionCreated = await this.createSession();\n if (isSessionCreated) {\n tileUrl = await this.constructUrl(row, column, zoomLevel);\n tileResponse = await this.makeTileRequest(tileUrl);\n if (!tileResponse.ok) {\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\n await this.logJsonError(tileResponse);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n }\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\n return undefined;\n }\n } else {\n await this.logJsonError(tileResponse);\n }\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\n return undefined;\n }\n }\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\n } catch (error: any) {\n if (error?.code === 401) {\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\n } else {\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\n }\n return undefined;\n }\n }\n\n public override decorate(context: DecorateContext): void {\n this._decorator.decorate(context);\n }\n\n private getSelectedTiles(vp: ScreenViewport) {\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\n }\n\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\n let copyrightMsg = \"\";\n const tiles = this.getSelectedTiles(vp);\n if (tiles) {\n try {\n const attrList = await this.fetchAttributions(tiles);\n for (const attr of attrList) {\n attr.split(\",\").forEach((line) => {\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\n });\n }\n }\n catch (error: any) {\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\n }\n }\n\n cards.appendChild(IModelApp.makeLogoCard({\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\n heading: \"Google Maps\",\n notice: copyrightMsg }));\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0E;AAE1E,wDAA+K;AAE/K,uFAAwF;AACxF,uEAAiE;AAEjE,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;;EAGE;AACF,MAAa,yBAA0B,SAAQ,uCAAuB;IAE5D,UAAU,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AE,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBACrD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;wBAC/B,YAAY,IAAI,GAAG,YAAY,CAAC,MAAM,KAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,KAAU,EAAE,CAAC;gBAClB,qBAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,qCAAqC,KAAK,EAAE,OAAO,IAAE,eAAe,EAAE,CAAC,CAAC;YAC1G,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,yBAAS,CAAC,YAAY,CAAC;YACvC,OAAO,EAAE,GAAG,yBAAS,CAAC,UAAU,iCAAiC;YACjE,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AA/ND,8DA+NC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\r\nimport { DecorateContext, GoogleMapsDecorator, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapTile, QuadIdProps, ScreenViewport, Tile } from \"@itwin/core-frontend\";\r\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession, GoogleMapsSessionManager, ViewportInfo } from \"./GoogleMapsSession.js\";\r\nimport { NativeGoogleMapsSessionManager } from \"../internal/NativeGoogleMapsSession.js\";\r\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils.js\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GoogleMaps\";\r\n\r\n/*\r\n* Google Maps imagery provider\r\n* @beta\r\n*/\r\nexport class GoogleMapsImageryProvider extends MapLayerImageryProvider {\r\n\r\n private _decorator: GoogleMapsDecorator;\r\n private _hadUnrecoverableError = false;\r\n private _tileSize = 256;\r\n private _sessionManager?: GoogleMapsSessionManager;\r\n private _sessionOptions: GoogleMapsCreateSessionOptions|undefined;\r\n private _activeSession?: GoogleMapsSession;\r\n constructor(settings: ImageMapLayerSettings, sessionManager?: GoogleMapsSessionManager) {\r\n super(settings, true);\r\n this._decorator = new GoogleMapsDecorator();\r\n this._sessionManager = sessionManager;\r\n\r\n }\r\n public override get tileSize(): number { return this._tileSize; }\r\n\r\n public override async initialize(): Promise<void> {\r\n this._sessionOptions = GoogleMapsUtils.getSessionOptionsFromMapLayer(this._settings);\r\n this._sessionManager = await this.getSessionManager();\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);;\r\n this._tileSize = this._activeSession.getTileSize();\r\n const isActivated = await this._decorator.activate(this._settings.properties!.mapType as GoogleMapsMapTypes);\r\n if (!isActivated) {\r\n const msg = `Failed to activate decorator`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected async getSessionManager (): Promise<GoogleMapsSessionManager> {\r\n if (this._sessionManager)\r\n return this._sessionManager;\r\n\r\n if (this._settings.accessKey?.value) {\r\n return new NativeGoogleMapsSessionManager(this._settings.accessKey.value);\r\n } else {\r\n const msg = `Missing GoogleMaps api key`;\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n }\r\n\r\n protected createCreateSessionOptions(settings: ImageMapLayerSettings): GoogleMapsCreateSessionOptions {\r\n const layerPropertyKeys = settings.properties ? Object.keys(settings.properties) : undefined;\r\n if (layerPropertyKeys === undefined ||\r\n !layerPropertyKeys.includes(\"mapType\") ||\r\n !layerPropertyKeys.includes(\"language\") ||\r\n !layerPropertyKeys.includes(\"region\")) {\r\n const msg = \"Missing session options\";\r\n Logger.logError(loggerCategory, msg);\r\n throw new BentleyError(BentleyStatus.ERROR, msg);\r\n }\r\n\r\n const createSessionOptions: GoogleMapsCreateSessionOptions = {\r\n mapType: settings.properties!.mapType as GoogleMapsMapTypes,\r\n region: this._settings.properties!.region as string,\r\n language: this._settings.properties!.language as string,\r\n }\r\n\r\n if (Array.isArray(this._settings.properties?.layerTypes) && this._settings.properties.layerTypes.length > 0) {\r\n createSessionOptions.layerTypes = this._settings.properties.layerTypes as GoogleMapsLayerTypes[];\r\n }\r\n\r\n if (this._settings.properties?.scale !== undefined) {\r\n createSessionOptions.scale = this._settings.properties.scale as GoogleMapsScaleFactors;\r\n }\r\n\r\n if (this._settings.properties?.overlay !== undefined) {\r\n createSessionOptions.overlay = this._settings.properties.overlay as boolean;\r\n }\r\n\r\n if (this._settings.properties?.apiOptions !== undefined) {\r\n createSessionOptions.apiOptions = this._settings.properties.apiOptions as string[];\r\n }\r\n return createSessionOptions;\r\n }\r\n\r\n // not used, see loadTile\r\n public async constructUrl(_row: number, _column: number, _level: number): Promise<string> {\r\n return \"\";\r\n }\r\n\r\n public async fetchViewportInfo(rectangle: MapCartoRectangle, zoomLevel: number): Promise<ViewportInfo> {\r\n if (!this._activeSession) {\r\n Logger.logError(loggerCategory, `Session is not initialized`);\r\n throw new BentleyError(BentleyStatus.ERROR, \"Session is not initialized\");\r\n }\r\n\r\n const req = this._activeSession.getViewportInfoRequest(rectangle, zoomLevel);\r\n const request = new Request(req.url, {method: \"GET\"});\r\n if (req.authorization) {\r\n request.headers.set(\"Authorization\", req.authorization);\r\n }\r\n // Add the session token to the request\r\n const response = await fetch(request);\r\n if (!response.ok) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${response.statusText}`);\r\n throw new BentleyError(BentleyStatus.ERROR, `Error while loading viewport info: ${response.statusText}`);\r\n }\r\n return response.json() as Promise<ViewportInfo>;\r\n }\r\n\r\n private async fetchAttributions(tiles: Set<Tile>): Promise<string[]> {\r\n const zooms = new Set<number>();\r\n const matchingAttributions: string[] = [];\r\n\r\n // Viewport info requests must be made for a specific zoom level\r\n tiles.forEach((tile) => zooms.add(tile.depth));\r\n\r\n for (const zoom of zooms) {\r\n let cartoRect: MapCartoRectangle|undefined;\r\n for (const tile of tiles) {\r\n if (tile.depth === zoom && tile instanceof MapTile) {\r\n const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);\r\n const rect = MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop)\r\n if (cartoRect)\r\n cartoRect.union(rect);\r\n else\r\n cartoRect = rect;\r\n }\r\n }\r\n if (cartoRect && this._activeSession) {\r\n try {\r\n const viewportInfo = await this.fetchViewportInfo(cartoRect, zoom);\r\n if (viewportInfo?.copyright) {\r\n matchingAttributions.push(viewportInfo.copyright);\r\n }\r\n } catch (error:any) {\r\n Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n }\r\n\r\n return matchingAttributions;\r\n }\r\n private async logJsonError(tileResponse: Response) {\r\n try {\r\n const error = await tileResponse.json();\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);\r\n } catch {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n }\r\n\r\n public override async loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined> {\r\n const tilePos: QuadIdProps = {row, column, level: zoomLevel};\r\n if (this._hadUnrecoverableError)\r\n return undefined;\r\n\r\n if (this._activeSession === undefined || this._sessionOptions === undefined) {\r\n Logger.logError(loggerCategory, `Session manager is not initialized`);\r\n return undefined;\r\n }\r\n\r\n try {\r\n let tileRequest = this._activeSession.getTileRequest(tilePos);\r\n let tileResponse: Response = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\") && this._sessionManager) {\r\n try {\r\n // Session might have expired, lets try to refresh it\r\n this._activeSession = await this._sessionManager.createSession(this._sessionOptions);\r\n tileRequest = this._activeSession.getTileRequest(tilePos);\r\n tileResponse = await this.makeTileRequest(tileRequest.url.toString(), undefined, tileRequest.authorization);\r\n if (!tileResponse.ok) {\r\n if (tileResponse.headers.get(\"content-type\")?.includes(\"application/json\")) {\r\n await this.logJsonError(tileResponse);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n }\r\n this._hadUnrecoverableError = true; // Prevent from doing more invalid requests\r\n return undefined;\r\n }\r\n }\r\n catch {\r\n await this.logJsonError(tileResponse);\r\n }\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);\r\n return undefined;\r\n }\r\n }\r\n return await this.getImageFromTileResponse(tileResponse, zoomLevel);\r\n } catch (error: any) {\r\n if (error?.code === 401) {\r\n Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);\r\n } else {\r\n Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);\r\n }\r\n return undefined;\r\n }\r\n }\r\n\r\n public override decorate(context: DecorateContext): void {\r\n this._decorator.decorate(context);\r\n }\r\n\r\n private getSelectedTiles(vp: ScreenViewport) {\r\n return IModelApp.tileAdmin.getTilesForUser(vp)?.selected\r\n }\r\n\r\n public override async addAttributions (cards: HTMLTableElement, vp: ScreenViewport): Promise<void> {\r\n let copyrightMsg = \"\";\r\n const tiles = this.getSelectedTiles(vp);\r\n if (tiles) {\r\n try {\r\n const attrList = await this.fetchAttributions(tiles);\r\n for (const attr of attrList) {\r\n attr.split(\",\").forEach((line) => {\r\n copyrightMsg += `${copyrightMsg.length===0 ? \"\": \"<br\"}${line}`;\r\n });\r\n }\r\n }\r\n catch (error: any) {\r\n Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message??\"Unknown error\"}`);\r\n }\r\n }\r\n\r\n cards.appendChild(IModelApp.makeLogoCard({\r\n iconSrc: `${IModelApp.publicPath}images/google_on_white_hdpi.png`,\r\n heading: \"Google Maps\",\r\n notice: copyrightMsg }));\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module MapLayersFormats
|
|
3
|
+
*/
|
|
4
|
+
import { MapCartoRectangle, QuadIdProps } from "@itwin/core-frontend";
|
|
5
|
+
/**
|
|
6
|
+
* The type of base map .
|
|
7
|
+
* @beta*/
|
|
8
|
+
export type GoogleMapsLayerTypes = "layerRoadmap" | "layerStreetview";
|
|
9
|
+
/**
|
|
10
|
+
* Layer types that can be added to the map.
|
|
11
|
+
* @beta
|
|
12
|
+
* */
|
|
13
|
+
export type GoogleMapsMapTypes = "roadmap" | "satellite" | "terrain";
|
|
14
|
+
/**
|
|
15
|
+
* Scale factors that can be applied to labels and objects in the map.
|
|
16
|
+
* @beta
|
|
17
|
+
* */
|
|
18
|
+
export type GoogleMapsScaleFactors = "scaleFactor1x" | "scaleFactor2x" | "scaleFactor4x";
|
|
19
|
+
/**
|
|
20
|
+
* Represents the options to create a Google Maps session.
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export interface GoogleMapsCreateSessionOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The type of base map.
|
|
26
|
+
*
|
|
27
|
+
* `roadmap`: The standard Google Maps painted map tiles.
|
|
28
|
+
*
|
|
29
|
+
* `satellite`: Satellite imagery.
|
|
30
|
+
*
|
|
31
|
+
* `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.
|
|
32
|
+
* @beta
|
|
33
|
+
* */
|
|
34
|
+
mapType: GoogleMapsMapTypes;
|
|
35
|
+
/**
|
|
36
|
+
* An {@link https://en.wikipedia.org/wiki/IETF_language_tag | IETF language tag} that specifies the language used to display information on the tiles. For example, `en-US` specifies the English language as spoken in the United States.
|
|
37
|
+
*/
|
|
38
|
+
language: string;
|
|
39
|
+
/**
|
|
40
|
+
* A {@link https://cldr.unicode.org/ | Common Locale Data Repository} region identifier (two uppercase letters) that represents the physical location of the user. For example, `US`.
|
|
41
|
+
*/
|
|
42
|
+
region: string;
|
|
43
|
+
/**
|
|
44
|
+
* An array of values that specifies the layer types added to the map.
|
|
45
|
+
*
|
|
46
|
+
* `layerRoadmap`: Required if you specify terrain as the map type. Can also be optionally overlaid on the satellite map type. Has no effect on roadmap tiles.
|
|
47
|
+
*
|
|
48
|
+
* `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.
|
|
49
|
+
*
|
|
50
|
+
* @beta
|
|
51
|
+
* */
|
|
52
|
+
layerTypes?: GoogleMapsLayerTypes[];
|
|
53
|
+
/**
|
|
54
|
+
* Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.
|
|
55
|
+
* Increasing the scale also reduces the number of labels on the map, which reduces clutter.
|
|
56
|
+
*
|
|
57
|
+
* `scaleFactor1x`: The default.
|
|
58
|
+
*
|
|
59
|
+
* `scaleFactor2x`: Doubles label size and removes minor feature labels.
|
|
60
|
+
*
|
|
61
|
+
* `scaleFactor4x`: Quadruples label size and removes minor feature labels.
|
|
62
|
+
* @beta
|
|
63
|
+
* */
|
|
64
|
+
scale?: GoogleMapsScaleFactors;
|
|
65
|
+
/**
|
|
66
|
+
* A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.
|
|
67
|
+
* When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.
|
|
68
|
+
* Default is false.
|
|
69
|
+
* @beta
|
|
70
|
+
* */
|
|
71
|
+
overlay?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* An array of values specifying additional options to apply.
|
|
74
|
+
* @beta
|
|
75
|
+
* */
|
|
76
|
+
apiOptions?: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Session data returned by the Google Maps API.
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
export interface GoogleMapsSessionData {
|
|
83
|
+
/** A session token value that you must include in all of your Map Tiles API requests. */
|
|
84
|
+
session: string;
|
|
85
|
+
/** string that contains the time (in seconds since the epoch) at which the token expires. A session token is valid for two weeks from its creation time, but this policy might change without notice. */
|
|
86
|
+
expiry: number;
|
|
87
|
+
/** The width of the tiles measured in pixels. */
|
|
88
|
+
tileWidth: number;
|
|
89
|
+
/** he height of the tiles measured in pixels. */
|
|
90
|
+
tileHeight: number;
|
|
91
|
+
/** The image format, which can be either `png` or `jpeg`. */
|
|
92
|
+
imageFormat: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Maximum zoom level available within a bounding rectangle.
|
|
96
|
+
* @beta
|
|
97
|
+
*/
|
|
98
|
+
export interface MaxZoomRectangle {
|
|
99
|
+
maxZoom: number;
|
|
100
|
+
north: number;
|
|
101
|
+
south: number;
|
|
102
|
+
east: number;
|
|
103
|
+
west: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Indicate which areas of given viewport have imagery, and at which zoom levels.
|
|
107
|
+
* @beta
|
|
108
|
+
*/
|
|
109
|
+
export interface ViewportInfo {
|
|
110
|
+
/** Attribution string that you must display on your map when you display roadmap and satellite tiles. */
|
|
111
|
+
copyright: string;
|
|
112
|
+
/** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */
|
|
113
|
+
maxZoomRects: MaxZoomRectangle[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Google Maps Request
|
|
117
|
+
* @beta
|
|
118
|
+
*/
|
|
119
|
+
export interface GoogleMapsRequest {
|
|
120
|
+
/** The URL of the request */
|
|
121
|
+
url: URL;
|
|
122
|
+
authorization?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Google Maps session.
|
|
126
|
+
* @beta
|
|
127
|
+
*/
|
|
128
|
+
export interface GoogleMapsSession {
|
|
129
|
+
getTileSize: () => number;
|
|
130
|
+
getTileRequest: (position: QuadIdProps) => GoogleMapsRequest;
|
|
131
|
+
getViewportInfoRequest(rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Base implementation of Google Maps session.
|
|
135
|
+
* @beta
|
|
136
|
+
*/
|
|
137
|
+
export declare abstract class BaseGoogleMapsSession implements GoogleMapsSession {
|
|
138
|
+
protected abstract getTileApiBaseUrl(): string;
|
|
139
|
+
protected getTilePositionUrl(position: QuadIdProps): URL;
|
|
140
|
+
abstract getTileSize(): number;
|
|
141
|
+
abstract getTileRequest(position: QuadIdProps): GoogleMapsRequest;
|
|
142
|
+
abstract getViewportInfoRequest(rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Google Maps session manager interface.
|
|
146
|
+
* @beta
|
|
147
|
+
*/
|
|
148
|
+
export declare abstract class GoogleMapsSessionManager {
|
|
149
|
+
readonly type = "GoogleMapsSessionManager";
|
|
150
|
+
abstract createSession(sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession>;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=GoogleMapsSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsSession.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,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G,SAAS,EAAE,MAAM,CAAC;IAElB,kJAAkJ;IAClJ,YAAY,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAGD;;;EAGE;AACF,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,GAAG,EAAE,GAAG,CAAC;IAGT,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;EAGE;AACF,MAAM,WAAW,iBAAiB;IAEhC,WAAW,EAAE,MAAM,MAAM,CAAC;IAG1B,cAAc,EAAE,CAAC,QAAQ,EAAE,WAAW,KAAK,iBAAiB,CAAC;IAG7D,sBAAsB,CAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAC5F;AAED;;;EAGE;AACF,8BAAsB,qBAAsB,YAAW,iBAAiB;IACtE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,IAAI,MAAM;IAE9C,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,WAAW;aAMlC,WAAW,IAAI,MAAM;aACrB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,iBAAiB;aACxD,sBAAsB,CAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB;CAC5G;AAED;;;EAGE;AACF,8BAAsB,wBAAwB;IAC5C,SAAgB,IAAI,8BAA8B;aAClC,aAAa,CAAE,cAAc,EAAE,8BAA8B,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAC3G"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module MapLayersFormats
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GoogleMapsSessionManager = exports.BaseGoogleMapsSession = void 0;
|
|
11
|
+
;
|
|
12
|
+
;
|
|
13
|
+
/**
|
|
14
|
+
* Base implementation of Google Maps session.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
class BaseGoogleMapsSession {
|
|
18
|
+
getTilePositionUrl(position) {
|
|
19
|
+
const baseUrl = this.getTileApiBaseUrl();
|
|
20
|
+
const tmpUrl = `${baseUrl}/${position.level}/${position.column}/${position.row}`;
|
|
21
|
+
return new URL(tmpUrl);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.BaseGoogleMapsSession = BaseGoogleMapsSession;
|
|
25
|
+
/**
|
|
26
|
+
* Google Maps session manager interface.
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
class GoogleMapsSessionManager {
|
|
30
|
+
type = "GoogleMapsSessionManager";
|
|
31
|
+
}
|
|
32
|
+
exports.GoogleMapsSessionManager = GoogleMapsSessionManager;
|
|
33
|
+
//# sourceMappingURL=GoogleMapsSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsSession.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsSession.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAoFF,CAAC;AAsBD,CAAC;AAsDF;;;EAGE;AACF,MAAsB,qBAAqB;IAG/B,kBAAkB,CAAC,QAAqB;QAChD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,GAAG,OAAO,IAAI,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;QACjF,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CAKF;AAZD,sDAYC;AAED;;;EAGE;AACF,MAAsB,wBAAwB;IAC5B,IAAI,GAAG,0BAA0B,CAAC;CAEnD;AAHD,4DAGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module MapLayersFormats\r\n */\r\n\r\nimport { MapCartoRectangle, QuadIdProps} from \"@itwin/core-frontend\";\r\n\r\n\r\n/**\r\n * The type of base map .\r\n * @beta*/\r\nexport type GoogleMapsLayerTypes = \"layerRoadmap\" | \"layerStreetview\";\r\n\r\n/**\r\n * Layer types that can be added to the map.\r\n * @beta\r\n * */\r\nexport type GoogleMapsMapTypes = \"roadmap\"|\"satellite\"|\"terrain\";\r\n\r\n/**\r\n * Scale factors that can be applied to labels and objects in the map.\r\n * @beta\r\n * */\r\nexport type GoogleMapsScaleFactors = \"scaleFactor1x\" | \"scaleFactor2x\" | \"scaleFactor4x\";\r\n\r\n/**\r\n* Represents the options to create a Google Maps session.\r\n* @beta\r\n*/\r\nexport interface GoogleMapsCreateSessionOptions {\r\n /**\r\n * The type of base map.\r\n *\r\n * `roadmap`: The standard Google Maps painted map tiles.\r\n *\r\n * `satellite`: Satellite imagery.\r\n *\r\n * `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.\r\n * @beta\r\n * */\r\n mapType: GoogleMapsMapTypes,\r\n /**\r\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.\r\n */\r\n language: string;\r\n /**\r\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`.\r\n */\r\n region: string;\r\n\r\n /**\r\n * An array of values that specifies the layer types added to the map.\r\n *\r\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.\r\n *\r\n * `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.\r\n *\r\n * @beta\r\n * */\r\n layerTypes?: GoogleMapsLayerTypes[];\r\n\r\n /**\r\n * Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.\r\n * Increasing the scale also reduces the number of labels on the map, which reduces clutter.\r\n *\r\n * `scaleFactor1x`: The default.\r\n *\r\n * `scaleFactor2x`: Doubles label size and removes minor feature labels.\r\n *\r\n * `scaleFactor4x`: Quadruples label size and removes minor feature labels.\r\n * @beta\r\n * */\r\n scale?: GoogleMapsScaleFactors\r\n\r\n /**\r\n * A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.\r\n * When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.\r\n * Default is false.\r\n * @beta\r\n * */\r\n overlay? : boolean;\r\n\r\n /**\r\n * An array of values specifying additional options to apply.\r\n * @beta\r\n * */\r\n apiOptions?: string[];\r\n};\r\n\r\n\r\n/**\r\n* Session data returned by the Google Maps API.\r\n* @beta\r\n*/\r\nexport interface GoogleMapsSessionData {\r\n /** A session token value that you must include in all of your Map Tiles API requests. */\r\n session: string;\r\n\r\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. */\r\n expiry: number;\r\n\r\n /** The width of the tiles measured in pixels. */\r\n tileWidth: number;\r\n\r\n /** he height of the tiles measured in pixels. */\r\n tileHeight: number;\r\n\r\n /** The image format, which can be either `png` or `jpeg`. */\r\n imageFormat: string;\r\n};\r\n\r\n/**\r\n * Maximum zoom level available within a bounding rectangle.\r\n* @beta\r\n*/\r\nexport interface MaxZoomRectangle {\r\n maxZoom: number;\r\n north: number;\r\n south: number;\r\n east: number;\r\n west: number;\r\n}\r\n\r\n/**\r\n * Indicate which areas of given viewport have imagery, and at which zoom levels.\r\n * @beta\r\n*/\r\nexport interface ViewportInfo {\r\n /** Attribution string that you must display on your map when you display roadmap and satellite tiles. */\r\n copyright: string;\r\n\r\n /** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */\r\n maxZoomRects: MaxZoomRectangle[];\r\n}\r\n\r\n\r\n/**\r\n* Google Maps Request\r\n* @beta\r\n*/\r\nexport interface GoogleMapsRequest {\r\n /** The URL of the request */\r\n url: URL;\r\n\r\n /* Authorization header for the request */\r\n authorization?: string;\r\n}\r\n\r\n/**\r\n* Google Maps session.\r\n* @beta\r\n*/\r\nexport interface GoogleMapsSession {\r\n /* Tile size in pixels */\r\n getTileSize: () => number;\r\n\r\n /* Tile URL for the given tile position */\r\n getTileRequest: (position: QuadIdProps) => GoogleMapsRequest;\r\n\r\n /* Viewport information request */\r\n getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest\r\n}\r\n\r\n/**\r\n* Base implementation of Google Maps session.\r\n* @beta\r\n*/\r\nexport abstract class BaseGoogleMapsSession implements GoogleMapsSession {\r\n protected abstract getTileApiBaseUrl(): string;\r\n\r\n protected getTilePositionUrl(position: QuadIdProps) {\r\n const baseUrl = this.getTileApiBaseUrl();\r\n const tmpUrl = `${baseUrl}/${position.level}/${position.column}/${position.row}`;\r\n return new URL(tmpUrl);\r\n }\r\n\r\n public abstract getTileSize(): number;\r\n public abstract getTileRequest(position: QuadIdProps): GoogleMapsRequest;\r\n public abstract getViewportInfoRequest (rectangle: MapCartoRectangle, zoomLevel: number): GoogleMapsRequest\r\n}\r\n\r\n/**\r\n* Google Maps session manager interface.\r\n* @beta\r\n*/\r\nexport abstract class GoogleMapsSessionManager {\r\n public readonly type = \"GoogleMapsSessionManager\";\r\n public abstract createSession (sessionOptions: GoogleMapsCreateSessionOptions): Promise<GoogleMapsSession>;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapInfoIcon.js","sourceRoot":"","sources":["../../../src/Icons/MapInfoIcon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gBAAgB;AACH,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,goCAAgoC;CACjoC,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\n/** @internal */\nexport const mapInfoIcon = {\n dataUri: \"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTUuODYyIDUuMTYyYTEuNDg4IDEuNDg4IDAgMSAxLTIuOTc1IDAgMS40ODggMS40ODggMCAwIDEgMi45NzUgMFpNMTIgN2MuNzEyIDAgMS4zODcuMTU0IDIgLjQyMlYwaC0xLjA1bC0yLjI3OCA3LjIwMUE0Ljk1IDQuOTUgMCAwIDEgMTIgN1ptLTQuNzkyIDYuMzQ5TDcgMTRIMFYwaDExLjQ2M0w4Ljg3MiA4LjEyOUM3LjczOSA5LjA0NSA3IDEwLjQyOSA3IDEyYzAgLjQ3LjA4Ni45MTcuMjA4IDEuMzQ5Wm0tLjAzMy04LjE4N1Y1LjA5YTIuNzY0IDIuNzY0IDAgMCAwLTIuODcyLTIuNzI4IDIuNzY0IDIuNzY0IDAgMCAwLTIuNzI4IDIuOEE2LjkwMyA2LjkwMyAwIDAgMCAyLjggOC4zMTJjLjQ3NC44NzcgMSAxLjcyNCAxLjU3NSAyLjUzOCAwIDAgLjk2My0xLjQ4OCAxLjU3NS0yLjUzN2E2LjkwMyA2LjkwMyAwIDAgMCAxLjIyNS0zLjE1Wk0xNiAxMmE0IDQgMCAxIDEtOCAwIDQgNCAwIDAgMSA4IDBabS00LjA1LTEuODVhLjQ2OS40NjkgMCAwIDAgLjUuNS42NTUuNjU1IDAgMCAwIC42NS0uNmwtLjAwMi0uMDMyQS40Ni40NiAwIDAgMCAxMi42IDkuNmEuNjE1LjYxNSAwIDAgMC0uNjUuNTVabTEuMTUgMy40NS0uMTUtLjJhMSAxIDAgMCAxLS41NS4zYy0uMSAwLS4xLS4wNS0uMDUtLjNsLjM1LTEuM2MuMTUtLjUuMS0uOC0uMTUtLjhhMy4yNSAzLjI1IDAgMCAwLTEuNjUuOGwuMS4yNWMuMTk4LS4xMjUuNDItLjIxLjY1LS4yNS4wNSAwIC4wNS4wNSAwIC4yNWwtLjMgMS4yYy0uMi43IDAgLjg1LjI1Ljg1YTIuODg1IDIuODg1IDAgMCAwIDEuNS0uOFoiLz48L3N2Zz4=\",\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"MapInfoIcon.js","sourceRoot":"","sources":["../../../src/Icons/MapInfoIcon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gBAAgB;AACH,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,goCAAgoC;CACjoC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @internal */\r\nexport const mapInfoIcon = {\r\n dataUri: \"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+PHBhdGggZD0iTTUuODYyIDUuMTYyYTEuNDg4IDEuNDg4IDAgMSAxLTIuOTc1IDAgMS40ODggMS40ODggMCAwIDEgMi45NzUgMFpNMTIgN2MuNzEyIDAgMS4zODcuMTU0IDIgLjQyMlYwaC0xLjA1bC0yLjI3OCA3LjIwMUE0Ljk1IDQuOTUgMCAwIDEgMTIgN1ptLTQuNzkyIDYuMzQ5TDcgMTRIMFYwaDExLjQ2M0w4Ljg3MiA4LjEyOUM3LjczOSA5LjA0NSA3IDEwLjQyOSA3IDEyYzAgLjQ3LjA4Ni45MTcuMjA4IDEuMzQ5Wm0tLjAzMy04LjE4N1Y1LjA5YTIuNzY0IDIuNzY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E,MAAM,CAAC,gBAAgB,CAAC,CAAC;gBACtF,cAAc,GAAG,IAAA,iCAAiB,EAAC,cAAc,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC;gBAC9E,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;gBAC7C,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;oBACpC,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBACxC,MAAM,GAAG,oCAAoB,CAAC,KAAK,CAAC;gBACtC,CAAC;YAEH,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAE/B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,GAAG,oCAAoB,CAAC,UAAU,CAAC;YACzC,IAAI,GAAG,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,oCAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,oCAAoB,CAAC,WAAW,CAAC,CAAC;YACjH,CAAC;YACD,OAAO,EAAE,MAAM,EAAC,CAAC;QACnB,CAAC;IACH,CAAC;;AA1FH,oEA2FC","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 { ImageMapLayerSettings, MapSubLayerProps } from \"@itwin/core-common\";\nimport { appendQueryParams, ImageryMapLayerFormat, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, setBasicAuthorization, ValidateSourceArgs } from \"@itwin/core-frontend\";\nimport { OgcApiFeaturesProvider } from \"./OgcApiFeaturesProvider.js\";\n\n/** @internal */\nexport class OgcApiFeaturesMapLayerFormat extends ImageryMapLayerFormat {\n public static override formatId = \"OgcApiFeatures\";\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined { return new OgcApiFeaturesProvider(settings); }\n\n public static override async validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation> {\n\n const {source} = args;\n const { userName, password } = source;\n let status = MapLayerSourceStatus.InvalidUrl;\n try {\n\n let headers: Headers | undefined;\n if (userName && password) {\n headers = new Headers();\n setBasicAuthorization(headers, userName, password);\n }\n const opts: RequestInit = {\n method: \"GET\",\n headers,\n };\n\n let url = appendQueryParams(source.url, source.savedQueryParams);\n url = appendQueryParams(url, source.unsavedQueryParams);\n let response = await fetch(url, opts);\n let json = await response.json();\n if (!json) {\n return { status };\n }\n\n const createCollectionsList = (data: any) => {\n let array: MapSubLayerProps[] | undefined;\n for (const collection of data.collections) {\n if (collection.itemType === \"feature\") {\n const subLayerProps = {\n id: collection.id,\n name: collection.id,\n title: collection.title,\n visible: true,\n parent: undefined,\n children: undefined,\n };\n if (array)\n array.push(subLayerProps);\n else\n array = [subLayerProps];\n }\n }\n return array;\n };\n\n let subLayers: MapSubLayerProps[] | undefined;\n if (Array.isArray(json.collections)) {\n subLayers = createCollectionsList(json);\n status = MapLayerSourceStatus.Valid;\n } else if (json.itemType === \"feature\" || json.type === \"FeatureCollection\") {\n // We expect one of the following URL:\n // http://server/collections/<collectionName>\n // http://server/collections/<collectionName>/items\n subLayers = [{\n id: json.id,\n name: json.id,\n title: json.title,\n visible: true,\n parent: undefined,\n children: undefined,\n }];\n status = MapLayerSourceStatus.Valid;\n } else if (Array.isArray(json.links)) {\n // This might be the main landing page\n const collectionsLink = json.links.find((link: any)=> link.rel.includes(\"data\") && link.type === \"application/json\");\n let collectionsUrl = appendQueryParams(collectionsLink.href, source.savedQueryParams);\n collectionsUrl = appendQueryParams(collectionsUrl, source.unsavedQueryParams);\n response = await fetch(collectionsUrl, opts);\n json = await response.json();\n if (Array.isArray(json.collections)) {\n subLayers = createCollectionsList(json);\n status = MapLayerSourceStatus.Valid;\n }\n\n }\n\n return { status, subLayers };\n\n } catch (err: any) {\n status = MapLayerSourceStatus.InvalidUrl;\n if (err?.status === 401) {\n status = ((userName && password) ? MapLayerSourceStatus.InvalidCredentials : MapLayerSourceStatus.RequireAuth);\n }\n return { status};\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":";;;AAKA,wDAAoM;AACpM,2EAAqE;AAErE,gBAAgB;AAChB,MAAa,4BAA6B,SAAQ,qCAAqB;IAC9D,MAAM,CAAU,QAAQ,GAAG,gBAAgB,CAAC;IAC5C,MAAM,CAAU,qBAAqB,CAAC,QAA+B,IAAyC,OAAO,IAAI,kDAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5J,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,IAAwB;QAE5D,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;QACtB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACtC,IAAI,MAAM,GAAG,oCAAoB,CAAC,UAAU,CAAC;QAC7C,IAAI,CAAC;YAEH,IAAI,OAA4B,CAAC;YACjC,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBACzB,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;gBACxB,IAAA,qCAAqB,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,GAAgB;gBACxB,MAAM,EAAE,KAAK;gBACb,OAAO;aACR,CAAC;YAEF,IAAI,GAAG,GAAG,IAAA,iCAAiB,EAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACjE,GAAG,GAAG,IAAA,iCAAiB,EAAC,GAAG,EAAE,MAAM,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AC;gBACxB,MAAM,GAAG,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,oCAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,oCAAoB,CAAC,WAAW,CAAC,CAAC;YACjH,CAAC;YACD,OAAO,EAAE,MAAM,EAAC,CAAC;QACnB,CAAC;IACH,CAAC;;AA1FH,oEA2FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { ImageMapLayerSettings, MapSubLayerProps } from \"@itwin/core-common\";\r\nimport { appendQueryParams, ImageryMapLayerFormat, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, setBasicAuthorization, ValidateSourceArgs } from \"@itwin/core-frontend\";\r\nimport { OgcApiFeaturesProvider } from \"./OgcApiFeaturesProvider.js\";\r\n\r\n/** @internal */\r\nexport class OgcApiFeaturesMapLayerFormat extends ImageryMapLayerFormat {\r\n public static override formatId = \"OgcApiFeatures\";\r\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined { return new OgcApiFeaturesProvider(settings); }\r\n\r\n public static override async validate(args: ValidateSourceArgs): Promise<MapLayerSourceValidation> {\r\n\r\n const {source} = args;\r\n const { userName, password } = source;\r\n let status = MapLayerSourceStatus.InvalidUrl;\r\n try {\r\n\r\n let headers: Headers | undefined;\r\n if (userName && password) {\r\n headers = new Headers();\r\n setBasicAuthorization(headers, userName, password);\r\n }\r\n const opts: RequestInit = {\r\n method: \"GET\",\r\n headers,\r\n };\r\n\r\n let url = appendQueryParams(source.url, source.savedQueryParams);\r\n url = appendQueryParams(url, source.unsavedQueryParams);\r\n let response = await fetch(url, opts);\r\n let json = await response.json();\r\n if (!json) {\r\n return { status };\r\n }\r\n\r\n const createCollectionsList = (data: any) => {\r\n let array: MapSubLayerProps[] | undefined;\r\n for (const collection of data.collections) {\r\n if (collection.itemType === \"feature\") {\r\n const subLayerProps = {\r\n id: collection.id,\r\n name: collection.id,\r\n title: collection.title,\r\n visible: true,\r\n parent: undefined,\r\n children: undefined,\r\n };\r\n if (array)\r\n array.push(subLayerProps);\r\n else\r\n array = [subLayerProps];\r\n }\r\n }\r\n return array;\r\n };\r\n\r\n let subLayers: MapSubLayerProps[] | undefined;\r\n if (Array.isArray(json.collections)) {\r\n subLayers = createCollectionsList(json);\r\n status = MapLayerSourceStatus.Valid;\r\n } else if (json.itemType === \"feature\" || json.type === \"FeatureCollection\") {\r\n // We expect one of the following URL:\r\n // http://server/collections/<collectionName>\r\n // http://server/collections/<collectionName>/items\r\n subLayers = [{\r\n id: json.id,\r\n name: json.id,\r\n title: json.title,\r\n visible: true,\r\n parent: undefined,\r\n children: undefined,\r\n }];\r\n status = MapLayerSourceStatus.Valid;\r\n } else if (Array.isArray(json.links)) {\r\n // This might be the main landing page\r\n const collectionsLink = json.links.find((link: any)=> link.rel.includes(\"data\") && link.type === \"application/json\");\r\n let collectionsUrl = appendQueryParams(collectionsLink.href, source.savedQueryParams);\r\n collectionsUrl = appendQueryParams(collectionsUrl, source.unsavedQueryParams);\r\n response = await fetch(collectionsUrl, opts);\r\n json = await response.json();\r\n if (Array.isArray(json.collections)) {\r\n subLayers = createCollectionsList(json);\r\n status = MapLayerSourceStatus.Valid;\r\n }\r\n\r\n }\r\n\r\n return { status, subLayers };\r\n\r\n } catch (err: any) {\r\n status = MapLayerSourceStatus.InvalidUrl;\r\n if (err?.status === 401) {\r\n status = ((userName && password) ? MapLayerSourceStatus.InvalidCredentials : MapLayerSourceStatus.RequireAuth);\r\n }\r\n return { status};\r\n }\r\n }\r\n}\r\n"]}
|