@defra/interactive-map 0.0.3-alpha → 0.0.5-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/README.md +16 -57
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +176 -0
- package/docs/api/context.md +124 -0
- package/docs/api/control-definition.md +72 -0
- package/docs/api/icon-definition.md +28 -0
- package/docs/api/map-style-config.md +76 -0
- package/docs/api/marker-config.md +51 -0
- package/docs/api/panel-definition.md +117 -0
- package/docs/api/slots.md +25 -0
- package/docs/api.md +721 -0
- package/docs/architecture.md +139 -0
- package/docs/building-a-plugin.md +149 -0
- package/docs/getting-started.md +46 -0
- package/docs/govuk-prototype.md +0 -0
- package/docs/plugins/interact.md +205 -0
- package/docs/plugins/map-styles.md +84 -0
- package/docs/plugins/plugin-context.md +67 -0
- package/docs/plugins/plugin-descriptor.md +71 -0
- package/docs/plugins/plugin-manifest.md +118 -0
- package/docs/plugins/scale-bar.md +62 -0
- package/docs/plugins/search.md +162 -0
- package/docs/plugins.md +116 -0
- package/govuk-prototype-kit.config.json +7 -7
- package/package.json +16 -2
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +2 -0
- package/plugins/beta/datasets/dist/esm/index.js +2 -0
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +2 -0
- package/plugins/beta/datasets/dist/umd/index.js +2 -0
- package/plugins/beta/datasets/src/datasets.js +113 -0
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +206 -0
- package/plugins/beta/datasets/src/fetch/fetchGeoJSON.js +38 -0
- package/plugins/{datasets → beta/datasets}/src/handleSetMapStyle.js +8 -1
- package/plugins/{datasets → beta/datasets}/src/manifest.js +1 -1
- package/plugins/{datasets → beta/datasets}/src/mapLayers.js +42 -4
- package/plugins/{datasets → beta/datasets}/src/panels/Key.jsx +1 -1
- package/plugins/beta/datasets/src/utils/bbox.js +115 -0
- package/plugins/beta/draw-ml/dist/css/index.css +1 -0
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -0
- package/plugins/beta/draw-ml/dist/esm/index.js +2 -0
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -0
- package/plugins/beta/draw-ml/dist/umd/index.js +2 -0
- package/plugins/beta/draw-ml/src/api/addFeature.js +27 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/api/editFeature.js +17 -6
- package/plugins/beta/draw-ml/src/api/merge.js +9 -0
- package/plugins/beta/draw-ml/src/api/newLine.js +68 -0
- package/plugins/beta/draw-ml/src/api/newPolygon.js +68 -0
- package/plugins/beta/draw-ml/src/api/split.js +81 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/defaults.js +3 -0
- package/plugins/beta/draw-ml/src/draw.scss +32 -0
- package/plugins/beta/draw-ml/src/events.js +171 -0
- package/plugins/beta/draw-ml/src/manifest.js +132 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/mapboxDraw.js +51 -2
- package/plugins/{draw-ml → beta/draw-ml}/src/mapboxSnap.js +18 -12
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +497 -0
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +18 -0
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +16 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +135 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +2 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +134 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +133 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +141 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +121 -0
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +437 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/reducer.js +30 -2
- package/plugins/{draw-ml → beta/draw-ml}/src/styles.js +66 -36
- package/plugins/beta/draw-ml/src/undoStack.js +50 -0
- package/plugins/beta/draw-ml/src/utils/debounce.js +16 -0
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +49 -0
- package/plugins/beta/draw-ml/src/utils/spatial.js +258 -0
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -0
- package/plugins/beta/frame/dist/esm/index.js +2 -0
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -0
- package/plugins/beta/frame/dist/umd/index.js +2 -0
- package/plugins/{frame → beta/frame}/src/Frame.jsx +1 -1
- package/plugins/{map-styles → beta/map-styles}/dist/css/index.css +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
- package/plugins/beta/map-styles/dist/esm/index.js +2 -0
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/beta/map-styles/dist/umd/index.js +2 -0
- package/plugins/{map-styles → beta/map-styles}/src/MapStyles.jsx +1 -1
- package/plugins/{map-styles → beta/map-styles}/src/manifest.js +8 -10
- package/plugins/{map-styles → beta/map-styles}/src/mapStyles.scss +4 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -0
- package/plugins/beta/scale-bar/dist/esm/index.js +2 -0
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -0
- package/plugins/beta/scale-bar/dist/umd/index.js +2 -0
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -0
- package/plugins/beta/use-location/dist/esm/index.js +2 -0
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -0
- package/plugins/beta/use-location/dist/umd/index.js +2 -0
- package/plugins/interact/dist/css/index.css +1 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.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 +1 -1
- package/plugins/interact/src/InteractInit.test.js +97 -0
- package/plugins/interact/src/api/clear.test.js +18 -0
- package/plugins/interact/src/api/disable.test.js +12 -0
- package/plugins/interact/src/api/enable.test.js +48 -0
- package/plugins/interact/src/api/selectFeature.test.js +33 -0
- package/plugins/interact/src/api/unselectFeature.test.js +33 -0
- package/plugins/interact/src/defaults.js +2 -0
- package/plugins/interact/src/events.js +37 -52
- package/plugins/interact/src/events.test.js +186 -0
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useHighlightSync.test.js +212 -0
- package/plugins/interact/src/hooks/useInteractionHandlers.js +80 -41
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +316 -0
- package/plugins/interact/src/index.test.js +22 -0
- package/plugins/interact/src/interact.scss +6 -0
- package/plugins/interact/src/manifest.js +1 -1
- package/plugins/interact/src/manifest.test.js +94 -0
- package/plugins/interact/src/reducer.js +28 -21
- package/plugins/interact/src/reducer.test.js +155 -0
- package/plugins/interact/src/utils/buildStylesMap.test.js +57 -0
- package/plugins/interact/src/utils/featureQueries.js +2 -2
- package/plugins/interact/src/utils/featureQueries.test.js +56 -0
- package/plugins/interact/src/utils/spatial.js +95 -0
- package/plugins/interact/src/utils/spatial.test.js +93 -0
- 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 +2 -2
- package/plugins/search/src/components/Form/Form.jsx +1 -1
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +5 -5
- package/plugins/search/src/datasets.js +1 -1
- package/plugins/search/src/defaults.js +3 -0
- package/plugins/search/src/events/fetchSuggestions.js +48 -53
- package/plugins/search/src/events/formHandlers.js +3 -2
- package/plugins/search/src/events/index.js +1 -1
- package/plugins/search/src/events/inputHandlers.js +3 -1
- package/plugins/search/src/events/suggestionHandlers.js +12 -3
- package/plugins/search/src/search.scss +4 -1
- package/plugins/search/src/utils/parseOsNamesResults.js +15 -19
- package/providers/{esri → beta/esri}/src/esriProvider.js +1 -1
- package/providers/{esri → beta/esri}/src/index.js +1 -1
- package/providers/{esri → beta/esri}/src/mapEvents.js +2 -2
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +2 -0
- package/providers/beta/open-names/dist/esm/index.js +2 -0
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +2 -0
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js.LICENSE.txt +1 -0
- package/providers/beta/open-names/dist/umd/index.js +2 -0
- package/providers/beta/open-names/dist/umd/index.js.LICENSE.txt +1 -0
- package/providers/maplibre/dist/esm/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.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/defaults.js +3 -2
- package/providers/maplibre/src/index.js +36 -20
- package/providers/maplibre/src/maplibreProvider.js +140 -11
- package/providers/maplibre/src/utils/detectWebgl.js +1 -2
- package/providers/maplibre/src/utils/highlightFeatures.js +78 -67
- package/providers/maplibre/src/utils/labels.js +174 -120
- package/providers/maplibre/src/utils/maplibreFixes.js +2 -2
- package/providers/maplibre/src/utils/queryFeatures.js +146 -0
- package/providers/maplibre/src/utils/spatial.js +14 -17
- package/sonar-project.properties +40 -3
- package/src/App/components/Actions/Actions.jsx +2 -2
- package/src/App/components/Actions/Actions.module.scss +2 -2
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +3 -1
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +9 -0
- package/src/App/components/Logo/Logo.jsx +1 -1
- package/src/App/components/MapButton/MapButton.jsx +217 -41
- package/src/App/components/MapButton/MapButton.module.scss +32 -21
- package/src/App/components/MapButton/MapButton.test.jsx +128 -84
- package/src/App/components/Markers/Markers.jsx +1 -1
- package/src/App/components/Markers/Markers.module.scss +0 -5
- package/src/App/components/Panel/Panel.jsx +75 -45
- package/src/App/components/Panel/Panel.module.scss +18 -24
- package/src/App/components/Panel/Panel.test.jsx +18 -0
- package/src/App/components/PopupMenu/PopupMenu.jsx +246 -0
- package/src/App/components/PopupMenu/PopupMenu.module.scss +70 -0
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +304 -0
- package/src/App/components/Tooltip/Tooltip.jsx +4 -2
- package/src/App/components/Tooltip/getTooltipPosition.js +1 -1
- package/src/App/components/Viewport/MapController.jsx +1 -1
- package/src/App/components/Viewport/MapStatus.jsx +1 -1
- package/src/App/components/Viewport/Viewport.jsx +2 -2
- package/src/App/components/Viewport/Viewport.module.scss +2 -2
- package/src/App/controls/keyboardActions.js +3 -2
- package/src/App/controls/keyboardShortcuts.js +4 -2
- package/src/App/hooks/useButtonStateEvaluator.js +58 -45
- package/src/App/hooks/useButtonStateEvaluator.test.js +36 -3
- package/src/App/hooks/useCrossHairAPI.js +49 -47
- package/src/App/hooks/useFocusVisible.js +2 -2
- package/src/App/hooks/useInterfaceAPI.js +36 -1
- package/src/App/hooks/useKeyboardHint.js +1 -1
- package/src/App/hooks/useKeyboardShortcuts.js +4 -2
- package/src/App/hooks/useMapAnnouncements.js +34 -32
- package/src/App/hooks/useMapEvents.js +12 -1
- package/src/App/hooks/useMapProviderOverrides.js +3 -3
- package/src/App/hooks/useMapStateSync.js +7 -1
- package/src/App/hooks/useMapURLSync.js +6 -1
- package/src/App/hooks/useMarkersAPI.js +88 -50
- package/src/App/hooks/useMediaQueryDispatch.test.js +48 -0
- package/src/App/hooks/useModalPanelBehaviour.js +46 -40
- package/src/App/hooks/useResizeObserver.js +2 -2
- package/src/App/initialiseApp.js +45 -38
- package/src/App/layout/Layout.jsx +6 -4
- package/src/App/layout/layout.module.scss +13 -17
- package/src/App/registry/keyboardShortcutRegistry.js +12 -2
- package/src/App/registry/keyboardShortcutRegistry.test.js +28 -0
- package/src/App/registry/mergeManifests.js +1 -1
- package/src/App/registry/panelRegistry.js +1 -1
- package/src/App/registry/panelRegistry.test.js +30 -1
- package/src/App/registry/pluginRegistry.js +14 -51
- package/src/App/registry/pluginRegistry.test.js +54 -6
- package/src/App/renderer/HtmlElementHost.jsx +186 -0
- package/src/App/renderer/HtmlElementHost.test.jsx +231 -0
- package/src/App/renderer/mapButtons.js +12 -9
- package/src/App/renderer/mapButtons.test.js +6 -4
- package/src/App/renderer/mapControls.js +6 -0
- package/src/App/renderer/mapControls.test.js +10 -2
- package/src/App/renderer/mapPanels.js +39 -26
- package/src/App/renderer/mapPanels.test.js +29 -0
- package/src/App/renderer/pluginWrapper.test.js +28 -0
- package/src/App/renderer/slotHelpers.js +60 -0
- package/src/App/renderer/slotHelpers.test.js +82 -0
- package/src/App/store/AppProvider.jsx +3 -0
- package/src/App/store/AppProvider.test.jsx +40 -0
- package/src/App/store/PluginProvider.jsx +7 -5
- package/src/App/store/appActionsMap.js +46 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appReducer.js +1 -0
- package/src/App/store/mapActionsMap.js +12 -24
- package/src/App/store/mapReducer.js +1 -1
- package/src/InteractiveMap/InteractiveMap.js +194 -13
- package/src/InteractiveMap/InteractiveMap.test.js +164 -2
- package/src/InteractiveMap/behaviourController.js +12 -2
- package/src/InteractiveMap/behaviourController.test.js +82 -1
- package/src/InteractiveMap/deviceChecker.js +1 -1
- package/src/InteractiveMap/deviceChecker.test.js +2 -2
- package/src/InteractiveMap/historyManager.js +41 -5
- package/src/InteractiveMap/historyManager.test.js +37 -6
- package/src/InteractiveMap/polyfills.js +39 -0
- package/src/InteractiveMap/polyfills.test.js +127 -0
- package/src/config/appConfig.js +5 -5
- package/src/config/appConfig.test.js +107 -42
- package/src/config/defaults.js +30 -20
- package/src/config/events.js +110 -4
- package/src/index.js +5 -2
- package/src/index.umd.js +1 -1
- package/src/scss/main.scss +1 -0
- package/src/scss/settings/_dimensions.scss +6 -2
- package/src/scss/tools/_border-focus.scss +20 -4
- package/src/services/eventBus.test.js +24 -1
- package/src/test-utils.js +1 -0
- package/src/types.js +590 -0
- package/src/utils/detectBreakpoint.js +78 -77
- package/src/utils/detectBreakpoint.test.js +50 -4
- package/src/utils/detectInterfaceType.js +4 -4
- package/src/utils/getIsFullscreen.js +3 -1
- package/src/utils/getSafeZoneInset.js +23 -7
- package/src/utils/getSafeZoneInset.test.js +18 -0
- package/src/utils/mapStateSync.js +3 -3
- package/src/utils/queryString.js +1 -1
- package/src/utils/stringToKebab.js +1 -1
- package/src/utils/toggleInertElements.js +37 -12
- package/webpack.dev.mjs +3 -4
- package/webpack.esm.mjs +8 -8
- package/webpack.umd.mjs +8 -8
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +0 -1
- package/plugins/datasets/dist/esm/index.js +0 -2
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +0 -1
- package/plugins/datasets/dist/umd/index.js +0 -2
- package/plugins/datasets/src/datasets.js +0 -60
- package/plugins/datasets/src/utils/bbox.js +0 -4
- package/plugins/draw-ml/dist/css/index.css +0 -1
- package/plugins/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/draw-ml/dist/esm/index.js +0 -2
- package/plugins/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/draw-ml/dist/umd/index.js +0 -2
- package/plugins/draw-ml/src/api/addFeature.js +0 -15
- package/plugins/draw-ml/src/api/newPolygon.js +0 -43
- package/plugins/draw-ml/src/draw.scss +0 -9
- package/plugins/draw-ml/src/events.js +0 -127
- package/plugins/draw-ml/src/manifest.js +0 -100
- package/plugins/draw-ml/src/modes/drawVertexMode.js +0 -275
- package/plugins/draw-ml/src/modes/editVertexMode.js +0 -426
- package/plugins/draw-ml/src/utils.js +0 -102
- package/plugins/frame/dist/esm/im-frame-plugin.js +0 -1
- package/plugins/frame/dist/esm/index.js +0 -2
- package/plugins/frame/dist/umd/im-frame-plugin.js +0 -1
- package/plugins/frame/dist/umd/index.js +0 -2
- package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/map-styles/dist/esm/index.js +0 -2
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/map-styles/dist/umd/index.js +0 -2
- package/plugins/scale-bar/dist/esm/im-scale-bar-plugin.js +0 -1
- package/plugins/scale-bar/dist/esm/index.js +0 -2
- package/plugins/scale-bar/dist/umd/im-scale-bar-plugin.js +0 -1
- package/plugins/scale-bar/dist/umd/index.js +0 -2
- package/plugins/search/src/utils/fetchDataset.js +0 -23
- package/plugins/use-location/dist/esm/im-use-location-plugin.js +0 -1
- package/plugins/use-location/dist/esm/index.js +0 -2
- package/plugins/use-location/dist/umd/im-use-location-plugin.js +0 -1
- package/plugins/use-location/dist/umd/index.js +0 -2
- package/providers/maplibre/dist/esm/im-maplibre-legacy-framework.js +0 -1
- package/providers/maplibre/dist/umd/im-maplibre-legacy-framework.js +0 -1
- package/providers/open-names/dist/esm/im-reverse-geocode.js +0 -2
- package/providers/open-names/dist/esm/index.js +0 -2
- package/providers/open-names/dist/umd/im-reverse-geocode.js +0 -2
- package/providers/open-names/dist/umd/index.js +0 -2
- /package/docs/architecture/{ARCHITECTURE_DIAGRAMS.md → architecture-diagrams.md} +0 -0
- /package/plugins/{datasets → beta/datasets}/dist/css/index.css +0 -0
- /package/plugins/{datasets/dist/esm/index.js.LICENSE.txt → beta/datasets/dist/esm/im-datasets-plugin.js.LICENSE.txt} +0 -0
- /package/plugins/{datasets/dist/umd → beta/datasets/dist/esm}/index.js.LICENSE.txt +0 -0
- /package/plugins/{draw-ml/dist/esm/index.js.LICENSE.txt → beta/datasets/dist/umd/im-datasets-plugin.js.LICENSE.txt} +0 -0
- /package/plugins/{draw-ml → beta/datasets}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{datasets → beta/datasets}/src/DatasetsInit.jsx +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/addDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/hideDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/hideFeatures.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/removeDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/showDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/showFeatures.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/datasets.scss +0 -0
- /package/plugins/{datasets → beta/datasets}/src/defaults.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/index.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/panels/Key.module.scss +0 -0
- /package/plugins/{datasets → beta/datasets}/src/panels/Layers.jsx +0 -0
- /package/plugins/{datasets → beta/datasets}/src/panels/Layers.module.scss +0 -0
- /package/plugins/{datasets → beta/datasets}/src/reducer.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/utils/debounce.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/utils/filters.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/DrawInit.jsx +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/events.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/graphic.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/index.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/manifest.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/reducer.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{frame → beta/draw-ml}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{frame → beta/draw-ml}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/DrawInit.jsx +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/api/deleteFeature.js +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/index.js +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/modes/disabledMode.js +0 -0
- /package/plugins/{draw-ml/src → beta/draw-ml/src/utils}/snapHelpers.js +0 -0
- /package/plugins/{frame → beta/frame}/dist/css/index.css +0 -0
- /package/plugins/{map-styles → beta/frame}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{map-styles → beta/frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{frame → beta/frame}/package.json +0 -0
- /package/plugins/{frame → beta/frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{frame → beta/frame}/src/api/addFrame.js +0 -0
- /package/plugins/{frame → beta/frame}/src/api/editFeature.js +0 -0
- /package/plugins/{frame → beta/frame}/src/config.js +0 -0
- /package/plugins/{frame → beta/frame}/src/frame.scss +0 -0
- /package/plugins/{frame → beta/frame}/src/index.js +0 -0
- /package/plugins/{frame → beta/frame}/src/manifest.js +0 -0
- /package/plugins/{frame → beta/frame}/src/reducer.js +0 -0
- /package/plugins/{frame → beta/frame}/src/utils.js +0 -0
- /package/plugins/{scale-bar → beta/map-styles}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{scale-bar → beta/map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{map-styles → beta/map-styles}/src/MapStylesInit.jsx +0 -0
- /package/plugins/{map-styles → beta/map-styles}/src/config.js +0 -0
- /package/plugins/{map-styles → beta/map-styles}/src/index.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{use-location → beta/scale-bar}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{use-location → beta/scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/package.json +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/index.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/index.test.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/manifest.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/utils.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/utils.test.js +0 -0
- /package/{providers/open-names → plugins/beta/use-location}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/{providers/open-names → plugins/beta/use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{use-location → beta/use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{use-location → beta/use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{use-location → beta/use-location}/src/defaults.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/events.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/index.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/manifest.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/reducer.js +0 -0
- /package/providers/{esri → beta/esri}/src/appEvents.js +0 -0
- /package/providers/{esri → beta/esri}/src/defaults.js +0 -0
- /package/providers/{esri → beta/esri}/src/esriProvider.scss +0 -0
- /package/providers/{esri → beta/esri}/src/utils/coords.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/query.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/spatial.js +0 -0
- /package/providers/{open-names → beta/open-names}/dist/esm/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/providers/{open-names/dist/umd/im-reverse-geocode.js.LICENSE.txt → beta/open-names/dist/esm/index.js.LICENSE.txt} +0 -0
- /package/providers/{open-names → beta/open-names}/src/index.js +0 -0
- /package/providers/{open-names → beta/open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{open-names → beta/open-names}/src/utils/mapToLocationModel.js +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# PluginDescriptor
|
|
2
|
+
|
|
3
|
+
Descriptor for lazy-loading a plugin.
|
|
4
|
+
|
|
5
|
+
## Creating a Plugin Descriptor
|
|
6
|
+
|
|
7
|
+
Plugins typically export a factory function that returns a PluginDescriptor. This pattern allows configuration to be passed when registering the plugin:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// scale-bar/index.js
|
|
11
|
+
export default function createPlugin ({ units = 'metric' } = {}) {
|
|
12
|
+
return {
|
|
13
|
+
id: 'scaleBar',
|
|
14
|
+
units,
|
|
15
|
+
load: async () => {
|
|
16
|
+
const { manifest } = await import('./manifest.js')
|
|
17
|
+
return manifest
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Any properties passed to the factory (except `id` and `load`) are available as [pluginConfig](./plugin-context.md#pluginconfig) within the plugin:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
// Registering the plugin with configuration
|
|
27
|
+
import createScaleBarPlugin from '@defra/interactive-map-plugin-scale-bar'
|
|
28
|
+
|
|
29
|
+
const interactiveMap = new InteractiveMap({
|
|
30
|
+
plugins: [
|
|
31
|
+
createScaleBarPlugin({ units: 'imperial' })
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
// Accessing configuration within the plugin
|
|
38
|
+
export function ScaleBar ({ mapState, pluginConfig }) {
|
|
39
|
+
const { units } = pluginConfig
|
|
40
|
+
// ...
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Properties
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### `id`
|
|
49
|
+
**Type:** `string`
|
|
50
|
+
**Required**
|
|
51
|
+
|
|
52
|
+
Unique plugin identifier.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### `load`
|
|
57
|
+
**Type:** `function`
|
|
58
|
+
**Required**
|
|
59
|
+
|
|
60
|
+
Async function that loads and returns a [PluginManifest](./plugin-manifest.md).
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
() => Promise<PluginManifest>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### `manifest`
|
|
69
|
+
**Type:** `Partial<PluginManifest>`
|
|
70
|
+
|
|
71
|
+
Optional manifest overrides. Allows overriding properties of the loaded [PluginManifest](./plugin-manifest.md).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# PluginManifest
|
|
2
|
+
|
|
3
|
+
Manifest defining a plugin's buttons, panels, controls, icons, API methods, and state.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### `api`
|
|
10
|
+
**Type:** `Object`
|
|
11
|
+
|
|
12
|
+
Public methods exposed by the plugin for external use. These methods can be called via the plugin instance:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
myPlugin.doSomething()
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Each function receives a [PluginContext](./plugin-context.md) as its first argument, providing access to app state, map provider, services, and more. Additional arguments follow.
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
{
|
|
22
|
+
doSomething: (context) => {
|
|
23
|
+
console.log(context.appState.breakpoint)
|
|
24
|
+
},
|
|
25
|
+
getValue: (context, id) => {
|
|
26
|
+
return context.pluginState[id]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### `buttons`
|
|
34
|
+
**Type:** `ButtonDefinition[]`
|
|
35
|
+
|
|
36
|
+
Button definitions to register in the UI.
|
|
37
|
+
|
|
38
|
+
Buttons come with pre-built behaviour and styling, including icon support, labels, tooltips, and pressed states. Supports responsive breakpoint configuration.
|
|
39
|
+
|
|
40
|
+
See [ButtonDefinition](../api/button-definition.md) for full details.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### `controls`
|
|
45
|
+
**Type:** `ControlDefinition[]`
|
|
46
|
+
|
|
47
|
+
Custom control definitions to register in the UI.
|
|
48
|
+
|
|
49
|
+
Use controls for bespoke UI elements that don't fit the button or panel pattern. Controls have no pre-built behaviour or styling—you have full control over rendering and interaction. Supports responsive breakpoint configuration.
|
|
50
|
+
|
|
51
|
+
See [ControlDefinition](../api/control-definition.md) for full details.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### `icons`
|
|
56
|
+
**Type:** `IconDefinition[]`
|
|
57
|
+
|
|
58
|
+
Icon definitions to register in the icon registry.
|
|
59
|
+
|
|
60
|
+
The icon registry is a singleton shared across all map instances and plugins. Registering an icon with an existing ID will override it. This enforces visual consistency across the application, including when multiple map instances exist on the same page.
|
|
61
|
+
|
|
62
|
+
See [IconDefinition](../api/icon-definition.md) for full details.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### `InitComponent`
|
|
67
|
+
**Type:** `ComponentType`
|
|
68
|
+
|
|
69
|
+
A React/Preact component rendered when the plugin loads. Use this for initialisation logic, side effects, or rendering hidden UI elements.
|
|
70
|
+
|
|
71
|
+
- Mounted once when the app loads
|
|
72
|
+
- Re-renders when [PluginContext](./plugin-context.md) state changes (e.g., `appState`, `pluginState`, `mapState`)
|
|
73
|
+
- Typically returns `null` if no visible UI is needed
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
const InitComponent = ({ context }) => {
|
|
77
|
+
const { appState, mapProvider, pluginState } = context
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
// Run side effects when state changes
|
|
81
|
+
console.log('Breakpoint:', appState.breakpoint)
|
|
82
|
+
}, [appState.breakpoint])
|
|
83
|
+
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### `panels`
|
|
91
|
+
**Type:** `PanelDefinition[]`
|
|
92
|
+
|
|
93
|
+
Panel definitions to register in the UI.
|
|
94
|
+
|
|
95
|
+
Panels come with pre-built behaviour and styling, including headings, dismissable states, and modal overlays. Supports responsive breakpoint configuration.
|
|
96
|
+
|
|
97
|
+
See [PanelDefinition](../api/panel-definition.md) for full details.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### `reducer`
|
|
102
|
+
**Type:** `Object`
|
|
103
|
+
|
|
104
|
+
Reducer configuration for plugin state management.
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
{
|
|
108
|
+
initialState: {
|
|
109
|
+
isActive: false
|
|
110
|
+
},
|
|
111
|
+
actions: {
|
|
112
|
+
setActive: (state, isActive) => ({
|
|
113
|
+
...state,
|
|
114
|
+
isActive
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Scale Bar Plugin
|
|
2
|
+
|
|
3
|
+
Displays the current map scale. The scale bar automatically updates as the user zooms in and out.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import createScaleBarPlugin from '@defra/interactive-map/plugins/scale-bar'
|
|
9
|
+
|
|
10
|
+
const scaleBarPlugin = createScaleBarPlugin({
|
|
11
|
+
units: 'metric'
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const interactiveMap = new InteractiveMap({
|
|
15
|
+
plugins: [scaleBarPlugin]
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Options
|
|
20
|
+
|
|
21
|
+
Options are passed to the factory function when creating the plugin.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### `units`
|
|
26
|
+
**Type:** `'metric' | 'imperial'`
|
|
27
|
+
**Default:** `'metric'`
|
|
28
|
+
|
|
29
|
+
The unit system used to display the scale.
|
|
30
|
+
|
|
31
|
+
| Value | Description |
|
|
32
|
+
|-------|-------------|
|
|
33
|
+
| `'metric'` | Displays scale in metres and kilometres |
|
|
34
|
+
| `'imperial'` | Displays scale in feet and miles |
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
createScaleBarPlugin({ units: 'imperial' })
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### `includeModes`
|
|
43
|
+
**Type:** `string[]`
|
|
44
|
+
|
|
45
|
+
Array of mode identifiers. When set, the plugin only renders when the app is in one of these modes.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### `excludeModes`
|
|
50
|
+
**Type:** `string[]`
|
|
51
|
+
|
|
52
|
+
Array of mode identifiers. When set, the plugin does not render when the app is in one of these modes.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Methods
|
|
57
|
+
|
|
58
|
+
This plugin does not expose any public methods.
|
|
59
|
+
|
|
60
|
+
## Events
|
|
61
|
+
|
|
62
|
+
This plugin does not emit any custom events.
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Search Plugin
|
|
2
|
+
|
|
3
|
+
Location search plugin with autocomplete functionality. Supports custom datasets for searching locations, addresses, or other geographic features.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import createSearchPlugin from '@defra/interactive-map/plugins/search'
|
|
9
|
+
|
|
10
|
+
const searchPlugin = createSearchPlugin({
|
|
11
|
+
showMarker: true,
|
|
12
|
+
datasets: [
|
|
13
|
+
{
|
|
14
|
+
id: 'os-places',
|
|
15
|
+
url: '/api/search',
|
|
16
|
+
minChars: 3
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const interactiveMap = new InteractiveMap({
|
|
22
|
+
plugins: [searchPlugin]
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Options
|
|
27
|
+
|
|
28
|
+
Options are passed to the factory function when creating the plugin.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### `showMarker`
|
|
33
|
+
**Type:** `boolean`
|
|
34
|
+
**Default:** `true`
|
|
35
|
+
|
|
36
|
+
Whether to display a marker at the selected location.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### `datasets`
|
|
41
|
+
**Type:** `SearchDataset[]`
|
|
42
|
+
|
|
43
|
+
Array of dataset configurations for search. Each dataset defines a source for search suggestions.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
createSearchPlugin({
|
|
47
|
+
datasets: [
|
|
48
|
+
{
|
|
49
|
+
id: 'os-places',
|
|
50
|
+
url: '/api/os-places/search',
|
|
51
|
+
minChars: 3,
|
|
52
|
+
params: {
|
|
53
|
+
maxResults: 10
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### `isExpanded`
|
|
63
|
+
**Type:** `boolean`
|
|
64
|
+
**Default:** `false`
|
|
65
|
+
|
|
66
|
+
Whether the search input is initially expanded on mobile devices.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### `markerColor`
|
|
71
|
+
**Type:** `string`
|
|
72
|
+
|
|
73
|
+
Colour of the search result marker. Overrides the default `markerColor` option.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### `includeModes`
|
|
78
|
+
**Type:** `string[]`
|
|
79
|
+
|
|
80
|
+
Array of mode identifiers. When set, the plugin only renders when the app is in one of these modes.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### `excludeModes`
|
|
85
|
+
**Type:** `string[]`
|
|
86
|
+
|
|
87
|
+
Array of mode identifiers. When set, the plugin does not render when the app is in one of these modes.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Methods
|
|
92
|
+
|
|
93
|
+
This plugin does not expose any public methods.
|
|
94
|
+
|
|
95
|
+
## Events
|
|
96
|
+
|
|
97
|
+
Subscribe to events using `interactiveMap.on()`.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### `search:match`
|
|
102
|
+
|
|
103
|
+
Emitted when a search result is selected.
|
|
104
|
+
|
|
105
|
+
**Payload:**
|
|
106
|
+
```js
|
|
107
|
+
{
|
|
108
|
+
query: 'London',
|
|
109
|
+
text: 'London, Greater London',
|
|
110
|
+
point: [lng, lat],
|
|
111
|
+
bounds: [west, south, east, north]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
interactiveMap.on('search:match', ({ query, point, bounds }) => {
|
|
117
|
+
console.log('Location selected:', query)
|
|
118
|
+
console.log('Coordinates:', point)
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### `search:open`
|
|
125
|
+
|
|
126
|
+
Emitted when the search input is expanded (mobile only).
|
|
127
|
+
|
|
128
|
+
**Payload:** None
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
interactiveMap.on('search:open', () => {
|
|
132
|
+
console.log('Search opened')
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### `search:close`
|
|
139
|
+
|
|
140
|
+
Emitted when the search input is collapsed or dismissed.
|
|
141
|
+
|
|
142
|
+
**Payload:** None
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
interactiveMap.on('search:close', () => {
|
|
146
|
+
console.log('Search closed')
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### `search:clear`
|
|
153
|
+
|
|
154
|
+
Emitted when the search input is cleared.
|
|
155
|
+
|
|
156
|
+
**Payload:** None
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
interactiveMap.on('search:clear', () => {
|
|
160
|
+
console.log('Search cleared')
|
|
161
|
+
})
|
|
162
|
+
```
|
package/docs/plugins.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Plugins
|
|
2
|
+
|
|
3
|
+
Plugins extend the InteractiveMap with additional functionality. This page lists the available plugins and links to their documentation.
|
|
4
|
+
|
|
5
|
+
For guidance on building your own plugins, see [Building a Plugin](./building-a-plugin.md).
|
|
6
|
+
|
|
7
|
+
## Available Plugins
|
|
8
|
+
|
|
9
|
+
The following plugins are available for use with InteractiveMap.
|
|
10
|
+
|
|
11
|
+
### [Interact](./plugins/interact.md)
|
|
12
|
+
|
|
13
|
+
Select features or place markers on the map.
|
|
14
|
+
|
|
15
|
+
### [Map Styles](./plugins/map-styles.md)
|
|
16
|
+
|
|
17
|
+
Map style switching plugin that adds a UI control for changing the basemap appearance and the map size (provider depending).
|
|
18
|
+
|
|
19
|
+
### [Scale Bar](./plugins/scale-bar.md)
|
|
20
|
+
|
|
21
|
+
Scale bar display plugin that shows the current map scale.
|
|
22
|
+
|
|
23
|
+
### [Search](./plugins/search.md)
|
|
24
|
+
|
|
25
|
+
Location search plugin with autocomplete functionality. Include custom datasets to search.
|
|
26
|
+
|
|
27
|
+
## Alpha Plugins
|
|
28
|
+
|
|
29
|
+
The following plugins are in early development. APIs and features may change.
|
|
30
|
+
|
|
31
|
+
### Datasets
|
|
32
|
+
|
|
33
|
+
Add datasets to your map, configure the display, layer toggling and render a key of symbology.
|
|
34
|
+
|
|
35
|
+
### Draw for MapLibre
|
|
36
|
+
|
|
37
|
+
Draw lines and polygons using the MapLibre map provider.
|
|
38
|
+
|
|
39
|
+
### Draw for ESRI SDK
|
|
40
|
+
|
|
41
|
+
Draw polygons using the Esri map provider.
|
|
42
|
+
|
|
43
|
+
### Frame
|
|
44
|
+
|
|
45
|
+
Add a regular shaped frame to the map and control its position. Use to generate reports or draw features.
|
|
46
|
+
|
|
47
|
+
### Use Location
|
|
48
|
+
|
|
49
|
+
Geolocation plugin that allows users to centre the map on their current location.
|
|
50
|
+
|
|
51
|
+
## Coming Soon
|
|
52
|
+
|
|
53
|
+
The following plugins are planned for future releases.
|
|
54
|
+
|
|
55
|
+
### Geometry Actions
|
|
56
|
+
|
|
57
|
+
Split and merge polygons.
|
|
58
|
+
|
|
59
|
+
## Using Plugins
|
|
60
|
+
|
|
61
|
+
Plugins are registered via the `plugins` option when creating an InteractiveMap. Plugins typically export a factory function that accepts configuration options:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import createHighlightPlugin from '@example/highlight-plugin'
|
|
65
|
+
|
|
66
|
+
const highlightPlugin = createHighlightPlugin({
|
|
67
|
+
color: '#ff0000',
|
|
68
|
+
opacity: 0.5
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const interactiveMap = new InteractiveMap({
|
|
72
|
+
// ... other options
|
|
73
|
+
plugins: [highlightPlugin]
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The factory function returns a [PluginDescriptor](./plugins/plugin-descriptor.md) with:
|
|
78
|
+
|
|
79
|
+
- **id** - Unique identifier for the plugin instance
|
|
80
|
+
- **load** - Function that returns a [PluginManifest](./plugins/plugin-manifest.md)
|
|
81
|
+
- **...options** - Configuration passed to the factory, available as [pluginConfig](./plugins/plugin-context.md#pluginconfig)
|
|
82
|
+
|
|
83
|
+
## Plugin Events
|
|
84
|
+
|
|
85
|
+
Plugins can emit events that you can listen to using `interactiveMap.on()`:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
interactiveMap.on('highlight:added', ({ id, coords }) => {
|
|
89
|
+
console.log('Highlight added:', id)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
interactiveMap.on('highlight:removed', ({ id }) => {
|
|
93
|
+
console.log('Highlight removed:', id)
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Plugin Methods
|
|
98
|
+
|
|
99
|
+
Plugins can expose methods that you call on the plugin instance:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
// After map:ready, call methods on the plugin instance
|
|
103
|
+
interactiveMap.on('map:ready', () => {
|
|
104
|
+
highlightPlugin.add('area-1', [[0, 0], [1, 0], [1, 1], [0, 1]])
|
|
105
|
+
highlightPlugin.remove('area-1')
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
See individual plugin documentation for available events and methods.
|
|
110
|
+
|
|
111
|
+
## Further Reading
|
|
112
|
+
|
|
113
|
+
- [Building a Plugin](./building-a-plugin.md) - Guide to creating custom plugins
|
|
114
|
+
- [PluginDescriptor](./plugins/plugin-descriptor.md) - Plugin registration reference
|
|
115
|
+
- [PluginManifest](./plugins/plugin-manifest.md) - Plugin manifest reference
|
|
116
|
+
- [PluginContext](./plugins/plugin-context.md) - Context available to plugin code
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"/dist/css/",
|
|
12
12
|
"/dist/umd/",
|
|
13
13
|
"/providers/maplibre/dist",
|
|
14
|
-
"/providers/open-names/dist",
|
|
15
|
-
"/plugins/datasets/dist",
|
|
14
|
+
"/providers/beta/open-names/dist",
|
|
15
|
+
"/plugins/beta/datasets/dist",
|
|
16
16
|
"/plugins/interact/dist",
|
|
17
|
-
"/plugins/map-styles/dist",
|
|
18
|
-
"/plugins/scale-bar/dist",
|
|
17
|
+
"/plugins/beta/map-styles/dist",
|
|
18
|
+
"/plugins/beta/scale-bar/dist",
|
|
19
19
|
"/plugins/search/dist",
|
|
20
|
-
"/plugins/use-location/dist",
|
|
21
|
-
"/plugins/draw-ml/dist",
|
|
22
|
-
"/plugins/frame/dist"
|
|
20
|
+
"/plugins/beta/use-location/dist",
|
|
21
|
+
"/plugins/beta/draw-ml/dist",
|
|
22
|
+
"/plugins/beta/frame/dist"
|
|
23
23
|
]
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra/interactive-map",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-alpha",
|
|
4
4
|
"description": "An accessible map component",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@mapbox/mapbox-gl-draw": "^1.5.0",
|
|
62
62
|
"@testing-library/jest-dom": "^6.6.3",
|
|
63
63
|
"@testing-library/react": "^16.3.0",
|
|
64
|
+
"@types/geojson": "^7946.0.16",
|
|
64
65
|
"@types/react": "^19.1.8",
|
|
65
66
|
"@types/react-dom": "^19.1.6",
|
|
66
67
|
"babel-loader": "^10.0.0",
|
|
@@ -72,17 +73,19 @@
|
|
|
72
73
|
"express-static-gzip": "^3.0.0",
|
|
73
74
|
"geodesy": "^2.4.0",
|
|
74
75
|
"html-webpack-plugin": "^5.6.3",
|
|
76
|
+
"install": "^0.13.0",
|
|
75
77
|
"jest": "^29.7.0",
|
|
76
78
|
"jest-environment-jsdom": "^30.0.4",
|
|
77
79
|
"mapbox-gl-snap": "^1.1.9",
|
|
78
80
|
"mini-css-extract-plugin": "^2.9.2",
|
|
79
81
|
"node-fetch": "^3.3.2",
|
|
82
|
+
"npm": "^11.8.0",
|
|
80
83
|
"npm-run-all": "^4.1.5",
|
|
81
84
|
"prettier": "^3.6.2",
|
|
82
85
|
"react": "^19.2.0",
|
|
83
86
|
"react-dom": "^19.2.0",
|
|
84
87
|
"remove-files-webpack-plugin": "^1.5.0",
|
|
85
|
-
"resize-observer": "^1.
|
|
88
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
86
89
|
"rimraf": "^6.1.0",
|
|
87
90
|
"sass": "^1.89.2",
|
|
88
91
|
"sass-loader": "^16.0.5",
|
|
@@ -107,15 +110,26 @@
|
|
|
107
110
|
],
|
|
108
111
|
"author": "",
|
|
109
112
|
"license": "",
|
|
113
|
+
"overrides": {
|
|
114
|
+
"@turf/bearing": "^7.3.3"
|
|
115
|
+
},
|
|
110
116
|
"dependencies": {
|
|
111
117
|
"@arcgis/core": "^4.34.8",
|
|
112
118
|
"@turf/area": "^7.2.0",
|
|
119
|
+
"@turf/bearing": "^7.3.3",
|
|
120
|
+
"@turf/boolean-disjoint": "^7.3.3",
|
|
113
121
|
"@turf/boolean-valid": "^7.2.0",
|
|
122
|
+
"@turf/destination": "^7.3.3",
|
|
114
123
|
"@turf/helpers": "^7.2.0",
|
|
124
|
+
"@turf/line-intersect": "^7.3.3",
|
|
125
|
+
"@turf/point-to-line-distance": "^7.3.3",
|
|
126
|
+
"@turf/polygon-to-line": "^7.3.3",
|
|
127
|
+
"abortcontroller-polyfill": "^1.7.8",
|
|
115
128
|
"core-js": "^3.44.0",
|
|
116
129
|
"govuk-frontend": "^5.13.0",
|
|
117
130
|
"maplibre-gl": "^5.15.0",
|
|
118
131
|
"maplibre-gl-legacy": "npm:maplibre-gl@1.15.3",
|
|
132
|
+
"polygon-splitter": "^0.0.11",
|
|
119
133
|
"preact": "^10.27.2"
|
|
120
134
|
}
|
|
121
135
|
}
|