@mapcreator/sdk 0.0.9 → 0.0.11

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.
Files changed (121) hide show
  1. package/README.md +29 -0
  2. package/dist/{esm/HighlightManager.d.ts → HighlightManager.d.ts} +2 -2
  3. package/dist/{esm/MCMap.d.ts → MCMap.d.ts} +1 -1
  4. package/dist/{esm/PopupManager.d.ts → PopupManager.d.ts} +4 -4
  5. package/dist/{esm/Registry.d.ts → Registry.d.ts} +3 -3
  6. package/dist/{esm/adornments → adornments}/categoricalLegend.d.ts +1 -1
  7. package/dist/{esm/adornments → adornments}/connectedLegend.d.ts +2 -2
  8. package/dist/{esm/adornments → adornments}/customAdornment.d.ts +1 -1
  9. package/dist/{esm/adornments → adornments}/heading.d.ts +1 -1
  10. package/dist/adornments/insetMap.d.ts +3 -0
  11. package/dist/{esm/adornments → adornments}/manualLegend.d.ts +1 -1
  12. package/dist/adornments/northArrow.d.ts +3 -0
  13. package/dist/adornments/scalebar.d.ts +3 -0
  14. package/dist/{esm/constants → constants}/index.d.ts +2 -2
  15. package/dist/{esm/controls → controls}/fullscreenControls.d.ts +1 -1
  16. package/dist/{esm/controls → controls}/geocoderControl.d.ts +1 -1
  17. package/dist/{esm/controls → controls}/geolocationControls.d.ts +1 -1
  18. package/dist/controls/refreshMapControls.d.ts +3 -0
  19. package/dist/controls/webControls.d.ts +4 -0
  20. package/dist/{esm/controls → controls}/zoomControls.d.ts +1 -1
  21. package/dist/index.d.ts +3 -0
  22. package/dist/locales/da_DK/strings.json.d.ts +10 -0
  23. package/dist/locales/de_DE/strings.json.d.ts +10 -0
  24. package/dist/locales/en_GB/strings.json.d.ts +10 -0
  25. package/dist/locales/es_ES/strings.json.d.ts +10 -0
  26. package/dist/locales/fr_FR/strings.json.d.ts +10 -0
  27. package/dist/locales/it_IT/strings.json.d.ts +10 -0
  28. package/dist/locales/nl_NL/strings.json.d.ts +10 -0
  29. package/dist/mapcreator-sdk.js +39590 -0
  30. package/dist/models/area.d.ts +5 -0
  31. package/dist/models/circle.d.ts +5 -0
  32. package/dist/models/dot.d.ts +3 -0
  33. package/dist/models/line.d.ts +4 -0
  34. package/dist/models/marker.d.ts +5 -0
  35. package/dist/models/polygon.d.ts +5 -0
  36. package/dist/{esm/renderAdornments.d.ts → renderAdornments.d.ts} +3 -3
  37. package/dist/{esm/types → types}/index.d.ts +1 -1
  38. package/dist/{esm/types → types}/mapstyle.d.ts +2 -6
  39. package/dist/{esm/utils → utils}/choropleth.d.ts +3 -3
  40. package/dist/{esm/utils → utils}/geolocation.d.ts +1 -1
  41. package/dist/{esm/utils → utils}/graphhopper.d.ts +1 -1
  42. package/dist/{esm/utils → utils}/helpers.d.ts +2 -2
  43. package/dist/{esm/utils → utils}/language.d.ts +1 -1
  44. package/dist/{esm/utils → utils}/models.d.ts +4 -4
  45. package/dist/{esm/utils → utils}/overlays.d.ts +1 -1
  46. package/dist/{esm/utils → utils}/svgHelpers.d.ts +3 -4
  47. package/dist/{esm/utils → utils}/template.d.ts +2 -2
  48. package/dist/{esm/utils → utils}/youtube.d.ts +1 -1
  49. package/package.json +8 -6
  50. package/dist/esm/HighlightManager.js +0 -203
  51. package/dist/esm/MCMap.js +0 -254
  52. package/dist/esm/PopupManager.js +0 -297
  53. package/dist/esm/Registry.js +0 -74
  54. package/dist/esm/adornments/categoricalLegend.js +0 -141
  55. package/dist/esm/adornments/connectedLegend.js +0 -393
  56. package/dist/esm/adornments/customAdornment.js +0 -29
  57. package/dist/esm/adornments/heading.js +0 -71
  58. package/dist/esm/adornments/insetMap.d.ts +0 -3
  59. package/dist/esm/adornments/insetMap.js +0 -351
  60. package/dist/esm/adornments/manualLegend.js +0 -15
  61. package/dist/esm/adornments/northArrow.d.ts +0 -3
  62. package/dist/esm/adornments/northArrow.js +0 -24
  63. package/dist/esm/adornments/scalebar.d.ts +0 -3
  64. package/dist/esm/adornments/scalebar.js +0 -176
  65. package/dist/esm/constants/index.js +0 -53
  66. package/dist/esm/controls/controls.js +0 -7
  67. package/dist/esm/controls/fullscreenControls.js +0 -29
  68. package/dist/esm/controls/geocoderControl.js +0 -202
  69. package/dist/esm/controls/geolocationControls.js +0 -65
  70. package/dist/esm/controls/refreshMapControls.d.ts +0 -3
  71. package/dist/esm/controls/refreshMapControls.js +0 -26
  72. package/dist/esm/controls/webControls.d.ts +0 -4
  73. package/dist/esm/controls/webControls.js +0 -40
  74. package/dist/esm/controls/zoomControls.js +0 -23
  75. package/dist/esm/i18n.js +0 -21
  76. package/dist/esm/index.d.ts +0 -5
  77. package/dist/esm/index.js +0 -5
  78. package/dist/esm/locales/da_DK/strings.json +0 -7
  79. package/dist/esm/locales/de_DE/strings.json +0 -7
  80. package/dist/esm/locales/en_GB/strings.json +0 -7
  81. package/dist/esm/locales/es_ES/strings.json +0 -7
  82. package/dist/esm/locales/fr_FR/strings.json +0 -7
  83. package/dist/esm/locales/it_IT/strings.json +0 -7
  84. package/dist/esm/locales/nl_NL/strings.json +0 -7
  85. package/dist/esm/models/area.d.ts +0 -5
  86. package/dist/esm/models/area.js +0 -165
  87. package/dist/esm/models/circle.d.ts +0 -5
  88. package/dist/esm/models/circle.js +0 -110
  89. package/dist/esm/models/dot.d.ts +0 -3
  90. package/dist/esm/models/dot.js +0 -42
  91. package/dist/esm/models/line.d.ts +0 -4
  92. package/dist/esm/models/line.js +0 -117
  93. package/dist/esm/models/marker.d.ts +0 -5
  94. package/dist/esm/models/marker.js +0 -179
  95. package/dist/esm/models/polygon.d.ts +0 -5
  96. package/dist/esm/models/polygon.js +0 -80
  97. package/dist/esm/renderAdornments.js +0 -129
  98. package/dist/esm/types/geometry.js +0 -1
  99. package/dist/esm/types/index.js +0 -1
  100. package/dist/esm/types/jobObject.js +0 -1
  101. package/dist/esm/types/mapstyle.js +0 -1
  102. package/dist/esm/utils/browser.js +0 -6
  103. package/dist/esm/utils/choropleth.js +0 -110
  104. package/dist/esm/utils/fullscreen.js +0 -40
  105. package/dist/esm/utils/geolocation.js +0 -93
  106. package/dist/esm/utils/graphhopper.js +0 -41
  107. package/dist/esm/utils/helpers.js +0 -116
  108. package/dist/esm/utils/language.js +0 -170
  109. package/dist/esm/utils/models.js +0 -103
  110. package/dist/esm/utils/overlays.js +0 -87
  111. package/dist/esm/utils/scalebar.js +0 -52
  112. package/dist/esm/utils/svgHelpers.js +0 -1512
  113. package/dist/esm/utils/template.js +0 -120
  114. package/dist/esm/utils/youtube.js +0 -64
  115. /package/dist/{esm/controls → controls}/controls.d.ts +0 -0
  116. /package/dist/{esm/i18n.d.ts → i18n.d.ts} +0 -0
  117. /package/dist/{esm/types → types}/geometry.d.ts +0 -0
  118. /package/dist/{esm/types → types}/jobObject.d.ts +0 -0
  119. /package/dist/{esm/utils → utils}/browser.d.ts +0 -0
  120. /package/dist/{esm/utils → utils}/fullscreen.d.ts +0 -0
  121. /package/dist/{esm/utils → utils}/scalebar.d.ts +0 -0
@@ -1,110 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- import type { JobObjectDotGroup } from '@/types/jobObject';
2
- import type { Map } from '@mapcreator/maplibre-gl';
3
- export declare function addDotGroup(map: Map, group: JobObjectDotGroup, beforeId: string): void;
@@ -1,42 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
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;
@@ -1,117 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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;
@@ -1,179 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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;
@@ -1,80 +0,0 @@
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,129 +0,0 @@
1
- import { useCustomAdornment } from '@/adornments/customAdornment';
2
- import { useConnectedLegend } from '@/adornments/connectedLegend';
3
- import { useManualLegend } from '@/adornments/manualLegend';
4
- import { useNorthArrow } from '@/adornments/northArrow';
5
- import { useWebControls } from '@/controls/webControls';
6
- import { useInsetMap } from '@/adornments/insetMap';
7
- import { useScalebar } from '@/adornments/scalebar';
8
- import { useHeading } from '@/adornments/heading';
9
- import { positionConfig } from '@/constants';
10
- const positions = [
11
- 'top_left',
12
- 'top_right',
13
- 'bottom_left',
14
- 'bottom_right',
15
- 'top_center',
16
- 'left_center',
17
- 'right_center',
18
- 'bottom_center',
19
- ];
20
- const adornmentContainers = new Map();
21
- export function useRenderAdornments(jobObject, positionOffsets, map, initialPosition, vapiUrl, cdnUrl, accessToken) {
22
- const { adornments = [] } = jobObject;
23
- createContainers(map, positionOffsets);
24
- adornments.forEach(adornment => {
25
- if (adornment.type === 'custom') {
26
- const customElement = useCustomAdornment(adornment);
27
- addAdornment(customElement, adornment.position, adornment.stacking);
28
- }
29
- else if (adornment.type === 'scalebar') {
30
- const scalebarElement = useScalebar(adornment, map);
31
- addAdornment(scalebarElement, adornment.position, adornment.stacking);
32
- }
33
- else if (adornment.type === 'northArrow') {
34
- const northArrowElement = useNorthArrow(adornment, map);
35
- addAdornment(northArrowElement, adornment.position, adornment.stacking);
36
- }
37
- else if (adornment.type === 'webControls' && adornment.buttons) {
38
- const webControlsElement = useWebControls(adornment, map, initialPosition);
39
- addAdornment(webControlsElement, adornment.position, adornment.stacking);
40
- }
41
- else if (adornment.type === 'insetMap') {
42
- const insetMapElement = useInsetMap(adornment, map, cdnUrl);
43
- addAdornment(insetMapElement, adornment.position, adornment.stacking);
44
- }
45
- else if (adornment.type === 'heading') {
46
- const headerElement = useHeading(adornment, vapiUrl, accessToken);
47
- addAdornment(headerElement, adornment.position, adornment.stacking);
48
- }
49
- else if (adornment.type === 'manualLegend') {
50
- const categoricalLegendElement = useManualLegend(adornment, vapiUrl, accessToken);
51
- addAdornment(categoricalLegendElement, adornment.position, adornment.stacking);
52
- }
53
- else if (adornment.type === 'connectedLegend') {
54
- const connectedLegendElement = useConnectedLegend(adornment, jobObject, map, vapiUrl, accessToken);
55
- addAdornment(connectedLegendElement, adornment.position, adornment.stacking);
56
- }
57
- });
58
- updateCollisionDetection(map);
59
- map.on('moveend', () => updateCollisionDetection(map));
60
- }
61
- function createContainers(map, positionOffsets) {
62
- const mapContainer = map.getContainer();
63
- for (const position of positions) {
64
- const container = document.createElement('div');
65
- container.classList.add('adornment-container', `${position}`);
66
- if (positionOffsets?.[position]) {
67
- container.style.cssText = getContainerStyle(position, positionOffsets);
68
- }
69
- const horizontal = document.createElement('div');
70
- const vertical = document.createElement('div');
71
- container.classList.add('adornment-container', position);
72
- horizontal.classList.add('inner');
73
- vertical.classList.add('inner', 'vertical');
74
- container.append(horizontal, vertical);
75
- mapContainer.appendChild(container);
76
- adornmentContainers.set(position, {
77
- horizontal,
78
- vertical,
79
- });
80
- }
81
- }
82
- function getContainerStyle(position, positionOffsets) {
83
- const cfg = positionConfig[position];
84
- const { x, y, unit } = positionOffsets[position];
85
- let style = '';
86
- const transforms = [];
87
- if (cfg.x === 'center') {
88
- transforms.push(`translateX(${x}${unit})`);
89
- }
90
- else {
91
- style += `${cfg.x}: ${x}${unit};`;
92
- }
93
- if (cfg.y === 'center') {
94
- transforms.push(`translateY(${y}${unit})`);
95
- }
96
- else if (position === 'bottom_right') {
97
- style += `${cfg.y}: max(${y}${unit}, 25px);`;
98
- }
99
- else {
100
- style += `${cfg.y}: ${y}${unit};`;
101
- }
102
- if (transforms.length) {
103
- style += `transform: ${transforms.join(' ')};`;
104
- }
105
- return style;
106
- }
107
- function addAdornment(adornment, position, stacking) {
108
- if (!stacking) {
109
- stacking = ['left_center', 'right_center'].includes(position) ? 'vertical' : 'horizontal';
110
- }
111
- const container = adornmentContainers.get(position);
112
- const dominantAxis = position === 'left_center' || position === 'right_center' ? 'vertical' : 'horizontal';
113
- if (!container?.[dominantAxis].hasChildNodes()) {
114
- stacking = dominantAxis;
115
- }
116
- const target = container?.[stacking];
117
- target?.appendChild(adornment);
118
- }
119
- function updateCollisionDetection(map) {
120
- const elements = Array.from(document.querySelectorAll('.adornment, .maplibregl-ctrl-attrib'));
121
- const labelFreeAreas = [];
122
- elements.forEach(el => {
123
- const rect = el.getBoundingClientRect();
124
- if (rect) {
125
- labelFreeAreas.push([rect.x, rect.y, rect.x + rect.width, rect.y + rect.height]);
126
- }
127
- });
128
- map.setLabelFreeAreas(labelFreeAreas);
129
- }