@defra/interactive-map 0.0.16-alpha → 0.0.17-alpha
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/assets/images/slot-map.svg +264 -0
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/slots.md +16 -15
- package/docs/api.md +3 -3
- package/docs/getting-started.md +4 -1
- package/docs/plugins/datasets.md +561 -0
- package/docs/plugins.md +1 -1
- package/package.json +2 -2
- package/plugins/beta/datasets/dist/css/index.css +85 -15
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/index.js +1 -1
- package/plugins/beta/datasets/src/DatasetsInit.jsx +23 -8
- package/plugins/beta/datasets/src/adapters/maplibre/index.js +18 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +113 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerIds.js +69 -0
- package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +338 -0
- package/plugins/beta/datasets/src/adapters/maplibre/patternRegistry.js +48 -0
- package/plugins/beta/datasets/src/api/addDataset.js +2 -8
- package/plugins/beta/datasets/src/api/getOpacity.js +17 -0
- package/plugins/beta/datasets/src/api/getStyle.js +13 -0
- package/plugins/beta/datasets/src/api/removeDataset.js +2 -44
- package/plugins/beta/datasets/src/api/setData.js +8 -0
- package/plugins/beta/datasets/src/api/setDatasetVisibility.js +37 -0
- package/plugins/beta/datasets/src/api/setFeatureVisibility.js +22 -0
- package/plugins/beta/datasets/src/api/setOpacity.js +29 -0
- package/plugins/beta/datasets/src/api/setStyle.js +22 -0
- package/plugins/beta/datasets/src/datasets.js +29 -55
- package/plugins/beta/datasets/src/defaults.js +42 -8
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +34 -25
- package/plugins/beta/datasets/src/fetch/fetchGeoJSON.js +2 -2
- package/plugins/beta/datasets/src/manifest.js +24 -16
- package/plugins/beta/datasets/src/panels/Key.jsx +128 -50
- package/plugins/beta/datasets/src/panels/Key.module.scss +48 -9
- package/plugins/beta/datasets/src/panels/Layers.jsx +132 -29
- package/plugins/beta/datasets/src/panels/Layers.module.scss +50 -8
- package/plugins/beta/datasets/src/reducer.js +128 -9
- package/plugins/beta/datasets/src/styles/patterns.js +157 -0
- package/plugins/beta/datasets/src/utils/bbox.js +7 -5
- package/plugins/beta/datasets/src/utils/filters.js +5 -2
- package/plugins/beta/datasets/src/utils/mergeSublayer.js +78 -0
- package/plugins/beta/draw-ml/dist/css/index.css +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/draw.scss +0 -7
- package/plugins/beta/draw-ml/src/manifest.js +16 -16
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/src/Frame.jsx +5 -5
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/src/manifest.js +1 -1
- package/plugins/beta/scale-bar/dist/css/index.css +1 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/src/index.test.js +3 -3
- package/plugins/beta/scale-bar/src/manifest.js +3 -3
- package/plugins/beta/scale-bar/src/scaleBar.scss +2 -1
- package/plugins/interact/dist/css/index.css +1 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/src/interact.scss +0 -7
- package/plugins/interact/src/manifest.js +14 -18
- package/plugins/interact/src/manifest.test.js +3 -1
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/src/components/Form/Form.module.scss +2 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +1 -0
- package/providers/maplibre/src/utils/highlightFeatures.test.js +1 -0
- package/src/App/components/Actions/Actions.jsx +2 -2
- package/src/App/components/Actions/Actions.module.scss +0 -7
- package/src/App/components/Actions/Actions.test.jsx +1 -1
- package/src/App/components/Icon/Icon.jsx +3 -2
- package/src/App/components/Icon/Icon.module.scss +4 -0
- package/src/App/components/Icon/Icon.test.jsx +43 -4
- package/src/App/components/MapButton/MapButton.jsx +42 -17
- package/src/App/components/MapButton/MapButton.module.scss +4 -13
- package/src/App/components/MapButton/MapButton.test.jsx +27 -3
- package/src/App/components/PopupMenu/PopupMenu.jsx +51 -274
- package/src/App/components/PopupMenu/PopupMenu.module.scss +14 -7
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +70 -1
- package/src/App/components/PopupMenu/usePopupMenu.js +258 -0
- package/src/App/hooks/useButtonStateEvaluator.js +12 -2
- package/src/App/hooks/useButtonStateEvaluator.test.js +38 -4
- package/src/App/hooks/useInterfaceAPI.js +6 -0
- package/src/App/hooks/useLayoutMeasurements.js +84 -18
- package/src/App/hooks/useLayoutMeasurements.test.js +124 -17
- package/src/App/layout/Layout.jsx +12 -7
- package/src/App/layout/Layout.test.jsx +2 -2
- package/src/App/layout/layout.module.scss +67 -29
- package/src/App/registry/pluginRegistry.js +1 -1
- package/src/App/renderer/HtmlElementHost.jsx +2 -1
- package/src/App/renderer/HtmlElementHost.test.jsx +7 -7
- package/src/App/renderer/mapButtons.js +1 -1
- package/src/App/renderer/mapPanels.test.js +2 -2
- package/src/App/renderer/slotHelpers.js +2 -2
- package/src/App/renderer/slotHelpers.test.js +5 -5
- package/src/App/renderer/slots.js +9 -5
- package/src/App/store/AppProvider.jsx +3 -1
- package/src/App/store/AppProvider.test.jsx +1 -1
- package/src/App/store/ServiceProvider.jsx +3 -1
- package/src/App/store/appActionsMap.js +16 -0
- package/src/App/store/appActionsMap.test.js +27 -0
- package/src/App/store/appDispatchMiddleware.js +1 -1
- package/src/App/store/appDispatchMiddleware.test.js +2 -2
- package/src/App/store/appReducer.js +2 -0
- package/src/InteractiveMap/InteractiveMap.js +4 -0
- package/src/config/appConfig.js +5 -2
- package/src/config/events.js +28 -0
- package/src/scss/main.scss +1 -0
- package/src/scss/settings/_dimensions.scss +0 -1
- package/src/utils/getSafeZoneInset.js +9 -7
- package/src/utils/getSafeZoneInset.test.js +10 -10
- package/webpack.dev.mjs +1 -1
- package/docs/api/slot-map.svg +0 -1
- package/plugins/beta/datasets/src/api/hideDataset.js +0 -14
- package/plugins/beta/datasets/src/api/hideFeatures.js +0 -41
- package/plugins/beta/datasets/src/api/showDataset.js +0 -14
- package/plugins/beta/datasets/src/api/showFeatures.js +0 -44
- package/plugins/beta/datasets/src/handleSetMapStyle.js +0 -54
- package/plugins/beta/datasets/src/mapLayers.js +0 -164
- /package/src/{utils → services}/logger.js +0 -0
- /package/src/{utils → services}/logger.test.js +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { getValueForStyle } from '../../../../src/utils/getValueForStyle.js'
|
|
2
|
-
|
|
3
|
-
// Generate a hash for consistent source ID generation
|
|
4
|
-
const hashString = (str) => {
|
|
5
|
-
const HASH_BASE = 36
|
|
6
|
-
let hash = 0
|
|
7
|
-
for (const ch of str) {
|
|
8
|
-
hash = ((hash << 5) - hash) + ch.codePointAt(0)
|
|
9
|
-
hash = hash & hash
|
|
10
|
-
}
|
|
11
|
-
return Math.abs(hash).toString(HASH_BASE)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Generate a consistent source ID for source sharing
|
|
15
|
-
const getSourceId = (dataset) => {
|
|
16
|
-
if (dataset.tiles) {
|
|
17
|
-
const tilesKey = Array.isArray(dataset.tiles) ? dataset.tiles.join(',') : dataset.tiles
|
|
18
|
-
return `tiles-${hashString(tilesKey)}`
|
|
19
|
-
}
|
|
20
|
-
if (dataset.geojson) {
|
|
21
|
-
// Dynamic sources get unique IDs per dataset (no sharing)
|
|
22
|
-
if (isDynamicSource(dataset)) {
|
|
23
|
-
return `geojson-dynamic-${dataset.id}`
|
|
24
|
-
}
|
|
25
|
-
// URL strings can be shared, inline GeoJSON objects get unique IDs per dataset
|
|
26
|
-
if (typeof dataset.geojson === 'string') {
|
|
27
|
-
return `geojson-${hashString(dataset.geojson)}`
|
|
28
|
-
}
|
|
29
|
-
// Inline GeoJSON - use dataset ID since object identity can't be shared
|
|
30
|
-
return `geojson-${dataset.id}`
|
|
31
|
-
}
|
|
32
|
-
// Fallback to dataset ID
|
|
33
|
-
return `source-${dataset.id}`
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Check if a dataset uses dynamic fetching (bbox-based)
|
|
38
|
-
* Dynamic sources require: URL geojson, idProperty for deduplication, and transformRequest for URL building
|
|
39
|
-
* @param {Object} dataset
|
|
40
|
-
* @returns {boolean}
|
|
41
|
-
*/
|
|
42
|
-
const isDynamicSource = (dataset) => {
|
|
43
|
-
return (
|
|
44
|
-
typeof dataset.geojson === 'string' &&
|
|
45
|
-
!!dataset.idProperty &&
|
|
46
|
-
typeof dataset.transformRequest === 'function'
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Update the data for a GeoJSON source
|
|
52
|
-
* @param {Object} map - Map instance
|
|
53
|
-
* @param {string} sourceId - Source ID
|
|
54
|
-
* @param {Object} geojson - GeoJSON FeatureCollection
|
|
55
|
-
*/
|
|
56
|
-
const updateSourceData = (map, sourceId, geojson) => {
|
|
57
|
-
const source = map.getSource(sourceId)
|
|
58
|
-
if (source && typeof source.setData === 'function') {
|
|
59
|
-
source.setData(geojson)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Get all layer IDs that use a given source
|
|
65
|
-
* @param {string} sourceId
|
|
66
|
-
* @returns {string[]} Array of layer IDs using the source
|
|
67
|
-
*/
|
|
68
|
-
const getLayersUsingSource = (map, sourceId) => {
|
|
69
|
-
const style = map.getStyle()
|
|
70
|
-
if (!style?.layers) {
|
|
71
|
-
return []
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return style.layers
|
|
75
|
-
.filter(layer => layer.source === sourceId)
|
|
76
|
-
.map(layer => layer.id)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const addMapLayers = (map, mapStyleId, dataset) => {
|
|
80
|
-
const sourceId = getSourceId(dataset)
|
|
81
|
-
|
|
82
|
-
// --- Add source (shared across datasets with same tiles/data URL) ---
|
|
83
|
-
if (!map.getSource(sourceId)) {
|
|
84
|
-
if (dataset.tiles) {
|
|
85
|
-
// Tiles
|
|
86
|
-
map.addSource(sourceId, {
|
|
87
|
-
type: 'vector',
|
|
88
|
-
tiles: dataset.tiles,
|
|
89
|
-
minzoom: dataset.minZoom || 0,
|
|
90
|
-
maxzoom: dataset.maxZoom || 22
|
|
91
|
-
})
|
|
92
|
-
} else if (dataset.geojson) {
|
|
93
|
-
// Dynamic source - start with empty FeatureCollection, will be populated by createDynamicSource
|
|
94
|
-
// Static source - use URL or inline GeoJSON directly
|
|
95
|
-
const initialData = isDynamicSource(dataset)
|
|
96
|
-
? { type: 'FeatureCollection', features: [] }
|
|
97
|
-
: dataset.geojson
|
|
98
|
-
|
|
99
|
-
map.addSource(sourceId, {
|
|
100
|
-
type: 'geojson',
|
|
101
|
-
data: initialData
|
|
102
|
-
})
|
|
103
|
-
} else {
|
|
104
|
-
// No action
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// --- Determine layer IDs ---
|
|
109
|
-
const hasFill = !!dataset.fill
|
|
110
|
-
const hasStroke = !!dataset.stroke
|
|
111
|
-
const fillLayerId = hasFill ? dataset.id : null
|
|
112
|
-
const strokeLayerId = hasStroke ? (hasFill ? `${dataset.id}-stroke` : dataset.id) : null
|
|
113
|
-
|
|
114
|
-
// --- Determie visiblity ---
|
|
115
|
-
const visibility = dataset.visibility === 'hidden' ? 'none' : 'visible'
|
|
116
|
-
|
|
117
|
-
// --- Add fill layer ---
|
|
118
|
-
if (hasFill && !map.getLayer(fillLayerId)) {
|
|
119
|
-
const fillColor = getValueForStyle(dataset.fill, mapStyleId)
|
|
120
|
-
map.addLayer({
|
|
121
|
-
id: fillLayerId,
|
|
122
|
-
type: 'fill',
|
|
123
|
-
source: sourceId,
|
|
124
|
-
'source-layer': dataset?.tiles?.length ? dataset.sourceLayer : undefined,
|
|
125
|
-
layout: {
|
|
126
|
-
visibility
|
|
127
|
-
},
|
|
128
|
-
paint: {
|
|
129
|
-
'fill-color': fillColor,
|
|
130
|
-
'fill-opacity': dataset.opacity || 1
|
|
131
|
-
},
|
|
132
|
-
...(dataset.filter ? { filter: dataset.filter } : {})
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// --- Add stroke layer ---
|
|
137
|
-
if (hasStroke && !map.getLayer(strokeLayerId)) {
|
|
138
|
-
const strokeColor = getValueForStyle(dataset.stroke, mapStyleId)
|
|
139
|
-
map.addLayer({
|
|
140
|
-
id: strokeLayerId,
|
|
141
|
-
type: 'line',
|
|
142
|
-
source: sourceId,
|
|
143
|
-
'source-layer': dataset?.tiles?.length ? dataset.sourceLayer : undefined,
|
|
144
|
-
layout: {
|
|
145
|
-
visibility
|
|
146
|
-
},
|
|
147
|
-
paint: {
|
|
148
|
-
'line-color': strokeColor,
|
|
149
|
-
'line-width': dataset.strokeWidth || 1,
|
|
150
|
-
'line-opacity': dataset.opacity || 1,
|
|
151
|
-
...(dataset.strokeDashArray ? { 'line-dasharray': dataset.strokeDashArray } : {})
|
|
152
|
-
},
|
|
153
|
-
...(dataset.filter ? { filter: dataset.filter } : {})
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export {
|
|
159
|
-
getSourceId,
|
|
160
|
-
getLayersUsingSource,
|
|
161
|
-
addMapLayers,
|
|
162
|
-
isDynamicSource,
|
|
163
|
-
updateSourceData
|
|
164
|
-
}
|
|
File without changes
|
|
File without changes
|