@mapcreator/sdk 0.0.7 → 0.0.9
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/dist/{HighlightManager.d.ts → esm/HighlightManager.d.ts} +2 -2
- package/dist/esm/HighlightManager.js +203 -0
- package/dist/{MCMap.d.ts → esm/MCMap.d.ts} +3 -5
- package/dist/esm/MCMap.js +254 -0
- package/dist/{PopupManager.d.ts → esm/PopupManager.d.ts} +4 -4
- package/dist/esm/PopupManager.js +297 -0
- package/dist/{Registry.d.ts → esm/Registry.d.ts} +3 -3
- package/dist/esm/Registry.js +74 -0
- package/dist/{adornments → esm/adornments}/categoricalLegend.d.ts +1 -1
- package/dist/esm/adornments/categoricalLegend.js +141 -0
- package/dist/{adornments → esm/adornments}/connectedLegend.d.ts +2 -2
- package/dist/esm/adornments/connectedLegend.js +393 -0
- package/dist/{adornments → esm/adornments}/customAdornment.d.ts +1 -1
- package/dist/esm/adornments/customAdornment.js +29 -0
- package/dist/{adornments → esm/adornments}/heading.d.ts +1 -1
- package/dist/esm/adornments/heading.js +71 -0
- package/dist/esm/adornments/insetMap.d.ts +3 -0
- package/dist/esm/adornments/insetMap.js +351 -0
- package/dist/{adornments → esm/adornments}/manualLegend.d.ts +1 -1
- package/dist/esm/adornments/manualLegend.js +15 -0
- package/dist/esm/adornments/northArrow.d.ts +3 -0
- package/dist/esm/adornments/northArrow.js +24 -0
- package/dist/esm/adornments/scalebar.d.ts +3 -0
- package/dist/esm/adornments/scalebar.js +176 -0
- package/dist/{constants → esm/constants}/index.d.ts +2 -2
- package/dist/esm/constants/index.js +53 -0
- package/dist/esm/controls/controls.js +7 -0
- package/dist/{controls → esm/controls}/fullscreenControls.d.ts +1 -1
- package/dist/esm/controls/fullscreenControls.js +29 -0
- package/dist/{controls → esm/controls}/geocoderControl.d.ts +1 -1
- package/dist/esm/controls/geocoderControl.js +202 -0
- package/dist/{controls → esm/controls}/geolocationControls.d.ts +1 -1
- package/dist/esm/controls/geolocationControls.js +65 -0
- package/dist/esm/controls/refreshMapControls.d.ts +3 -0
- package/dist/esm/controls/refreshMapControls.js +26 -0
- package/dist/esm/controls/webControls.d.ts +4 -0
- package/dist/esm/controls/webControls.js +40 -0
- package/dist/{controls → esm/controls}/zoomControls.d.ts +1 -1
- package/dist/esm/controls/zoomControls.js +23 -0
- package/dist/esm/i18n.js +21 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/locales/da_DK/strings.json +7 -0
- package/dist/esm/locales/de_DE/strings.json +7 -0
- package/dist/esm/locales/en_GB/strings.json +7 -0
- package/dist/esm/locales/es_ES/strings.json +7 -0
- package/dist/esm/locales/fr_FR/strings.json +7 -0
- package/dist/esm/locales/it_IT/strings.json +7 -0
- package/dist/esm/locales/nl_NL/strings.json +7 -0
- package/dist/esm/models/area.d.ts +5 -0
- package/dist/esm/models/area.js +165 -0
- package/dist/esm/models/circle.d.ts +5 -0
- package/dist/esm/models/circle.js +110 -0
- package/dist/esm/models/dot.d.ts +3 -0
- package/dist/esm/models/dot.js +42 -0
- package/dist/esm/models/line.d.ts +4 -0
- package/dist/esm/models/line.js +117 -0
- package/dist/esm/models/marker.d.ts +5 -0
- package/dist/esm/models/marker.js +179 -0
- package/dist/esm/models/polygon.d.ts +5 -0
- package/dist/esm/models/polygon.js +80 -0
- package/dist/{renderAdornments.d.ts → esm/renderAdornments.d.ts} +3 -3
- package/dist/esm/renderAdornments.js +129 -0
- package/dist/esm/types/geometry.js +1 -0
- package/dist/{types → esm/types}/index.d.ts +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/jobObject.js +1 -0
- package/dist/{types → esm/types}/mapstyle.d.ts +6 -2
- package/dist/esm/types/mapstyle.js +1 -0
- package/dist/esm/utils/browser.js +6 -0
- package/dist/{utils → esm/utils}/choropleth.d.ts +3 -3
- package/dist/esm/utils/choropleth.js +110 -0
- package/dist/esm/utils/fullscreen.js +40 -0
- package/dist/{utils → esm/utils}/geolocation.d.ts +1 -1
- package/dist/esm/utils/geolocation.js +93 -0
- package/dist/{utils → esm/utils}/graphhopper.d.ts +1 -1
- package/dist/esm/utils/graphhopper.js +41 -0
- package/dist/{utils → esm/utils}/helpers.d.ts +2 -2
- package/dist/esm/utils/helpers.js +116 -0
- package/dist/{utils → esm/utils}/language.d.ts +1 -1
- package/dist/esm/utils/language.js +170 -0
- package/dist/{utils → esm/utils}/models.d.ts +4 -4
- package/dist/esm/utils/models.js +103 -0
- package/dist/{utils → esm/utils}/overlays.d.ts +1 -1
- package/dist/esm/utils/overlays.js +87 -0
- package/dist/esm/utils/scalebar.js +52 -0
- package/dist/{utils → esm/utils}/svgHelpers.d.ts +4 -3
- package/dist/esm/utils/svgHelpers.js +1512 -0
- package/dist/{utils → esm/utils}/template.d.ts +2 -2
- package/dist/esm/utils/template.js +120 -0
- package/dist/{utils → esm/utils}/youtube.d.ts +1 -1
- package/dist/esm/utils/youtube.js +64 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/mapcreator-sdk.umd.cjs +91 -91
- package/dist/report.html +4950 -0
- package/package.json +7 -7
- package/dist/adornments/insetMap.d.ts +0 -3
- package/dist/adornments/northArrow.d.ts +0 -3
- package/dist/adornments/scalebar.d.ts +0 -3
- package/dist/controls/refreshMapControls.d.ts +0 -3
- package/dist/controls/webControls.d.ts +0 -4
- package/dist/index.d.ts +0 -2
- package/dist/locales/da_DK/strings.json.d.ts +0 -10
- package/dist/locales/de_DE/strings.json.d.ts +0 -10
- package/dist/locales/en_GB/strings.json.d.ts +0 -10
- package/dist/locales/es_ES/strings.json.d.ts +0 -10
- package/dist/locales/fr_FR/strings.json.d.ts +0 -10
- package/dist/locales/it_IT/strings.json.d.ts +0 -10
- package/dist/locales/nl_NL/strings.json.d.ts +0 -10
- package/dist/mapcreator-sdk.js +0 -39590
- package/dist/models/area.d.ts +0 -5
- package/dist/models/circle.d.ts +0 -5
- package/dist/models/dot.d.ts +0 -3
- package/dist/models/line.d.ts +0 -4
- package/dist/models/marker.d.ts +0 -5
- package/dist/models/polygon.d.ts +0 -5
- /package/dist/{controls → esm/controls}/controls.d.ts +0 -0
- /package/dist/{i18n.d.ts → esm/i18n.d.ts} +0 -0
- /package/dist/{types → esm/types}/geometry.d.ts +0 -0
- /package/dist/{types → esm/types}/jobObject.d.ts +0 -0
- /package/dist/{utils → esm/utils}/browser.d.ts +0 -0
- /package/dist/{utils → esm/utils}/fullscreen.d.ts +0 -0
- /package/dist/{utils → esm/utils}/scalebar.d.ts +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { calculateCircle, calculateRadiusLine } from '@/utils/models';
|
|
2
|
+
import { getColorValue, SvgCache } from '@/utils/svgHelpers';
|
|
3
|
+
import { stringToId } from '@/utils/helpers';
|
|
4
|
+
export function addCircleGroup(map, group, beforeId, svgs, svgCache) {
|
|
5
|
+
map.addSource(group.id, {
|
|
6
|
+
type: 'geojson',
|
|
7
|
+
data: {
|
|
8
|
+
type: 'FeatureCollection',
|
|
9
|
+
features: group.models
|
|
10
|
+
.filter(model => model.visible ?? true)
|
|
11
|
+
.map(model => buildFeature(group, model, svgs, svgCache)),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
map.addLayer({
|
|
15
|
+
id: group.id,
|
|
16
|
+
type: 'fill',
|
|
17
|
+
source: group.id,
|
|
18
|
+
metadata: {
|
|
19
|
+
'mc-model-type': 'circle',
|
|
20
|
+
'mc-group-id': group.id,
|
|
21
|
+
},
|
|
22
|
+
filter: ['==', ['geometry-type'], 'Polygon'],
|
|
23
|
+
paint: {
|
|
24
|
+
'fill-color': ['get', 'fill-color'],
|
|
25
|
+
},
|
|
26
|
+
}, beforeId);
|
|
27
|
+
map.addLayer({
|
|
28
|
+
id: `${group.id}-pattern`,
|
|
29
|
+
type: 'fill',
|
|
30
|
+
source: group.id,
|
|
31
|
+
filter: ['has', 'fill-pattern'],
|
|
32
|
+
paint: {
|
|
33
|
+
'fill-pattern': ['get', 'fill-pattern'],
|
|
34
|
+
},
|
|
35
|
+
metadata: {
|
|
36
|
+
'mc-model-type': 'circle',
|
|
37
|
+
'mc-group-id': group.id,
|
|
38
|
+
},
|
|
39
|
+
}, beforeId);
|
|
40
|
+
map.addLayer({
|
|
41
|
+
id: `${group.id}-radius-line`,
|
|
42
|
+
type: 'line',
|
|
43
|
+
source: group.id,
|
|
44
|
+
metadata: {
|
|
45
|
+
'mc-model-type': 'circle',
|
|
46
|
+
'mc-group-id': group.id,
|
|
47
|
+
},
|
|
48
|
+
filter: ['all', ['==', ['geometry-type'], 'LineString'], ['get', 'radius-line-enabled']],
|
|
49
|
+
paint: {
|
|
50
|
+
'line-color': ['get', 'radius-line-color'],
|
|
51
|
+
'line-width': ['get', 'radius-line-width'],
|
|
52
|
+
},
|
|
53
|
+
}, beforeId);
|
|
54
|
+
map.addLayer({
|
|
55
|
+
id: `${group.id}-outline`,
|
|
56
|
+
type: 'line',
|
|
57
|
+
source: group.id,
|
|
58
|
+
metadata: {
|
|
59
|
+
'mc-model-type': 'circle',
|
|
60
|
+
'mc-group-id': group.id,
|
|
61
|
+
},
|
|
62
|
+
filter: ['==', ['geometry-type'], 'Polygon'],
|
|
63
|
+
layout: {
|
|
64
|
+
'line-cap': 'round',
|
|
65
|
+
'line-join': 'round',
|
|
66
|
+
},
|
|
67
|
+
paint: {
|
|
68
|
+
'line-width': ['get', 'outline-width'],
|
|
69
|
+
'line-color': ['get', 'outline-color'],
|
|
70
|
+
},
|
|
71
|
+
}, beforeId);
|
|
72
|
+
}
|
|
73
|
+
function buildFeature(group, circle, svgs, svgCache) {
|
|
74
|
+
const patternKey = circle.fillPattern !== undefined
|
|
75
|
+
? svgCache.getMapLibreImageKey(svgs[circle.fillPattern], 2 * window.devicePixelRatio)
|
|
76
|
+
: undefined;
|
|
77
|
+
return {
|
|
78
|
+
type: 'Feature',
|
|
79
|
+
id: stringToId(circle.id),
|
|
80
|
+
properties: {
|
|
81
|
+
'id': circle.id,
|
|
82
|
+
'fill-color': group.fillColor || circle.fillColor
|
|
83
|
+
? getColorValue(circle.dataBindings ?? {}, circle.fillColor, group.fillColor)
|
|
84
|
+
: '#000000',
|
|
85
|
+
'outline-color': group.outlineColor || circle.outlineColor
|
|
86
|
+
? getColorValue(circle.dataBindings ?? {}, circle.outlineColor, group.outlineColor)
|
|
87
|
+
: '#000000',
|
|
88
|
+
'outline-width': circle.outlineWidth ?? 0,
|
|
89
|
+
'fill-pattern': patternKey,
|
|
90
|
+
'radius-line-enabled': circle.radiusLineEnabled ?? false,
|
|
91
|
+
'radius-line-color': group.radiusLineColor || circle.radiusLineColor
|
|
92
|
+
? getColorValue(circle.dataBindings ?? {}, circle.radiusLineColor, group.radiusLineColor)
|
|
93
|
+
: '#000000',
|
|
94
|
+
'radius-line-width': circle.radiusLineWidth ?? 0,
|
|
95
|
+
},
|
|
96
|
+
geometry: {
|
|
97
|
+
type: 'GeometryCollection',
|
|
98
|
+
geometries: [
|
|
99
|
+
{
|
|
100
|
+
type: 'Polygon',
|
|
101
|
+
coordinates: [calculateCircle(circle.center, circle.radius)],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: 'LineString',
|
|
105
|
+
coordinates: calculateRadiusLine(circle.center, circle.radius, circle.radiusLineBearing ?? 0),
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getColorValue } from '@/utils/svgHelpers';
|
|
2
|
+
export function addDotGroup(map, group, beforeId) {
|
|
3
|
+
map.addSource(group.id, {
|
|
4
|
+
type: 'geojson',
|
|
5
|
+
data: {
|
|
6
|
+
type: 'FeatureCollection',
|
|
7
|
+
features: group.models
|
|
8
|
+
.filter(model => model.visible ?? true)
|
|
9
|
+
.map(model => buildFeature(group, model)),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
map.addLayer({
|
|
13
|
+
id: group.id,
|
|
14
|
+
type: 'circle',
|
|
15
|
+
source: group.id,
|
|
16
|
+
metadata: {
|
|
17
|
+
'mc-model-type': 'dot',
|
|
18
|
+
'mc-group-id': group.id,
|
|
19
|
+
},
|
|
20
|
+
paint: {
|
|
21
|
+
'circle-color': ['get', 'circle-color'],
|
|
22
|
+
'circle-radius': ['get', 'circle-radius'],
|
|
23
|
+
},
|
|
24
|
+
}, beforeId);
|
|
25
|
+
}
|
|
26
|
+
function buildFeature(group, dot) {
|
|
27
|
+
return {
|
|
28
|
+
type: 'Feature',
|
|
29
|
+
id: dot.id,
|
|
30
|
+
properties: {
|
|
31
|
+
'id': dot.id,
|
|
32
|
+
'circle-radius': dot.radius,
|
|
33
|
+
'circle-color': group.fillColor || dot.fillColor
|
|
34
|
+
? getColorValue(dot.dataBindings ?? {}, dot.fillColor, group.fillColor)
|
|
35
|
+
: '#000000',
|
|
36
|
+
},
|
|
37
|
+
geometry: {
|
|
38
|
+
type: 'Point',
|
|
39
|
+
coordinates: [dot.center.lng, dot.center.lat],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SvgCache } from '@/utils/svgHelpers';
|
|
2
|
+
import type { JobObjectLineGroup } from '@/types/jobObject';
|
|
3
|
+
import type { Map } from '@mapcreator/maplibre-gl';
|
|
4
|
+
export declare function addLineGroup(map: Map, group: JobObjectLineGroup, beforeId: string, svgCache: SvgCache): void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { getColorValue, getSvgValue, SvgCache } from '@/utils/svgHelpers';
|
|
2
|
+
import { getLineAngle } from '@/utils/models';
|
|
3
|
+
import { stringToId } from '@/utils/helpers';
|
|
4
|
+
const lineDashValues = {
|
|
5
|
+
solid: [1, 0],
|
|
6
|
+
dotted: [0.7, 0.3],
|
|
7
|
+
dashed: [3.5, 1.5],
|
|
8
|
+
};
|
|
9
|
+
export function addLineGroup(map, group, beforeId, svgCache) {
|
|
10
|
+
map.addSource(group.id, {
|
|
11
|
+
type: 'geojson',
|
|
12
|
+
data: {
|
|
13
|
+
type: 'FeatureCollection',
|
|
14
|
+
features: group.models
|
|
15
|
+
.filter(model => model.visible ?? true)
|
|
16
|
+
.map(model => buildFeature(map, group, model, svgCache)),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
Object.entries(lineDashValues).forEach(([lineStyle, dashArray]) => {
|
|
20
|
+
if (group.models.some(line => (line.lineStyle ?? 'solid') === lineStyle)) {
|
|
21
|
+
map.addLayer({
|
|
22
|
+
id: `${group.id}-${lineStyle}`,
|
|
23
|
+
type: 'line',
|
|
24
|
+
source: group.id,
|
|
25
|
+
metadata: {
|
|
26
|
+
'mc-model-type': 'line',
|
|
27
|
+
'mc-group-id': group.id,
|
|
28
|
+
},
|
|
29
|
+
filter: [
|
|
30
|
+
'all',
|
|
31
|
+
['==', ['geometry-type'], 'LineString'],
|
|
32
|
+
['==', ['get', 'line-style'], lineStyle],
|
|
33
|
+
],
|
|
34
|
+
paint: {
|
|
35
|
+
'line-width': ['get', 'line-width'],
|
|
36
|
+
'line-color': ['get', 'line-color'],
|
|
37
|
+
'line-dasharray': dashArray,
|
|
38
|
+
},
|
|
39
|
+
}, beforeId);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
map.addLayer({
|
|
43
|
+
id: `${group.id}-clickable`,
|
|
44
|
+
type: 'line',
|
|
45
|
+
source: group.id,
|
|
46
|
+
metadata: {
|
|
47
|
+
'mc-model-type': 'line',
|
|
48
|
+
'mc-group-id': group.id,
|
|
49
|
+
},
|
|
50
|
+
paint: {
|
|
51
|
+
'line-width': ['max', ['get', 'line-width'], 15],
|
|
52
|
+
'line-opacity': 0,
|
|
53
|
+
},
|
|
54
|
+
filter: ['==', ['geometry-type'], 'LineString'],
|
|
55
|
+
}, beforeId);
|
|
56
|
+
if (group.models.some(line => line.svg)) {
|
|
57
|
+
map.addLayer({
|
|
58
|
+
id: `${group.id}-icon`,
|
|
59
|
+
type: 'symbol',
|
|
60
|
+
source: group.id,
|
|
61
|
+
metadata: {
|
|
62
|
+
'mc-model-type': 'line',
|
|
63
|
+
'mc-group-id': group.id,
|
|
64
|
+
},
|
|
65
|
+
layout: {
|
|
66
|
+
'icon-allow-overlap': true,
|
|
67
|
+
'icon-ignore-placement': true,
|
|
68
|
+
'icon-image': ['get', 'mc-image-key'],
|
|
69
|
+
'icon-anchor': 'center',
|
|
70
|
+
'icon-size': ['get', 'icon-size'],
|
|
71
|
+
'icon-rotate': ['get', 'icon-rotate'],
|
|
72
|
+
'icon-offset': ['get', 'icon-offset'],
|
|
73
|
+
},
|
|
74
|
+
filter: ['==', ['geometry-type'], 'Point'],
|
|
75
|
+
}, beforeId);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function buildFeature(map, group, line, svgCache) {
|
|
79
|
+
const maplibreImageKey = line.svg !== undefined
|
|
80
|
+
? svgCache.getMapLibreImageKey(getSvgValue(line.dataBindings ?? {}, line.svg, undefined), window.devicePixelRatio * (line.iconScale ?? 1))
|
|
81
|
+
: undefined;
|
|
82
|
+
return {
|
|
83
|
+
type: 'Feature',
|
|
84
|
+
id: stringToId(line.id),
|
|
85
|
+
properties: {
|
|
86
|
+
'id': line.id,
|
|
87
|
+
'line-width': line.lineWidth ?? 3,
|
|
88
|
+
'line-color': group.lineColor || line.lineColor
|
|
89
|
+
? getColorValue(line.dataBindings ?? {}, line.lineColor, group.lineColor)
|
|
90
|
+
: '#000000',
|
|
91
|
+
'line-style': line.lineStyle ?? 'solid',
|
|
92
|
+
'mc-image-key': maplibreImageKey,
|
|
93
|
+
'icon-rotate': getIconRotation(line, map),
|
|
94
|
+
'icon-offset': line.iconOffset,
|
|
95
|
+
'icon-size': line.iconScale,
|
|
96
|
+
},
|
|
97
|
+
geometry: {
|
|
98
|
+
type: 'GeometryCollection',
|
|
99
|
+
geometries: [
|
|
100
|
+
{
|
|
101
|
+
type: 'LineString',
|
|
102
|
+
coordinates: line.geometry,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'Point',
|
|
106
|
+
coordinates: line.geometry[line.geometry.length - 1],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function getIconRotation(line, map) {
|
|
113
|
+
if (!line.iconRotation) {
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
return line.iconAlign ? getLineAngle(line.geometry, map) + line.iconRotation : line.iconRotation;
|
|
117
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SvgCache } from '@/utils/svgHelpers';
|
|
2
|
+
import type { JobObjectMarkerGroup } from '@/types/jobObject';
|
|
3
|
+
import type { Map } from '@mapcreator/maplibre-gl';
|
|
4
|
+
import type { Svgs } from '@/types';
|
|
5
|
+
export declare function addMarkerGroup(map: Map, group: JobObjectMarkerGroup, beforeId: string, svgs: Svgs, svgCache: SvgCache): void;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { getColorValue, getSvgValue, getTextValue, SvgCache } from '@/utils/svgHelpers';
|
|
2
|
+
import { stringToId } from '@/utils/helpers';
|
|
3
|
+
const defaultFont = 'Roboto-Regular';
|
|
4
|
+
export function addMarkerGroup(map, group, beforeId, svgs, svgCache) {
|
|
5
|
+
const features = [];
|
|
6
|
+
const fontSet = new Set();
|
|
7
|
+
const lineHeights = new Set();
|
|
8
|
+
const textFontExpression = ['match', ['get', 'text-font']];
|
|
9
|
+
const cluster = Boolean(group.clustering);
|
|
10
|
+
for (const marker of group.models) {
|
|
11
|
+
if (marker.visible ?? true) {
|
|
12
|
+
features.push(buildFeature(group, marker, svgs, svgCache));
|
|
13
|
+
}
|
|
14
|
+
fontSet.add(marker.textFont);
|
|
15
|
+
lineHeights.add(marker.textLineHeight ?? 1.2);
|
|
16
|
+
}
|
|
17
|
+
const fonts = Array.from(fontSet);
|
|
18
|
+
if (fonts.length > 0) {
|
|
19
|
+
for (const font of Array.from(fontSet)) {
|
|
20
|
+
textFontExpression.push(font, ['literal', [font, defaultFont]]);
|
|
21
|
+
}
|
|
22
|
+
textFontExpression.push(['literal', [defaultFont]]);
|
|
23
|
+
}
|
|
24
|
+
map.addSource(group.id, {
|
|
25
|
+
type: 'geojson',
|
|
26
|
+
data: {
|
|
27
|
+
type: 'FeatureCollection',
|
|
28
|
+
features,
|
|
29
|
+
},
|
|
30
|
+
cluster,
|
|
31
|
+
clusterRadius: group.clusterRadius ?? 50,
|
|
32
|
+
clusterMaxZoom: group.clusterMaxZoom ?? 14,
|
|
33
|
+
});
|
|
34
|
+
lineHeights.forEach(lineHeight => {
|
|
35
|
+
map.addLayer({
|
|
36
|
+
id: `${group.id}-${lineHeight}`,
|
|
37
|
+
type: 'symbol',
|
|
38
|
+
source: group.id,
|
|
39
|
+
metadata: {
|
|
40
|
+
'mc-model-type': 'marker',
|
|
41
|
+
'mc-group-id': group.id,
|
|
42
|
+
},
|
|
43
|
+
layout: {
|
|
44
|
+
'icon-allow-overlap': !group.collisionDetection,
|
|
45
|
+
'icon-ignore-placement': !group.collisionDetection,
|
|
46
|
+
'text-allow-overlap': !group.collisionDetection,
|
|
47
|
+
'text-ignore-placement': !group.collisionDetection,
|
|
48
|
+
'icon-image': ['get', 'mc-image-key'],
|
|
49
|
+
'icon-anchor': ['get', 'icon-anchor'],
|
|
50
|
+
'icon-size': ['get', 'icon-size'],
|
|
51
|
+
'icon-rotate': ['get', 'icon-rotate'],
|
|
52
|
+
'icon-offset': ['get', 'icon-offset'],
|
|
53
|
+
'text-field': '{text}',
|
|
54
|
+
'text-font': textFontExpression,
|
|
55
|
+
'text-max-width': ['get', 'text-max-width'],
|
|
56
|
+
'text-offset': ['get', 'text-offset'],
|
|
57
|
+
'text-rotate': ['get', 'text-rotate'],
|
|
58
|
+
'text-size': ['get', 'text-size'],
|
|
59
|
+
'text-anchor': ['get', 'text-anchor'],
|
|
60
|
+
'text-letter-spacing': ['get', 'text-letter-spacing'],
|
|
61
|
+
'text-line-height': lineHeight,
|
|
62
|
+
'text-justify': ['get', 'text-justify'],
|
|
63
|
+
},
|
|
64
|
+
paint: {
|
|
65
|
+
'text-color': ['get', 'text-color'],
|
|
66
|
+
'text-halo-color': ['get', 'text-halo-color'],
|
|
67
|
+
'text-halo-width': ['get', 'text-halo-width'],
|
|
68
|
+
},
|
|
69
|
+
filter: [
|
|
70
|
+
'all',
|
|
71
|
+
['==', ['get', 'text-line-height'], lineHeight],
|
|
72
|
+
['!', ['has', 'point_count']],
|
|
73
|
+
],
|
|
74
|
+
}, beforeId);
|
|
75
|
+
});
|
|
76
|
+
if (cluster) {
|
|
77
|
+
map.addLayer({
|
|
78
|
+
id: `${group.id}-circle-cluster`,
|
|
79
|
+
type: 'circle',
|
|
80
|
+
source: group.id,
|
|
81
|
+
filter: ['has', 'point_count'],
|
|
82
|
+
paint: {
|
|
83
|
+
'circle-color': {
|
|
84
|
+
property: 'point_count',
|
|
85
|
+
type: 'interval',
|
|
86
|
+
stops: group.clusterCircleColor ?? [],
|
|
87
|
+
},
|
|
88
|
+
'circle-radius': {
|
|
89
|
+
property: 'point_count',
|
|
90
|
+
type: 'interval',
|
|
91
|
+
stops: group.clusterCircleRadius ?? [],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
map.addLayer({
|
|
96
|
+
id: `${group.id}-text-cluster`,
|
|
97
|
+
type: 'symbol',
|
|
98
|
+
source: group.id,
|
|
99
|
+
filter: ['has', 'point_count'],
|
|
100
|
+
paint: {
|
|
101
|
+
'text-color': {
|
|
102
|
+
property: 'point_count',
|
|
103
|
+
type: 'interval',
|
|
104
|
+
stops: group.clusterTextColor ?? [],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
layout: {
|
|
108
|
+
'text-font': ['literal', [defaultFont]],
|
|
109
|
+
'text-field': '{point_count_abbreviated}',
|
|
110
|
+
'text-size': {
|
|
111
|
+
property: 'point_count',
|
|
112
|
+
type: 'interval',
|
|
113
|
+
stops: group.clusterTextSize ?? [],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
addClusterClick(map, group);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function addClusterClick(map, group) {
|
|
121
|
+
map.on('click', `${group.id}-circle-cluster`, async (e) => {
|
|
122
|
+
const cluster = map.queryRenderedFeatures(e.point).find(feature => feature.properties.cluster);
|
|
123
|
+
if (!cluster) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const source = map.getSource(cluster.source);
|
|
127
|
+
if (!source) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const zoom = await source.getClusterExpansionZoom(Number(cluster.id));
|
|
131
|
+
map.easeTo({
|
|
132
|
+
center: cluster.geometry.coordinates,
|
|
133
|
+
zoom,
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function buildFeature(group, marker, svgs, svgCache) {
|
|
138
|
+
const maplibreImageKey = marker.svg !== undefined
|
|
139
|
+
? svgCache.getMapLibreImageKey(getSvgValue(marker.dataBindings ?? {}, svgs[marker.svg], group.svg ? svgs[group.svg] : undefined), window.devicePixelRatio * (marker.iconScale ?? 1))
|
|
140
|
+
: undefined;
|
|
141
|
+
return {
|
|
142
|
+
type: 'Feature',
|
|
143
|
+
id: stringToId(marker.id),
|
|
144
|
+
properties: {
|
|
145
|
+
'id': marker.id,
|
|
146
|
+
'mc-image-key': maplibreImageKey,
|
|
147
|
+
'icon-anchor': marker.iconAnchor ?? 'center',
|
|
148
|
+
'icon-rotate': marker.iconRotation ?? 0,
|
|
149
|
+
'icon-offset': marker.iconOffset ?? [0, 0],
|
|
150
|
+
'icon-size': marker.iconScale ?? 1,
|
|
151
|
+
'text': group.text || marker.text
|
|
152
|
+
? getTextValue(marker.dataBindings ?? {}, marker.text, group.text)
|
|
153
|
+
: undefined,
|
|
154
|
+
'text-anchor': marker.textAnchor ?? 'center',
|
|
155
|
+
'text-font': marker.textFont,
|
|
156
|
+
'text-offset': [
|
|
157
|
+
(marker.textOffset?.[0] ?? 0) / (marker.textSize ?? 16),
|
|
158
|
+
(marker.textOffset?.[1] ?? 0) / (marker.textSize ?? 16),
|
|
159
|
+
],
|
|
160
|
+
'text-rotate': marker.textRotation ?? 0,
|
|
161
|
+
'text-max-width': marker.textMaxWidth ?? 10,
|
|
162
|
+
'text-size': marker.textSize ?? 16,
|
|
163
|
+
'text-color': group.textColor || marker.textColor
|
|
164
|
+
? getColorValue(marker.dataBindings ?? {}, marker.textColor, group.textColor)
|
|
165
|
+
: '#000000',
|
|
166
|
+
'text-halo-color': group.textHaloColor || marker.textHaloColor
|
|
167
|
+
? getColorValue(marker.dataBindings ?? {}, marker.textHaloColor, group.textHaloColor)
|
|
168
|
+
: '#000000',
|
|
169
|
+
'text-halo-width': marker.textHaloWidth ?? 0,
|
|
170
|
+
'text-line-height': marker.textLineHeight ?? 1.2,
|
|
171
|
+
'text-letter-spacing': marker.textLetterSpacing ?? 0,
|
|
172
|
+
'text-justify': marker.textJustify ?? 'center',
|
|
173
|
+
},
|
|
174
|
+
geometry: {
|
|
175
|
+
type: 'Point',
|
|
176
|
+
coordinates: [marker.lngLat.lng, marker.lngLat.lat],
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SvgCache } from '@/utils/svgHelpers';
|
|
2
|
+
import type { JobObjectPolygonGroup } from '@/types/jobObject';
|
|
3
|
+
import type { Map } from '@mapcreator/maplibre-gl';
|
|
4
|
+
import type { Svgs } from '@/types';
|
|
5
|
+
export declare function addPolygonGroup(map: Map, group: JobObjectPolygonGroup, beforeId: string, svgs: Svgs, svgCache: SvgCache): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getColorValue, SvgCache } from '@/utils/svgHelpers';
|
|
2
|
+
import { calculatePolygonGeometry } from '@/utils/models';
|
|
3
|
+
import { stringToId } from '@/utils/helpers';
|
|
4
|
+
export function addPolygonGroup(map, group, beforeId, svgs, svgCache) {
|
|
5
|
+
map.addSource(group.id, {
|
|
6
|
+
type: 'geojson',
|
|
7
|
+
data: {
|
|
8
|
+
type: 'FeatureCollection',
|
|
9
|
+
features: group.models
|
|
10
|
+
.filter(model => model.visible ?? true)
|
|
11
|
+
.map(model => buildFeature(group, model, svgs, svgCache)),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
map.addLayer({
|
|
15
|
+
id: group.id,
|
|
16
|
+
type: 'fill',
|
|
17
|
+
source: group.id,
|
|
18
|
+
metadata: {
|
|
19
|
+
'mc-model-type': 'polygon',
|
|
20
|
+
'mc-group-id': group.id,
|
|
21
|
+
},
|
|
22
|
+
paint: {
|
|
23
|
+
'fill-color': ['get', 'fill-color'],
|
|
24
|
+
},
|
|
25
|
+
}, beforeId);
|
|
26
|
+
map.addLayer({
|
|
27
|
+
id: `${group.id}-pattern`,
|
|
28
|
+
type: 'fill',
|
|
29
|
+
source: group.id,
|
|
30
|
+
filter: ['has', 'fill-pattern'],
|
|
31
|
+
paint: {
|
|
32
|
+
'fill-pattern': ['get', 'fill-pattern'],
|
|
33
|
+
},
|
|
34
|
+
metadata: {
|
|
35
|
+
'mc-model-type': 'polygon',
|
|
36
|
+
'mc-group-id': group.id,
|
|
37
|
+
},
|
|
38
|
+
}, beforeId);
|
|
39
|
+
map.addLayer({
|
|
40
|
+
id: `${group.id}-outline`,
|
|
41
|
+
type: 'line',
|
|
42
|
+
source: group.id,
|
|
43
|
+
metadata: {
|
|
44
|
+
'mc-model-type': 'polygon',
|
|
45
|
+
'mc-group-id': group.id,
|
|
46
|
+
},
|
|
47
|
+
layout: {
|
|
48
|
+
'line-cap': 'round',
|
|
49
|
+
'line-join': 'round',
|
|
50
|
+
},
|
|
51
|
+
paint: {
|
|
52
|
+
'line-width': ['get', 'outline-width'],
|
|
53
|
+
'line-color': ['get', 'outline-color'],
|
|
54
|
+
},
|
|
55
|
+
}, beforeId);
|
|
56
|
+
}
|
|
57
|
+
function buildFeature(group, polygon, svgs, svgCache) {
|
|
58
|
+
const patternKey = polygon.fillPattern !== undefined
|
|
59
|
+
? svgCache.getMapLibreImageKey(svgs[polygon.fillPattern], 2 * window.devicePixelRatio)
|
|
60
|
+
: undefined;
|
|
61
|
+
return {
|
|
62
|
+
type: 'Feature',
|
|
63
|
+
id: stringToId(polygon.id),
|
|
64
|
+
properties: {
|
|
65
|
+
'id': polygon.id,
|
|
66
|
+
'fill-color': group.fillColor || polygon.fillColor
|
|
67
|
+
? getColorValue(polygon.dataBindings ?? {}, polygon.fillColor, group.fillColor)
|
|
68
|
+
: '#000000',
|
|
69
|
+
'outline-color': group.outlineColor || polygon.outlineColor
|
|
70
|
+
? getColorValue(polygon.dataBindings ?? {}, polygon.outlineColor, group.outlineColor)
|
|
71
|
+
: '#000000',
|
|
72
|
+
'outline-width': polygon.outlineWidth ?? 0,
|
|
73
|
+
'fill-pattern': patternKey,
|
|
74
|
+
},
|
|
75
|
+
geometry: {
|
|
76
|
+
type: 'Polygon',
|
|
77
|
+
coordinates: calculatePolygonGeometry(polygon),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PositionOffsets, JobObject } from '
|
|
2
|
-
import { Map as MapLibre } from '@mapcreator/maplibre-gl';
|
|
3
|
-
import { InitialPositionInfo } from '
|
|
1
|
+
import type { PositionOffsets, JobObject } from '@/types/jobObject';
|
|
2
|
+
import type { Map as MapLibre } from '@mapcreator/maplibre-gl';
|
|
3
|
+
import type { InitialPositionInfo } from '@/types';
|
|
4
4
|
export declare function useRenderAdornments(jobObject: JobObject, positionOffsets: PositionOffsets | undefined, map: MapLibre, initialPosition: InitialPositionInfo, vapiUrl: string, cdnUrl: string, accessToken: string): void;
|