@defra/interactive-map 0.0.55-alpha → 0.0.57-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/templates/style-switcher.njk +2 -2
- 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/button-definition.md +11 -0
- package/docs/api/context.md +4 -0
- package/docs/api.md +20 -2
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +197 -35
- package/docs/plugins/interact.md +24 -1
- package/docs/plugins/search.md +2 -2
- package/docusaurus.config.cjs +25 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +20 -23
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
- package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
- package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
- package/plugins/datasets/src/api/getOpacity.js +1 -2
- package/plugins/datasets/src/api/getOpacity.test.js +9 -12
- package/plugins/datasets/src/api/getStyle.js +1 -2
- package/plugins/datasets/src/api/getStyle.test.js +5 -8
- package/plugins/datasets/src/api/removeDataset.js +2 -4
- package/plugins/datasets/src/api/removeDataset.test.js +5 -10
- package/plugins/datasets/src/api/setData.js +2 -4
- package/plugins/datasets/src/api/setData.test.js +6 -14
- package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
- package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
- package/plugins/datasets/src/index.js +2 -2
- package/plugins/datasets/src/index.test.js +8 -1
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +37 -26
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +120 -89
- package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
- package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
- package/plugins/datasets/src/manifest.js +53 -44
- package/plugins/datasets/src/manifest.test.js +36 -4
- package/plugins/datasets/src/reducers/pluginState.js +5 -5
- package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
- package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
- package/plugins/datasets/src/registry/createDataset.js +2 -2
- package/plugins/datasets/src/registry/dataset.js +9 -10
- package/plugins/datasets/src/registry/dataset.test.js +63 -64
- package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
- package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
- package/plugins/datasets/src/registry/globalDataset.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
- package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
- package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
- package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +53 -29
- package/plugins/draw/src/DrawInit.test.jsx +105 -2
- package/plugins/draw/src/adapterEvents.js +78 -44
- package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
- package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
- package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
- package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
- package/plugins/draw/src/api/createNewShape.js +4 -4
- package/plugins/draw/src/api/createNewShape.test.js +1 -1
- package/plugins/draw/src/api/editFeature.js +8 -11
- package/plugins/draw/src/api/editFeature.test.js +33 -22
- package/plugins/draw/src/api/newLine.test.js +3 -3
- package/plugins/draw/src/api/newPoint.js +4 -5
- package/plugins/draw/src/api/newPoint.test.js +3 -3
- package/plugins/draw/src/api/newPolygon.test.js +3 -3
- package/plugins/draw/src/api/recheckGeometry.js +32 -0
- package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
- package/plugins/draw/src/api/setGeometry.js +33 -0
- package/plugins/draw/src/api/setGeometry.test.js +48 -0
- package/plugins/draw/src/api/split.js +23 -22
- package/plugins/draw/src/api/split.test.js +33 -18
- package/plugins/draw/src/events.js +265 -77
- package/plugins/draw/src/events.test.js +708 -34
- package/plugins/draw/src/hooks/useSpatialList.js +10 -11
- package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
- package/plugins/draw/src/manifest.js +33 -17
- package/plugins/draw/src/manifest.test.js +104 -10
- package/plugins/draw/src/reducer.js +31 -9
- package/plugins/draw/src/reducer.test.js +35 -3
- package/plugins/draw/src/utils/drawModes.js +27 -0
- package/plugins/draw/src/utils/drawModes.test.js +27 -0
- package/plugins/draw/src/utils/needsDrawTarget.js +18 -0
- package/plugins/draw/src/utils/needsDrawTarget.test.js +32 -0
- package/plugins/draw/src/utils/touchTarget.js +34 -26
- package/plugins/draw/src/utils/touchTarget.test.js +32 -20
- package/plugins/draw/src/validation/commitChecks.js +185 -0
- package/plugins/draw/src/validation/commitChecks.test.js +205 -0
- package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
- package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
- package/plugins/draw/src/validation/liveStroke.js +6 -6
- package/plugins/draw/src/validation/liveStroke.test.js +27 -27
- package/plugins/draw/src/validation/rules.js +16 -14
- package/plugins/draw/src/validation/rules.test.js +5 -5
- package/plugins/draw/src/validation/validateGeometry.js +58 -31
- package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
- package/plugins/draw-es/dist/esm/index.js +1 -0
- package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
- package/plugins/{beta/frame → frame}/package.json +2 -2
- 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 +3 -3
- package/plugins/interact/src/api/enable.test.js +13 -0
- package/plugins/interact/src/defaults.js +1 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
- package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
- package/plugins/interact/src/hooks/useSpatialList.js +16 -17
- package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
- package/plugins/interact/src/manifest.js +4 -4
- package/plugins/interact/src/manifest.test.js +29 -0
- package/plugins/interact/src/reducer.js +7 -2
- package/plugins/interact/src/reducer.test.js +12 -2
- package/plugins/interact/src/utils/needsTarget.js +20 -0
- package/plugins/interact/src/utils/needsTarget.test.js +36 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
- package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
- package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
- package/plugins/map-key/src/manifest.test.js +0 -1
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
- package/plugins/map-key/src/reducers/pluginState.js +6 -1
- package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
- package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +3 -3
- package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
- 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/components/Suggestions/Suggestions.jsx +3 -1
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
- package/plugins/search/src/utils/markedToElements.jsx +25 -0
- package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
- package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
- package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
- package/providers/esri/dist/esm/index.js +1 -0
- package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
- package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +11 -2
- package/providers/maplibre/src/index.test.js +23 -1
- package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
- package/providers/maplibre/src/utils/workerUrl.js +12 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
- package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
- package/rollup.esm.mjs +43 -47
- package/sonar-project.properties +1 -1
- package/src/App/App.jsx +4 -1
- package/src/App/App.test.jsx +6 -0
- package/src/App/components/MapButton/MapButton.jsx +6 -0
- package/src/App/components/MapButton/MapButton.test.jsx +10 -0
- package/src/App/components/Markers/Markers.jsx +3 -5
- package/src/App/components/Markers/Markers.test.jsx +9 -11
- package/src/App/components/Panel/Panel.jsx +2 -9
- package/src/App/hooks/useInterfaceAPI.js +16 -4
- package/src/App/hooks/useInterfaceAPI.test.js +66 -1
- package/src/App/renderer/PluginInits.jsx +8 -7
- package/src/App/renderer/PluginInits.test.jsx +20 -5
- package/src/App/renderer/SlotItemsProvider.jsx +33 -0
- package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
- package/src/App/renderer/SlotRenderer.jsx +3 -14
- package/src/App/renderer/SlotRenderer.test.jsx +11 -44
- package/src/App/renderer/mapButtons.js +24 -12
- package/src/App/renderer/mapButtons.test.js +32 -1
- package/src/App/renderer/mapControls.js +6 -8
- package/src/App/renderer/mapControls.test.js +10 -0
- package/src/App/renderer/mapPanels.js +16 -19
- package/src/App/renderer/mapPanels.test.js +37 -9
- package/src/App/renderer/pluginWrapper.js +10 -8
- package/src/App/renderer/pluginWrapper.test.js +23 -9
- package/src/App/renderer/slotAggregator.js +18 -5
- package/src/App/renderer/slotAggregator.test.js +68 -25
- package/src/App/renderer/slotHelpers.js +13 -0
- package/src/App/renderer/slotHelpers.test.js +16 -1
- package/src/App/store/AppProvider.jsx +19 -1
- package/src/App/store/AppProvider.test.jsx +41 -0
- package/src/App/store/MapProvider.jsx +3 -0
- package/src/App/store/MapProvider.test.jsx +24 -0
- package/src/App/store/appActionsMap.js +10 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appDispatchMiddleware.js +29 -17
- package/src/App/store/appDispatchMiddleware.test.js +31 -0
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/config/events.js +4 -2
- package/src/config/mapSizeScales.js +3 -0
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/src/types.js +4 -0
- package/src/utils/focusAfterPanelClose.js +9 -0
- package/src/utils/focusAfterPanelClose.test.js +40 -0
- package/webpack.dev.mjs +9 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +6 -7
- package/plugins/beta/draw-es/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
- package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
- package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
- package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
- package/plugins/beta/draw-ml/src/api/merge.js +0 -9
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
- package/plugins/beta/draw-ml/src/api/split.js +0 -81
- package/plugins/beta/draw-ml/src/defaults.js +0 -17
- package/plugins/beta/draw-ml/src/draw.scss +0 -26
- package/plugins/beta/draw-ml/src/events.js +0 -185
- package/plugins/beta/draw-ml/src/index.js +0 -13
- package/plugins/beta/draw-ml/src/manifest.js +0 -110
- package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
- package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
- package/plugins/beta/draw-ml/src/reducer.js +0 -90
- package/plugins/beta/draw-ml/src/styles.js +0 -190
- package/plugins/beta/draw-ml/src/undoStack.js +0 -50
- package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
- package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
- package/plugins/beta/draw-ol/dist/css/index.css +0 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
- package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
- package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
- package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
- package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
- package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
- package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
- package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
- package/plugins/beta/draw-ol/src/core/styles.js +0 -98
- package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
- package/plugins/beta/draw-ol/src/defaults.js +0 -16
- package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
- package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
- package/plugins/beta/draw-ol/src/draw.scss +0 -17
- package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
- package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
- package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
- package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
- package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
- package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
- package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
- package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
- package/plugins/beta/draw-ol/src/events.js +0 -114
- package/plugins/beta/draw-ol/src/index.js +0 -12
- package/plugins/beta/draw-ol/src/manifest.js +0 -125
- package/plugins/beta/draw-ol/src/olDraw.js +0 -38
- package/plugins/beta/draw-ol/src/reducer.js +0 -41
- package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
- package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
- package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
- package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
- package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
- package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
- package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
- package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
- package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
- package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
- package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
- package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
- package/plugins/map-key/src/registry/index.js +0 -1
- package/plugins/map-key/src/registry/index.test.js +0 -7
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
- /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
- /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/frame → frame}/src/config.js +0 -0
- /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
- /package/plugins/{beta/frame → frame}/src/index.js +0 -0
- /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
- /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
- /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
- /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
- /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
- /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
- /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
- /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
- /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
- /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
- /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
- /package/providers/{beta/esri → esri}/src/index.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
package/docs/plugins/draw.md
CHANGED
|
@@ -71,11 +71,19 @@ createDrawPlugin({
|
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
+
### `onGeometryPreview`
|
|
75
|
+
|
|
76
|
+
**Type:** `Function`
|
|
77
|
+
|
|
78
|
+
Plugin-level synchronous check, called while a shape is drawn or dragged and when a vertex is about to be placed. Can be overridden per call. See [`onGeometryPreview`](#ongeometrypreviewevent).
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
74
82
|
### `onGeometryChange`
|
|
75
83
|
|
|
76
84
|
**Type:** `Function`
|
|
77
85
|
|
|
78
|
-
Plugin-level
|
|
86
|
+
Plugin-level check, called after each committed change to a shape. Can return a Promise, so the shape can be checked against a service. Can be overridden per call. See [`onGeometryChange`](#ongeometrychangeevent-context).
|
|
79
87
|
|
|
80
88
|
---
|
|
81
89
|
|
|
@@ -113,7 +121,10 @@ createDrawPlugin({
|
|
|
113
121
|
|
|
114
122
|
## Validation
|
|
115
123
|
|
|
116
|
-
Every geometry change
|
|
124
|
+
Every geometry change is checked against a set of built-in rules, plus your own callbacks if you provide them:
|
|
125
|
+
|
|
126
|
+
- [`onGeometryPreview`](#ongeometrypreviewevent) — synchronous. Gives live feedback while a shape is drawn or dragged, and can reject a vertex before it's placed.
|
|
127
|
+
- [`onGeometryChange`](#ongeometrychangeevent-context) — called after each committed change. Can be asynchronous. Its result for the latest change gates the Done button.
|
|
117
128
|
|
|
118
129
|
### Built-in rules
|
|
119
130
|
|
|
@@ -126,53 +137,138 @@ Every geometry change — placing a vertex, dragging one, finishing a shape —
|
|
|
126
137
|
|
|
127
138
|
Rule failures gate the Done button (the shape can pass through interim invalid states while being built or reshaped, shown with a dashed outline) except the placement-time self-intersection check, which is a hard veto — that specific vertex is rejected and never placed.
|
|
128
139
|
|
|
129
|
-
###
|
|
140
|
+
### Setting the callbacks
|
|
130
141
|
|
|
131
|
-
|
|
142
|
+
Both callbacks are set at the plugin level (`createDrawPlugin({ onGeometryPreview, onGeometryChange })`) or per call, in the options of `newPolygon`, `newLine`, `newPoint` and `editFeature`. A per-call callback replaces the plugin-level one for that session. To run both, call the plugin-level callback from the per-call one.
|
|
132
143
|
|
|
133
|
-
|
|
144
|
+
Each session has one of each callback. When more than one part of your app needs `onGeometryChange`, such as a measurements panel and a rules service, pass a single callback that calls each of them and returns the result that should gate Done:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
createDrawPlugin({
|
|
148
|
+
onGeometryChange: (event, context) => {
|
|
149
|
+
measurements.update(event.feature)
|
|
150
|
+
return rules.check(event, context)
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Neither is used by `split` (which checks that the line divides the shape in two) or by `merge`, `addFeature` and `setStyle`.
|
|
156
|
+
|
|
157
|
+
Both return the same result:
|
|
134
158
|
|
|
135
159
|
| Return value | Meaning |
|
|
136
160
|
|---|---|
|
|
137
161
|
| `true` / `undefined` | Valid |
|
|
138
162
|
| `false` | Invalid, no reason shown |
|
|
139
|
-
| `{ valid, reason }` | Valid or invalid, with
|
|
163
|
+
| `{ valid, reason, announcement, recheckOnFinish }` | Valid or invalid, with these optional fields |
|
|
164
|
+
|
|
165
|
+
| Result field | Type | Description |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| `reason` | `string` | Why the shape is invalid. Shown as a hint toast and sent with [`draw:geometryinvalid`](#drawgeometryinvalid) |
|
|
168
|
+
| `announcement` | `string` | Announced to screen readers instead of draw's own message, whether the result is valid or not. When set, `reason` isn't shown as a hint toast, so you can present the issue yourself. From `onGeometryPreview`, only a rejected placement is announced |
|
|
169
|
+
| `recheckOnFinish` | `boolean` | `onGeometryChange` only. When the shape is finished, check it again with phase `'create'` or `'edit-finish'` rather than reusing this result. See [Checking once a shape is finished](#checking-once-a-shape-is-finished) |
|
|
140
170
|
|
|
141
|
-
|
|
171
|
+
Both receive the same event:
|
|
142
172
|
|
|
143
173
|
| Property | Type | Description |
|
|
144
174
|
|----------|------|-------------|
|
|
145
|
-
| `feature` | `GeoJSON.Feature` | The shape
|
|
146
|
-
| `phase` | `string` |
|
|
175
|
+
| `feature` | `GeoJSON.Feature` | The shape being checked — the in-progress feature during `'preview'`, the committed or candidate feature in every other phase |
|
|
176
|
+
| `phase` | `string` | Why the callback was called — see each callback's phases below |
|
|
147
177
|
| `mode` | `'draw_polygon' \| 'draw_line' \| 'draw_point' \| 'edit_vertex' \| 'edit_point'` | The active draw mode |
|
|
148
|
-
| `vertexIndex` | `number` | Index of the vertex being placed
|
|
178
|
+
| `vertexIndex` | `number` | Index of the vertex being placed, added, moved, inserted or deleted. Present on `'place'`, and on a `'change'` to a single vertex |
|
|
149
179
|
| `numVertices` | `number` | Count of already-committed vertices, excluding any in-progress cursor point. Present on every `'preview'` call |
|
|
150
180
|
|
|
151
|
-
|
|
181
|
+
### `onGeometryPreview(event)`
|
|
182
|
+
|
|
183
|
+
**Signature:** `onGeometryPreview(event) => boolean | { valid: boolean, reason?: string, announcement?: string } | undefined`
|
|
184
|
+
|
|
185
|
+
Must return synchronously. A returned Promise is treated as valid.
|
|
186
|
+
|
|
187
|
+
| Phase | When | Effect |
|
|
188
|
+
|-------|------|--------|
|
|
189
|
+
| `'preview'` | Every rubber-band move or drag, throttled to once per frame | Drives the dashed outline and the Add point button. While editing, also gates the Done button |
|
|
190
|
+
| `'place'` | A click, tap, <kbd>Enter</kbd> or Add point press, before the vertex is placed | Invalid rejects the vertex — it never appears |
|
|
191
|
+
|
|
192
|
+
It runs on every frame of a drag, so keep it quick, using only the shape and data already in the page. Rules about a single vertex, such as where the first point may go, belong here: `onGeometryChange` isn't called until the shape has its minimum number of vertices.
|
|
193
|
+
|
|
194
|
+
### `onGeometryChange(event, context)`
|
|
152
195
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
|
158
|
-
|
|
159
|
-
| `'
|
|
160
|
-
| `'
|
|
161
|
-
| `'
|
|
162
|
-
| `'
|
|
196
|
+
**Signature:** `onGeometryChange(event, { signal, revision }) => boolean | { valid: boolean, reason?: string, announcement?: string, recheckOnFinish?: boolean } | undefined | Promise<…>`
|
|
197
|
+
|
|
198
|
+
Called after each change to a shape. It can return a Promise, so you can check the shape with a service.
|
|
199
|
+
|
|
200
|
+
| Phase | When |
|
|
201
|
+
|-------|------|
|
|
202
|
+
| `'change'` | The shape changed, including with [`setGeometry`](#setgeometrygeometry) or undo |
|
|
203
|
+
| `'create'` | A new shape was finished without a passing result, such as a new point, or with [`recheckOnFinish`](#checking-once-a-shape-is-finished) |
|
|
204
|
+
| `'edit-start'` | `editFeature` opened the shape |
|
|
205
|
+
| `'edit-finish'` | Done was pressed on an edit, with [`recheckOnFinish`](#checking-once-a-shape-is-finished) |
|
|
206
|
+
| `'recheck'` | [`recheckGeometry`](#recheckgeometrydetail) was called. Its `detail` is on `event.detail` |
|
|
207
|
+
|
|
208
|
+
| Context property | Type | Description |
|
|
209
|
+
|----------|------|-------------|
|
|
210
|
+
| `signal` | `AbortSignal` | Aborted when the shape changes again or the session ends. Pass it to `fetch` to cancel the request |
|
|
211
|
+
| `revision` | `number` | Increases with every check |
|
|
212
|
+
|
|
213
|
+
- It's only called once the built-in rules pass.
|
|
214
|
+
- Only the result for the latest change counts.
|
|
215
|
+
- A shape that fails, or whose check throws or rejects, can't be finished. Call `recheckGeometry()` to retry.
|
|
216
|
+
- If the user finishes while a check is running, draw waits for it. A new shape that then fails is reopened in edit mode ([`draw:reopened`](#drawreopened)). An edit that fails stays open.
|
|
217
|
+
|
|
218
|
+
### Checking once a shape is finished
|
|
219
|
+
|
|
220
|
+
When a shape is finished, the result for its last change is used. To check the whole shape once at the end instead, such as with a single service call, return `recheckOnFinish: true` for each change. `onGeometryChange` is then called again when the shape is finished, with phase `'create'` for a new shape or `'edit-finish'` when Done is pressed on an edit.
|
|
221
|
+
|
|
222
|
+
This updates a panel on every change, and calls a validation service once, when the shape is finished:
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
createDrawPlugin({
|
|
226
|
+
onGeometryChange: ({ feature, phase }, { signal }) => {
|
|
227
|
+
// Update the panel without waiting for it, so finishing never waits on it.
|
|
228
|
+
// The signal cancels the request if the shape changes again.
|
|
229
|
+
contextPanel.update(feature, { signal })
|
|
230
|
+
|
|
231
|
+
// Let each change through, and check once the shape is finished
|
|
232
|
+
if (phase === 'change' || phase === 'edit-start') {
|
|
233
|
+
return { valid: true, recheckOnFinish: true }
|
|
234
|
+
}
|
|
235
|
+
// 'create', 'edit-finish' and 'recheck' are checked by the service
|
|
236
|
+
return validateWithService(feature, { signal })
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This works with an `async` function too, as long as the panel update isn't awaited. Otherwise draw treats the check as pending until the panel replies.
|
|
242
|
+
|
|
243
|
+
In a reopened shape, Undo starts empty, and Cancel discards the shape, as it does while the shape is waiting on its check.
|
|
244
|
+
|
|
245
|
+
### Debouncing
|
|
246
|
+
|
|
247
|
+
Debouncing and timeouts are up to you. Waiting on `signal` gives a debounce that cancels itself when the shape changes again:
|
|
163
248
|
|
|
164
249
|
```js
|
|
250
|
+
const wait = (ms, signal) => new Promise((resolve, reject) => {
|
|
251
|
+
const timer = setTimeout(resolve, ms)
|
|
252
|
+
signal.addEventListener('abort', () => { clearTimeout(timer); reject(signal.reason) }, { once: true })
|
|
253
|
+
})
|
|
254
|
+
|
|
165
255
|
createDrawPlugin({
|
|
166
|
-
|
|
256
|
+
onGeometryPreview: (event) => ({
|
|
167
257
|
valid: isEastOfWalesBorder(event.feature.geometry),
|
|
168
258
|
reason: 'Points must be placed east of the England/Wales border'
|
|
169
|
-
})
|
|
259
|
+
}),
|
|
260
|
+
onGeometryChange: async ({ feature }, { signal }) => {
|
|
261
|
+
infoPanel.update(measureArea(feature))
|
|
262
|
+
await wait(300, signal)
|
|
263
|
+
const response = await fetch('/api/boundary-checks', { method: 'POST', body: JSON.stringify(feature), signal })
|
|
264
|
+
return response.json() // { valid, reason }
|
|
265
|
+
}
|
|
170
266
|
})
|
|
171
267
|
```
|
|
172
268
|
|
|
173
269
|
## Methods
|
|
174
270
|
|
|
175
|
-
Methods are called on the plugin instance. `newPolygon`, `newLine`, `newPoint`, `editFeature`, `addFeature`, `setStyle`, `deleteFeature`, `split`, and `
|
|
271
|
+
Methods are called on the plugin instance. `newPolygon`, `newLine`, `newPoint`, `editFeature`, `addFeature`, `setStyle`, `deleteFeature`, `split`, `merge`, `setGeometry` and `recheckGeometry` all need `mapProvider.draw` to be ready — call them after [`draw:ready`](#drawready).
|
|
176
272
|
|
|
177
273
|
---
|
|
178
274
|
|
|
@@ -184,7 +280,8 @@ Start drawing a new polygon.
|
|
|
184
280
|
|----------|------|-------------|
|
|
185
281
|
| `featureId` | `string` | **Required.** ID to assign the finished feature |
|
|
186
282
|
| `options.snapLayers` | `string[]` | Overrides the plugin-level `snapLayers` for this session |
|
|
187
|
-
| `options.
|
|
283
|
+
| `options.onGeometryPreview` | `Function` | Replaces the plugin-level `onGeometryPreview` for this session — see [Validation](#validation) |
|
|
284
|
+
| `options.onGeometryChange` | `Function` | Replaces the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
|
|
188
285
|
| `options.stroke` | `string \| Record<string, string>` | Stroke colour for this shape |
|
|
189
286
|
| `options.fill` | `string \| Record<string, string>` | Fill colour for this shape |
|
|
190
287
|
| `options.strokeWidth` | `number` | Stroke width in pixels for this shape |
|
|
@@ -220,7 +317,8 @@ Start drawing a new point. Unlike `newPolygon`/`newLine`, it commits as soon as
|
|
|
220
317
|
|----------|------|-------------|
|
|
221
318
|
| `featureId` | `string` | **Required.** ID to assign the finished feature |
|
|
222
319
|
| `options.snapLayers` | `string[]` | Overrides the plugin-level `snapLayers` for this session |
|
|
223
|
-
| `options.
|
|
320
|
+
| `options.onGeometryPreview` | `Function` | Replaces the plugin-level `onGeometryPreview` for this session — see [Validation](#validation) |
|
|
321
|
+
| `options.onGeometryChange` | `Function` | Replaces the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
|
|
224
322
|
| `options.properties` | `Object` | Custom GeoJSON properties to set on the finished feature |
|
|
225
323
|
| `options.symbol` | `string` | Built-in symbol id — `'pin'`, `'circle'`, `'square'`, `'hexagon'`, `'triangle'`, or `'diamond'` |
|
|
226
324
|
| `options.symbolSvgContent` | `string` | Custom SVG markup, used instead of `symbol` |
|
|
@@ -251,7 +349,8 @@ Open an existing feature in edit mode — vertex-edit for a `Polygon`/`LineStrin
|
|
|
251
349
|
|----------|------|-------------|
|
|
252
350
|
| `featureId` | `string` | **Required.** ID of the feature to edit |
|
|
253
351
|
| `options.snapLayers` | `string[]` | Overrides the plugin-level `snapLayers` for this session |
|
|
254
|
-
| `options.
|
|
352
|
+
| `options.onGeometryPreview` | `Function` | Replaces the plugin-level `onGeometryPreview` for this session — see [Validation](#validation) |
|
|
353
|
+
| `options.onGeometryChange` | `Function` | Replaces the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
|
|
255
354
|
|
|
256
355
|
```js
|
|
257
356
|
const editSuccess = drawPlugin.editFeature(selectedFeatureId)
|
|
@@ -382,6 +481,55 @@ interactiveMap.on('draw:merge', (event) => {
|
|
|
382
481
|
})
|
|
383
482
|
```
|
|
384
483
|
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
### `setGeometry(geometry)`
|
|
487
|
+
|
|
488
|
+
Replace the shape in the current edit session, for example with a corrected boundary from a service. The change can be undone, and is checked like any other change, with phase `'change'`. Returns `false` (without doing anything) outside an edit session, or when the geometry type differs from the shape being edited.
|
|
489
|
+
|
|
490
|
+
| Argument | Type | Description |
|
|
491
|
+
|----------|------|-------------|
|
|
492
|
+
| `geometry` | `GeoJSON.Geometry` | **Required.** The new geometry, of the same type as the shape being edited |
|
|
493
|
+
|
|
494
|
+
```js
|
|
495
|
+
drawPlugin.setGeometry(correctedBoundary)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
### `recheckGeometry(detail?)`
|
|
501
|
+
|
|
502
|
+
Call `onGeometryChange` again for the current shape, unchanged, with phase `'recheck'`. Use it when your answer may have changed without the shape changing — for example after the user chooses to ignore a warning — or to retry a check that failed. Returns `false` (without doing anything) outside a draw or edit session, or before the shape has been checked.
|
|
503
|
+
|
|
504
|
+
| Argument | Type | Description |
|
|
505
|
+
|----------|------|-------------|
|
|
506
|
+
| `detail` | `any` | Passed to `onGeometryChange` as `event.detail`, for example to tell an ignored warning from a retry |
|
|
507
|
+
|
|
508
|
+
```js
|
|
509
|
+
const ignoredWarnings = new Set()
|
|
510
|
+
|
|
511
|
+
let warnings = []
|
|
512
|
+
|
|
513
|
+
createDrawPlugin({
|
|
514
|
+
onGeometryChange: async ({ feature, detail }, { signal }) => {
|
|
515
|
+
// Ignoring a warning reuses the last answer; anything else, including a retry, asks again
|
|
516
|
+
if (detail?.reason !== 'ignore') {
|
|
517
|
+
warnings = await checkBoundary(feature, { signal })
|
|
518
|
+
}
|
|
519
|
+
return { valid: warnings.every((warning) => ignoredWarnings.has(warning.id)) }
|
|
520
|
+
}
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
const onIgnoreWarning = (warning) => {
|
|
524
|
+
ignoredWarnings.add(warning.id)
|
|
525
|
+
drawPlugin.recheckGeometry({ reason: 'ignore' })
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const onRetry = () => drawPlugin.recheckGeometry({ reason: 'retry' })
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
385
533
|
## Application mode
|
|
386
534
|
|
|
387
535
|
While drawing or editing, the plugin sets the `'draw'` [application mode](../api.md#setapplicationmodeid-options), which gives the interface over to drawing: every button, panel and control, in every slot, is hidden except draw's own and these defaults:
|
|
@@ -405,11 +553,17 @@ new InteractiveMap('map', {
|
|
|
405
553
|
Or set `draw: false` when every button on the map is deliberate — for example a single-task map that goes straight into editing a shape — so nothing is hidden.
|
|
406
554
|
|
|
407
555
|
> [!NOTE]
|
|
408
|
-
> The mode only changes the interface. Other plugins' own behaviour keeps running while their buttons are hidden, so disable any that shouldn't respond while drawing
|
|
556
|
+
> The mode only changes the interface. Other plugins' own behaviour keeps running while their buttons are hidden, so disable any that shouldn't respond while drawing.
|
|
557
|
+
|
|
558
|
+
> [!IMPORTANT]
|
|
559
|
+
> If you use the [interact plugin](interact.md), disable it while drawing or editing. Otherwise map clicks select features as well as placing points, and both plugins show and hide the same crosshair. Call `interactPlugin.disable()` on [`draw:started`](#drawstarted) and [`draw:editstart`](#draweditstart), and `interactPlugin.enable()` on [`draw:created`](#drawcreated), [`draw:edited`](#drawedited) and [`draw:cancelled`](#drawcancelled).
|
|
409
560
|
|
|
410
561
|
## Buttons and keyboard shortcuts
|
|
411
562
|
|
|
412
|
-
The plugin registers its own toolbar buttons automatically — Cancel, Add point
|
|
563
|
+
The plugin registers its own toolbar buttons automatically — Cancel, Add point and Done in the actions bar, plus Undo, Snap and Delete point in the middle of the top row — which show and enable themselves based on the current draw/edit state. You don't need to render these yourself; augment them with your own trigger buttons (e.g. "Draw polygon", "Draw line") the way the [Draw tools example](../examples/draw-tools.mdx) does.
|
|
564
|
+
|
|
565
|
+
> [!NOTE]
|
|
566
|
+
> While drawing, a crosshair marks where the next point is placed. On touch, it's shown with the Add point button. Keyboard users get the crosshair and press <kbd>Enter</kbd> to add a point. Opening the map controls shows the crosshair and Add point button for every input type. Edit modes don't use the crosshair: vertices and midpoints are selected directly.
|
|
413
567
|
|
|
414
568
|
| Shortcut | Action |
|
|
415
569
|
|----------|--------|
|
|
@@ -441,7 +595,7 @@ Emitted once the draw plugin has initialised. Safe to call API methods from here
|
|
|
441
595
|
|
|
442
596
|
Emitted when `newPolygon`, `newLine`, or `newPoint` starts a new draw session.
|
|
443
597
|
|
|
444
|
-
**Payload:** `{ mode: 'draw_polygon' | 'draw_line' | 'draw_point' }`
|
|
598
|
+
**Payload:** `{ mode: 'draw_polygon' | 'draw_line' | 'draw_point', featureId: string }`
|
|
445
599
|
|
|
446
600
|
---
|
|
447
601
|
|
|
@@ -449,13 +603,13 @@ Emitted when `newPolygon`, `newLine`, or `newPoint` starts a new draw session.
|
|
|
449
603
|
|
|
450
604
|
Emitted when `editFeature` opens an existing feature for editing.
|
|
451
605
|
|
|
452
|
-
**Payload:** `{ mode: 'edit_polygon' | 'edit_line' | 'edit_point' }`
|
|
606
|
+
**Payload:** `{ mode: 'edit_polygon' | 'edit_line' | 'edit_point', featureId: string }`
|
|
453
607
|
|
|
454
608
|
---
|
|
455
609
|
|
|
456
610
|
### `draw:created`
|
|
457
611
|
|
|
458
|
-
Emitted when a new shape finishes drawing and passes
|
|
612
|
+
Emitted when a new shape finishes drawing and passes its checks. Also fires for a shape that finished invalid, was automatically reopened in edit mode, and was then fixed and finished — from the caller's perspective it's still a creation, not an edit.
|
|
459
613
|
|
|
460
614
|
**Payload:** the finished `GeoJSON.Feature`
|
|
461
615
|
|
|
@@ -469,9 +623,17 @@ Emitted when an existing feature finishes an edit session (via `editFeature`).
|
|
|
469
623
|
|
|
470
624
|
---
|
|
471
625
|
|
|
626
|
+
### `draw:reopened`
|
|
627
|
+
|
|
628
|
+
Emitted when a new shape is finished, its `onGeometryChange` check fails, and it reopens in edit mode. See [Validation](#validation).
|
|
629
|
+
|
|
630
|
+
**Payload:** `{ feature, status: 'invalid' | 'error', reason }` — `reason` is `null` unless an invalid result gave one
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
472
634
|
### `draw:cancelled`
|
|
473
635
|
|
|
474
|
-
Emitted when the Cancel button is pressed during a draw or edit session.
|
|
636
|
+
Emitted when the Cancel button is pressed during a draw or edit session. Cancelling a new shape that's waiting on its check, or has reopened in edit mode, removes it from the map. Also emitted when a new session starts while a finished shape is still waiting on its check, which discards it.
|
|
475
637
|
|
|
476
638
|
**Payload:** the feature being drawn/edited at the time of cancellation
|
|
477
639
|
|
|
@@ -503,9 +665,9 @@ Emitted when the input device changes mid-session (e.g. switching from mouse to
|
|
|
503
665
|
|
|
504
666
|
### `draw:geometryinvalid`
|
|
505
667
|
|
|
506
|
-
Emitted whenever a
|
|
668
|
+
Emitted whenever a check — a built-in rule, a placement rejected by `onGeometryPreview`, or an invalid result from `onGeometryChange` for the latest change — fails. Not emitted for the `'edit-start'` check of a feature that was already invalid. The `reason` is also shown as a hint toast, unless the result has its own `announcement`, or the shape simply hasn't reached its minimum vertex count yet. See [Validation](#validation).
|
|
507
669
|
|
|
508
|
-
**Payload:** `{ feature, reason, phase, mode, vertexIndex? }`
|
|
670
|
+
**Payload:** `{ feature, reason, source, phase, mode, vertexIndex? }` — `source` is `'rules'` for a built-in rule and `'callback'` for `onGeometryPreview` or `onGeometryChange`
|
|
509
671
|
|
|
510
672
|
---
|
|
511
673
|
|
package/docs/plugins/interact.md
CHANGED
|
@@ -37,7 +37,9 @@ Controls which interactions are active when the user clicks the map. Values can
|
|
|
37
37
|
- `'placeMarker'` — if no feature is matched (or `selectFeature` is not active), places a location marker at the clicked coordinates
|
|
38
38
|
|
|
39
39
|
> [!NOTE]
|
|
40
|
-
> On touch
|
|
40
|
+
> On touch, a crosshair and "Select" action button are shown when `'placeMarker'` or `'selectFeature'` is included — modes where a precise point on the map needs to be chosen. When `'selectMarker'` is the only active mode, touch users tap markers directly and neither is shown. [`touchTarget`](#touchtarget) turns them off for touch in every mode.
|
|
41
|
+
>
|
|
42
|
+
> Keyboard users get the crosshair while the map has focus, and press <kbd>Enter</kbd> to select. Opening the map controls shows the crosshair and "Select" button for every input type.
|
|
41
43
|
|
|
42
44
|
**Common combinations:**
|
|
43
45
|
|
|
@@ -113,6 +115,27 @@ Click detection radius in pixels applied to line features. Lines have a 1px rend
|
|
|
113
115
|
|
|
114
116
|
---
|
|
115
117
|
|
|
118
|
+
### `touchTarget`
|
|
119
|
+
**Type:** `boolean`
|
|
120
|
+
**Default:** `true`
|
|
121
|
+
|
|
122
|
+
When `false`, touch users don't get the crosshair and "Select" button, and tap features directly instead. Opening the map controls shows both again, for every input type. Keyboard behaviour is unchanged.
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
createInteractPlugin({
|
|
126
|
+
interactionModes: ['selectFeature'],
|
|
127
|
+
touchTarget: false
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> [!IMPORTANT]
|
|
132
|
+
> Only set `touchTarget: false` when the features users select are at least 44×44 CSS pixels at the zoom levels they use ([WCAG 2.2 Target Size (Enhanced)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced)), for example field parcels at a sensible zoom. Thin lines and small shapes are hard to tap accurately, especially for users with motor impairments, who rely on the crosshair to position the map instead.
|
|
133
|
+
|
|
134
|
+
> [!NOTE]
|
|
135
|
+
> If you also use the [draw plugin](draw.md), disable interact while drawing or editing, so the two plugins don't both control the crosshair. See [Application mode](draw.md#application-mode).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
116
139
|
### `closeOnAction`
|
|
117
140
|
**Type:** `boolean`
|
|
118
141
|
**Default:** `true`
|
package/docs/plugins/search.md
CHANGED
|
@@ -205,7 +205,7 @@ Custom datasets let you add your own search sources alongside or instead of OS N
|
|
|
205
205
|
const gridRefDataset = {
|
|
206
206
|
name: 'gridref',
|
|
207
207
|
includeRegex: /^[A-Z]{2}\d{6,10}$/i,
|
|
208
|
-
buildRequest: (query) => `https://api.example.com/gridref?q=${query}`,
|
|
208
|
+
buildRequest: (query) => `https://api.example.com/gridref?q=${encodeURIComponent(query)}`,
|
|
209
209
|
parseResults: (json, query) => [{
|
|
210
210
|
id: query,
|
|
211
211
|
text: query,
|
|
@@ -272,7 +272,7 @@ Each suggestion object must have:
|
|
|
272
272
|
|----------|------|-------------|
|
|
273
273
|
| `id` | `string` | Unique identifier for the suggestion |
|
|
274
274
|
| `text` | `string` | Display text shown in the autocomplete list |
|
|
275
|
-
| `marked` | `string` | Optional.
|
|
275
|
+
| `marked` | `string` | Optional. Label text with query terms wrapped in `<mark>` tags. Any other markup is shown as text, not rendered as HTML. If omitted, the suggestion label will be blank |
|
|
276
276
|
| `point` | `[x, y]` | Centre coordinate for placing a marker |
|
|
277
277
|
| `bounds` | `[minX, minY, maxX, maxY]` | Bounding box to fit the map to when selected |
|
|
278
278
|
| `type` | `string` | Optional. Value to include in the `search:match` payload to identify the source dataset |
|
package/docusaurus.config.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
const path = require('path');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { getBabelOptions } = require('@docusaurus/babel');
|
|
3
4
|
require('dotenv').config({ path: path.join(__dirname, '.env'), quiet: true });
|
|
4
5
|
|
|
5
6
|
/** @type {import('@docusaurus/types').Config} */
|
|
@@ -31,8 +32,29 @@ const config = {
|
|
|
31
32
|
|
|
32
33
|
presets: [],
|
|
33
34
|
|
|
35
|
+
// Docusaurus compiles the map's source with loose Babel, which assumes every iterable
|
|
36
|
+
// is an array: [...map.values()] becomes [].concat(map.values()), an array holding the
|
|
37
|
+
// iterator rather than its values. Turning off that one assumption spreads iterables
|
|
38
|
+
// properly and keeps the rest of the Docusaurus Babel setup.
|
|
39
|
+
//
|
|
40
|
+
// It's limited to the map's own source because Docusaurus also compiles its own
|
|
41
|
+
// CommonJS packages, where the helper imports this adds break their `exports`.
|
|
42
|
+
webpack: {
|
|
43
|
+
jsLoader: (isServer) => ({
|
|
44
|
+
loader: require.resolve('babel-loader'),
|
|
45
|
+
options: {
|
|
46
|
+
...getBabelOptions({ isServer }),
|
|
47
|
+
overrides: [{
|
|
48
|
+
include: ['src', 'plugins', 'providers'].map((dir) => path.join(__dirname, dir)),
|
|
49
|
+
assumptions: { iterableIsArray: false },
|
|
50
|
+
}],
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
|
|
34
55
|
themes: [
|
|
35
|
-
|
|
56
|
+
/** @type {import('@docusaurus/types').PluginConfig} */
|
|
57
|
+
([
|
|
36
58
|
require.resolve('@easyops-cn/docusaurus-search-local'),
|
|
37
59
|
/** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
|
|
38
60
|
({
|
|
@@ -45,7 +67,7 @@ const config = {
|
|
|
45
67
|
highlightSearchTermsOnTargetPage: true,
|
|
46
68
|
searchResultContextMaxLength: 60,
|
|
47
69
|
}),
|
|
48
|
-
],
|
|
70
|
+
]),
|
|
49
71
|
'@defra/docusaurus-theme-govuk',
|
|
50
72
|
],
|
|
51
73
|
|
|
@@ -64,15 +64,14 @@
|
|
|
64
64
|
"/plugins/interact/dist",
|
|
65
65
|
"/plugins/search/dist",
|
|
66
66
|
"/plugins/draw/dist",
|
|
67
|
-
"/providers/
|
|
68
|
-
"/providers/
|
|
67
|
+
"/providers/open-names/dist",
|
|
68
|
+
"/providers/openlayers/dist",
|
|
69
69
|
"/plugins/datasets/dist",
|
|
70
70
|
"/plugins/map-key/dist",
|
|
71
71
|
"/plugins/menu/dist",
|
|
72
|
-
"/plugins/
|
|
73
|
-
"/plugins/
|
|
74
|
-
"/plugins/
|
|
75
|
-
"/plugins/
|
|
76
|
-
"/plugins/beta/frame/dist"
|
|
72
|
+
"/plugins/map-styles/dist",
|
|
73
|
+
"/plugins/scale-bar/dist",
|
|
74
|
+
"/plugins/use-location/dist",
|
|
75
|
+
"/plugins/frame/dist"
|
|
77
76
|
]
|
|
78
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra/interactive-map",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57-alpha",
|
|
4
4
|
"description": "An accessible map component",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
"require": "./providers/maplibre/dist/umd/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./providers/open-names": {
|
|
21
|
-
"import": "./providers/
|
|
22
|
-
"require": "./providers/
|
|
21
|
+
"import": "./providers/open-names/dist/esm/index.js",
|
|
22
|
+
"require": "./providers/open-names/dist/umd/index.js"
|
|
23
23
|
},
|
|
24
24
|
"./providers/esri": {
|
|
25
|
-
"import": "./providers/
|
|
25
|
+
"import": "./providers/esri/dist/esm/index.js"
|
|
26
26
|
},
|
|
27
27
|
"./providers/openlayers": {
|
|
28
|
-
"import": "./providers/
|
|
29
|
-
"require": "./providers/
|
|
28
|
+
"import": "./providers/openlayers/dist/esm/index.js",
|
|
29
|
+
"require": "./providers/openlayers/dist/umd/index.js"
|
|
30
30
|
},
|
|
31
31
|
"./plugins/scale-bar": {
|
|
32
|
-
"import": "./plugins/
|
|
33
|
-
"require": "./plugins/
|
|
32
|
+
"import": "./plugins/scale-bar/dist/esm/index.js",
|
|
33
|
+
"require": "./plugins/scale-bar/dist/umd/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./plugins/use-location": {
|
|
36
|
-
"import": "./plugins/
|
|
37
|
-
"require": "./plugins/
|
|
36
|
+
"import": "./plugins/use-location/dist/esm/index.js",
|
|
37
|
+
"require": "./plugins/use-location/dist/umd/index.js"
|
|
38
38
|
},
|
|
39
39
|
"./plugins/search": {
|
|
40
40
|
"import": "./plugins/search/dist/esm/index.js",
|
|
@@ -54,34 +54,30 @@
|
|
|
54
54
|
"import": "./plugins/map-key/dist/esm/index.js"
|
|
55
55
|
},
|
|
56
56
|
"./plugins/map-styles": {
|
|
57
|
-
"import": "./plugins/
|
|
58
|
-
"require": "./plugins/
|
|
59
|
-
},
|
|
60
|
-
"./plugins/draw-ml": {
|
|
61
|
-
"import": "./plugins/beta/draw-ml/dist/esm/index.js",
|
|
62
|
-
"require": "./plugins/beta/draw-ml/dist/umd/index.js"
|
|
57
|
+
"import": "./plugins/map-styles/dist/esm/index.js",
|
|
58
|
+
"require": "./plugins/map-styles/dist/umd/index.js"
|
|
63
59
|
},
|
|
64
60
|
"./plugins/draw-es": {
|
|
65
|
-
"import": "./plugins/
|
|
61
|
+
"import": "./plugins/draw-es/dist/esm/index.js"
|
|
66
62
|
},
|
|
67
63
|
"./plugins/draw": {
|
|
68
64
|
"import": "./plugins/draw/dist/esm/index.js",
|
|
69
65
|
"require": "./plugins/draw/dist/umd/index.js"
|
|
70
66
|
},
|
|
71
67
|
"./plugins/frame": {
|
|
72
|
-
"import": "./plugins/
|
|
73
|
-
"require": "./plugins/
|
|
68
|
+
"import": "./plugins/frame/dist/esm/index.js",
|
|
69
|
+
"require": "./plugins/frame/dist/umd/index.js"
|
|
74
70
|
},
|
|
75
71
|
"./css": "./dist/css/index.css",
|
|
76
72
|
"./plugins/draw/css": "./plugins/draw/dist/css/index.css",
|
|
77
|
-
"./plugins/scale-bar/css": "./plugins/
|
|
73
|
+
"./plugins/scale-bar/css": "./plugins/scale-bar/dist/css/index.css",
|
|
78
74
|
"./plugins/datasets/css": "./plugins/datasets/dist/css/index.css",
|
|
79
75
|
"./plugins/menu/css": "./plugins/menu/dist/css/index.css",
|
|
80
76
|
"./plugins/map-key/css": "./plugins/map-key/dist/css/index.css",
|
|
81
|
-
"./plugins/frame/css": "./plugins/
|
|
82
|
-
"./plugins/map-styles/css": "./plugins/
|
|
77
|
+
"./plugins/frame/css": "./plugins/frame/dist/css/index.css",
|
|
78
|
+
"./plugins/map-styles/css": "./plugins/map-styles/dist/css/index.css",
|
|
83
79
|
"./plugins/search/css": "./plugins/search/dist/css/index.css",
|
|
84
|
-
"./providers/esri/css": "./providers/
|
|
80
|
+
"./providers/esri/css": "./providers/esri/dist/css/index.css"
|
|
85
81
|
},
|
|
86
82
|
"type": "module",
|
|
87
83
|
"sideEffects": [
|
|
@@ -150,6 +146,7 @@
|
|
|
150
146
|
"@babel/preset-env": "^7.28.0",
|
|
151
147
|
"@babel/preset-react": "^7.27.1",
|
|
152
148
|
"@defra/docusaurus-theme-govuk": "^0.0.22-alpha",
|
|
149
|
+
"@docusaurus/babel": "^3.10.1",
|
|
153
150
|
"@docusaurus/core": "^3.10.1",
|
|
154
151
|
"@docusaurus/module-type-aliases": "^3.10.1",
|
|
155
152
|
"@docusaurus/plugin-content-docs": "^3.10.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"@arcgis/core/layers/VectorTileLayer.js";import e from"@arcgis/core/layers/FeatureLayer.js";import i from"@arcgis/core/layers/GroupLayer.js";import{g as s,L as a}from"./layerAdapter.js";import{D as r,l as y}from"./im-datasets-plugin.js";import"preact/compat";import"preact/jsx-runtime";class o extends r{applyLayerPaintProperties(t){const{mapStyle:e}=this._datasetRegistry;return this.hasStroke&&(t["line-color"]=s(this.style.stroke,e.id)),this.hasFill&&(t["fill-color"]=s(this.style.fill,e.id)),t}get esriGroupId(){return void 0===this._datasetDefinition.esriGroupId?this.parent?.esriGroupId:this._datasetDefinition.esriGroupId}get useServerStyle(){return Boolean(this._datasetDefinition.esriUseServerStyle)}get renderer(){if("FeatureService"!==this.type)return;const t=this._datasetDefinition.style?.renderer||this.parent?.renderer;if(!t)return;const{mapStyle:e}=this._datasetRegistry,i=structuredClone(t);return i.symbol?.color&&(i.symbol.color=s(i.symbol.color,e.id)),i.symbol?.outline?.color&&(i.symbol.outline.color=s(i.symbol.outline.color,e.id)),i}}const l=(t,e)=>{if("baseLayer"===t.id)return-1/0;if(t.id.includes("ketchLayer"))return 1/0;const i="group"===t.type?t.layers?.items?.[0]?.id:t.id;return e.indexOf(i)};class p extends a{constructor(t,e,i,s){super(),this._datasetRegistry=s,this.ready=new Promise(t=>{this.resolveReady=t}),this._mapProvider=t,this._map=t.map,this._mapVisibilityLayers={},this._mapOpacityLayers={},this._groupLayers={}}createDataset(t,e){return new o(t,e)}async init(){const t=this._datasetRegistry.topLevelDatasets(),e=async t=>this._addLayers(t).then(()=>{const e=this._mapVisibilityLayers[t.id];t.sublayers?.forEach(t=>{"visible"===t.visibility&&this._applyStyleLayerPaintProperties(t,e)}),this.applyDatasetVisibility(t.id)});for(const i of t)"visible"===i.visibility&&await e(i);this._reorderLayers();for(const i of t)"visible"!==i.visibility&&await e(i);await this.onMapStyleChange(),await this.applyGlobalOpacity(),await Promise.all(t.map(t=>this.applyDatasetVisibility(t.id))),this._reorderLayers(),this.resolveReady()}_reorderLayers(){const t=this._map?.allLayers?.items;if(!t?.length)return;const e=this._datasetRegistry._orderedDatasets;[...t.filter(t=>"group"!==t.parent?.type)].sort((t,i)=>l(t,e)-l(i,e)).forEach((t,e)=>this._map.reorder(t,e)),this._reorderGroupLayers()}_reorderGroupLayers(){const t=this._datasetRegistry._orderedDatasets;Object.values(this._groupLayers).forEach(e=>{[...e?.allLayers?.items||[]].filter(Boolean).sort((e,i)=>l(e,t)-l(i,t)).forEach((t,i)=>e?.reorder?.(t,i))})}_addGroupLayer(t){if(!this._groupLayers[t]){const e=new i({id:t,opacity:1,visible:!0});this._groupLayers[t]=e,this._map.add(e)}return this._groupLayers[t]}async _addFeatureLayers(t){const i=new e({id:t.id,url:t.tiles,renderer:t.renderer,opacity:1,visible:!1});this._mapVisibilityLayers[t.id]=i,this._mapOpacityLayers[t.id]=i;try{return this._map.add(i),i.when()}catch(e){y.error(`Error adding FeatureLayer for dataset ${t.id}:`,e)}return null}async _addLayers(e){const{type:i,esriGroupId:s,tiles:a}=e;if(!a)return null;if("FeatureService"===i)return this._addFeatureLayers(e);const r=s?this._addGroupLayer(s):this._map,y=new t({id:e.id,url:e.tiles,opacity:1,visible:!1});return this._mapVisibilityLayers[e.id]=y,this._mapOpacityLayers[e.id]=s?r:y,r.add(y),y.when()}async addDataset(t){const e=this._datasetRegistry.getDataset(t);if(!e)return void y.warn(`addDataset called, but Dataset with id ${t} not found in registry`);await this._addLayers(e);const{parentId:i}=e,s=this._mapVisibilityLayers[i||t];this._reorderLayers(),this.applyDatasetOpacity(t),this._applyStyleLayerPaintProperties(e,s),this.applyDatasetVisibility(t)}async removeDataset(t){const e=this._datasetRegistry.getDataset(t);if(!e)return;const{esriGroupId:i}=e,s=this._mapVisibilityLayers[t],a=i?this._groupLayers[i]:null,r=a||this._map;s&&(r.remove(s),delete this._mapVisibilityLayers[t],delete this._mapOpacityLayers[t]),0===a?.layers.length&&(this._map.remove(a),delete this._groupLayers[i])}_applyRegistryDatasetVisibility(t){const{id:e,isSublayer:i,parentId:s}=t,a="visible"===t.visibility,r=this._mapVisibilityLayers[i?s:e];r&&(i?this._applyStyleLayerVisibility(t,r):(a&&t.sublayers.forEach(t=>this._applyStyleLayerVisibility(t,r)),r.visible=a))}async applyDatasetVisibility(t){const e=this._datasetRegistry.getDataset(t);e&&this._applyRegistryDatasetVisibility(e)}async applyGlobalVisibility(){this._datasetRegistry.forEachDataset(t=>this._applyRegistryDatasetVisibility(t))}async applyDatasetOpacity(t){const e=this._mapOpacityLayers[t],i=this._datasetRegistry.getDataset(t);e&&i&&(e.opacity=i.opacity)}async applyGlobalOpacity(){Object.entries(this._mapOpacityLayers).forEach(([t,e])=>{const i=this._datasetRegistry.getDataset(t);i&&(e.opacity=i.opacity)})}_applyStyleLayerVisibility(t,e){const{esriStyleLayerId:i}=t;i&&e&&this.ready.then(()=>{e.setStyleLayerVisibility(i,t.visibility)})}_applyStyleLayerPaintProperties(t,e){const{esriStyleLayerId:i,useServerStyle:s}=t;if(s||!i||!e)return;const a=e.getPaintProperties(i);a&&e.setPaintProperties(i,t.applyLayerPaintProperties(a))}async onMapStyleChange(){this._datasetRegistry.forEach(t=>{const{id:e,isSublayer:i,parent:s}=t,a=this._mapVisibilityLayers[i?s.id:e];a&&("FeatureService"===t.type?a.renderer=t.renderer:(this._applyStyleLayerVisibility(t,a),this._applyStyleLayerPaintProperties(t,a)))})}async onMapSizeChange(){}async applyFeatureFilter(...t){console.log("TODO: applyFeatureFilter",t)}async setData(...t){console.log("TODO: setData",t)}async applyStyle(...t){console.log("TODO: applyStyle",t)}}export{p as default};
|