@defra/interactive-map 0.0.16-alpha → 0.0.18-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/context.md +53 -7
- package/docs/api/map-style-config.md +41 -2
- package/docs/api/marker-config.md +53 -11
- package/docs/api/slots.md +16 -15
- package/docs/api/symbol-config.md +160 -0
- package/docs/api/symbol-registry.md +115 -0
- package/docs/api.md +25 -22
- package/docs/getting-started.md +4 -1
- package/docs/plugins/datasets.md +657 -0
- package/docs/plugins/interact.md +68 -43
- package/docs/plugins/search.md +15 -3
- package/docs/plugins.md +1 -1
- package/package.json +2 -2
- package/plugins/beta/datasets/dist/css/index.css +103 -15
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/esm/index.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 +29 -9
- package/plugins/beta/datasets/src/adapters/maplibre/index.js +18 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +159 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerIds.js +75 -0
- package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +440 -0
- package/plugins/beta/datasets/src/adapters/maplibre/patternImages.js +27 -0
- package/plugins/beta/datasets/src/adapters/maplibre/symbolImages.js +31 -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 +10 -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/components/EmptyKey.jsx +7 -0
- package/plugins/beta/datasets/src/components/EmptyKey.test.jsx +21 -0
- package/plugins/beta/datasets/src/components/KeySvg.jsx +24 -0
- package/plugins/beta/datasets/src/components/KeySvgLine.jsx +19 -0
- package/plugins/beta/datasets/src/components/KeySvgPattern.jsx +15 -0
- package/plugins/beta/datasets/src/components/KeySvgRect.jsx +22 -0
- package/plugins/beta/datasets/src/components/KeySvgSymbol.jsx +16 -0
- package/plugins/beta/datasets/src/components/svgProperties.js +20 -0
- package/plugins/beta/datasets/src/datasets.js +39 -56
- package/plugins/beta/datasets/src/defaults.js +44 -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/index.js +2 -1
- package/plugins/beta/datasets/src/manifest.js +25 -17
- package/plugins/beta/datasets/src/panels/Key.jsx +51 -51
- package/plugins/beta/datasets/src/panels/Key.module.scss +59 -9
- package/plugins/beta/datasets/src/panels/Layers.jsx +132 -29
- package/plugins/beta/datasets/src/panels/Layers.module.scss +56 -8
- package/plugins/beta/datasets/src/reducer.js +134 -9
- package/plugins/beta/datasets/src/reducers/keyReducer.js +34 -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 +86 -0
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/DrawInit.jsx +3 -2
- package/plugins/beta/draw-ml/dist/css/index.css +21 -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/dist/umd/index.js +1 -1
- package/plugins/beta/draw-ml/src/DrawInit.jsx +4 -3
- 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/dist/umd/index.js +1 -1
- package/plugins/beta/map-styles/src/MapStyles.jsx +5 -4
- package/plugins/beta/map-styles/src/MapStylesInit.jsx +5 -4
- 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/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +14 -5
- package/plugins/interact/src/InteractInit.test.js +26 -6
- package/plugins/interact/src/api/enable.test.js +7 -7
- package/plugins/interact/src/defaults.js +4 -6
- package/plugins/interact/src/events.js +9 -6
- package/plugins/interact/src/events.test.js +28 -4
- package/plugins/interact/src/hooks/useHighlightSync.js +3 -3
- package/plugins/interact/src/hooks/useHighlightSync.test.js +6 -6
- package/plugins/interact/src/hooks/useHoverCursor.js +10 -0
- package/plugins/interact/src/hooks/useHoverCursor.test.js +44 -0
- package/plugins/interact/src/hooks/useInteractionHandlers.js +111 -69
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +147 -32
- 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/interact/src/reducer.js +23 -4
- package/plugins/interact/src/reducer.test.js +60 -11
- package/plugins/interact/src/utils/buildStylesMap.js +17 -4
- package/plugins/interact/src/utils/buildStylesMap.test.js +16 -2
- package/plugins/interact/src/utils/featureQueries.js +11 -6
- package/plugins/interact/src/utils/featureQueries.test.js +8 -1
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/src/Search.jsx +3 -1
- package/plugins/search/src/components/Form/Form.module.scss +2 -1
- package/plugins/search/src/events/fetchSuggestions.js +6 -4
- package/plugins/search/src/events/fetchSuggestions.test.js +26 -4
- package/plugins/search/src/events/formHandlers.js +3 -3
- package/plugins/search/src/events/formHandlers.test.js +1 -1
- package/plugins/search/src/events/suggestionHandlers.js +2 -2
- package/plugins/search/src/events/suggestionHandlers.test.js +1 -1
- package/plugins/search/src/utils/updateMap.js +3 -3
- package/plugins/search/src/utils/updateMap.test.js +3 -3
- 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/dist/umd/index.js +1 -1
- package/providers/maplibre/src/appEvents.js +7 -0
- package/providers/maplibre/src/appEvents.test.js +18 -4
- package/providers/maplibre/src/maplibreProvider.js +52 -0
- package/providers/maplibre/src/maplibreProvider.test.js +105 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +37 -7
- package/providers/maplibre/src/utils/highlightFeatures.test.js +153 -95
- package/providers/maplibre/src/utils/hoverCursor.js +61 -0
- package/providers/maplibre/src/utils/hoverCursor.test.js +130 -0
- package/providers/maplibre/src/utils/patternImages.js +70 -0
- package/providers/maplibre/src/utils/patternImages.test.js +180 -0
- package/providers/maplibre/src/utils/queryFeatures.js +38 -16
- package/providers/maplibre/src/utils/queryFeatures.test.js +20 -3
- package/providers/maplibre/src/utils/rasteriseToImageData.js +30 -0
- package/providers/maplibre/src/utils/rasteriseToImageData.test.js +69 -0
- package/providers/maplibre/src/utils/symbolImages.js +147 -0
- package/providers/maplibre/src/utils/symbolImages.test.js +248 -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/Markers/Markers.jsx +122 -27
- package/src/App/components/Markers/Markers.module.scss +0 -10
- package/src/App/components/Markers/Markers.test.jsx +246 -0
- 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/useInterfaceAPI.test.js +156 -0
- package/src/App/hooks/useLayoutMeasurements.js +84 -18
- package/src/App/hooks/useLayoutMeasurements.test.js +124 -17
- package/src/App/hooks/useMarkersAPI.js +2 -5
- package/src/App/hooks/useMarkersAPI.test.js +4 -4
- package/src/App/layout/Layout.jsx +14 -9
- package/src/App/layout/Layout.test.jsx +6 -4
- 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 +8 -4
- 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/App/store/mapActionsMap.js +4 -6
- package/src/App/store/mapActionsMap.test.js +3 -2
- package/src/App/store/mapReducer.js +2 -1
- package/src/InteractiveMap/InteractiveMap.js +4 -0
- package/src/config/appConfig.js +5 -8
- package/src/config/appConfig.test.js +1 -2
- package/src/config/defaults.js +0 -2
- package/src/config/events.js +28 -0
- package/src/config/mapTheme.js +56 -0
- package/src/config/patternConfig.js +16 -0
- package/src/config/symbolConfig.js +80 -0
- package/src/scss/main.scss +1 -0
- package/src/scss/settings/_colors.scss +0 -9
- package/src/scss/settings/_dimensions.scss +0 -1
- package/src/services/patternRegistry.js +40 -0
- package/src/services/patternRegistry.test.js +48 -0
- package/src/services/symbolRegistry.js +113 -0
- package/src/services/symbolRegistry.test.js +262 -0
- package/src/types.js +93 -11
- package/src/utils/getSafeZoneInset.js +9 -7
- package/src/utils/getSafeZoneInset.test.js +10 -10
- package/src/utils/patternUtils.js +94 -0
- package/src/utils/patternUtils.test.js +160 -0
- package/src/utils/symbolUtils.js +85 -0
- package/src/utils/symbolUtils.test.js +156 -0
- 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
|