@itwin/map-layers-formats 5.1.0-dev.9 → 5.1.0
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 +75 -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 +18 -16
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/map-layers-formats",
|
|
3
|
-
"version": "5.1.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Enables additional map-layers formats in iTwin.js",
|
|
5
5
|
"main": "lib/cjs/map-layers-formats.js",
|
|
6
6
|
"module": "lib/esm/map-layers-formats.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"import": "./lib/esm/map-layers-formats.js",
|
|
12
12
|
"require": "./lib/cjs/map-layers-formats.js"
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
14
15
|
},
|
|
15
16
|
"license": "MIT",
|
|
16
17
|
"repository": {
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"url": "http://www.bentley.com"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@itwin/eslint-plugin": "5.
|
|
33
|
+
"@itwin/eslint-plugin": "5.2.2-dev.2",
|
|
33
34
|
"@types/chai": "4.3.1",
|
|
34
35
|
"@types/chai-as-promised": "^7",
|
|
35
36
|
"@types/geojson": "~7946.0.14",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"chai": "^4.3.10",
|
|
42
43
|
"chai-as-promised": "^7.1.1",
|
|
43
44
|
"cpx2": "^8.0.0",
|
|
44
|
-
"eslint": "^9.
|
|
45
|
+
"eslint": "^9.31.0",
|
|
45
46
|
"jsdom": "^26.0.0",
|
|
46
47
|
"mocha": "^11.1.0",
|
|
47
48
|
"nyc": "^17.1.0",
|
|
@@ -52,20 +53,20 @@
|
|
|
52
53
|
"typemoq": "^2.1.0",
|
|
53
54
|
"typescript": "~5.6.2",
|
|
54
55
|
"fetch-mock": "~11.1.3",
|
|
55
|
-
"@itwin/appui-abstract": "5.1.0
|
|
56
|
-
"@itwin/
|
|
57
|
-
"@itwin/core-
|
|
58
|
-
"@itwin/
|
|
59
|
-
"
|
|
60
|
-
"@itwin/core-
|
|
61
|
-
"
|
|
56
|
+
"@itwin/appui-abstract": "5.1.0",
|
|
57
|
+
"@itwin/build-tools": "5.1.0",
|
|
58
|
+
"@itwin/core-geometry": "5.1.0",
|
|
59
|
+
"@itwin/core-common": "5.1.0",
|
|
60
|
+
"internal-tools": "3.0.0-dev.69",
|
|
61
|
+
"@itwin/core-frontend": "5.1.0",
|
|
62
|
+
"@itwin/core-bentley": "5.1.0"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
|
-
"@itwin/appui-abstract": "5.1.0
|
|
65
|
-
"@itwin/core-
|
|
66
|
-
"@itwin/core-
|
|
67
|
-
"@itwin/core-
|
|
68
|
-
"@itwin/core-
|
|
65
|
+
"@itwin/appui-abstract": "5.1.0",
|
|
66
|
+
"@itwin/core-bentley": "5.1.0",
|
|
67
|
+
"@itwin/core-frontend": "5.1.0",
|
|
68
|
+
"@itwin/core-common": "5.1.0",
|
|
69
|
+
"@itwin/core-geometry": "5.1.0"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
72
|
"google-protobuf": "~3.20.1",
|
|
@@ -102,6 +103,7 @@
|
|
|
102
103
|
"docs": "betools docs --json=../../generated-docs/core/map-layers-formats/file.json --tsIndexFile=./map-layers-formats.ts --onlyJson --excludes=**/ArcGisFeature/*.ts,**/*.gen.ts",
|
|
103
104
|
"extract-api": "betools extract-api --entry=map-layers-formats",
|
|
104
105
|
"lint": "eslint \"./src/**/*.{ts,tsx}\" 1>&2",
|
|
106
|
+
"lint-deprecation": "eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \"./src/**/*.ts\"",
|
|
105
107
|
"pseudolocalize": "betools pseudolocalize --englishDir=./src/public/locales/en --out=./src/public/locales/en-PSEUDO",
|
|
106
108
|
"test": "mocha",
|
|
107
109
|
"rebuild": "npm run -s clean && npm run -s build"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CanvasDecoration, DecorateContext, Decorator, Sprite } from "@itwin/core-frontend";
|
|
2
|
-
import { Point3d } from "@itwin/core-geometry";
|
|
3
|
-
import { GoogleMapsMapTypes } from "./GoogleMaps.js";
|
|
4
|
-
/** A simple decorator that show logo at the a given screen position.
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare class LogoDecoration implements CanvasDecoration {
|
|
8
|
-
private _sprite?;
|
|
9
|
-
/** The current position of the logo in view coordinates. */
|
|
10
|
-
readonly position: Point3d;
|
|
11
|
-
private _offset;
|
|
12
|
-
set offset(offset: Point3d | undefined);
|
|
13
|
-
/** The logo offset in view coordinates.*/
|
|
14
|
-
get offset(): Point3d | undefined;
|
|
15
|
-
/** Move the logo to the lower left corner of the screen. */
|
|
16
|
-
moveToLowerLeftCorner(context: DecorateContext): boolean;
|
|
17
|
-
/** Indicate if the logo is loaded and ready to be drawn. */
|
|
18
|
-
get isLoaded(): boolean;
|
|
19
|
-
activate(sprite: Sprite): Promise<boolean>;
|
|
20
|
-
/** Draw this sprite onto the supplied canvas.
|
|
21
|
-
* @see [[CanvasDecoration.drawDecoration]]
|
|
22
|
-
*/
|
|
23
|
-
drawDecoration(ctx: CanvasRenderingContext2D): void;
|
|
24
|
-
decorate(context: DecorateContext): void;
|
|
25
|
-
}
|
|
26
|
-
/** A decorator that adds the Google Maps logo to the lower left corner of the screen.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare class GoogleMapsDecorator implements Decorator {
|
|
30
|
-
readonly logo: LogoDecoration;
|
|
31
|
-
/** Activate the logo based on the given map type. */
|
|
32
|
-
activate(mapType: GoogleMapsMapTypes): Promise<boolean>;
|
|
33
|
-
/** Decorate implementation */
|
|
34
|
-
decorate: (context: DecorateContext) => void;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=GoogleMapDecorator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapDecorator.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapDecorator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAA0B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;GAEG;AACH,qBAAa,cAAe,YAAW,gBAAgB;IACrD,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,4DAA4D;IAC5D,SAAgB,QAAQ,UAAiB;IAEzC,OAAO,CAAC,OAAO,CAAoB;IAEnC,IAAW,MAAM,CAAC,MAAM,EAAE,OAAO,GAAC,SAAS,EAExC;IAEH,0CAA0C;IAC1C,IAAW,MAAM,IALS,OAAO,GAAC,SAAS,CAO1C;IAED,4DAA4D;IACrD,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAI,OAAO;IAahE,4DAA4D;IAC5D,IAAW,QAAQ,YAA8C;IAEpD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWvD;;OAEG;IACI,cAAc,CAAC,GAAG,EAAE,wBAAwB,GAAG,IAAI;IAOnD,QAAQ,CAAC,OAAO,EAAE,eAAe;CAGzC;AAED;;EAEE;AACF,qBAAa,mBAAoB,YAAW,SAAS;IACnD,SAAgB,IAAI,iBAAwB;IAE5C,qDAAqD;IACxC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpE,8BAA8B;IACvB,QAAQ,YAAa,eAAe,UAKzC;CACH"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GoogleMapsDecorator = exports.LogoDecoration = void 0;
|
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
|
5
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
const core_frontend_1 = require("@itwin/core-frontend");
|
|
9
|
-
const core_geometry_1 = require("@itwin/core-geometry");
|
|
10
|
-
/** A simple decorator that show logo at the a given screen position.
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
class LogoDecoration {
|
|
14
|
-
_sprite;
|
|
15
|
-
/** The current position of the logo in view coordinates. */
|
|
16
|
-
position = new core_geometry_1.Point3d();
|
|
17
|
-
_offset;
|
|
18
|
-
set offset(offset) {
|
|
19
|
-
this._offset = offset;
|
|
20
|
-
}
|
|
21
|
-
/** The logo offset in view coordinates.*/
|
|
22
|
-
get offset() {
|
|
23
|
-
return this._offset;
|
|
24
|
-
}
|
|
25
|
-
/** Move the logo to the lower left corner of the screen. */
|
|
26
|
-
moveToLowerLeftCorner(context) {
|
|
27
|
-
if (!this._sprite || !this._sprite.isLoaded)
|
|
28
|
-
return false;
|
|
29
|
-
this.position.x = this._offset?.x ?? 0;
|
|
30
|
-
this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;
|
|
31
|
-
if (this._offset?.y)
|
|
32
|
-
this.position.y -= this._offset.y;
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
/* TODO: Add other move methods as needed */
|
|
36
|
-
/** Indicate if the logo is loaded and ready to be drawn. */
|
|
37
|
-
get isLoaded() { return this._sprite?.isLoaded ?? false; }
|
|
38
|
-
async activate(sprite) {
|
|
39
|
-
this._sprite = sprite;
|
|
40
|
-
return new Promise((resolve, _reject) => {
|
|
41
|
-
sprite.loadPromise.then(() => {
|
|
42
|
-
resolve(true);
|
|
43
|
-
}).catch(() => {
|
|
44
|
-
resolve(false);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/** Draw this sprite onto the supplied canvas.
|
|
49
|
-
* @see [[CanvasDecoration.drawDecoration]]
|
|
50
|
-
*/
|
|
51
|
-
drawDecoration(ctx) {
|
|
52
|
-
if (this.isLoaded) {
|
|
53
|
-
// Draw image with an origin at the top left corner
|
|
54
|
-
ctx.drawImage(this._sprite.image, 0, 0);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
decorate(context) {
|
|
58
|
-
context.addCanvasDecoration(this);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.LogoDecoration = LogoDecoration;
|
|
62
|
-
/** A decorator that adds the Google Maps logo to the lower left corner of the screen.
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
class GoogleMapsDecorator {
|
|
66
|
-
logo = new LogoDecoration();
|
|
67
|
-
/** Activate the logo based on the given map type. */
|
|
68
|
-
async activate(mapType) {
|
|
69
|
-
// Pick the logo that is the most visible on the background map
|
|
70
|
-
const imageName = mapType === "roadmap" ?
|
|
71
|
-
"google_on_white" :
|
|
72
|
-
"google_on_non_white";
|
|
73
|
-
// We need to move the logo right after the 'i.js' button
|
|
74
|
-
this.logo.offset = new core_geometry_1.Point3d(45, 10);
|
|
75
|
-
return this.logo.activate(core_frontend_1.IconSprites.getSpriteFromUrl(`${core_frontend_1.IModelApp.publicPath}images/${imageName}.png`));
|
|
76
|
-
}
|
|
77
|
-
;
|
|
78
|
-
/** Decorate implementation */
|
|
79
|
-
decorate = (context) => {
|
|
80
|
-
if (!this.logo.isLoaded)
|
|
81
|
-
return;
|
|
82
|
-
this.logo.moveToLowerLeftCorner(context);
|
|
83
|
-
this.logo.decorate(context);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
exports.GoogleMapsDecorator = GoogleMapsDecorator;
|
|
87
|
-
//# sourceMappingURL=GoogleMapDecorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapDecorator.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapDecorator.ts"],"names":[],"mappings":"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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CanvasDecoration, DecorateContext, Decorator, IconSprites, IModelApp, Sprite } from \"@itwin/core-frontend\";\nimport { Point3d } from \"@itwin/core-geometry\";\nimport { GoogleMapsMapTypes } from \"./GoogleMaps.js\";\n\n\n/** A simple decorator that show logo at the a given screen position.\n * @internal\n */\nexport class LogoDecoration implements CanvasDecoration {\n private _sprite?: Sprite;\n\n /** The current position of the logo in view coordinates. */\n public readonly position = new Point3d();\n\n private _offset: Point3d|undefined;\n\n public set offset(offset: Point3d|undefined) {\n this._offset = offset;\n }\n\n /** The logo offset in view coordinates.*/\n public get offset() {\n return this._offset;\n }\n\n /** Move the logo to the lower left corner of the screen. */\n public moveToLowerLeftCorner(context: DecorateContext) : boolean{\n if (!this._sprite || !this._sprite.isLoaded)\n return false;\n\n this.position.x = this._offset?.x ?? 0;\n this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;\n if (this._offset?.y)\n this.position.y -= this._offset.y;\n return true;\n }\n\n /* TODO: Add other move methods as needed */\n\n /** Indicate if the logo is loaded and ready to be drawn. */\n public get isLoaded() { return this._sprite?.isLoaded ?? false; }\n\n public async activate(sprite: Sprite): Promise<boolean> {\n this._sprite = sprite;\n return new Promise<boolean>((resolve, _reject) => {\n sprite.loadPromise.then(() => {\n resolve(true);\n }).catch(() => {\n resolve (false);\n });\n });\n }\n\n /** Draw this sprite onto the supplied canvas.\n * @see [[CanvasDecoration.drawDecoration]]\n */\n public drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (this.isLoaded) {\n // Draw image with an origin at the top left corner\n ctx.drawImage(this._sprite!.image!, 0, 0);\n }\n }\n\n public decorate(context: DecorateContext) {\n context.addCanvasDecoration(this);\n }\n}\n\n/** A decorator that adds the Google Maps logo to the lower left corner of the screen.\n * @internal\n*/\nexport class GoogleMapsDecorator implements Decorator {\n public readonly logo = new LogoDecoration();\n\n /** Activate the logo based on the given map type. */\n public async activate(mapType: GoogleMapsMapTypes): Promise<boolean> {\n // Pick the logo that is the most visible on the background map\n const imageName = mapType === \"roadmap\" ?\n \"google_on_white\" :\n \"google_on_non_white\";\n\n // We need to move the logo right after the 'i.js' button\n this.logo.offset = new Point3d(45, 10);\n\n return this.logo.activate(IconSprites.getSpriteFromUrl(`${IModelApp.publicPath}images/${imageName}.png`));\n };\n\n /** Decorate implementation */\n public decorate = (context: DecorateContext) => {\n if (!this.logo.isLoaded)\n return;\n this.logo.moveToLowerLeftCorner(context);\n this.logo.decorate(context);\n };\n}\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CanvasDecoration, DecorateContext, Decorator, Sprite } from "@itwin/core-frontend";
|
|
2
|
-
import { Point3d } from "@itwin/core-geometry";
|
|
3
|
-
import { GoogleMapsMapTypes } from "./GoogleMaps.js";
|
|
4
|
-
/** A simple decorator that show logo at the a given screen position.
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare class LogoDecoration implements CanvasDecoration {
|
|
8
|
-
private _sprite?;
|
|
9
|
-
/** The current position of the logo in view coordinates. */
|
|
10
|
-
readonly position: Point3d;
|
|
11
|
-
private _offset;
|
|
12
|
-
set offset(offset: Point3d | undefined);
|
|
13
|
-
/** The logo offset in view coordinates.*/
|
|
14
|
-
get offset(): Point3d | undefined;
|
|
15
|
-
/** Move the logo to the lower left corner of the screen. */
|
|
16
|
-
moveToLowerLeftCorner(context: DecorateContext): boolean;
|
|
17
|
-
/** Indicate if the logo is loaded and ready to be drawn. */
|
|
18
|
-
get isLoaded(): boolean;
|
|
19
|
-
activate(sprite: Sprite): Promise<boolean>;
|
|
20
|
-
/** Draw this sprite onto the supplied canvas.
|
|
21
|
-
* @see [[CanvasDecoration.drawDecoration]]
|
|
22
|
-
*/
|
|
23
|
-
drawDecoration(ctx: CanvasRenderingContext2D): void;
|
|
24
|
-
decorate(context: DecorateContext): void;
|
|
25
|
-
}
|
|
26
|
-
/** A decorator that adds the Google Maps logo to the lower left corner of the screen.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare class GoogleMapsDecorator implements Decorator {
|
|
30
|
-
readonly logo: LogoDecoration;
|
|
31
|
-
/** Activate the logo based on the given map type. */
|
|
32
|
-
activate(mapType: GoogleMapsMapTypes): Promise<boolean>;
|
|
33
|
-
/** Decorate implementation */
|
|
34
|
-
decorate: (context: DecorateContext) => void;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=GoogleMapDecorator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapDecorator.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapDecorator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAA0B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;GAEG;AACH,qBAAa,cAAe,YAAW,gBAAgB;IACrD,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB,4DAA4D;IAC5D,SAAgB,QAAQ,UAAiB;IAEzC,OAAO,CAAC,OAAO,CAAoB;IAEnC,IAAW,MAAM,CAAC,MAAM,EAAE,OAAO,GAAC,SAAS,EAExC;IAEH,0CAA0C;IAC1C,IAAW,MAAM,IALS,OAAO,GAAC,SAAS,CAO1C;IAED,4DAA4D;IACrD,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAI,OAAO;IAahE,4DAA4D;IAC5D,IAAW,QAAQ,YAA8C;IAEpD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWvD;;OAEG;IACI,cAAc,CAAC,GAAG,EAAE,wBAAwB,GAAG,IAAI;IAOnD,QAAQ,CAAC,OAAO,EAAE,eAAe;CAGzC;AAED;;EAEE;AACF,qBAAa,mBAAoB,YAAW,SAAS;IACnD,SAAgB,IAAI,iBAAwB;IAE5C,qDAAqD;IACxC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpE,8BAA8B;IACvB,QAAQ,YAAa,eAAe,UAKzC;CACH"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { IconSprites, IModelApp } from "@itwin/core-frontend";
|
|
6
|
-
import { Point3d } from "@itwin/core-geometry";
|
|
7
|
-
/** A simple decorator that show logo at the a given screen position.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export class LogoDecoration {
|
|
11
|
-
_sprite;
|
|
12
|
-
/** The current position of the logo in view coordinates. */
|
|
13
|
-
position = new Point3d();
|
|
14
|
-
_offset;
|
|
15
|
-
set offset(offset) {
|
|
16
|
-
this._offset = offset;
|
|
17
|
-
}
|
|
18
|
-
/** The logo offset in view coordinates.*/
|
|
19
|
-
get offset() {
|
|
20
|
-
return this._offset;
|
|
21
|
-
}
|
|
22
|
-
/** Move the logo to the lower left corner of the screen. */
|
|
23
|
-
moveToLowerLeftCorner(context) {
|
|
24
|
-
if (!this._sprite || !this._sprite.isLoaded)
|
|
25
|
-
return false;
|
|
26
|
-
this.position.x = this._offset?.x ?? 0;
|
|
27
|
-
this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;
|
|
28
|
-
if (this._offset?.y)
|
|
29
|
-
this.position.y -= this._offset.y;
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
/* TODO: Add other move methods as needed */
|
|
33
|
-
/** Indicate if the logo is loaded and ready to be drawn. */
|
|
34
|
-
get isLoaded() { return this._sprite?.isLoaded ?? false; }
|
|
35
|
-
async activate(sprite) {
|
|
36
|
-
this._sprite = sprite;
|
|
37
|
-
return new Promise((resolve, _reject) => {
|
|
38
|
-
sprite.loadPromise.then(() => {
|
|
39
|
-
resolve(true);
|
|
40
|
-
}).catch(() => {
|
|
41
|
-
resolve(false);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/** Draw this sprite onto the supplied canvas.
|
|
46
|
-
* @see [[CanvasDecoration.drawDecoration]]
|
|
47
|
-
*/
|
|
48
|
-
drawDecoration(ctx) {
|
|
49
|
-
if (this.isLoaded) {
|
|
50
|
-
// Draw image with an origin at the top left corner
|
|
51
|
-
ctx.drawImage(this._sprite.image, 0, 0);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
decorate(context) {
|
|
55
|
-
context.addCanvasDecoration(this);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/** A decorator that adds the Google Maps logo to the lower left corner of the screen.
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
export class GoogleMapsDecorator {
|
|
62
|
-
logo = new LogoDecoration();
|
|
63
|
-
/** Activate the logo based on the given map type. */
|
|
64
|
-
async activate(mapType) {
|
|
65
|
-
// Pick the logo that is the most visible on the background map
|
|
66
|
-
const imageName = mapType === "roadmap" ?
|
|
67
|
-
"google_on_white" :
|
|
68
|
-
"google_on_non_white";
|
|
69
|
-
// We need to move the logo right after the 'i.js' button
|
|
70
|
-
this.logo.offset = new Point3d(45, 10);
|
|
71
|
-
return this.logo.activate(IconSprites.getSpriteFromUrl(`${IModelApp.publicPath}images/${imageName}.png`));
|
|
72
|
-
}
|
|
73
|
-
;
|
|
74
|
-
/** Decorate implementation */
|
|
75
|
-
decorate = (context) => {
|
|
76
|
-
if (!this.logo.isLoaded)
|
|
77
|
-
return;
|
|
78
|
-
this.logo.moveToLowerLeftCorner(context);
|
|
79
|
-
this.logo.decorate(context);
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=GoogleMapDecorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapDecorator.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapDecorator.ts"],"names":[],"mappings":"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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { CanvasDecoration, DecorateContext, Decorator, IconSprites, IModelApp, Sprite } from \"@itwin/core-frontend\";\nimport { Point3d } from \"@itwin/core-geometry\";\nimport { GoogleMapsMapTypes } from \"./GoogleMaps.js\";\n\n\n/** A simple decorator that show logo at the a given screen position.\n * @internal\n */\nexport class LogoDecoration implements CanvasDecoration {\n private _sprite?: Sprite;\n\n /** The current position of the logo in view coordinates. */\n public readonly position = new Point3d();\n\n private _offset: Point3d|undefined;\n\n public set offset(offset: Point3d|undefined) {\n this._offset = offset;\n }\n\n /** The logo offset in view coordinates.*/\n public get offset() {\n return this._offset;\n }\n\n /** Move the logo to the lower left corner of the screen. */\n public moveToLowerLeftCorner(context: DecorateContext) : boolean{\n if (!this._sprite || !this._sprite.isLoaded)\n return false;\n\n this.position.x = this._offset?.x ?? 0;\n this.position.y = context.viewport.parentDiv.clientHeight - this._sprite.size.y;\n if (this._offset?.y)\n this.position.y -= this._offset.y;\n return true;\n }\n\n /* TODO: Add other move methods as needed */\n\n /** Indicate if the logo is loaded and ready to be drawn. */\n public get isLoaded() { return this._sprite?.isLoaded ?? false; }\n\n public async activate(sprite: Sprite): Promise<boolean> {\n this._sprite = sprite;\n return new Promise<boolean>((resolve, _reject) => {\n sprite.loadPromise.then(() => {\n resolve(true);\n }).catch(() => {\n resolve (false);\n });\n });\n }\n\n /** Draw this sprite onto the supplied canvas.\n * @see [[CanvasDecoration.drawDecoration]]\n */\n public drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (this.isLoaded) {\n // Draw image with an origin at the top left corner\n ctx.drawImage(this._sprite!.image!, 0, 0);\n }\n }\n\n public decorate(context: DecorateContext) {\n context.addCanvasDecoration(this);\n }\n}\n\n/** A decorator that adds the Google Maps logo to the lower left corner of the screen.\n * @internal\n*/\nexport class GoogleMapsDecorator implements Decorator {\n public readonly logo = new LogoDecoration();\n\n /** Activate the logo based on the given map type. */\n public async activate(mapType: GoogleMapsMapTypes): Promise<boolean> {\n // Pick the logo that is the most visible on the background map\n const imageName = mapType === \"roadmap\" ?\n \"google_on_white\" :\n \"google_on_non_white\";\n\n // We need to move the logo right after the 'i.js' button\n this.logo.offset = new Point3d(45, 10);\n\n return this.logo.activate(IconSprites.getSpriteFromUrl(`${IModelApp.publicPath}images/${imageName}.png`));\n };\n\n /** Decorate implementation */\n public decorate = (context: DecorateContext) => {\n if (!this.logo.isLoaded)\n return;\n this.logo.moveToLowerLeftCorner(context);\n this.logo.decorate(context);\n };\n}\n"]}
|