@masterportal/masterportalapi 2.9.0 → 2.10.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 +14 -0
- package/example/index.js +6 -6
- package/package.json +1 -1
- package/src/crs.js +1 -1
- package/src/index.js +2 -2
- package/src/layer/wms.js +1 -1
- package/src/lib/load3DScript.js +5 -1
- package/src/maps/ol/olMap.js +11 -5
- package/src/rawLayerList.js +1 -1
- package/test/crs.test.js +1 -1
- package/test/layer/vectorTile.test.js +2 -2
- package/test/map.test.js +26 -21
- package/test/rawLayerList.test.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
|
|
15
15
|
### Fixed
|
|
16
16
|
|
|
17
|
+
---
|
|
18
|
+
## 2.10.0 - 2022-03-11
|
|
19
|
+
### Added
|
|
20
|
+
- DPS-1313: Added custom DragPan interaction to add ability to use 2-Finger-Pan instead of 1-Finger-Pan on mobile devices
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Exports in src/rawLayerList, src/crs.js and src/lib/load3DScript.js changed to export default {} to provide ES-Syntax.
|
|
24
|
+
|
|
25
|
+
### Deprecated
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
17
31
|
---
|
|
18
32
|
|
|
19
33
|
## 2.9.0 - 2022-10-25
|
package/example/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {Style, Stroke, Fill, Icon} from "ol/style.js";
|
|
|
4
4
|
|
|
5
5
|
import * as mpapi from "../src";
|
|
6
6
|
import mapsAPI from "../src/maps/api.js";
|
|
7
|
-
import
|
|
7
|
+
import rawLayerList from "../src/rawLayerList";
|
|
8
8
|
|
|
9
9
|
import services from "./config/services.json";
|
|
10
10
|
import portalConfig from "./config/portal.json";
|
|
11
11
|
import localGeoJSON from "./config/localGeoJSON.js";
|
|
12
|
-
import
|
|
12
|
+
import load3DScriptModule from "../src/lib/load3DScript";
|
|
13
13
|
|
|
14
14
|
function errorCallback (errorEvent) {
|
|
15
15
|
console.error("This is an error event:", errorEvent);
|
|
@@ -55,7 +55,7 @@ document.getElementById("enable").addEventListener("click", function () {
|
|
|
55
55
|
|
|
56
56
|
document.getElementById("layer-visibility").style.display = "block";
|
|
57
57
|
|
|
58
|
-
load3DScript(lib, function Loaded3DCallback () {
|
|
58
|
+
load3DScriptModule.load3DScript(lib, function Loaded3DCallback () {
|
|
59
59
|
let tilesetLayer = null;
|
|
60
60
|
|
|
61
61
|
const settings3D = {
|
|
@@ -71,9 +71,9 @@ document.getElementById("enable").addEventListener("click", function () {
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
map3D = mapsAPI.map.createMap(settings3D, "3D"),
|
|
74
|
-
rawLayerTerrain = getLayerWhere({id: "4001"}),
|
|
75
|
-
rawLayerTileset = getLayerWhere({id: "4002"}),
|
|
76
|
-
rawLayerEntities = getLayerWhere({id: "4003"});
|
|
74
|
+
rawLayerTerrain = rawLayerList.getLayerWhere({id: "4001"}),
|
|
75
|
+
rawLayerTileset = rawLayerList.getLayerWhere({id: "4002"}),
|
|
76
|
+
rawLayerEntities = rawLayerList.getLayerWhere({id: "4003"});
|
|
77
77
|
|
|
78
78
|
window.mpapi.map = map3D;
|
|
79
79
|
tilesetLayer = new mpapi.Tileset(rawLayerTileset, window.mpapi.map);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterportal/masterportalapi",
|
|
3
3
|
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
package/src/crs.js
CHANGED
|
@@ -121,7 +121,7 @@ function transformFromMapProjection (map, targetProjection, point) {
|
|
|
121
121
|
return transform(getMapProjection(map), targetProjection, point);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
export default {
|
|
125
125
|
transformFromMapProjection,
|
|
126
126
|
transformToMapProjection,
|
|
127
127
|
transform,
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {createMapView} from "./maps/mapView";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import crs from "./crs";
|
|
3
|
+
import rawLayerList from "./rawLayerList";
|
|
4
4
|
import * as wms from "./layer/wms";
|
|
5
5
|
import * as wmts from "./layer/wmts";
|
|
6
6
|
import * as wfs from "./layer/wfs";
|
package/src/layer/wms.js
CHANGED
|
@@ -5,7 +5,7 @@ import TileGrid from "ol/tilegrid/TileGrid";
|
|
|
5
5
|
import ImageWMS from "ol/source/ImageWMS.js";
|
|
6
6
|
import {get as getProjection} from "ol/proj";
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import rawLayerList from "../rawLayerList";
|
|
9
9
|
|
|
10
10
|
const OLCS_DEFAULT_OLCS_PROJECTION_CRS = "EPSG:3857";
|
|
11
11
|
|
package/src/lib/load3DScript.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {Function} callback - the Function to call after loading has completed
|
|
5
5
|
* @returns {undefined}
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
function load3DScript (fileName, callback) {
|
|
8
8
|
const head = document.getElementsByTagName("head")[0],
|
|
9
9
|
script = document.createElement("script");
|
|
10
10
|
|
|
@@ -20,3 +20,7 @@ export function load3DScript (fileName, callback) {
|
|
|
20
20
|
};
|
|
21
21
|
head.appendChild(script);
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
load3DScript
|
|
26
|
+
};
|
package/src/maps/ol/olMap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Map} from "ol";
|
|
2
|
-
import {defaults as olDefaultInteractions} from "ol/interaction.js";
|
|
2
|
+
import {DragPan, defaults as olDefaultInteractions} from "ol/interaction.js";
|
|
3
3
|
import setBackgroundImage from "../../lib/setBackgroundImage";
|
|
4
4
|
import getInitialLayers from "../../lib/getInitialLayers";
|
|
5
5
|
import defaults from "../../defaults";
|
|
@@ -11,8 +11,8 @@ import * as vectorBase from "../../layer/vectorBase";
|
|
|
11
11
|
import * as vectortile from "../../layer/vectorTile";
|
|
12
12
|
import * as oaf from "../../layer/oaf";
|
|
13
13
|
import {createMapView} from "../../maps/mapView";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
14
|
+
import rawLayerList from "../../rawLayerList";
|
|
15
|
+
import crs from "../../crs";
|
|
16
16
|
import {setGazetteerUrl} from "../../searchAddress";
|
|
17
17
|
|
|
18
18
|
let mapIdCounter = 0;
|
|
@@ -146,12 +146,18 @@ Map.prototype.addLayer = addLayer;
|
|
|
146
146
|
* @returns {object} map object from ol
|
|
147
147
|
*/
|
|
148
148
|
export function createMap (config = defaults, {mapParams, callback, errorCallback} = {}) {
|
|
149
|
-
registerProjections(config.namedProjections);
|
|
149
|
+
crs.registerProjections(config.namedProjections);
|
|
150
150
|
setBackgroundImage(config);
|
|
151
151
|
setGazetteerUrl(config.gazetteerUrl);
|
|
152
152
|
const map = new Map(Object.assign({
|
|
153
153
|
target: config.target || defaults.target,
|
|
154
|
-
interactions: olDefaultInteractions({altShiftDragRotate: false, pinchRotate: false})
|
|
154
|
+
interactions: olDefaultInteractions({dragPan: false, altShiftDragRotate: false, pinchRotate: false}).extend([
|
|
155
|
+
new DragPan({
|
|
156
|
+
condition: function (event) {
|
|
157
|
+
return (!event.originalEvent.pointerType || event.originalEvent.pointerType === "mouse") || (config.twoFingerPan && this.getPointerCount() === 2) || !config.twoFingerPan;
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
]),
|
|
155
161
|
controls: [],
|
|
156
162
|
view: createMapView(config)
|
|
157
163
|
}, mapParams));
|
package/src/rawLayerList.js
CHANGED
package/test/crs.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Map, View} from "ol";
|
|
2
2
|
import proj4 from "proj4";
|
|
3
3
|
import * as Proj from "ol/proj.js";
|
|
4
|
-
import
|
|
4
|
+
import crs from "../src/crs";
|
|
5
5
|
|
|
6
6
|
const namedProjections = [
|
|
7
7
|
["EPSG:31467", "+title=Bessel/Gauß-Krüger 3 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs"],
|
|
@@ -6,7 +6,7 @@ import {Feature} from "ol";
|
|
|
6
6
|
import Polygon from "ol/geom/Polygon";
|
|
7
7
|
|
|
8
8
|
import * as vectorTile from "../../src/layer/vectorTile";
|
|
9
|
-
import
|
|
9
|
+
import crs from "../../src/crs";
|
|
10
10
|
import defaults from "../../src/defaults";
|
|
11
11
|
|
|
12
12
|
jest.mock("../../src/rawLayerList.js", () => {
|
|
@@ -18,7 +18,7 @@ jest.mock("../../src/rawLayerList.js", () => {
|
|
|
18
18
|
|
|
19
19
|
describe("vectorTile.js", function () {
|
|
20
20
|
|
|
21
|
-
beforeAll(() => registerProjections());
|
|
21
|
+
beforeAll(() => crs.registerProjections());
|
|
22
22
|
|
|
23
23
|
const layerParams = {
|
|
24
24
|
name: "VT Test",
|
package/test/map.test.js
CHANGED
|
@@ -2,12 +2,12 @@ import {Map} from "ol";
|
|
|
2
2
|
import TileLayer from "ol/layer/Tile";
|
|
3
3
|
import map from "../src/maps/map.js";
|
|
4
4
|
import {createMap as create3DMap} from "../src/maps/olcs/olcsMap.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import rawLayerList from "../src/rawLayerList.js";
|
|
6
|
+
import crs from "../src/crs.js";
|
|
7
7
|
import setBackgroundImage from "../src/lib/setBackgroundImage.js";
|
|
8
8
|
import {createMapView} from "../src/maps/mapView";
|
|
9
9
|
import defaults from "../src/defaults";
|
|
10
|
-
import
|
|
10
|
+
import load3DScriptModule from "../src/lib/load3DScript";
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
* This test is mocking a lot to check what functions are called with.
|
|
@@ -15,18 +15,23 @@ import {load3DScript} from "../src/lib/load3DScript";
|
|
|
15
15
|
*/
|
|
16
16
|
jest.mock("ol");
|
|
17
17
|
jest.mock("../src/rawLayerList.js", () => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const originalModule = jest.requireActual("../src/rawLayerList.js");
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
__esModule: true,
|
|
22
|
+
...originalModule,
|
|
23
|
+
default: {
|
|
24
|
+
getLayerWhere: ({id}) => ({
|
|
25
|
+
exists: {
|
|
26
|
+
typ: "doesntExist"
|
|
27
|
+
},
|
|
28
|
+
works: {
|
|
29
|
+
typ: "WMS"
|
|
30
|
+
}
|
|
31
|
+
})[id],
|
|
32
|
+
initializeLayerList: jest.fn()
|
|
26
33
|
}
|
|
27
|
-
}
|
|
28
|
-
original.initializeLayerList = jest.fn();
|
|
29
|
-
return original;
|
|
34
|
+
};
|
|
30
35
|
});
|
|
31
36
|
jest.mock("../src/crs.js");
|
|
32
37
|
jest.mock("../src/lib/setBackgroundImage.js");
|
|
@@ -38,8 +43,8 @@ describe("map.js", function () {
|
|
|
38
43
|
const callback = jest.fn();
|
|
39
44
|
|
|
40
45
|
map.createMap(defaults, "2D", {mapParams: {}, callback: callback});
|
|
41
|
-
expect(initializeLayerList).toHaveBeenCalledWith(defaults.layerConf, expect.any(Function));
|
|
42
|
-
expect(registerProjections).toHaveBeenCalledWith(defaults.namedProjections);
|
|
46
|
+
expect(rawLayerList.initializeLayerList).toHaveBeenCalledWith(defaults.layerConf, expect.any(Function));
|
|
47
|
+
expect(crs.registerProjections).toHaveBeenCalledWith(defaults.namedProjections);
|
|
43
48
|
expect(setBackgroundImage).toHaveBeenCalledWith(defaults);
|
|
44
49
|
});
|
|
45
50
|
|
|
@@ -70,7 +75,7 @@ describe("map.js", function () {
|
|
|
70
75
|
cesiumLib: "https://lib.virtualcitymap.de/v3.6.x/lib/Cesium/Cesium.js"
|
|
71
76
|
};
|
|
72
77
|
|
|
73
|
-
load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
78
|
+
load3DScriptModule.load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
74
79
|
const map3D = map.createMap(config, "3D");
|
|
75
80
|
|
|
76
81
|
expect(create3DMap).toHaveBeenCalledWith(defaults);
|
|
@@ -163,7 +168,7 @@ describe("map.js", function () {
|
|
|
163
168
|
cesiumLib: "https://lib.virtualcitymap.de/v3.6.x/lib/Cesium/Cesium.js"
|
|
164
169
|
};
|
|
165
170
|
|
|
166
|
-
load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
171
|
+
load3DScriptModule.load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
167
172
|
const map3D = map.createMap(config, "3D");
|
|
168
173
|
|
|
169
174
|
expect(map3D.mapMode).toBe("3D");
|
|
@@ -198,7 +203,7 @@ describe("map.js", function () {
|
|
|
198
203
|
cesiumLib: "https://lib.virtualcitymap.de/v3.6.x/lib/Cesium/Cesium.js"
|
|
199
204
|
};
|
|
200
205
|
|
|
201
|
-
load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
206
|
+
load3DScriptModule.load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
202
207
|
const map3D = map.createMap(config, "3D");
|
|
203
208
|
|
|
204
209
|
expect(map3D.mapMode).toBe("3D");
|
|
@@ -243,7 +248,7 @@ describe("map.js", function () {
|
|
|
243
248
|
cesiumLib: "https://lib.virtualcitymap.de/v3.6.x/lib/Cesium/Cesium.js"
|
|
244
249
|
};
|
|
245
250
|
|
|
246
|
-
load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
251
|
+
load3DScriptModule.load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
247
252
|
const map3D = map.createMap(config, "3D");
|
|
248
253
|
|
|
249
254
|
expect(map3D.mapMode).toBe("3D");
|
|
@@ -279,7 +284,7 @@ describe("map.js", function () {
|
|
|
279
284
|
cesiumLib: "https://lib.virtualcitymap.de/v3.6.x/lib/Cesium/Cesium.js"
|
|
280
285
|
};
|
|
281
286
|
|
|
282
|
-
load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
287
|
+
load3DScriptModule.load3DScript(config.cesiumLib, function Loaded3DCallback () {
|
|
283
288
|
const map3D = map.createMap(config, "3D");
|
|
284
289
|
|
|
285
290
|
expect(map3D.mapMode).toBe("3D");
|