@masterportal/masterportalapi 2.59.0 → 2.60.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 +13 -1
- package/example/config/services.json +51 -0
- package/example/index.js +13 -0
- package/package.json +3 -2
- package/publiccode.yml +2 -2
- package/src/layer/vectorTile.js +51 -29
- package/test/layer/vectorTile.test.js +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## 2.60.0 - 2026-04-10
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Issue #15: At VectorTile layer the `vtStyles` attribute is evaluated, and the style is applied using the `layers` attribute or to the styles attribute `defaultStyle`.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- The following packages have been updated:
|
|
13
|
+
- dependencies:
|
|
14
|
+
- ol-mapbox-style: 12.5.0 to 13.3.0
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 2.59.0 - 2026-03-13
|
|
7
19
|
|
|
8
20
|
### Changed
|
|
9
21
|
- Updated examples to prevent console errors caused by certain layers/services.
|
|
@@ -200,6 +200,57 @@
|
|
|
200
200
|
}
|
|
201
201
|
]
|
|
202
202
|
},
|
|
203
|
+
{
|
|
204
|
+
"id": "6002",
|
|
205
|
+
"name": "ArcGIS VectorTile with layers attribute",
|
|
206
|
+
"shortname": "VectorTile",
|
|
207
|
+
"typ": "VectorTile",
|
|
208
|
+
"visibility": false,
|
|
209
|
+
"preview": {
|
|
210
|
+
"src": "./resources/vectorTile.png"
|
|
211
|
+
},
|
|
212
|
+
"layers": "M020_N/DS07_TatsaechlicheNutzung/G020_600_GEB_TNutz_F/P05_CI054_Platz,M020_N/DS07_TatsaechlicheNutzung/G020_600_GEB_TNutz_F/P06_CI060_BaulichGepraegteFlaeche",
|
|
213
|
+
"gfiAttributes": "showAll",
|
|
214
|
+
"url": "https://test.geoportal-hamburg.de/vt/esri/tile/{z}/{y}/{x}.pbf",
|
|
215
|
+
"epsg": "EPSG:25832",
|
|
216
|
+
"extent": [
|
|
217
|
+
441336.2209999999,
|
|
218
|
+
5915995,
|
|
219
|
+
594002,
|
|
220
|
+
5986767.56699999981
|
|
221
|
+
],
|
|
222
|
+
"origin": [
|
|
223
|
+
-9497963.94293634221,
|
|
224
|
+
9997963.94293634221
|
|
225
|
+
],
|
|
226
|
+
"resolutions": [
|
|
227
|
+
39054.5466520950868,
|
|
228
|
+
19527.2733260475434,
|
|
229
|
+
9763.63666302377169,
|
|
230
|
+
4881.81833151188584,
|
|
231
|
+
2440.90916575594292,
|
|
232
|
+
1220.45458287797146,
|
|
233
|
+
610.227291438985731,
|
|
234
|
+
305.113645719492865,
|
|
235
|
+
152.556822859746433,
|
|
236
|
+
76.2784114298732163,
|
|
237
|
+
38.1392057149366082,
|
|
238
|
+
19.0696028574683041,
|
|
239
|
+
9.534801428734152,
|
|
240
|
+
4.767400714367076,
|
|
241
|
+
2.383700357183538,
|
|
242
|
+
1.191850178591769
|
|
243
|
+
],
|
|
244
|
+
"tileSize": 512,
|
|
245
|
+
"vtStyles": [
|
|
246
|
+
{
|
|
247
|
+
"id": "VectorTile_STYLE",
|
|
248
|
+
"name": "Test",
|
|
249
|
+
"url": "https://test.geoportal-hamburg.de/vt/esri/resources/styles/root.json",
|
|
250
|
+
"defaultStyle": true
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
203
254
|
{
|
|
204
255
|
"id": "7001",
|
|
205
256
|
"name": "TopPlusOpen",
|
package/example/index.js
CHANGED
|
@@ -195,6 +195,19 @@ fetch(vtStyleUrl)
|
|
|
195
195
|
});
|
|
196
196
|
*/
|
|
197
197
|
|
|
198
|
+
/* VECTOR TILE EXAMPLE 2, using layers attribute */
|
|
199
|
+
/*
|
|
200
|
+
document.getElementById("enable").style.display = "none";
|
|
201
|
+
window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
|
202
|
+
|
|
203
|
+
window.mpapi.map.getLayers().forEach(layer => {
|
|
204
|
+
window.mpapi.map.removeLayer(layer);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const vtLayer = window.mpapi.map.addLayer("6002");
|
|
208
|
+
|
|
209
|
+
*/
|
|
210
|
+
|
|
198
211
|
/* WMTS example */
|
|
199
212
|
/*
|
|
200
213
|
window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
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.60.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"core-js": "^3.33.1",
|
|
36
36
|
"dayjs": "^1.11.10",
|
|
37
37
|
"ol": "10.8.0",
|
|
38
|
-
"ol-mapbox-style": "
|
|
38
|
+
"ol-mapbox-style": "13.3.0",
|
|
39
39
|
"olcs": "^2.22.1",
|
|
40
40
|
"proj4": "^2.10.0",
|
|
41
41
|
"xml2js": "^0.6.2"
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
85
85
|
"directories": {
|
|
86
|
+
"doc": "docs",
|
|
86
87
|
"example": "example",
|
|
87
88
|
"test": "test"
|
|
88
89
|
},
|
package/publiccode.yml
CHANGED
|
@@ -81,8 +81,8 @@ maintenance:
|
|
|
81
81
|
name: Masterportal
|
|
82
82
|
platforms:
|
|
83
83
|
- web
|
|
84
|
-
releaseDate: '2026-
|
|
84
|
+
releaseDate: '2026-04-10'
|
|
85
85
|
roadmap: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/src/master/'
|
|
86
86
|
softwareType: api
|
|
87
|
-
softwareVersion: 2.
|
|
87
|
+
softwareVersion: 2.60.0
|
|
88
88
|
url: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git'
|
package/src/layer/vectorTile.js
CHANGED
|
@@ -4,7 +4,7 @@ import VectorTileSource from "ol/source/VectorTile";
|
|
|
4
4
|
import OpenLayersTileGrid from "ol/tilegrid/TileGrid";
|
|
5
5
|
import {extentFromProjection} from "ol/tilegrid";
|
|
6
6
|
import * as webgl from "../renderer/webgl";
|
|
7
|
-
import {apply, stylefunction} from "ol-mapbox-style";
|
|
7
|
+
import {apply, applyStyle, stylefunction} from "ol-mapbox-style";
|
|
8
8
|
|
|
9
9
|
import defaults from "../defaults";
|
|
10
10
|
|
|
@@ -132,9 +132,54 @@ export function createLayerSource (url, options = {}) {
|
|
|
132
132
|
return new VectorTileSource(sourceParams);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Set a mapbox style
|
|
137
|
+
* @param {ol.layer.VectorTile} layer - layer to style
|
|
138
|
+
* @param {object} glStyle - MapBox style definition
|
|
139
|
+
* @param {options} [styleParams={}] - Additional options for style specification
|
|
140
|
+
* @param {string} url - MapBox style url
|
|
141
|
+
* @returns {void}
|
|
142
|
+
*/
|
|
143
|
+
export function setStyle (layer, glStyle, {options = {}} = {}, url) {
|
|
144
|
+
if (url) {
|
|
145
|
+
fetch(url)
|
|
146
|
+
.then(response => response.json())
|
|
147
|
+
.then(style => {
|
|
148
|
+
const styles = options.layers ? style.layers.filter((styleLayer) => options.layers.includes(styleLayer.id)) : style.layers;
|
|
149
|
+
|
|
150
|
+
style.layers = styles;
|
|
151
|
+
applyStyle(layer, style);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (glStyle && glStyle.sources) {
|
|
155
|
+
|
|
156
|
+
Object.keys(glStyle.sources).forEach((key) => {
|
|
157
|
+
const glStyleSourceId = key;
|
|
158
|
+
|
|
159
|
+
if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
|
|
160
|
+
const olMap = layer.get("map");
|
|
161
|
+
|
|
162
|
+
apply(olMap, url);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
stylefunction(layer, glStyle,
|
|
166
|
+
options.sourceId ? options.sourceId : glStyleSourceId,
|
|
167
|
+
options.resolutions,
|
|
168
|
+
options.spriteData,
|
|
169
|
+
options.spriteImageUrl,
|
|
170
|
+
options.getFonts);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
135
177
|
/**
|
|
136
178
|
* Creates a Vector Tiles layer.
|
|
137
179
|
*
|
|
180
|
+
* Note: Within the vtStyles of a layer we introduced a boolean flag called defaultStyle.
|
|
181
|
+
* This option allows to mark a vtStyle as default. When not present, the first entry will be taken
|
|
182
|
+
* as style.
|
|
138
183
|
* @param {rawLayer} rawLayer - rawLayer as specified in services.json
|
|
139
184
|
* @param {object} [layerParams={}] - extra params of the layer. Can overwrite or extend all ol layer parameters.
|
|
140
185
|
* @param {object} [options={}] - parameter object. Not used atm.
|
|
@@ -176,34 +221,11 @@ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {
|
|
|
176
221
|
if (options.style && rawLayer.renderer !== "webgl") {
|
|
177
222
|
layer.setStyle(options.style);
|
|
178
223
|
}
|
|
224
|
+
if (rawLayer.vtStyles) {
|
|
225
|
+
const vtStyle = rawLayer.vtStyles.filter((style) => style.defaultStyle)[0] || rawLayer.vtStyles[0];
|
|
179
226
|
|
|
180
|
-
|
|
181
|
-
}
|
|
227
|
+
setStyle(layer, {}, {options: {layers: rawLayer.layers}}, vtStyle.url);
|
|
182
228
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
* @param {ol.layer.VectorTile} layer - layer to style
|
|
186
|
-
* @param {object} glStyle - MapBox style definition
|
|
187
|
-
* @param {options} [styleParams={}] - Additional options for style specification
|
|
188
|
-
* @param {string} url - MapBox style url
|
|
189
|
-
* @returns {void}
|
|
190
|
-
*/
|
|
191
|
-
export function setStyle (layer, glStyle, {options = {}} = {}, url) {
|
|
192
|
-
Object.keys(glStyle.sources).forEach((key) => {
|
|
193
|
-
const glStyleSourceId = key;
|
|
194
|
-
|
|
195
|
-
if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
|
|
196
|
-
const olMap = layer.get("map");
|
|
197
|
-
|
|
198
|
-
apply(olMap, url);
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
stylefunction(layer, glStyle,
|
|
202
|
-
options.sourceId ? options.sourceId : glStyleSourceId,
|
|
203
|
-
options.resolutions,
|
|
204
|
-
options.spriteData,
|
|
205
|
-
options.spriteImageUrl,
|
|
206
|
-
options.getFonts);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
229
|
+
}
|
|
230
|
+
return layer;
|
|
209
231
|
}
|
|
@@ -29,7 +29,11 @@ jest.mock("../../src/renderer/webgl.js", () => {
|
|
|
29
29
|
|
|
30
30
|
describe("vectorTile.js", function () {
|
|
31
31
|
|
|
32
|
-
beforeAll(() =>
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
crs.registerProjections();
|
|
34
|
+
global.Request = global.Request || jest.fn();
|
|
35
|
+
global.Response = global.Response || jest.fn();
|
|
36
|
+
});
|
|
33
37
|
|
|
34
38
|
const rawLayer = {
|
|
35
39
|
name: "VT Test",
|