@itwin/map-layers-formats 5.0.0-dev.7 → 5.0.0-dev.70
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 +31 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js +43 -40
- package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureQuery.js +17 -0
- package/lib/cjs/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js +2 -0
- package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisFeatureResponse.js +3 -0
- package/lib/cjs/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js +1 -0
- package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
- package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js +37 -32
- package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
- package/lib/cjs/ArcGisFeature/EsriSymbology.js +26 -5
- package/lib/cjs/ArcGisFeature/EsriSymbology.js.map +1 -1
- package/lib/cjs/ArcGisFeature/esriPBuffer.gen.js +48 -72
- 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 +2 -0
- package/lib/cjs/Feature/FeatureCanvasRenderer.js.map +1 -1
- package/lib/cjs/Feature/FeatureInfoReader.js +20 -20
- package/lib/cjs/Feature/FeatureInfoReader.js.map +1 -1
- package/lib/cjs/Feature/FeatureSymbology.js.map +1 -1
- package/lib/cjs/Feature/RandomMapColor.js +10 -10
- package/lib/cjs/Feature/RandomMapColor.js.map +1 -1
- package/lib/cjs/GeoJSON/GeoJSONGeometry.js.map +1 -1
- package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js +1 -0
- package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js.map +1 -1
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts +36 -0
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.js +83 -0
- package/lib/cjs/GoogleMaps/GoogleMapDecorator.js.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.d.ts +166 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.js +56 -0
- package/lib/cjs/GoogleMaps/GoogleMaps.js.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts +10 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js +20 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts +25 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js +232 -0
- package/lib/cjs/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -0
- package/lib/cjs/Icons/MapInfoIcon.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js +41 -34
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js +1 -0
- package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.d.ts +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.d.ts.map +1 -1
- package/lib/cjs/Tools/GeometryTerrainDraper.js +10 -6
- package/lib/cjs/Tools/GeometryTerrainDraper.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js +56 -52
- package/lib/cjs/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/cjs/Tools/MapFeatureInfoTool.js +13 -16
- package/lib/cjs/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/cjs/internal/GoogleMapsUtils.d.ts +38 -0
- package/lib/cjs/internal/GoogleMapsUtils.d.ts.map +1 -0
- package/lib/cjs/internal/GoogleMapsUtils.js +104 -0
- package/lib/cjs/internal/GoogleMapsUtils.js.map +1 -0
- package/lib/cjs/map-layers-formats.d.ts +1 -0
- package/lib/cjs/map-layers-formats.d.ts.map +1 -1
- package/lib/cjs/map-layers-formats.js +1 -0
- package/lib/cjs/map-layers-formats.js.map +1 -1
- package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
- package/lib/cjs/mapLayersFormats.js +4 -1
- package/lib/cjs/mapLayersFormats.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js +43 -40
- package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureQuery.js +17 -0
- package/lib/esm/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js +2 -0
- package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisFeatureResponse.js +3 -0
- package/lib/esm/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js +1 -0
- package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
- package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js +37 -32
- package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
- package/lib/esm/ArcGisFeature/EsriSymbology.js +26 -5
- package/lib/esm/ArcGisFeature/EsriSymbology.js.map +1 -1
- package/lib/esm/ArcGisFeature/esriPBuffer.gen.js +48 -72
- 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 +2 -0
- package/lib/esm/Feature/FeatureCanvasRenderer.js.map +1 -1
- package/lib/esm/Feature/FeatureInfoReader.js +20 -20
- package/lib/esm/Feature/FeatureInfoReader.js.map +1 -1
- package/lib/esm/Feature/FeatureSymbology.js.map +1 -1
- package/lib/esm/Feature/RandomMapColor.js +10 -10
- package/lib/esm/Feature/RandomMapColor.js.map +1 -1
- package/lib/esm/GeoJSON/GeoJSONGeometry.js.map +1 -1
- package/lib/esm/GeoJSON/GeoJSONGeometryReader.js +1 -0
- package/lib/esm/GeoJSON/GeoJSONGeometryReader.js.map +1 -1
- package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts +36 -0
- package/lib/esm/GoogleMaps/GoogleMapDecorator.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapDecorator.js +78 -0
- package/lib/esm/GoogleMaps/GoogleMapDecorator.js.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMaps.d.ts +166 -0
- package/lib/esm/GoogleMaps/GoogleMaps.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMaps.js +53 -0
- package/lib/esm/GoogleMaps/GoogleMaps.js.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts +10 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js +16 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryFormat.js.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts +25 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.d.ts.map +1 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js +228 -0
- package/lib/esm/GoogleMaps/GoogleMapsImageryProvider.js.map +1 -0
- package/lib/esm/Icons/MapInfoIcon.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js +41 -34
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -1
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js +1 -0
- package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.d.ts +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.d.ts.map +1 -1
- package/lib/esm/Tools/GeometryTerrainDraper.js +10 -6
- package/lib/esm/Tools/GeometryTerrainDraper.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoDecorator.js +56 -52
- package/lib/esm/Tools/MapFeatureInfoDecorator.js.map +1 -1
- package/lib/esm/Tools/MapFeatureInfoTool.js +13 -16
- package/lib/esm/Tools/MapFeatureInfoTool.js.map +1 -1
- package/lib/esm/internal/GoogleMapsUtils.d.ts +38 -0
- package/lib/esm/internal/GoogleMapsUtils.d.ts.map +1 -0
- package/lib/esm/internal/GoogleMapsUtils.js +101 -0
- package/lib/esm/internal/GoogleMapsUtils.js.map +1 -0
- package/lib/esm/map-layers-formats.d.ts +1 -0
- package/lib/esm/map-layers-formats.d.ts.map +1 -1
- package/lib/esm/map-layers-formats.js +1 -0
- package/lib/esm/map-layers-formats.js.map +1 -1
- package/lib/esm/mapLayersFormats.d.ts.map +1 -1
- package/lib/esm/mapLayersFormats.js +4 -1
- package/lib/esm/mapLayersFormats.js.map +1 -1
- package/lib/public/images/google_on_non_white.png +0 -0
- package/lib/public/images/google_on_non_white_hdpi.png +0 -0
- package/lib/public/images/google_on_white.png +0 -0
- package/lib/public/images/google_on_white_hdpi.png +0 -0
- package/lib/public/locales/en/mapLayersFormats.json +18 -18
- package/package.json +13 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMaps.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMaps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiF;AAEjF,iEAA8D;AAkF7D,CAAC;AAqBD,CAAC;AA4CF;;;EAGE;AACF,gEAAgE;AACnD,QAAA,UAAU,GAAG;IAC1B;;;;;;;;;;;;;MAaE;IACA,sBAAsB,EAAE,CAAC,IAAa,EAAE,IAAqC,EAAE,EAAE;QAC/E,OAAO,mCAAqB,CAAC,QAAQ,CAAC,iCAAe,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACzF,CAAC;IAEH;;;;;;;;;;;;;MAaE;IACA,uBAAuB,EAAE,CAAC,IAAqC,EAAE,EAAE;QACjE,OAAO,kCAAoB,CAAC,QAAQ,CAAC,iCAAe,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAChG,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { BaseMapLayerSettings, ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { MapCartoRectangle } from \"@itwin/core-frontend\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils\";\n\n\n/**\n * The type of base map.\n * @beta*/\nexport type GoogleMapsLayerTypes = \"layerRoadmap\" | \"layerStreetview\";\n\n/**\n * Layer types that can be added to the map.\n * @beta\n * */\nexport type GoogleMapsMapTypes = \"roadmap\"|\"satellite\"|\"terrain\";\n\n/**\n * Scale factors that can be applied to labels and objects in the map.\n * @beta\n * */\nexport type GoogleMapsScaleFactors = \"scaleFactor1x\" | \"scaleFactor2x\" | \"scaleFactor4x\";\n\n/**\n* Represents the options to create a Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsCreateSessionOptions {\n /**\n * The type of base map.\n *\n * `roadmap`: The standard Google Maps painted map tiles.\n *\n * `satellite`: Satellite imagery.\n *\n * `terrain`: Terrain imagery. When selecting `terrain` as the map type, you must also include the `layerRoadmap` layer type.\n * @beta\n * */\n mapType: GoogleMapsMapTypes,\n /**\n * An {@link https://en.wikipedia.org/wiki/IETF_language_tag | IETF language tag} that specifies the language used to display information on the tiles. For example, `en-US` specifies the English language as spoken in the United States.\n */\n language: string;\n /**\n * A {@link https://cldr.unicode.org/ | Common Locale Data Repository} region identifier (two uppercase letters) that represents the physical location of the user. For example, `US`.\n */\n region: string;\n\n /**\n * An array of values that specifies the layer types added to the map.\n *\n * `layerRoadmap`: Required if you specify terrain as the map type. Can also be optionally overlaid on the satellite map type. Has no effect on roadmap tiles.\n *\n * `layerStreetview`: Shows Street View-enabled streets and locations using blue outlines on the map.\n *\n * @beta\n * */\n layerTypes?: GoogleMapsLayerTypes[];\n\n /**\n * Scales-up the size of map elements (such as road labels), while retaining the tile size and coverage area of the default tile.\n * Increasing the scale also reduces the number of labels on the map, which reduces clutter.\n *\n * `scaleFactor1x`: The default.\n *\n * `scaleFactor2x`: Doubles label size and removes minor feature labels.\n *\n * `scaleFactor4x`: Quadruples label size and removes minor feature labels.\n * @beta\n * */\n scale?: GoogleMapsScaleFactors\n\n /**\n * A boolean value that specifies whether layerTypes should be rendered as a separate overlay, or combined with the base imagery.\n * When true, the base map isn't displayed. If you haven't defined any layerTypes, then this value is ignored.\n * Default is false.\n * @beta\n * */\n overlay? : boolean;\n\n /**\n * An array of values specifying additional options to apply.\n * @beta\n * */\n apiOptions?: string[];\n};\n\n/**\n* Structure representing a Google Maps session.\n* @beta\n*/\nexport interface GoogleMapsSession {\n /** A session token value that you must include in all of your Map Tiles API requests. */\n session: string;\n\n /** string that contains the time (in seconds since the epoch) at which the token expires. A session token is valid for two weeks from its creation time, but this policy might change without notice. */\n expiry: number;\n\n /** The width of the tiles measured in pixels. */\n tileWidth: number;\n\n /** he height of the tiles measured in pixels. */\n tileHeight: number;\n\n /** The image format, which can be either `png` or `jpeg`. */\n imageFormat: string;\n};\n\n/**\n * Represents the maximum zoom level available within a bounding rectangle.\n* @beta\n*/\nexport interface MaxZoomRectangle {\n maxZoom: number;\n north: number;\n south: number;\n east: number;\n west: number;\n}\n\n/**\n * Indicate which areas of given viewport have imagery, and at which zoom levels.\n * @beta\n*/\nexport interface ViewportInfo {\n /** Attribution string that you must display on your map when you display roadmap and satellite tiles. */\n copyright: string;\n\n /** Array of bounding rectangles that overlap with the current viewport. Also contains the maximum zoom level available within each rectangle.. */\n maxZoomRects: MaxZoomRectangle[];\n}\n\n/**\n * Request parameters for the getViewportInfo method.\n * @beta\n*/\nexport interface ViewportInfoRequestParams {\n /** Bounding rectangle */\n rectangle: MapCartoRectangle;\n\n /** Session token */\n session: string;\n\n /** The Google Cloud API key */\n key: string;\n\n /** Zoom level of the viewport */\n zoom: number;\n}\n\n/**\n * Google Maps API\n * @beta\n*/\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const GoogleMaps = {\n/**\n * Creates Google Maps map-layer settings.\n * @param name Name of the layer (Defaults to \"GoogleMaps\")\n * @param opts Options to create the session (Defaults to satellite map type, English language, US region, and roadmap layer type)\n *\n * The following examples illustrates how a Googles Map layer can be attached to a viewport:\n * ```ts\n * [[include:GoogleMaps_AttachMapLayerSimple]]\n * ```\n * ```ts\n * [[include:GoogleMaps_AttachMapLayerOpts]]\n * ```\n * @beta\n*/\n createMapLayerSettings: (name?: string, opts?: GoogleMapsCreateSessionOptions) => {\n return ImageMapLayerSettings.fromJSON(GoogleMapsUtils.createMapLayerProps(name, opts));\n },\n\n/**\n * Creates Google Maps base layer settings.\n * @param name Name of the layer (Defaults to \"GoogleMaps\")\n * @param opts Options to create the session (Defaults to satellite map type, English language, US region, and roadmap layer type)\n *\n * The following examples illustrates how a Google Maps base layer can be set on a viewport:\n * ```ts\n * [[include:GoogleMaps_BaseMapSimple]]\n * ```\n * ```ts\n * [[include:GoogleMaps_BaseMapOpts]]\n * ```\n * @beta\n*/\n createBaseLayerSettings: (opts?: GoogleMapsCreateSessionOptions) => {\n return BaseMapLayerSettings.fromJSON(GoogleMapsUtils.createMapLayerProps(\"GoogleMaps\", opts));\n }\n};"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module MapLayersFormats
|
|
3
|
+
*/
|
|
4
|
+
import { ImageMapLayerSettings } from "@itwin/core-common";
|
|
5
|
+
import { ImageryMapLayerFormat, MapLayerImageryProvider } from "@itwin/core-frontend";
|
|
6
|
+
export declare class GoogleMapsMapLayerFormat extends ImageryMapLayerFormat {
|
|
7
|
+
static formatId: string;
|
|
8
|
+
static createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=GoogleMapsImageryFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryFormat.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGtF,qBAAa,wBAAyB,SAAQ,qBAAqB;IACjE,OAAuB,QAAQ,SAAgB;WACxB,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,uBAAuB,GAAG,SAAS;CAGnH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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.GoogleMapsMapLayerFormat = void 0;
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const GoogleMapsImageryProvider_1 = require("./GoogleMapsImageryProvider");
|
|
13
|
+
class GoogleMapsMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat {
|
|
14
|
+
static formatId = "GoogleMaps";
|
|
15
|
+
static createImageryProvider(settings) {
|
|
16
|
+
return new GoogleMapsImageryProvider_1.GoogleMapsImageryProvider(settings);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.GoogleMapsMapLayerFormat = GoogleMapsMapLayerFormat;
|
|
20
|
+
//# sourceMappingURL=GoogleMapsImageryFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryFormat.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAAsF;AACtF,2EAAwE;AAExE,MAAa,wBAAyB,SAAQ,qCAAqB;IAC1D,MAAM,CAAU,QAAQ,GAAG,YAAY,CAAC;IACxC,MAAM,CAAU,qBAAqB,CAAC,QAA+B;QAC1E,OAAO,IAAI,qDAAyB,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;;AAJH,4DAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module MapLayersFormats\n */\n\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { ImageryMapLayerFormat, MapLayerImageryProvider } from \"@itwin/core-frontend\";\nimport { GoogleMapsImageryProvider } from \"./GoogleMapsImageryProvider\";\n\nexport class GoogleMapsMapLayerFormat extends ImageryMapLayerFormat {\n public static override formatId = \"GoogleMaps\";\n public static override createImageryProvider(settings: ImageMapLayerSettings): MapLayerImageryProvider | undefined {\n return new GoogleMapsImageryProvider(settings);\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module MapLayersFormats
|
|
3
|
+
*/
|
|
4
|
+
import { ImageMapLayerSettings, ImageSource } from "@itwin/core-common";
|
|
5
|
+
import { DecorateContext, MapLayerImageryProvider, MapLayerSourceValidation, ScreenViewport } from "@itwin/core-frontend";
|
|
6
|
+
import { GoogleMapsSession } from "./GoogleMaps";
|
|
7
|
+
export declare class GoogleMapsImageryProvider extends MapLayerImageryProvider {
|
|
8
|
+
private _decorator;
|
|
9
|
+
private _hadUnrecoverableError;
|
|
10
|
+
private _tileSize;
|
|
11
|
+
constructor(settings: ImageMapLayerSettings);
|
|
12
|
+
static validateUrlTemplate(template: string): MapLayerSourceValidation;
|
|
13
|
+
protected createSession(): Promise<GoogleMapsSession | undefined>;
|
|
14
|
+
get tileSize(): number;
|
|
15
|
+
initialize(): Promise<void>;
|
|
16
|
+
private createCreateSessionOptions;
|
|
17
|
+
constructUrl(row: number, column: number, level: number): Promise<string>;
|
|
18
|
+
private fetchAttributions;
|
|
19
|
+
private logJsonError;
|
|
20
|
+
loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined>;
|
|
21
|
+
decorate(context: DecorateContext): void;
|
|
22
|
+
private getSelectedTiles;
|
|
23
|
+
addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=GoogleMapsImageryProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.d.ts","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAgC,uBAAuB,EAAwB,wBAAwB,EAAW,cAAc,EAAQ,MAAM,sBAAsB,CAAC;AAC7L,OAAO,EAAoG,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAenJ,qBAAa,yBAA0B,SAAQ,uBAAuB;IAEpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,SAAS,CAAM;gBACX,QAAQ,EAAE,qBAAqB;WAI7B,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB;cAI7D,aAAa,IAAK,OAAO,CAAC,iBAAiB,GAAC,SAAS,CAAC;IAYtE,IAAoB,QAAQ,IAAI,MAAM,CAA2B;IAE3C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BjD,OAAO,CAAC,0BAA0B;IAoCrB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAWxE,iBAAiB;YAqCjB,YAAY;IASJ,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IA0ChG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIxD,OAAO,CAAC,gBAAgB;IAIF,eAAe,CAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBnG"}
|
|
@@ -0,0 +1,232 @@
|
|
|
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.GoogleMapsImageryProvider = void 0;
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
+
const GoogleMapDecorator_1 = require("./GoogleMapDecorator");
|
|
14
|
+
const GoogleMapsUtils_1 = require("../internal/GoogleMapsUtils");
|
|
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
|
+
/*
|
|
21
|
+
* Google Maps imagery provider
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
class GoogleMapsImageryProvider extends core_frontend_1.MapLayerImageryProvider {
|
|
25
|
+
_decorator;
|
|
26
|
+
_hadUnrecoverableError = false;
|
|
27
|
+
_tileSize = 256;
|
|
28
|
+
constructor(settings) {
|
|
29
|
+
super(settings, true);
|
|
30
|
+
this._decorator = new GoogleMapDecorator_1.GoogleMapsDecorator();
|
|
31
|
+
}
|
|
32
|
+
static validateUrlTemplate(template) {
|
|
33
|
+
return { status: (template.indexOf(levelToken) > 0 && template.indexOf(columnToken) > 0 && template.indexOf(rowToken) > 0) ? core_frontend_1.MapLayerSourceStatus.Valid : core_frontend_1.MapLayerSourceStatus.InvalidUrl };
|
|
34
|
+
}
|
|
35
|
+
async createSession() {
|
|
36
|
+
const sessionOptions = this.createCreateSessionOptions();
|
|
37
|
+
if (this._settings.accessKey) {
|
|
38
|
+
// Create session and store in query parameters
|
|
39
|
+
const sessionObj = await GoogleMapsUtils_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
|
+
}
|
|
47
|
+
}
|
|
48
|
+
get tileSize() { return this._tileSize; }
|
|
49
|
+
async initialize() {
|
|
50
|
+
const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
|
|
51
|
+
if (layerPropertyKeys === undefined ||
|
|
52
|
+
!layerPropertyKeys.includes("mapType") ||
|
|
53
|
+
!layerPropertyKeys.includes("language") ||
|
|
54
|
+
!layerPropertyKeys.includes("region")) {
|
|
55
|
+
const msg = "Missing session options";
|
|
56
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
57
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
58
|
+
}
|
|
59
|
+
const session = await this.createSession();
|
|
60
|
+
if (!session) {
|
|
61
|
+
const msg = `Failed to create session`;
|
|
62
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
63
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
64
|
+
}
|
|
65
|
+
this._tileSize = session.tileWidth; // assuming here tiles are square
|
|
66
|
+
const isActivated = await this._decorator.activate(this._settings.properties.mapType);
|
|
67
|
+
if (!isActivated) {
|
|
68
|
+
const msg = `Failed to activate decorator`;
|
|
69
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
70
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
createCreateSessionOptions() {
|
|
74
|
+
const layerPropertyKeys = this._settings.properties ? Object.keys(this._settings.properties) : undefined;
|
|
75
|
+
if (layerPropertyKeys === undefined ||
|
|
76
|
+
!layerPropertyKeys.includes("mapType") ||
|
|
77
|
+
!layerPropertyKeys.includes("language") ||
|
|
78
|
+
!layerPropertyKeys.includes("region")) {
|
|
79
|
+
const msg = "Missing session options";
|
|
80
|
+
core_bentley_1.Logger.logError(loggerCategory, msg);
|
|
81
|
+
throw new core_bentley_1.BentleyError(core_bentley_1.BentleyStatus.ERROR, msg);
|
|
82
|
+
}
|
|
83
|
+
const createSessionOptions = {
|
|
84
|
+
mapType: this._settings.properties.mapType,
|
|
85
|
+
region: this._settings.properties.region,
|
|
86
|
+
language: this._settings.properties.language,
|
|
87
|
+
};
|
|
88
|
+
if (this._settings.properties?.layerTypes !== undefined) {
|
|
89
|
+
createSessionOptions.layerTypes = this._settings.properties.layerTypes;
|
|
90
|
+
}
|
|
91
|
+
if (this._settings.properties?.scale !== undefined) {
|
|
92
|
+
createSessionOptions.scale = this._settings.properties.scale;
|
|
93
|
+
}
|
|
94
|
+
if (this._settings.properties?.overlay !== undefined) {
|
|
95
|
+
createSessionOptions.overlay = this._settings.properties.overlay;
|
|
96
|
+
}
|
|
97
|
+
if (this._settings.properties?.apiOptions !== undefined) {
|
|
98
|
+
createSessionOptions.apiOptions = this._settings.properties.apiOptions;
|
|
99
|
+
}
|
|
100
|
+
return createSessionOptions;
|
|
101
|
+
}
|
|
102
|
+
// construct the Url from the desired Tile
|
|
103
|
+
async constructUrl(row, column, level) {
|
|
104
|
+
const tmpUrl = urlTemplate.replace(levelToken, level.toString()).replace(columnToken, column.toString()).replace(rowToken, row.toString());
|
|
105
|
+
const obj = new URL(tmpUrl);
|
|
106
|
+
if (this._settings.accessKey) {
|
|
107
|
+
obj.searchParams.append("key", this._settings.accessKey.value);
|
|
108
|
+
}
|
|
109
|
+
// We assume the 'session' param to be already part of the query parameters (checked in initialize)
|
|
110
|
+
return this.appendCustomParams(obj.toString());
|
|
111
|
+
}
|
|
112
|
+
async fetchAttributions(tiles) {
|
|
113
|
+
const zooms = new Set();
|
|
114
|
+
const matchingAttributions = [];
|
|
115
|
+
// Viewport info requests must be made for a specific zoom level
|
|
116
|
+
tiles.forEach((tile) => zooms.add(tile.depth));
|
|
117
|
+
for (const zoom of zooms) {
|
|
118
|
+
let cartoRect;
|
|
119
|
+
for (const tile of tiles) {
|
|
120
|
+
if (tile.depth === zoom && tile instanceof core_frontend_1.MapTile) {
|
|
121
|
+
const extent = this.getEPSG4326Extent(tile.quadId.row, tile.quadId.column, tile.depth);
|
|
122
|
+
const rect = core_frontend_1.MapCartoRectangle.fromDegrees(extent.longitudeLeft, extent.latitudeBottom, extent.longitudeRight, extent.latitudeTop);
|
|
123
|
+
if (cartoRect)
|
|
124
|
+
cartoRect.union(rect);
|
|
125
|
+
else
|
|
126
|
+
cartoRect = rect;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (cartoRect) {
|
|
130
|
+
try {
|
|
131
|
+
const viewportInfo = await GoogleMapsUtils_1.GoogleMapsUtils.getViewportInfo({
|
|
132
|
+
rectangle: cartoRect,
|
|
133
|
+
session: this._settings.collectQueryParams().session,
|
|
134
|
+
key: this._settings.accessKey.value,
|
|
135
|
+
zoom
|
|
136
|
+
});
|
|
137
|
+
if (viewportInfo?.copyright) {
|
|
138
|
+
matchingAttributions.push(viewportInfo.copyright);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading viewport info: ${error?.message ?? "Unknown error"}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return matchingAttributions;
|
|
147
|
+
}
|
|
148
|
+
async logJsonError(tileResponse) {
|
|
149
|
+
try {
|
|
150
|
+
const error = await tileResponse.json();
|
|
151
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${error?.message}`);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async loadTile(row, column, zoomLevel) {
|
|
158
|
+
if (this._hadUnrecoverableError)
|
|
159
|
+
return undefined;
|
|
160
|
+
try {
|
|
161
|
+
let tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
162
|
+
let tileResponse = await this.makeTileRequest(tileUrl);
|
|
163
|
+
if (!tileResponse.ok) {
|
|
164
|
+
if (tileResponse.headers.get("content-type")?.includes("application/json")) {
|
|
165
|
+
// Session might have expired, lets try to re-new it.
|
|
166
|
+
const isSessionCreated = await this.createSession();
|
|
167
|
+
if (isSessionCreated) {
|
|
168
|
+
tileUrl = await this.constructUrl(row, column, zoomLevel);
|
|
169
|
+
tileResponse = await this.makeTileRequest(tileUrl);
|
|
170
|
+
if (!tileResponse.ok) {
|
|
171
|
+
if (tileResponse.headers.get("content-type")?.includes("application/json")) {
|
|
172
|
+
await this.logJsonError(tileResponse);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
176
|
+
}
|
|
177
|
+
this._hadUnrecoverableError = true; // Prevent from doing more invalid requests
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
await this.logJsonError(tileResponse);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${tileResponse.statusText}`);
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return await this.getImageFromTileResponse(tileResponse, zoomLevel);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (error?.code === 401) {
|
|
194
|
+
core_bentley_1.Logger.logError(loggerCategory, `Authorize to load tile: ${error.message}`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading tile: ${error.message}`);
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
decorate(context) {
|
|
203
|
+
this._decorator.decorate(context);
|
|
204
|
+
}
|
|
205
|
+
getSelectedTiles(vp) {
|
|
206
|
+
return core_frontend_1.IModelApp.tileAdmin.getTilesForUser(vp)?.selected;
|
|
207
|
+
}
|
|
208
|
+
async addAttributions(cards, vp) {
|
|
209
|
+
let copyrightMsg = "";
|
|
210
|
+
const tiles = this.getSelectedTiles(vp);
|
|
211
|
+
if (tiles) {
|
|
212
|
+
try {
|
|
213
|
+
const attrList = await this.fetchAttributions(tiles);
|
|
214
|
+
for (const attr of attrList) {
|
|
215
|
+
attr.split(",").forEach((line) => {
|
|
216
|
+
copyrightMsg += `${copyrightMsg.length === 0 ? "" : "<br"}${line}`;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
core_bentley_1.Logger.logError(loggerCategory, `Error while loading attributions: ${error?.message ?? "Unknown error"}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
cards.appendChild(core_frontend_1.IModelApp.makeLogoCard({
|
|
225
|
+
iconSrc: `${core_frontend_1.IModelApp.publicPath}images/google_on_white_hdpi.png`,
|
|
226
|
+
heading: "Google Maps",
|
|
227
|
+
notice: copyrightMsg
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.GoogleMapsImageryProvider = GoogleMapsImageryProvider;
|
|
232
|
+
//# sourceMappingURL=GoogleMapsImageryProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleMapsImageryProvider.js","sourceRoot":"","sources":["../../../src/GoogleMaps/GoogleMapsImageryProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAA6L;AAE7L,sDAA0E;AAC1E,6DAA2D;AAC3D,iEAA8D;AAC9D,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,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,wCAAmB,EAAE,CAAC;IAC9C,CAAC;IACM,MAAM,CAAC,mBAAmB,CAAC,QAAgB;QAChD,OAAO,EAAE,MAAM,EAAE,CAAC,Q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AAK,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 { ImageMapLayerSettings, ImageSource } from \"@itwin/core-common\";\nimport { DecorateContext, IModelApp, MapCartoRectangle, MapLayerImageryProvider, MapLayerSourceStatus, MapLayerSourceValidation, MapTile, ScreenViewport, Tile } from \"@itwin/core-frontend\";\nimport { GoogleMapsCreateSessionOptions, GoogleMapsLayerTypes, GoogleMapsMapTypes, GoogleMapsScaleFactors, GoogleMapsSession } from \"./GoogleMaps\";\nimport { BentleyError, BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { GoogleMapsDecorator } from \"./GoogleMapDecorator\";\nimport { GoogleMapsUtils } from \"../internal/GoogleMapsUtils\";\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 +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":["/*---------------------------------------------------------------------------------------------\
|
|
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"]}
|
|
@@ -5,6 +5,7 @@ const core_frontend_1 = require("@itwin/core-frontend");
|
|
|
5
5
|
const OgcApiFeaturesProvider_1 = require("./OgcApiFeaturesProvider");
|
|
6
6
|
/** @internal */
|
|
7
7
|
class OgcApiFeaturesMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat {
|
|
8
|
+
static formatId = "OgcApiFeatures";
|
|
8
9
|
static createImageryProvider(settings) { return new OgcApiFeaturesProvider_1.OgcApiFeaturesProvider(settings); }
|
|
9
10
|
static async validate(args) {
|
|
10
11
|
const { source } = args;
|
|
@@ -90,5 +91,4 @@ class OgcApiFeaturesMapLayerFormat extends core_frontend_1.ImageryMapLayerFormat
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
exports.OgcApiFeaturesMapLayerFormat = OgcApiFeaturesMapLayerFormat;
|
|
93
|
-
OgcApiFeaturesMapLayerFormat.formatId = "OgcApiFeatures";
|
|
94
94
|
//# sourceMappingURL=OgcApiFeaturesFormat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":";;;AAKA,wDAAoM;AACpM,qEAAkE;AAElE,gBAAgB;AAChB,MAAa,4BAA6B,SAAQ,qCAAqB;
|
|
1
|
+
{"version":3,"file":"OgcApiFeaturesFormat.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesFormat.ts"],"names":[],"mappings":";;;AAKA,wDAAoM;AACp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AAe,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAS,EAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC;gBACrH,IAAI,cAAc,GAAG,IAAA,iCAAiB,EAAC,eAAe,CAAC,IAAI,EAAE,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\";\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"]}
|
|
@@ -21,8 +21,31 @@ const dataUrlHeaderToken = "base64,";
|
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
23
|
class DefaultOgcSymbology {
|
|
24
|
+
static _defaultPMSProps = {
|
|
25
|
+
type: "esriPMS",
|
|
26
|
+
url: "",
|
|
27
|
+
width: 16,
|
|
28
|
+
height: 24,
|
|
29
|
+
// We want the anchor point to be the bottom of the push pin, so apply offset on the y-axis (anchor point is already in the center of the icon)
|
|
30
|
+
xoffset: 0,
|
|
31
|
+
yoffset: -12,
|
|
32
|
+
};
|
|
33
|
+
_defaultPMS;
|
|
34
|
+
static _defaultSLSProps = {
|
|
35
|
+
type: "esriSLS",
|
|
36
|
+
color: [0, 0, 255, 255],
|
|
37
|
+
width: 1,
|
|
38
|
+
style: "esriSLSSolid",
|
|
39
|
+
};
|
|
40
|
+
_defaultSLS;
|
|
41
|
+
static _defaultSFSProps = {
|
|
42
|
+
type: "esriSFS",
|
|
43
|
+
color: [0, 0, 255, 255], // blue fill
|
|
44
|
+
style: "esriSFSSolid",
|
|
45
|
+
outline: DefaultOgcSymbology._defaultSLSProps,
|
|
46
|
+
};
|
|
47
|
+
_defaultSFS = EsriSymbology_1.EsriSFS.fromJSON(DefaultOgcSymbology._defaultSFSProps);
|
|
24
48
|
constructor(randomColor) {
|
|
25
|
-
this._defaultSFS = EsriSymbology_1.EsriSFS.fromJSON(DefaultOgcSymbology._defaultSFSProps);
|
|
26
49
|
const color = randomColor ? randomColor.getColorDef() : core_common_1.ColorDef.blue;
|
|
27
50
|
this._defaultPMS = EsriSymbology_1.EsriPMS.fromJSON({
|
|
28
51
|
...DefaultMarkerIcon_1.DefaultMarkerIcon.getContent(color),
|
|
@@ -63,43 +86,27 @@ class DefaultOgcSymbology {
|
|
|
63
86
|
}
|
|
64
87
|
}
|
|
65
88
|
exports.DefaultOgcSymbology = DefaultOgcSymbology;
|
|
66
|
-
DefaultOgcSymbology._defaultPMSProps = {
|
|
67
|
-
type: "esriPMS",
|
|
68
|
-
url: "",
|
|
69
|
-
width: 16,
|
|
70
|
-
height: 24,
|
|
71
|
-
// We want the anchor point to be the bottom of the push pin, so apply offset on the y-axis (anchor point is already in the center of the icon)
|
|
72
|
-
xoffset: 0,
|
|
73
|
-
yoffset: -12,
|
|
74
|
-
};
|
|
75
|
-
DefaultOgcSymbology._defaultSLSProps = {
|
|
76
|
-
type: "esriSLS",
|
|
77
|
-
color: [0, 0, 255, 255],
|
|
78
|
-
width: 1,
|
|
79
|
-
style: "esriSLSSolid",
|
|
80
|
-
};
|
|
81
|
-
DefaultOgcSymbology._defaultSFSProps = {
|
|
82
|
-
type: "esriSFS",
|
|
83
|
-
color: [0, 0, 255, 255], // blue fill
|
|
84
|
-
style: "esriSFSSolid",
|
|
85
|
-
outline: DefaultOgcSymbology._defaultSLSProps,
|
|
86
|
-
};
|
|
87
89
|
/** @internal */
|
|
88
90
|
class OgcApiFeaturesProvider extends core_frontend_1.MapLayerImageryProvider {
|
|
91
|
+
// Debug flags, should always be committed to FALSE !
|
|
92
|
+
_drawDebugInfo = false;
|
|
93
|
+
/// ////////////////////////////
|
|
94
|
+
_limitParamMaxValue = 10000; // This is documented in OGC Features specification; a single items request never returns more than 10 000 items
|
|
95
|
+
_tiledModeMinLod = 14;
|
|
96
|
+
_staticModeFetchTimeout = 10000;
|
|
97
|
+
_tileModeFetchTimeout = 10000;
|
|
98
|
+
_forceTileMode = false;
|
|
99
|
+
_spatialIdx;
|
|
100
|
+
_defaultSymbol = new DefaultOgcSymbology(new RandomMapColor_1.RandomMapColor());
|
|
101
|
+
_renderer;
|
|
102
|
+
_collectionUrl = "";
|
|
103
|
+
_itemsUrl = "";
|
|
104
|
+
_itemsCrs = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; // Fixed fow now
|
|
105
|
+
_queryables;
|
|
106
|
+
serviceJson;
|
|
107
|
+
_staticData;
|
|
89
108
|
constructor(settings) {
|
|
90
109
|
super(settings, true);
|
|
91
|
-
// Debug flags, should always be committed to FALSE !
|
|
92
|
-
this._drawDebugInfo = false;
|
|
93
|
-
/// ////////////////////////////
|
|
94
|
-
this._limitParamMaxValue = 10000; // This is documented in OGC Features specification; a single items request never returns more than 10 000 items
|
|
95
|
-
this._tiledModeMinLod = 14;
|
|
96
|
-
this._staticModeFetchTimeout = 10000;
|
|
97
|
-
this._tileModeFetchTimeout = 10000;
|
|
98
|
-
this._forceTileMode = false;
|
|
99
|
-
this._defaultSymbol = new DefaultOgcSymbology(new RandomMapColor_1.RandomMapColor());
|
|
100
|
-
this._collectionUrl = "";
|
|
101
|
-
this._itemsUrl = "";
|
|
102
|
-
this._itemsCrs = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; // Fixed fow now
|
|
103
110
|
}
|
|
104
111
|
get supportsMapFeatureInfo() { return true; }
|
|
105
112
|
get minimumZoomLevel() { return this.staticMode ? super.minimumZoomLevel : this._tiledModeMinLod; }
|