@defra/interactive-map 0.0.14-alpha → 0.0.16-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/css/docusaurus.css +104 -0
- package/assets/images/favicon.svg +1 -0
- package/assets/images/hero.png +0 -0
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/slot-map.svg +1 -0
- package/docs/api/slots.md +89 -6
- package/docs/api.md +1 -1
- package/docs/architecture.md +3 -1
- package/docs/{demo.mdx → examples.mdx} +1 -1
- package/docs/getting-started.md +1 -3
- package/docs/index.mdx +42 -0
- package/docs/plugins/interact.md +176 -55
- package/docs/plugins/map-styles.md +64 -7
- package/docs/plugins/search.md +207 -63
- package/docs/plugins.md +7 -15
- package/docusaurus.config.cjs +34 -34
- package/jest.setup.js +1 -1
- package/package.json +5 -4
- 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/src/DatasetsInit.jsx +1 -1
- package/plugins/beta/datasets/src/api/addDataset.js +1 -1
- package/plugins/beta/datasets/src/api/hideDataset.js +1 -1
- package/plugins/beta/datasets/src/api/hideFeatures.js +1 -1
- package/plugins/beta/datasets/src/api/removeDataset.js +1 -1
- package/plugins/beta/datasets/src/api/showDataset.js +1 -1
- package/plugins/beta/datasets/src/api/showFeatures.js +1 -1
- package/plugins/beta/datasets/src/datasets.js +4 -4
- package/plugins/beta/datasets/src/defaults.js +1 -1
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +5 -5
- package/plugins/beta/datasets/src/handleSetMapStyle.js +1 -1
- package/plugins/beta/datasets/src/manifest.js +7 -7
- package/plugins/beta/datasets/src/mapLayers.js +2 -3
- package/plugins/beta/datasets/src/panels/Key.jsx +31 -29
- package/plugins/beta/datasets/src/panels/Layers.jsx +8 -9
- package/plugins/beta/datasets/src/utils/bbox.js +4 -4
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/DrawInit.jsx +16 -16
- package/plugins/beta/draw-es/src/api/addFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/deleteFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/editFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/newPolygon.js +3 -3
- package/plugins/beta/draw-es/src/events.js +52 -20
- package/plugins/beta/draw-es/src/events.test.js +301 -0
- package/plugins/beta/draw-es/src/graphic.js +1 -1
- package/plugins/beta/draw-es/src/manifest.js +4 -4
- package/plugins/beta/draw-es/src/reducer.js +1 -1
- package/plugins/beta/draw-es/src/sketchViewModel.js +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/DrawInit.jsx +49 -52
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +1 -1
- package/plugins/beta/draw-ml/src/api/editFeature.js +8 -5
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -1
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -1
- package/plugins/beta/draw-ml/src/api/split.js +4 -4
- package/plugins/beta/draw-ml/src/defaults.js +1 -1
- package/plugins/beta/draw-ml/src/events.js +8 -6
- package/plugins/beta/draw-ml/src/manifest.js +15 -15
- package/plugins/beta/draw-ml/src/mapboxDraw.js +1 -1
- package/plugins/beta/draw-ml/src/mapboxSnap.js +17 -18
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +31 -31
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +1 -1
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +11 -11
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +8 -8
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +32 -24
- package/plugins/beta/draw-ml/src/reducer.js +1 -1
- package/plugins/beta/draw-ml/src/undoStack.js +4 -4
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +12 -12
- package/plugins/beta/draw-ml/src/utils/spatial.js +11 -11
- package/plugins/beta/frame/src/Frame.jsx +4 -4
- package/plugins/beta/frame/src/FrameInit.jsx +4 -4
- package/plugins/beta/frame/src/api/addFrame.js +1 -1
- package/plugins/beta/frame/src/api/editFeature.js +1 -1
- package/plugins/beta/frame/src/config.js +1 -1
- package/plugins/beta/frame/src/manifest.js +3 -3
- package/plugins/beta/frame/src/reducer.js +1 -1
- package/plugins/beta/frame/src/utils.js +1 -1
- 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/MapStyles.jsx +18 -18
- package/plugins/beta/map-styles/src/manifest.js +2 -2
- package/plugins/beta/scale-bar/src/ScaleBar.jsx +5 -5
- package/plugins/beta/use-location/src/UseLocation.jsx +1 -1
- package/plugins/beta/use-location/src/defaults.js +1 -1
- package/plugins/beta/use-location/src/events.js +3 -3
- package/plugins/interact/src/InteractInit.jsx +1 -2
- package/plugins/interact/src/api/enable.js +8 -5
- package/plugins/interact/src/api/enable.test.js +2 -2
- package/plugins/interact/src/api/selectFeature.js +4 -4
- package/plugins/interact/src/api/unselectFeature.js +5 -5
- package/plugins/interact/src/defaults.js +0 -1
- package/plugins/interact/src/events.test.js +15 -15
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.js +2 -2
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -5
- package/plugins/interact/src/manifest.js +2 -2
- package/plugins/interact/src/manifest.test.js +3 -4
- package/plugins/interact/src/reducer.js +3 -3
- package/plugins/interact/src/reducer.test.js +0 -1
- package/plugins/interact/src/utils/spatial.js +10 -10
- package/plugins/interact/src/utils/spatial.test.js +14 -14
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +7 -6
- package/plugins/search/src/Search.test.jsx +23 -23
- package/plugins/search/src/components/CloseButton/CloseButton.jsx +15 -15
- package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +2 -2
- package/plugins/search/src/components/Form/Form.jsx +14 -14
- package/plugins/search/src/components/Form/Form.test.jsx +11 -11
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +16 -15
- package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +6 -2
- package/plugins/search/src/components/SubmitButton/SubmitButton.jsx +15 -15
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +6 -6
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +4 -4
- package/plugins/search/src/datasets.js +12 -13
- package/plugins/search/src/datasets.test.js +1 -1
- package/plugins/search/src/defaults.js +1 -1
- package/plugins/search/src/events/fetchSuggestions.js +4 -4
- package/plugins/search/src/events/fetchSuggestions.test.js +5 -5
- package/plugins/search/src/events/formHandlers.js +3 -3
- package/plugins/search/src/events/formHandlers.test.js +1 -1
- package/plugins/search/src/events/index.js +2 -2
- package/plugins/search/src/events/index.test.js +2 -2
- package/plugins/search/src/events/inputHandlers.js +4 -4
- package/plugins/search/src/events/inputHandlers.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/index.js +2 -1
- package/plugins/search/src/index.test.js +3 -3
- package/plugins/search/src/manifest.js +6 -4
- package/plugins/search/src/reducer.js +1 -2
- package/plugins/search/src/reducer.test.js +2 -2
- package/plugins/search/src/search.scss +18 -6
- package/plugins/search/src/utils/parseOsNamesResults.js +1 -2
- package/plugins/search/src/utils/parseOsNamesResults.test.js +2 -2
- package/plugins/search/src/utils/updateMap.js +1 -1
- package/plugins/search/src/utils/updateMap.test.js +5 -5
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +5 -5
- package/providers/beta/esri/src/utils/coords.js +1 -1
- package/providers/beta/esri/src/utils/esriFixes.js +1 -1
- package/providers/beta/esri/src/utils/query.js +4 -4
- package/providers/beta/esri/src/utils/spatial.js +1 -2
- package/providers/beta/esri/src/utils/spatial.test.js +4 -1
- package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +1 -1
- package/providers/maplibre/src/appEvents.test.js +1 -1
- package/providers/maplibre/src/index.js +1 -1
- package/providers/maplibre/src/index.test.js +3 -5
- package/providers/maplibre/src/mapEvents.test.js +15 -5
- package/providers/maplibre/src/maplibreProvider.test.js +6 -2
- package/providers/maplibre/src/utils/calculateLinearTextSize.js +4 -4
- package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +3 -3
- package/providers/maplibre/src/utils/detectWebgl.test.js +1 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +2 -2
- package/providers/maplibre/src/utils/highlightFeatures.test.js +12 -6
- package/providers/maplibre/src/utils/labels.js +19 -20
- package/providers/maplibre/src/utils/labels.test.js +15 -13
- package/providers/maplibre/src/utils/maplibreFixes.test.js +1 -1
- package/providers/maplibre/src/utils/queryFeatures.js +6 -6
- package/providers/maplibre/src/utils/queryFeatures.test.js +13 -13
- package/providers/maplibre/src/utils/spatial.js +0 -1
- package/providers/maplibre/src/utils/spatial.test.js +26 -27
- package/src/App/components/Panel/Panel.module.scss +1 -0
- package/src/App/hooks/useLayoutMeasurements.js +1 -10
- package/src/App/hooks/useLayoutMeasurements.test.js +2 -5
- package/src/App/hooks/useVisibleGeometry.js +7 -13
- package/src/App/hooks/useVisibleGeometry.test.js +72 -47
- package/src/App/layout/Layout.jsx +0 -3
- package/src/App/layout/Layout.test.jsx +0 -1
- package/src/App/layout/layout.module.scss +11 -77
- package/src/App/registry/pluginRegistry.js +17 -0
- package/src/App/registry/pluginRegistry.test.js +33 -0
- package/src/App/renderer/HtmlElementHost.jsx +0 -1
- package/src/App/renderer/HtmlElementHost.test.jsx +20 -11
- package/src/App/renderer/mapButtons.js +3 -2
- package/src/App/renderer/mapPanels.test.js +3 -3
- package/src/App/renderer/slotHelpers.js +2 -2
- package/src/App/renderer/slotHelpers.test.js +3 -3
- package/src/App/renderer/slots.js +0 -3
- package/src/App/store/AppProvider.jsx +0 -1
- package/src/App/store/appDispatchMiddleware.js +33 -1
- package/src/App/store/appDispatchMiddleware.test.js +250 -222
- package/src/config/appConfig.js +4 -4
- package/src/utils/getSafeZoneInset.js +139 -42
- package/src/utils/getSafeZoneInset.test.js +298 -122
- package/src/utils/logger.js +6 -0
- package/src/utils/logger.test.js +32 -0
- package/webpack.dev.mjs +22 -18
- package/docs/govuk-prototype.md +0 -23
- package/docs/index.md +0 -19
|
@@ -17,7 +17,7 @@ export const createUndoStack = (map) => {
|
|
|
17
17
|
* Push an undo operation onto the stack
|
|
18
18
|
* @param {Object} operation - { type, undo: Function, ...data }
|
|
19
19
|
*/
|
|
20
|
-
push(operation) {
|
|
20
|
+
push (operation) {
|
|
21
21
|
stack.push(operation)
|
|
22
22
|
fireChange()
|
|
23
23
|
},
|
|
@@ -26,7 +26,7 @@ export const createUndoStack = (map) => {
|
|
|
26
26
|
* Pop and return the last operation (does not execute it)
|
|
27
27
|
* @returns {Object|undefined} The operation or undefined if empty
|
|
28
28
|
*/
|
|
29
|
-
pop() {
|
|
29
|
+
pop () {
|
|
30
30
|
const op = stack.pop()
|
|
31
31
|
fireChange()
|
|
32
32
|
return op
|
|
@@ -35,7 +35,7 @@ export const createUndoStack = (map) => {
|
|
|
35
35
|
/**
|
|
36
36
|
* Clear all operations from the stack
|
|
37
37
|
*/
|
|
38
|
-
clear() {
|
|
38
|
+
clear () {
|
|
39
39
|
stack.length = 0
|
|
40
40
|
fireChange()
|
|
41
41
|
},
|
|
@@ -43,7 +43,7 @@ export const createUndoStack = (map) => {
|
|
|
43
43
|
/**
|
|
44
44
|
* Get current stack length
|
|
45
45
|
*/
|
|
46
|
-
get length() {
|
|
46
|
+
get length () {
|
|
47
47
|
return stack.length
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @param {maplibregl.Map} map - Map instance
|
|
9
9
|
* @returns {MapboxSnap|null} Snap instance or null
|
|
10
10
|
*/
|
|
11
|
-
export function getSnapInstance(map) {
|
|
11
|
+
export function getSnapInstance (map) {
|
|
12
12
|
return map?._snapInstance ?? null
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ export function getSnapInstance(map) {
|
|
|
17
17
|
* @param {MapboxSnap} snap - Snap instance
|
|
18
18
|
* @returns {boolean} True if snap is active with valid coordinates
|
|
19
19
|
*/
|
|
20
|
-
export function isSnapActive(snap) {
|
|
20
|
+
export function isSnapActive (snap) {
|
|
21
21
|
// Also check snap.status to ensure snap feature is enabled
|
|
22
22
|
return !!(snap?.status && snap?.snapStatus && snap.snapCoords?.length >= 2)
|
|
23
23
|
}
|
|
@@ -27,7 +27,7 @@ export function isSnapActive(snap) {
|
|
|
27
27
|
* @param {MapboxSnap} snap - Snap instance
|
|
28
28
|
* @returns {{ lng: number, lat: number }|null} Snapped coordinates or null
|
|
29
29
|
*/
|
|
30
|
-
export function getSnapLngLat(snap) {
|
|
30
|
+
export function getSnapLngLat (snap) {
|
|
31
31
|
if (!isSnapActive(snap)) {
|
|
32
32
|
return null
|
|
33
33
|
}
|
|
@@ -42,7 +42,7 @@ export function getSnapLngLat(snap) {
|
|
|
42
42
|
* @param {MapboxSnap} snap - Snap instance
|
|
43
43
|
* @returns {[number, number]|null} Snapped coordinates or null
|
|
44
44
|
*/
|
|
45
|
-
export function getSnapCoords(snap) {
|
|
45
|
+
export function getSnapCoords (snap) {
|
|
46
46
|
if (!isSnapActive(snap)) {
|
|
47
47
|
return null
|
|
48
48
|
}
|
|
@@ -56,7 +56,7 @@ export function getSnapCoords(snap) {
|
|
|
56
56
|
* @param {{ x: number, y: number }} point - Screen point
|
|
57
57
|
* @returns {boolean} True if snap was triggered
|
|
58
58
|
*/
|
|
59
|
-
export function triggerSnapAtPoint(snap, map, point) {
|
|
59
|
+
export function triggerSnapAtPoint (snap, map, point) {
|
|
60
60
|
if (!snap || !map || !snap.status) {
|
|
61
61
|
return false
|
|
62
62
|
}
|
|
@@ -72,7 +72,7 @@ export function triggerSnapAtPoint(snap, map, point) {
|
|
|
72
72
|
* @param {maplibregl.Map} map - Map instance
|
|
73
73
|
* @returns {boolean} True if snap was triggered
|
|
74
74
|
*/
|
|
75
|
-
export function triggerSnapAtCenter(snap, map) {
|
|
75
|
+
export function triggerSnapAtCenter (snap, map) {
|
|
76
76
|
// Don't trigger snap if library is disabled
|
|
77
77
|
if (!snap || !map || !snap.status) {
|
|
78
78
|
return false
|
|
@@ -89,7 +89,7 @@ export function triggerSnapAtCenter(snap, map) {
|
|
|
89
89
|
* @param {MapboxSnap} snap - Snap instance
|
|
90
90
|
* @param {maplibregl.Map} [map] - Optional map instance for direct layer control
|
|
91
91
|
*/
|
|
92
|
-
export function clearSnapIndicator(snap, map) {
|
|
92
|
+
export function clearSnapIndicator (snap, map) {
|
|
93
93
|
if (snap) {
|
|
94
94
|
snap.snapStatus = false
|
|
95
95
|
snap.snapCoords = null
|
|
@@ -116,7 +116,7 @@ export function clearSnapIndicator(snap, map) {
|
|
|
116
116
|
* Clear all snap state (for use between drag operations)
|
|
117
117
|
* @param {MapboxSnap} snap - Snap instance
|
|
118
118
|
*/
|
|
119
|
-
export function clearSnapState(snap) {
|
|
119
|
+
export function clearSnapState (snap) {
|
|
120
120
|
if (!snap) {
|
|
121
121
|
return
|
|
122
122
|
}
|
|
@@ -139,7 +139,7 @@ export function clearSnapState(snap) {
|
|
|
139
139
|
* @param {MapboxSnap} snap - Snap instance
|
|
140
140
|
* @returns {number} Snap radius in pixels (default 15)
|
|
141
141
|
*/
|
|
142
|
-
export function getSnapRadius(snap) {
|
|
142
|
+
export function getSnapRadius (snap) {
|
|
143
143
|
return snap?.options?.radius ?? 15
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -148,7 +148,7 @@ export function getSnapRadius(snap) {
|
|
|
148
148
|
* @param {object} state - Mode state with optional getSnapEnabled function
|
|
149
149
|
* @returns {boolean} True if snapping is enabled
|
|
150
150
|
*/
|
|
151
|
-
export function isSnapEnabled(state) {
|
|
151
|
+
export function isSnapEnabled (state) {
|
|
152
152
|
// Only return true if getSnapEnabled exists and explicitly returns true
|
|
153
153
|
if (typeof state?.getSnapEnabled !== 'function') {
|
|
154
154
|
return false
|
|
@@ -162,7 +162,7 @@ export function isSnapEnabled(state) {
|
|
|
162
162
|
* @param {MapboxSnap} snap - Snap instance
|
|
163
163
|
* @returns {object} Event with snapped lngLat or original event
|
|
164
164
|
*/
|
|
165
|
-
export function createSnappedEvent(e, snap) {
|
|
165
|
+
export function createSnappedEvent (e, snap) {
|
|
166
166
|
const lngLat = getSnapLngLat(snap)
|
|
167
167
|
if (!lngLat) {
|
|
168
168
|
return e
|
|
@@ -180,7 +180,7 @@ export function createSnappedEvent(e, snap) {
|
|
|
180
180
|
* @param {MapboxSnap} snap - Snap instance
|
|
181
181
|
* @returns {object|null} Synthetic event or null if no snap
|
|
182
182
|
*/
|
|
183
|
-
export function createSnappedClickEvent(map, snap) {
|
|
183
|
+
export function createSnappedClickEvent (map, snap) {
|
|
184
184
|
const lngLat = getSnapLngLat(snap)
|
|
185
185
|
if (!lngLat) {
|
|
186
186
|
return null
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
* @param {Feature<LineString>} line
|
|
29
29
|
* @param {number} extendDist (distance to extend in Turf units)
|
|
30
30
|
*/
|
|
31
|
-
function extendLine(line, extendDist = 1, units = 'meters') {
|
|
31
|
+
function extendLine (line, extendDist = 1, units = 'meters') {
|
|
32
32
|
const coords = line.geometry.coordinates
|
|
33
33
|
const result = []
|
|
34
34
|
|
|
@@ -113,17 +113,17 @@ const toTurfGeometry = (featureOrGeom) => {
|
|
|
113
113
|
|
|
114
114
|
switch (geom.type) {
|
|
115
115
|
case 'Polygon':
|
|
116
|
-
return turfPolygon(geom.coordinates)
|
|
116
|
+
return turfPolygon(geom.coordinates)
|
|
117
117
|
case 'MultiPolygon':
|
|
118
|
-
return turfMultiPolygon(geom.coordinates)
|
|
118
|
+
return turfMultiPolygon(geom.coordinates)
|
|
119
119
|
case 'LineString':
|
|
120
|
-
return turfLineString(geom.coordinates)
|
|
120
|
+
return turfLineString(geom.coordinates)
|
|
121
121
|
case 'MultiLineString':
|
|
122
|
-
return turfMultiLineString(geom.coordinates)
|
|
122
|
+
return turfMultiLineString(geom.coordinates)
|
|
123
123
|
case 'Point':
|
|
124
|
-
return turfPoint(geom.coordinates)
|
|
124
|
+
return turfPoint(geom.coordinates)
|
|
125
125
|
case 'MultiPoint':
|
|
126
|
-
return turfMultiPoint(geom.coordinates)
|
|
126
|
+
return turfMultiPoint(geom.coordinates)
|
|
127
127
|
default:
|
|
128
128
|
throw new Error(`Unsupported geometry type: ${geom.type}`)
|
|
129
129
|
}
|
|
@@ -251,8 +251,8 @@ export {
|
|
|
251
251
|
toTurfGeometry,
|
|
252
252
|
splitPolygon,
|
|
253
253
|
extendLine,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
isNewCoordinate,
|
|
255
|
+
isValidClick,
|
|
256
|
+
isValidLineClick,
|
|
257
257
|
spatialNavigate
|
|
258
|
-
}
|
|
258
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useState } from 'react'
|
|
2
2
|
import { computeInset } from './utils.js'
|
|
3
3
|
|
|
4
|
-
export function Frame({ appState, mapState, pluginState, mapProvider }) {
|
|
4
|
+
export function Frame ({ appState, mapState, pluginState, mapProvider }) {
|
|
5
5
|
const { actionsRef, mainRef, footerRef, viewportRef } = appState.layoutRefs
|
|
6
6
|
const { dispatch } = pluginState
|
|
7
7
|
const elRef = useRef(null)
|
|
@@ -87,7 +87,7 @@ export function Frame({ appState, mapState, pluginState, mapProvider }) {
|
|
|
87
87
|
const viewportRect = viewportEl.getBoundingClientRect()
|
|
88
88
|
|
|
89
89
|
// Calculate padding from viewport edges to frame edges
|
|
90
|
-
const scale = {small: 1, medium: 1.5, large: 2}[mapState.mapSize]
|
|
90
|
+
const scale = { small: 1, medium: 1.5, large: 2 }[mapState.mapSize]
|
|
91
91
|
|
|
92
92
|
const padding = {
|
|
93
93
|
top: (frameRect.top - viewportRect.top) / scale,
|
|
@@ -108,11 +108,11 @@ export function Frame({ appState, mapState, pluginState, mapProvider }) {
|
|
|
108
108
|
return (
|
|
109
109
|
<>
|
|
110
110
|
{/* Spacer */}
|
|
111
|
-
<div className=
|
|
111
|
+
<div className='im-c-frame-spacer' style={{ inset: parentInset }} ref={elRef} />
|
|
112
112
|
|
|
113
113
|
{/* Child */}
|
|
114
114
|
{childStyle && (
|
|
115
|
-
<div ref={displayRef} className=
|
|
115
|
+
<div ref={displayRef} className='im-c-frame-display' style={{ ...childStyle }} />
|
|
116
116
|
)}
|
|
117
117
|
</>
|
|
118
118
|
)
|
|
@@ -23,8 +23,8 @@ export const FrameInit = ({
|
|
|
23
23
|
// Attach events
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
if (!isActive) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
28
|
|
|
29
29
|
// --- Done
|
|
30
30
|
frameDone.onClick = () => {
|
|
@@ -32,7 +32,7 @@ export const FrameInit = ({
|
|
|
32
32
|
frameEl: frameRefs.displayRef.current,
|
|
33
33
|
viewportEl: layoutRefs.viewportRef.current,
|
|
34
34
|
featureId: frame?.featureId,
|
|
35
|
-
scale: {small: 1, medium: 1.5, large: 2}[mapState.mapSize],
|
|
35
|
+
scale: { small: 1, medium: 1.5, large: 2 }[mapState.mapSize],
|
|
36
36
|
mapProvider
|
|
37
37
|
})
|
|
38
38
|
|
|
@@ -51,4 +51,4 @@ export const FrameInit = ({
|
|
|
51
51
|
frameCancel.onClick = null
|
|
52
52
|
}
|
|
53
53
|
}, [mapState.isMapReady, mode, breakpoint, frame, frameRefs, layoutRefs, mapProvider, dispatch, eventBus, frameDone, frameCancel])
|
|
54
|
-
}
|
|
54
|
+
}
|
|
@@ -6,8 +6,8 @@ import { addFrame } from './api/addFrame.js'
|
|
|
6
6
|
import { editFeature } from './api/editFeature.js'
|
|
7
7
|
|
|
8
8
|
const buttonSlots = {
|
|
9
|
-
mobile:
|
|
10
|
-
tablet:
|
|
9
|
+
mobile: { slot: 'actions', showLabel: true },
|
|
10
|
+
tablet: { slot: 'actions', showLabel: true },
|
|
11
11
|
desktop: { slot: 'actions', showLabel: true }
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -40,7 +40,7 @@ export const manifest = {
|
|
|
40
40
|
variant: 'primary',
|
|
41
41
|
hiddenWhen: ({ pluginState }) => !pluginState.frame,
|
|
42
42
|
...buttonSlots
|
|
43
|
-
},{
|
|
43
|
+
}, {
|
|
44
44
|
id: 'frameCancel',
|
|
45
45
|
label: 'Cancel',
|
|
46
46
|
variant: 'tertiary',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as e,useContext as t,createContext as i}from"preact/compat";import{jsx as s,Fragment as l,jsxs as a}from"preact/jsx-runtime";import r from"@babel/runtime/helpers/defineProperty";new Set;function m(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function
|
|
1
|
+
import{useEffect as e,useContext as t,createContext as i}from"preact/compat";import{jsx as s,Fragment as l,jsxs as a}from"preact/jsx-runtime";import r from"@babel/runtime/helpers/defineProperty";new Set;function m(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function o(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?m(Object(i),!0).forEach(function(t){r(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):m(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var n={slot:"middle",open:!1,dismissible:!0,modal:!0};o({},n),o(o({},n),{},{width:"500px"}),o(o({},n),{},{width:"500px"});var c={small:1,medium:1.5,large:2},p={InitComponent:function(t){var{pluginConfig:i,services:a}=t,{events:r,eventBus:m}=a,o=()=>{m.emit(r.MAP_INIT_MAP_STYLES,i.mapStyles)};return e(()=>(m.on(r.APP_READY,o),()=>m.off(r.APP_READY,o)),[]),s(l,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"bottom",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:e=>{var{mapState:t,pluginConfig:i,services:l,mapProvider:r}=e,{mapStyle:m,mapSize:o}=t,{mapStyles:n}=i,{events:p,eventBus:d}=l,{supportsMapSizes:h}=r.capabilities;return a("div",{className:"im-c-map-styles",children:[s("div",{className:"im-c-map-styles__group",children:s("div",{className:"im-c-map-styles__inner",children:n.filter(e=>e.url).map(e=>s("div",{className:"im-c-map-styles__item",children:a("button",{className:"im-c-map-styles__button","aria-pressed":e.id===m.id,onClick:()=>{return t=e,void d.emit(p.MAP_SET_STYLE,t);var t},children:[s("div",{className:"im-c-map-styles__image",children:s("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id))})}),h&&a("div",{className:"im-c-map-styles__group",children:[s("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),s("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(e=>s("div",{className:"im-c-map-styles__item",children:a("button",{className:"im-c-map-styles__button",onClick:()=>{return t=e,d.emit(p.MAP_SET_SIZE,t),void d.emit(p.MAP_SET_PIXEL_RATIO,window.devicePixelRatio*c[t]);var t},"aria-pressed":e===o,children:[s("div",{className:"im-c-map-styles__image",children:a("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd",children:[s("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),s("g",{style:{transform:"scale(".concat(c[e],")"),transformOrigin:"8px 52px"},children:s("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e))})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]};export{p as manifest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[657],{860(e,t,i){i.r(t),i.d(t,{manifest:()=>p});var s=i(738),r=i(287);new Set,new Set;function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function l(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function a(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?l(Object(i),!0).forEach(function(t){o(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):l(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function o(e,t,i){return(t=function(e){var t=function(e){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var c={slot:"middle",open:!1,dismissible:!0,modal:!0},m=(a({},c),a(a({},c),{},{width:"500px"}),a(a({},c),{},{width:"500px"}),{small:1,medium:1.5,large:2}),p={InitComponent:function(e){var t=e.pluginConfig,i=e.services,n=i.events,l=i.eventBus,a=function(){l.emit(n.MAP_INIT_MAP_STYLES,t.mapStyles)};return(0,s.useEffect)(function(){return l.on(n.APP_READY,a),function(){return l.off(n.APP_READY,a)}},[]),(0,r.jsx)(r.Fragment,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"bottom",modal:!0,dismissible:!0},tablet:{slot:"
|
|
1
|
+
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[657],{860(e,t,i){i.r(t),i.d(t,{manifest:()=>p});var s=i(738),r=i(287);new Set,new Set;function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function l(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function a(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?l(Object(i),!0).forEach(function(t){o(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):l(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function o(e,t,i){return(t=function(e){var t=function(e){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var c={slot:"middle",open:!1,dismissible:!0,modal:!0},m=(a({},c),a(a({},c),{},{width:"500px"}),a(a({},c),{},{width:"500px"}),{small:1,medium:1.5,large:2}),p={InitComponent:function(e){var t=e.pluginConfig,i=e.services,n=i.events,l=i.eventBus,a=function(){l.emit(n.MAP_INIT_MAP_STYLES,t.mapStyles)};return(0,s.useEffect)(function(){return l.on(n.APP_READY,a),function(){return l.off(n.APP_READY,a)}},[]),(0,r.jsx)(r.Fragment,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"bottom",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:function(e){var t=e.mapState,i=e.pluginConfig,s=e.services,n=e.mapProvider,l=t.mapStyle,a=t.mapSize,o=i.mapStyles,c=s.events,p=s.eventBus,d=n.capabilities.supportsMapSizes;return(0,r.jsxs)("div",{className:"im-c-map-styles",children:[(0,r.jsx)("div",{className:"im-c-map-styles__group",children:(0,r.jsx)("div",{className:"im-c-map-styles__inner",children:o.filter(function(e){return e.url}).map(function(e){return(0,r.jsx)("div",{className:"im-c-map-styles__item",children:(0,r.jsxs)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===l.id,onClick:function(){return t=e,void p.emit(c.MAP_SET_STYLE,t);var t},children:[(0,r.jsx)("div",{className:"im-c-map-styles__image",children:(0,r.jsx)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id)})})}),d&&(0,r.jsxs)("div",{className:"im-c-map-styles__group",children:[(0,r.jsx)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,r.jsx)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(function(e){return(0,r.jsx)("div",{className:"im-c-map-styles__item",children:(0,r.jsxs)("button",{className:"im-c-map-styles__button",onClick:function(){return t=e,p.emit(c.MAP_SET_SIZE,t),void p.emit(c.MAP_SET_PIXEL_RATIO,window.devicePixelRatio*m[t]);var t},"aria-pressed":e===a,children:[(0,r.jsx)("div",{className:"im-c-map-styles__image",children:(0,r.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd",children:[(0,r.jsx)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,r.jsx)("g",{style:{transform:"scale(".concat(m[e],")"),transformOrigin:"8px 52px"},children:(0,r.jsx)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e)})})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}}}]);
|
|
@@ -18,14 +18,14 @@ export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) =>
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
|
-
<div className=
|
|
22
|
-
<div className=
|
|
23
|
-
<div className=
|
|
21
|
+
<div className='im-c-map-styles'>
|
|
22
|
+
<div className='im-c-map-styles__group'>
|
|
23
|
+
<div className='im-c-map-styles__inner'>
|
|
24
24
|
{mapStyles.filter(mapStyle => mapStyle.url).map(mapStyle => (
|
|
25
|
-
<div className=
|
|
26
|
-
<button className=
|
|
27
|
-
<div className=
|
|
28
|
-
<img src={mapStyle.thumbnail || undefined} alt=
|
|
25
|
+
<div className='im-c-map-styles__item' key={mapStyle.id}>
|
|
26
|
+
<button className='im-c-map-styles__button' aria-pressed={mapStyle.id === currentMapStyle.id} onClick={() => handleMapStyleClick(mapStyle)}>
|
|
27
|
+
<div className='im-c-map-styles__image'>
|
|
28
|
+
<img src={mapStyle.thumbnail || undefined} alt='' height='60' width='60' />
|
|
29
29
|
</div>
|
|
30
30
|
{mapStyle.label}
|
|
31
31
|
</button>
|
|
@@ -34,16 +34,16 @@ export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) =>
|
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
{supportsMapSizes && (
|
|
37
|
-
<div className=
|
|
38
|
-
<h3 className=
|
|
39
|
-
<div className=
|
|
40
|
-
{[
|
|
41
|
-
<div className=
|
|
42
|
-
<button className=
|
|
43
|
-
<div className=
|
|
44
|
-
<svg width=
|
|
45
|
-
<rect className=
|
|
46
|
-
<g style={{ transform: `scale(${scaleFactor[size]})`, transformOrigin:
|
|
37
|
+
<div className='im-c-map-styles__group'>
|
|
38
|
+
<h3 className='im-c-map-styles__heading' id='map-text-sizes'>Map size</h3>
|
|
39
|
+
<div className='im-c-map-styles__inner'>
|
|
40
|
+
{['small', 'medium', 'large'].map(size => (
|
|
41
|
+
<div className='im-c-map-styles__item' key={size}>
|
|
42
|
+
<button className='im-c-map-styles__button' onClick={() => handleMapSizeClick(size)} aria-pressed={size === currentMapSize}>
|
|
43
|
+
<div className='im-c-map-styles__image'>
|
|
44
|
+
<svg width='60' height='60' viewBox='0 0 60 60' fillRule='evenodd'>
|
|
45
|
+
<rect className='im-c-map-styles__image-bg' width='100%' height='100%' />
|
|
46
|
+
<g style={{ transform: `scale(${scaleFactor[size]})`, transformOrigin: '8px 52px' }}>
|
|
47
47
|
<path d={textSizeSvgPath} />
|
|
48
48
|
</g>
|
|
49
49
|
</svg>
|
|
@@ -57,4 +57,4 @@ export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) =>
|
|
|
57
57
|
)}
|
|
58
58
|
</div>
|
|
59
59
|
)
|
|
60
|
-
}
|
|
60
|
+
}
|
|
@@ -14,13 +14,13 @@ export const manifest = {
|
|
|
14
14
|
dismissible: true
|
|
15
15
|
},
|
|
16
16
|
tablet: {
|
|
17
|
-
slot: '
|
|
17
|
+
slot: 'left-top',
|
|
18
18
|
modal: true,
|
|
19
19
|
width: '400px',
|
|
20
20
|
dismissible: true
|
|
21
21
|
},
|
|
22
22
|
desktop: {
|
|
23
|
-
slot: '
|
|
23
|
+
slot: 'left-top',
|
|
24
24
|
modal: true,
|
|
25
25
|
width: '400px',
|
|
26
26
|
dismissible: true
|
|
@@ -23,12 +23,12 @@ export function ScaleBar ({
|
|
|
23
23
|
}, [resolution, mapSize, pluginConfig.units])
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<div className=
|
|
27
|
-
<span className=
|
|
28
|
-
<span className=
|
|
26
|
+
<div className='im-c-scale-bar' ref={elRef} style={{ width: `${scale.width}px` }}>
|
|
27
|
+
<span className='im-c-scale-bar__label'>
|
|
28
|
+
<span className='im-u-visually-hidden'>Scale bar: </span>
|
|
29
29
|
{scale.label}
|
|
30
|
-
<span aria-hidden=
|
|
31
|
-
<span className=
|
|
30
|
+
<span aria-hidden='true'>{scale.abbr}</span>
|
|
31
|
+
<span className='im-u-visually-hidden'>{scale.unit}</span>
|
|
32
32
|
</span>
|
|
33
33
|
</div>
|
|
34
34
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorMessages } from './defaults.js'
|
|
2
2
|
|
|
3
|
-
export function attachEvents({ appState, pluginState, mapProvider, useLocationButton }) {
|
|
3
|
+
export function attachEvents ({ appState, pluginState, mapProvider, useLocationButton }) {
|
|
4
4
|
const { dispatch: appDispatch, buttonRefs } = appState
|
|
5
5
|
const { dispatch: pluginDispatch } = pluginState
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ export function attachEvents({ appState, pluginState, mapProvider, useLocationBu
|
|
|
30
30
|
const message = getFriendlyError(err)
|
|
31
31
|
const triggeringElement = buttonRefs.current[useLocationButton.id]
|
|
32
32
|
pluginDispatch({ type: 'SET_ERROR_MESSAGE', payload: message })
|
|
33
|
-
appDispatch({ type: 'OPEN_PANEL', payload: { panelId: 'useLocation', props: { triggeringElement }}})
|
|
33
|
+
appDispatch({ type: 'OPEN_PANEL', payload: { panelId: 'useLocation', props: { triggeringElement } } })
|
|
34
34
|
}, {
|
|
35
35
|
enableHighAccuracy: true,
|
|
36
36
|
maximumAge: 0,
|
|
@@ -78,4 +78,4 @@ export function attachEvents({ appState, pluginState, mapProvider, useLocationBu
|
|
|
78
78
|
|
|
79
79
|
// Return helpers in case you want them in future
|
|
80
80
|
return { startTracking, stopTracking }
|
|
81
|
-
}
|
|
81
|
+
}
|
|
@@ -24,7 +24,7 @@ export const InteractInit = ({
|
|
|
24
24
|
mapState,
|
|
25
25
|
pluginState,
|
|
26
26
|
services,
|
|
27
|
-
mapProvider
|
|
27
|
+
mapProvider
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
// Refs updated synchronously each render — keeps callbacks fresh without re-attaching events
|
|
@@ -89,6 +89,5 @@ export const InteractInit = ({
|
|
|
89
89
|
return cleanupEvents
|
|
90
90
|
}, [pluginState.enabled, buttonConfig, events, eventBus, closeApp])
|
|
91
91
|
|
|
92
|
-
|
|
93
92
|
return null
|
|
94
93
|
}
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
import { DEFAULTS } from '../defaults.js'
|
|
8
8
|
|
|
9
9
|
export const enable = ({ pluginState, pluginConfig }, options) => {
|
|
10
|
-
pluginState.dispatch({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
pluginState.dispatch({
|
|
11
|
+
type: 'ENABLE',
|
|
12
|
+
payload: {
|
|
13
|
+
...DEFAULTS,
|
|
14
|
+
...pluginConfig,
|
|
15
|
+
...options
|
|
16
|
+
}
|
|
17
|
+
})
|
|
15
18
|
}
|
|
@@ -18,9 +18,9 @@ describe('enable', () => {
|
|
|
18
18
|
expect(dispatch).toHaveBeenCalledWith({
|
|
19
19
|
type: 'ENABLE',
|
|
20
20
|
payload: expect.objectContaining({
|
|
21
|
-
interactionMode: 'select',
|
|
21
|
+
interactionMode: 'select', // options override DEFAULTS
|
|
22
22
|
multiSelect: DEFAULTS.multiSelect, // default preserved
|
|
23
|
-
markerColor: 'green',
|
|
23
|
+
markerColor: 'green', // options override pluginConfig
|
|
24
24
|
dataLayers: [{ layerId: 'test' }] // options passed
|
|
25
25
|
})
|
|
26
26
|
})
|