@masterportal/masterportalapi 2.2.0 → 2.5.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/src/defaults.js CHANGED
@@ -19,7 +19,7 @@ export default {
19
19
  {resolution: 1.3229159522920524, scale: 5000, zoomLevel: 6},
20
20
  {resolution: 0.6614579761460262, scale: 2500, zoomLevel: 7},
21
21
  {resolution: 0.2645831904584105, scale: 1000, zoomLevel: 8},
22
- {resolution: 0.13229159522920521, scale: 500, zoomLevel: 9}
22
+ {resolution: 0.1322915952292052, scale: 500, zoomLevel: 9}
23
23
  ],
24
24
  namedProjections: [
25
25
  ["EPSG:25832", "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"]
@@ -34,5 +34,21 @@ export default {
34
34
  }
35
35
  ],
36
36
  gazetteerUrl: "https://geodienste.hamburg.de/HH_WFS_GAGES?service=WFS&request=GetFeature&version=2.0.0",
37
- showGeographicIdentifier: false
37
+ showGeographicIdentifier: false,
38
+ sceneOptions: {
39
+ camera: {
40
+ enableTerrainAdjustmentWhenLoading: true
41
+ },
42
+ globe: {
43
+ depthTestAgainstTerrain: true // is necessary for scene.pickedPosition and correct height of the terrain. @see {https://github.com/CesiumGS/cesium/issues/5676}
44
+ },
45
+ highDynamicRange: false,
46
+ pickTranslucentDepth: true,
47
+ shadowMap: {
48
+ darkness: 0.6,
49
+ maximumDistance: 5000.0,
50
+ size: 2048
51
+ },
52
+ shadows: false
53
+ }
38
54
  };
package/src/index.js CHANGED
@@ -2,12 +2,14 @@ import {createMapView} from "./maps/mapView";
2
2
  import * as crs from "./crs";
3
3
  import * as rawLayerList from "./rawLayerList";
4
4
  import * as wms from "./layer/wms";
5
+ import * as wmts from "./layer/wmts";
5
6
  import * as wfs from "./layer/wfs";
6
7
  import * as geojson from "./layer/geojson";
7
8
  import * as vectorBase from "./layer/vectorBase";
8
9
  import * as vectorTile from "./layer/vectorTile";
9
10
  import * as oaf from "./layer/oaf";
10
11
  import * as terrain from "./layer/terrain";
12
+ import * as entities from "./layer/entities";
11
13
  import Tileset from "./layer/tileset";
12
14
  import * as layerLib from "./layer/lib";
13
15
  import {search, setGazetteerUrl} from "./searchAddress";
@@ -16,6 +18,7 @@ import setBackgroundImage from "./lib/setBackgroundImage";
16
18
  export {
17
19
  createMapView,
18
20
  wms,
21
+ wmts,
19
22
  wfs,
20
23
  geojson,
21
24
  layerLib,
@@ -23,6 +26,7 @@ export {
23
26
  vectorTile,
24
27
  oaf,
25
28
  terrain,
29
+ entities,
26
30
  Tileset,
27
31
  setBackgroundImage,
28
32
  setGazetteerUrl,
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Sets the layers visibility by setting the show attribute at the datasource.
3
+ * @param {boolean} value if true, the entity will be shown
4
+ * @param {Object} rawLayer attributes of the layer
5
+ * @param {string} [rawLayer.id] the id of the layer
6
+ * @param {OLCesium} map ol cesium map
7
+ * @returns {void}
8
+ */
9
+ export function setVisible (value, rawLayer, map) {
10
+ if (map && typeof map.getDataSources === "function") {
11
+ const dataSources = map.getDataSources(),
12
+ dataSource = dataSources.getByName(rawLayer?.id);
13
+
14
+ if (dataSource.length === 0) {
15
+ console.warn("Cannot change visibility of 3D entity for layer with id ", rawLayer.id, ". Datasource is not available.");
16
+ }
17
+ else {
18
+ dataSource[0].show = typeof value === "boolean" ? value : false;
19
+ }
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Adapts the rawEntity and adds it to the dataSource's entities.
25
+ * The created entity has the attribute 'layerReferenceId' which contains the rawLayer's id.
26
+ * @param {Object} rawEntity to add to the dataSource
27
+ * @param {string} [rawEntity.url] specifying the URI of the glTF asset
28
+ * @param {number} [rawEntity.longitude] longitude of the position
29
+ * @param {number} [rawEntity.latitude] latitude of the position
30
+ * @param {number} [rawEntity.height] height of the position
31
+ * @param {boolean} [rawEntity.allowPicking] if true, each geometry instance will only be pickable with Scene#pick. When false, GPU memory is saved
32
+ * @param {Array} [rawEntity.attributes] attributes of the glTF asset
33
+ * @param {number} [rawEntity.heading] the rotation about the negative z axis
34
+ * @param {number} [rawEntity.pitch] the rotation about the negative y axis
35
+ * @param {number} [rawEntity.roll] the rotation about the positive x axis
36
+ * @param {boolean} [rawEntity.show] optional- if true, entity is shown.
37
+ * @param {Cesium.CustomDataSource} dataSource a Cesium.DataSource implementation to manage a group of entities
38
+ * @param {Object} rawLayer layer specification as in services.json
39
+ * @param {string} [rawLayer.id] optional id of the layer, passed to help identification in services.json
40
+ * @returns {Object} the created entity
41
+ */
42
+ function addEntity (rawEntity, dataSource, rawLayer) {
43
+ if (typeof rawEntity.url !== "string") {
44
+ console.warn("Url of entity must be a string, but is:", rawEntity.url);
45
+ return null;
46
+ }
47
+ if (![rawEntity.longitude, rawEntity.latitude, rawEntity.height].every(num => typeof num === "number")) {
48
+ console.warn("longitude, latitude and height of entity must be a number.");
49
+ return null;
50
+ }
51
+ const position = Cesium.Cartesian3.fromDegrees(rawEntity.longitude, rawEntity.latitude, rawEntity.height),
52
+ allowPicking = typeof rawEntity.allowPicking === "boolean" ? rawEntity.allowPicking : true,
53
+ attributes = rawEntity.attributes ? rawEntity.attributes : {};
54
+ let headingPitchRoll = "",
55
+ orientation = "",
56
+ modelOptions = "",
57
+ entityOptions = null,
58
+ entity = "",
59
+ heading = 0,
60
+ pitch = 0,
61
+ roll = 0;
62
+
63
+ if (typeof rawEntity.heading === "number") {
64
+ heading = rawEntity.heading / 180 * Math.PI;
65
+ }
66
+ if (typeof rawEntity.pitch === "number") {
67
+ pitch = rawEntity.pitch / 180 * Math.PI;
68
+ }
69
+ if (typeof rawEntity.roll === "number") {
70
+ roll = rawEntity.roll / 180 * Math.PI;
71
+ }
72
+ headingPitchRoll = new Cesium.HeadingPitchRoll(heading, pitch, roll);
73
+ orientation = Cesium.Transforms.headingPitchRollQuaternion(position, headingPitchRoll);
74
+ modelOptions = Object.assign(rawEntity.modelOptions || {}, {
75
+ uri: rawEntity.url,
76
+ scale: typeof rawEntity.scale === "number" ? rawEntity.scale : 1,
77
+ show: typeof rawEntity.show === "boolean" ? rawEntity.show : false
78
+ });
79
+ entityOptions = {
80
+ name: rawEntity.url,
81
+ position,
82
+ orientation,
83
+ show: typeof rawEntity.show === "boolean" ? rawEntity.show : false,
84
+ model: modelOptions
85
+ };
86
+ entity = dataSource.entities.add(entityOptions);
87
+ entity.attributes = attributes;
88
+ entity.allowPicking = allowPicking;
89
+ entity.layerReferenceId = rawLayer.id;
90
+ return entity;
91
+ }
92
+
93
+ /**
94
+ * Iterates over the entities of the raw layer and adds them to dataSource.
95
+ * @param {Object} rawLayer attributes of the layer
96
+ * @param {string} [rawLayer.id] the id of the layer
97
+ * @param {string} [rawLayer.entities] array of entities to add
98
+ * @param {Cesium.CustomDataSource} dataSource a Cesium.DataSource implementation to manage a group of entities
99
+ * @returns {void}
100
+ */
101
+ function addEntities (rawLayer, dataSource) {
102
+ if (rawLayer.entities) {
103
+ rawLayer.entities.forEach(entity => {
104
+ // just created dataSource is an object, but if it is got by name it is contained in an array
105
+ addEntity(entity, Array.isArray(dataSource) ? dataSource[0] : dataSource, rawLayer);
106
+ });
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Creates a Cesium.CustomDataSource and adds it to map's dataSources.
112
+ * Iterates over the entities of the raw layer and adds them to dataSource.
113
+ * @param {Object} rawLayer attributes of the layer
114
+ * @param {string} [rawLayer.id] the id of the layer
115
+ * @param {string} [rawLayer.entities] array of entities to add
116
+ * @param {OLCesium} map ol cesium map
117
+ * @param {function} callback to execute after datasource is added to map and entities are added
118
+ * @returns {*} null or the return-value of the callback
119
+ */
120
+ export function createDataSource (rawLayer, map, callback) {
121
+ if (!rawLayer) {
122
+ console.warn("Cannot add entities to rawLayer which is null!");
123
+ }
124
+ else if (map && typeof map.getDataSources === "function") {
125
+ const dataSources = map.getDataSources();
126
+ let dataSource = dataSources.getByName(rawLayer.id);
127
+
128
+ if (dataSource.length === 0) {
129
+ dataSource = new Cesium.CustomDataSource(rawLayer.id);
130
+ dataSources.add(dataSource).then(function (addedDataSource) {
131
+ addEntities(rawLayer, addedDataSource, map);
132
+ if (callback) {
133
+ return callback();
134
+ }
135
+ return null;
136
+ });
137
+ }
138
+ else {
139
+ addEntities(rawLayer, dataSource, map);
140
+ if (callback) {
141
+ return callback();
142
+ }
143
+ }
144
+ }
145
+ return null;
146
+ }
147
+
148
+
149
+ /**
150
+ * Creates an entities layer to use in ol-Cesium map.
151
+ * @param {Object} rawLayer layer specification as in services.json
152
+ * @param {string} [rawLayer.id] optional id of the layer, passed to help identification in services.json
153
+ * @param {string} [rawLayer.name] optional name of the layer, passed to help identification in services.json
154
+ * @param {string} [rawLayer.typ] typ of the layer, passed to help identification in services.json
155
+ * @param {Array} [rawLayer.entities] array of entities to add
156
+ * @param {OLCesium} map ol cesium map
157
+ * @returns {Object} layer
158
+ */
159
+ export function createLayer (rawLayer, map) {
160
+ createDataSource(rawLayer, map);
161
+ this.values = {
162
+ name: rawLayer.name,
163
+ id: rawLayer.id,
164
+ typ: rawLayer.typ
165
+ };
166
+ return this;
167
+ }
168
+
169
+ /**
170
+ * Returns the value for the given key of the rawlayer.
171
+ * @param {String} key to get the value for
172
+ * @returns {*} the value to the key
173
+ */
174
+ export function get (key) {
175
+ if (!this.values) {
176
+ return undefined;
177
+ }
178
+ return this.values[key];
179
+ }
@@ -25,6 +25,13 @@ export function createLayerSource ({url, features, clusterDistance}, options) {
25
25
  if (clusterDistance) {
26
26
  return createClusterVectorSource(source, clusterDistance, options.clusterGeometryFunction);
27
27
  }
28
+
29
+ source.once("featuresloadend", event => {
30
+ if (typeof options.afterLoading === "function") {
31
+ options.afterLoading(event?.features);
32
+ }
33
+ });
34
+
28
35
  return source;
29
36
  }
30
37
 
@@ -14,6 +14,7 @@ export function setCustomStyles (styles) {
14
14
 
15
15
  // // // STYLE PARTS
16
16
  const marker = new Icon({
17
+ crossOrigin: "anonymous",
17
18
  src: markerSvg,
18
19
  // center bottom of marker 📍 is intended to show the spot
19
20
  anchor: [0.5, 1]
@@ -12,7 +12,6 @@ function createTerrainProvider (rawLayer) {
12
12
  Object.assign(options, rawLayer.cesiumTerrainProviderOptions);
13
13
  }
14
14
  options.url = rawLayer.url;
15
- /* eslint-disable no-undef */
16
15
  return new Cesium.CesiumTerrainProvider(options);
17
16
  }
18
17
 
@@ -31,7 +30,6 @@ export function setVisible (value, rawLayer, map) {
31
30
  map.getCesiumScene().terrainProvider = createTerrainProvider(rawLayer);
32
31
  }
33
32
  else {
34
- /* eslint-disable no-undef */
35
33
  map.getCesiumScene().terrainProvider = new Cesium.EllipsoidTerrainProvider({});
36
34
  }
37
35
  }
@@ -42,20 +40,15 @@ export function setVisible (value, rawLayer, map) {
42
40
  * @param {Object} rawLayer - layer specification as in services.json
43
41
  * @param {string} [rawLayer.id] - optional id of the layer, passed to help identification in services.json
44
42
  * @param {string} [rawLayer.url] - the URL of the Cesium terrain server
45
- * @param {string} [rawLayer.isSelected] - if true, terrain is created and shown
46
43
  * @param {string} [rawLayer.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
47
- * @param {OLCesium} map ol cesium map
48
44
  * @returns {Object} layer
49
45
  */
50
- export function createLayer (rawLayer, map) {
46
+ export function createLayer (rawLayer) {
51
47
  this.values = {
52
48
  name: rawLayer.name,
53
49
  id: rawLayer.id,
54
50
  typ: rawLayer.typ
55
51
  };
56
- if (rawLayer.isSelected && map && typeof map.getCesiumScene === "function") {
57
- setVisible(true, rawLayer, map);
58
- }
59
52
  return this;
60
53
  }
61
54
  /**
@@ -13,7 +13,6 @@ function createTileSet (rawLayer) {
13
13
  Object.assign(options, rawLayer.cesium3DTilesetOptions);
14
14
  }
15
15
  options.url = url;
16
- /* eslint-disable no-undef */
17
16
  return new Cesium.Cesium3DTileset(options);
18
17
  }
19
18
  /**
@@ -21,12 +20,10 @@ function createTileSet (rawLayer) {
21
20
  * @param {Object} rawLayer - layer specification as in services.json
22
21
  * @param {string} [rawLayer.id] - optional id of the layer, passed to help identification in services.json
23
22
  * @param {string} [rawLayer.url] - the URL of the Cesium terrain server
24
- * @param {string} [rawLayer.isSelected] - if true, terrain is created and shown
25
23
  * @param {string} [rawLayer.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
26
- * @param {OLCesium} map ol cesium map
27
24
  * @returns {void}
28
25
  */
29
- export default function Tileset (rawLayer, map) {
26
+ export default function Tileset (rawLayer) {
30
27
  this.values = {
31
28
  name: rawLayer.name,
32
29
  id: rawLayer.id,
@@ -34,10 +31,6 @@ export default function Tileset (rawLayer, map) {
34
31
  };
35
32
  this.tileset = createTileSet(rawLayer);
36
33
  this.tileset.layerReferenceId = rawLayer.id;
37
-
38
- if (rawLayer.isSelected && map && typeof map.getCesiumScene === "function") {
39
- this.setVisible(true, map);
40
- }
41
34
  }
42
35
  /**
43
36
  *
@@ -4,8 +4,8 @@ import VectorTileSource from "ol/source/VectorTile";
4
4
  import OpenLayersTileGrid from "ol/tilegrid/TileGrid";
5
5
  import {extentFromProjection} from "ol/tilegrid";
6
6
 
7
- import stylefunction from "ol-mapbox-style/dist/stylefunction";
8
- import {defaultResolutions} from "ol-mapbox-style/dist/util";
7
+ import {stylefunction} from "ol-mapbox-style";
8
+ import {defaultResolutions} from "ol-mapbox-style";
9
9
 
10
10
  import defaults from "../defaults";
11
11
 
@@ -171,4 +171,4 @@ export function setStyle (layer, glStyle, {options = {}} = {}) {
171
171
  options.spriteData,
172
172
  options.spriteImageUrl,
173
173
  options.getFonts);
174
- }
174
+ }
package/src/layer/wms.js CHANGED
@@ -7,6 +7,8 @@ import {get as getProjection} from "ol/proj";
7
7
 
8
8
  import {getLayerWhere} from "../rawLayerList";
9
9
 
10
+ const OLCS_DEFAULT_OLCS_PROJECTION_CRS = "EPSG:3857";
11
+
10
12
  /** @returns {number} random session id in range (0, 9999999) */
11
13
  export function generateSessionId () {
12
14
  return Math.floor(Math.random() * 9999999);
@@ -138,6 +140,8 @@ export function createLayer (rawLayer, layerParams = {}, options) {
138
140
  const source = createLayerSource(rawLayer, options),
139
141
  Layer = rawLayer.singleTile ? ImageLayer : TileLayer;
140
142
 
143
+ source.set("olcs.projection", getProjection(OLCS_DEFAULT_OLCS_PROJECTION_CRS));
144
+
141
145
  return new Layer(Object.assign({
142
146
  source,
143
147
  minResolution: rawLayer.minScale,
@@ -0,0 +1,194 @@
1
+ import WMTS, {optionsFromCapabilities} from "ol/source/WMTS";
2
+ import WMTSTileGrid from "ol/tilegrid/WMTS";
3
+ import TileLayer from "ol/layer/Tile";
4
+ import {DEVICE_PIXEL_RATIO} from "ol/has";
5
+ import {getWidth} from "ol/extent";
6
+ import WMTSCapabilities from "ol/format/WMTSCapabilities";
7
+ import {get as getProjection} from "ol/proj";
8
+
9
+ /**
10
+ * Shows error message in console for various WMTS errors.
11
+ * @param {String} errorMessage error message
12
+ * @param {String} layerName layerName
13
+ * @returns {void}
14
+ */
15
+ export function showErrorMessage (errorMessage, layerName) {
16
+ console.error("content: Layer " + layerName + ": " + errorMessage);
17
+ }
18
+
19
+ /**
20
+ * Generates resolutions and matrixIds arrays for the WMTS LayerSource.
21
+ * @param {Array} resolutions The resolutions array for the LayerSource.
22
+ * @param {Array} matrixIds The matrixIds array for the LayerSource.
23
+ * @param {Number} length The length of the given arrays.
24
+ * @param {Number} size The tileSize depending on the extent.
25
+ * @returns {void}
26
+ */
27
+ export function generateArrays (resolutions, matrixIds, length, size) {
28
+ for (let i = 0; i < length; ++i) {
29
+ resolutions[i] = size / Math.pow(2, i);
30
+ matrixIds[i] = i;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Gets the WMTS-GetCapabilities document and parse it
36
+ * @param {String} url url for getting capabilities
37
+ * @throws {Error} on unexpected return
38
+ * @returns {promise} promise resolves to parsed WMTS-GetCapabilities object
39
+ */
40
+ export function getWMTSCapabilities (url) {
41
+ return fetch(url)
42
+ .then(response => {
43
+ if (response && response.status === 200) {
44
+ return response.text();
45
+ }
46
+ console.error(response);
47
+ throw new Error(`Failing WMTS request to ${url}. Status: ${response?.status}`);
48
+ })
49
+ .then((text) => new WMTSCapabilities().read(text));
50
+ }
51
+
52
+ /**
53
+ * Creates the LayerSource from definitions in the service.json for this WMTSLayer.
54
+ * @param {Object} attrs attributes of the layer
55
+ * @param {WMTS} tileLayer layer object
56
+ * @returns {void}
57
+ */
58
+ export function createLayerSourceByDefinitions (attrs, tileLayer) {
59
+ const projection = getProjection(attrs.coordinateSystem),
60
+ extent = projection.getExtent(),
61
+ style = attrs.style,
62
+ format = attrs.format,
63
+ wrapX = attrs.wrapX ? attrs.wrapX : false,
64
+ urls = attrs.urls,
65
+ size = extent ? getWidth(extent) / parseInt(attrs.tileSize, 10) : null,
66
+ resLength = parseInt(attrs.resLength, 10),
67
+ resolutions = new Array(resLength),
68
+ matrixIds = new Array(resLength),
69
+ source = new WMTS({
70
+ projection: projection,
71
+ attributions: attrs.olAttribution,
72
+ tileGrid: new WMTSTileGrid({
73
+ origin: attrs.origin,
74
+ resolutions: resolutions,
75
+ matrixIds: matrixIds,
76
+ tileSize: attrs.tileSize
77
+ }),
78
+ tilePixelRatio: DEVICE_PIXEL_RATIO,
79
+ urls: urls,
80
+ matrixSet: attrs.tileMatrixSet,
81
+ matrixSizes: attrs.matrixSizes,
82
+ layer: attrs.layers,
83
+ format: format,
84
+ style: style,
85
+ version: attrs.version,
86
+ transparent: attrs.transparent.toString(),
87
+ wrapX: wrapX,
88
+ requestEncoding: attrs.requestEncoding,
89
+ scales: attrs.scales
90
+ });
91
+
92
+ if (size) {
93
+ generateArrays(resolutions, matrixIds, resLength, size);
94
+ }
95
+ else {
96
+ showErrorMessage(attrs.name, `${projection.getCode()} has been given as projection to wmts.js for layer with id ${attrs.id}, but only "EPSG:4326" and "EPSG:3857" are supported. Please use the "capabilitiesUrl" and "optionsFromCapabilities" configuration parameters on this layer.`);
97
+ }
98
+
99
+ source.matrixSizes = attrs.matrixSizes;
100
+ source.scales = attrs.scales;
101
+ tileLayer.setSource(source);
102
+ tileLayer.getSource().refresh();
103
+ }
104
+
105
+ /**
106
+ * Creates the LayerSource for this WMTSLayer from the WMTS capabilities.
107
+ * @param {Object} attrs attributes of the layer
108
+ * @param {WMTS} tileLayer layer object
109
+ * @returns {void}
110
+ */
111
+ export function createLayerSourceByCapabilities (attrs, tileLayer) {
112
+ const layerIdentifier = attrs.layers,
113
+ url = attrs.capabilitiesUrl,
114
+ matrixSet = attrs.tileMatrixSet,
115
+ capabilitiesOptions = {
116
+ layer: layerIdentifier
117
+ };
118
+
119
+ // use the matrixSet (if defined) for optionsFromCapabilities
120
+ // else look for a tilematrixset in epsg:3857
121
+ if (matrixSet && matrixSet.length > 0) {
122
+ capabilitiesOptions.matrixSet = matrixSet;
123
+ }
124
+ else {
125
+ capabilitiesOptions.projection = "EPSG:3857";
126
+ }
127
+
128
+ getWMTSCapabilities(url)
129
+ .then((result) => {
130
+ const options = optionsFromCapabilities(result, capabilitiesOptions),
131
+ tileMatrixSet = result.Contents.TileMatrixSet.filter(set => set.Identifier === options.matrixSet)[0],
132
+ matrixSizes = [],
133
+ scales = [];
134
+
135
+ // Add the parameters "ScaleDenominator" and "MatrixHeight" / "MatrixWidth" to the source to be able to print WMTS layers
136
+ tileMatrixSet.TileMatrix.forEach(({MatrixHeight, MatrixWidth, ScaleDenominator}) => {
137
+ matrixSizes.push([MatrixWidth, MatrixHeight]);
138
+ scales.push(ScaleDenominator);
139
+ });
140
+
141
+ if (options !== null) {
142
+ const source = new WMTS(options);
143
+
144
+ source.matrixSizes = matrixSizes;
145
+ source.scales = scales;
146
+ tileLayer.set("options", options);
147
+ tileLayer.setSource(source);
148
+ tileLayer.getSource().refresh();
149
+ }
150
+ else {
151
+ const errorMessage = "Cannot get options from WMTS-Capabilities";
152
+
153
+ showErrorMessage(errorMessage, attrs.name || attrs.id);
154
+ throw new Error(errorMessage);
155
+ }
156
+ })
157
+ .catch((error) => {
158
+ if (error === "Fetch error") {
159
+ // error message has already been printed earlier
160
+ return;
161
+ }
162
+ showErrorMessage(error, attrs.name || attrs.id);
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Creates the WMTSLayer.
168
+ * @param {Object} attrs attributes of the layer
169
+ * @returns {void}
170
+ */
171
+ export function createLayer (attrs) {
172
+ const tileLayer = new TileLayer({
173
+ id: attrs.id,
174
+ source: new WMTS({}),
175
+ name: attrs.name,
176
+ minResolution: attrs.minScale,
177
+ maxResolution: attrs.maxScale,
178
+ supported: ["2D", "3D"],
179
+ showSettings: true,
180
+ extent: null,
181
+ typ: attrs.typ,
182
+ legendURL: attrs.legendURL,
183
+ infoFormat: attrs.infoFormat
184
+ });
185
+
186
+ if (attrs.optionsFromCapabilities === undefined) {
187
+ createLayerSourceByDefinitions(attrs, tileLayer);
188
+ }
189
+ else {
190
+ createLayerSourceByCapabilities(attrs, tileLayer);
191
+ }
192
+
193
+ return tileLayer;
194
+ }
@@ -4,6 +4,7 @@ import setBackgroundImage from "../../lib/setBackgroundImage";
4
4
  import getInitialLayers from "../../lib/getInitialLayers";
5
5
  import defaults from "../../defaults";
6
6
  import * as wms from "../../layer/wms";
7
+ import * as wmts from "../../layer/wmts";
7
8
  import * as geojson from "../../layer/geojson";
8
9
  import * as wfs from "../../layer/wfs";
9
10
  import * as vectorBase from "../../layer/vectorBase";
@@ -22,6 +23,7 @@ let mapIdCounter = 0;
22
23
  */
23
24
  const layerBuilderMap = {
24
25
  wms,
26
+ wmts,
25
27
  wfs,
26
28
  geojson,
27
29
  vectorBase,