@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
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { clearSnapState, getSnapInstance } from './snapHelpers.js'
|
|
2
|
-
|
|
3
|
-
export function attachEvents ({ appState, appConfig, mapState, pluginState, mapProvider, buttonConfig, eventBus }) {
|
|
4
|
-
const {
|
|
5
|
-
drawDone,
|
|
6
|
-
drawAddPoint,
|
|
7
|
-
drawUndo,
|
|
8
|
-
drawFinish,
|
|
9
|
-
drawDeletePoint,
|
|
10
|
-
drawSnap,
|
|
11
|
-
drawCancel
|
|
12
|
-
} = buttonConfig
|
|
13
|
-
|
|
14
|
-
const { map, draw } = mapProvider
|
|
15
|
-
const { dispatch, feature, tempFeature } = pluginState
|
|
16
|
-
|
|
17
|
-
// --- Done
|
|
18
|
-
const handleDone = () => {
|
|
19
|
-
draw.changeMode('disabled')
|
|
20
|
-
dispatch({ type: 'SET_MODE', payload: null })
|
|
21
|
-
dispatch({ type: 'SET_FEATURE', payload: { feature: null, tempFeature: null }})
|
|
22
|
-
eventBus.emit('draw:done', { newFeature: tempFeature })
|
|
23
|
-
}
|
|
24
|
-
drawDone.onClick = handleDone
|
|
25
|
-
|
|
26
|
-
// --- Cancel
|
|
27
|
-
const handleCancel = () => {
|
|
28
|
-
draw.delete(tempFeature.id)
|
|
29
|
-
|
|
30
|
-
// Reinstate initial feature
|
|
31
|
-
if (feature) {
|
|
32
|
-
draw.add(feature)
|
|
33
|
-
}
|
|
34
|
-
draw.changeMode('disabled')
|
|
35
|
-
|
|
36
|
-
dispatch({ type: 'SET_MODE', payload: null })
|
|
37
|
-
dispatch({ type: 'SET_FEATURE', payload: { feature: null, tempFeature: null }})
|
|
38
|
-
eventBus.emit('draw:cancel', { originalFeature: feature })
|
|
39
|
-
}
|
|
40
|
-
drawCancel.onClick = handleCancel
|
|
41
|
-
|
|
42
|
-
// --- Snap toggle with throttle to prevent Safari slowdown
|
|
43
|
-
let lastToggleTime = 0
|
|
44
|
-
const THROTTLE_MS = 300
|
|
45
|
-
|
|
46
|
-
const handleSnap = () => {
|
|
47
|
-
// Strict throttle - ignore clicks within throttle window
|
|
48
|
-
const now = Date.now()
|
|
49
|
-
if (now - lastToggleTime < THROTTLE_MS) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
lastToggleTime = now
|
|
53
|
-
|
|
54
|
-
const newSnapState = !pluginState.snap
|
|
55
|
-
dispatch({ type: 'TOGGLE_SNAP' })
|
|
56
|
-
mapProvider.snapEnabled = newSnapState
|
|
57
|
-
|
|
58
|
-
const snap = getSnapInstance(map)
|
|
59
|
-
if (snap?.setSnapStatus) {
|
|
60
|
-
snap.setSnapStatus(newSnapState)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Clear all snap state when disabling - prevents accumulation
|
|
64
|
-
if (!newSnapState && snap) {
|
|
65
|
-
clearSnapState(snap)
|
|
66
|
-
// Hide indicator immediately when disabling (single call, not in RAF)
|
|
67
|
-
if (map.getLayer('snap-helper-circle')) {
|
|
68
|
-
map.setLayoutProperty('snap-helper-circle', 'visibility', 'none')
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// When enabling, the indicator will show automatically via setMapData patch
|
|
72
|
-
}
|
|
73
|
-
drawSnap.onClick = handleSnap
|
|
74
|
-
|
|
75
|
-
// --- Map style change
|
|
76
|
-
const handleStyleData = () => {
|
|
77
|
-
const layers = map.getStyle().layers || []
|
|
78
|
-
if (layers.length === 0 || layers[layers.length - 1].source?.startsWith('mapbox-gl-draw')) {
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
layers.filter(l => l.source?.startsWith('mapbox-gl-draw')).forEach(l => map.moveLayer(l.id))
|
|
82
|
-
}
|
|
83
|
-
map.on('styledata', () => handleStyleData())
|
|
84
|
-
|
|
85
|
-
// --- A new shape is created
|
|
86
|
-
const onCreate = (e) => {
|
|
87
|
-
const newFeature = e.features[0]
|
|
88
|
-
dispatch({ type: 'SET_FEATURE', payload: { tempFeature: newFeature }})
|
|
89
|
-
eventBus.emit('draw:create', e)
|
|
90
|
-
|
|
91
|
-
// Switch straight to edit vertex mode
|
|
92
|
-
dispatch({ type: 'SET_MODE', payload: 'edit_vertex'})
|
|
93
|
-
|
|
94
|
-
setTimeout(() => {
|
|
95
|
-
draw.changeMode('edit_vertex', {
|
|
96
|
-
container: appState.layoutRefs.viewportRef.current,
|
|
97
|
-
deleteVertexButtonId: `${appConfig.id}-draw-delete-point`,
|
|
98
|
-
isPanEnabled: appState.interfaceType !== 'keyboard',
|
|
99
|
-
interfaceType: appState.interfaceType,
|
|
100
|
-
scale: { small: 1, medium: 1.5, large: 2 }[mapState.mapSize],
|
|
101
|
-
featureId: newFeature.id,
|
|
102
|
-
getSnapEnabled: () => mapProvider.snapEnabled === true
|
|
103
|
-
})
|
|
104
|
-
}, 0)
|
|
105
|
-
}
|
|
106
|
-
map.on('draw.create', onCreate)
|
|
107
|
-
|
|
108
|
-
// --- A vertex is selected
|
|
109
|
-
const onVertexSelection = (e) => {
|
|
110
|
-
dispatch({ type: 'SET_SELECTED_VERTEX_INDEX', payload: e })
|
|
111
|
-
eventBus.emit('draw:vertexselection', e)
|
|
112
|
-
}
|
|
113
|
-
map.on('draw.vertexselection', onVertexSelection)
|
|
114
|
-
|
|
115
|
-
return () => {
|
|
116
|
-
drawDone.onClick = null
|
|
117
|
-
drawAddPoint.onClick = null
|
|
118
|
-
drawUndo.onClick = null
|
|
119
|
-
drawFinish.onClick = null
|
|
120
|
-
drawDeletePoint.onClick = null
|
|
121
|
-
drawSnap.onClick = null
|
|
122
|
-
drawCancel.onClick = null
|
|
123
|
-
map.off('styledata', handleStyleData)
|
|
124
|
-
map.off('draw.create', onCreate)
|
|
125
|
-
map.off('draw.vertexselection', onVertexSelection)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// /plugins/draw-ml/manifest.js
|
|
2
|
-
import { initialState, actions } from './reducer.js'
|
|
3
|
-
import { DrawInit } from './DrawInit.jsx'
|
|
4
|
-
import { newPolygon } from './api/newPolygon.js'
|
|
5
|
-
import { editFeature } from './api/editFeature.js'
|
|
6
|
-
import { addFeature } from './api/addFeature.js'
|
|
7
|
-
import { deleteFeature } from './api/deleteFeature.js'
|
|
8
|
-
|
|
9
|
-
const createButtonSlots = (showLabel) => ({
|
|
10
|
-
mobile: { slot: 'actions', showLabel },
|
|
11
|
-
tablet: { slot: 'actions', showLabel },
|
|
12
|
-
desktop: { slot: 'actions', showLabel }
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const manifest = {
|
|
16
|
-
reducer: {
|
|
17
|
-
initialState,
|
|
18
|
-
actions
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
InitComponent: DrawInit,
|
|
22
|
-
|
|
23
|
-
buttons: [{
|
|
24
|
-
id: 'drawDone',
|
|
25
|
-
label: 'Done',
|
|
26
|
-
variant: 'primary',
|
|
27
|
-
hiddenWhen: ({ appState, pluginState }) => !pluginState.mode || appState.interfaceType !== 'mouse' && pluginState.mode !== 'edit_vertex',
|
|
28
|
-
enableWhen: ({ pluginState }) => !!pluginState.tempFeature,
|
|
29
|
-
...createButtonSlots(true)
|
|
30
|
-
},{
|
|
31
|
-
id: 'drawAddPoint',
|
|
32
|
-
label: 'Add point',
|
|
33
|
-
variant: 'primary',
|
|
34
|
-
hiddenWhen: ({ appState, pluginState }) => pluginState.mode !== 'draw_vertex' || appState.interfaceType === 'mouse',
|
|
35
|
-
...createButtonSlots(true)
|
|
36
|
-
},{
|
|
37
|
-
id: 'drawUndo',
|
|
38
|
-
label: 'Undo',
|
|
39
|
-
iconId: 'undo',
|
|
40
|
-
variant: 'tertiary',
|
|
41
|
-
hiddenWhen: ({ pluginState }) => !pluginState.mode,
|
|
42
|
-
enableWhen: ({ pluginState }) => false,
|
|
43
|
-
...createButtonSlots(false)
|
|
44
|
-
},{
|
|
45
|
-
id: 'drawFinish',
|
|
46
|
-
label: 'Finish shape',
|
|
47
|
-
iconId: 'check',
|
|
48
|
-
variant: 'tertiary',
|
|
49
|
-
hiddenWhen: ({ pluginState }) => pluginState.mode !== 'draw_vertex',
|
|
50
|
-
enableWhen: ({ pluginState }) => pluginState.numVertecies > 3,
|
|
51
|
-
...createButtonSlots(false)
|
|
52
|
-
},{
|
|
53
|
-
id: 'drawDeletePoint',
|
|
54
|
-
label: 'Delete point',
|
|
55
|
-
iconId: 'close',
|
|
56
|
-
variant: 'tertiary',
|
|
57
|
-
enableWhen: ({ pluginState }) => pluginState.selectedVertexIndex >= 0 && pluginState.numVertecies > 3,
|
|
58
|
-
hiddenWhen: ({ pluginState }) => !(['simple_select', 'edit_vertex'].includes(pluginState.mode)),
|
|
59
|
-
...createButtonSlots(false)
|
|
60
|
-
},{
|
|
61
|
-
id: 'drawSnap',
|
|
62
|
-
label: 'Snap to line',
|
|
63
|
-
iconId: 'magnet',
|
|
64
|
-
variant: 'tertiary',
|
|
65
|
-
hiddenWhen: ({ pluginState }) => !pluginState.mode || !pluginState.hasSnapLayers,
|
|
66
|
-
pressedWhen: ({ pluginState }) => !!pluginState.snap,
|
|
67
|
-
...createButtonSlots(false)
|
|
68
|
-
},{
|
|
69
|
-
id: 'drawCancel',
|
|
70
|
-
label: 'Cancel',
|
|
71
|
-
variant: 'tertiary',
|
|
72
|
-
hiddenWhen: ({ pluginState }) => !pluginState.mode,
|
|
73
|
-
...createButtonSlots(true)
|
|
74
|
-
}],
|
|
75
|
-
|
|
76
|
-
keyboardShortcuts: [{
|
|
77
|
-
id: 'drawStart',
|
|
78
|
-
group: 'Drawing',
|
|
79
|
-
title: 'Edit vertex',
|
|
80
|
-
command: '<kbd>Spacebar</kbd></dd>'
|
|
81
|
-
}],
|
|
82
|
-
|
|
83
|
-
icons: [{
|
|
84
|
-
id: 'check',
|
|
85
|
-
svgContent: '<path d="M20 6 9 17l-5-5"/>'
|
|
86
|
-
},{
|
|
87
|
-
id: 'undo',
|
|
88
|
-
svgContent: '<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>'
|
|
89
|
-
},{
|
|
90
|
-
id: 'magnet',
|
|
91
|
-
svgContent: '<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'
|
|
92
|
-
}],
|
|
93
|
-
|
|
94
|
-
api: {
|
|
95
|
-
newPolygon,
|
|
96
|
-
editFeature,
|
|
97
|
-
addFeature,
|
|
98
|
-
deleteFeature
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import DrawPolygon from '../../../../node_modules/@mapbox/mapbox-gl-draw/src/modes/draw_polygon.js'
|
|
2
|
-
import createVertex from '../../../../node_modules/@mapbox/mapbox-gl-draw/src/lib/create_vertex.js'
|
|
3
|
-
import { isValidClick } from '../utils.js'
|
|
4
|
-
import {
|
|
5
|
-
getSnapInstance,
|
|
6
|
-
isSnapActive,
|
|
7
|
-
isSnapEnabled,
|
|
8
|
-
getSnapLngLat,
|
|
9
|
-
triggerSnapAtPoint,
|
|
10
|
-
triggerSnapAtCenter,
|
|
11
|
-
createSnappedEvent,
|
|
12
|
-
createSnappedClickEvent
|
|
13
|
-
} from '../snapHelpers.js'
|
|
14
|
-
|
|
15
|
-
export const DrawVertexMode = {
|
|
16
|
-
...DrawPolygon,
|
|
17
|
-
|
|
18
|
-
onSetup(options) {
|
|
19
|
-
const { map } = this
|
|
20
|
-
|
|
21
|
-
const state = {
|
|
22
|
-
...DrawPolygon.onSetup.call(this, options),
|
|
23
|
-
...options
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const { container, interfaceType, vertexMarkerId } = state
|
|
27
|
-
const vertexMarker = container.querySelector(`#${vertexMarkerId}`)
|
|
28
|
-
vertexMarker.style.display = ['touch', 'keyboard'].includes(interfaceType) ? 'block' : 'none'
|
|
29
|
-
state.vertexMarker = vertexMarker
|
|
30
|
-
|
|
31
|
-
// Bind all handlers once
|
|
32
|
-
const bind = (name, fn) => (this[name] = fn.bind(this, state))
|
|
33
|
-
const handlers = {
|
|
34
|
-
keydownHandler: this.onKeydown,
|
|
35
|
-
keyupHandler: this.onKeyup,
|
|
36
|
-
focusHandler: this.onFocus,
|
|
37
|
-
blurHandler: this.onBlur,
|
|
38
|
-
createHandler: this.onCreate,
|
|
39
|
-
moveHandler: this.onMove,
|
|
40
|
-
pointerdownHandler: this.onPointerdown,
|
|
41
|
-
pointermoveHandler: this.onPointermove,
|
|
42
|
-
pointerupHandler: this.onPointerup,
|
|
43
|
-
vertexButtonClickHandler: this.onVertexButtonClick
|
|
44
|
-
}
|
|
45
|
-
Object.entries(handlers).forEach(([k, fn]) => bind(k, fn))
|
|
46
|
-
|
|
47
|
-
// Register events
|
|
48
|
-
this._listeners = [
|
|
49
|
-
[window, 'keydown', this.keydownHandler],
|
|
50
|
-
[window, 'keyup', this.keyupHandler],
|
|
51
|
-
[window, 'click', this.vertexButtonClickHandler],
|
|
52
|
-
[container, 'focus', this.focusHandler],
|
|
53
|
-
[container, 'blur', this.blurHandler],
|
|
54
|
-
[container, 'pointermove', this.pointermoveHandler],
|
|
55
|
-
[container, 'pointerup', this.pointerupHandler],
|
|
56
|
-
[map, 'pointerdown', this.pointerdownHandler],
|
|
57
|
-
[map, 'draw.create', this.createHandler],
|
|
58
|
-
[map, 'move', this.moveHandler]
|
|
59
|
-
]
|
|
60
|
-
this._listeners.forEach(([t, e, h]) => t.addEventListener ? t.addEventListener(e, h) : t.on(e, h))
|
|
61
|
-
|
|
62
|
-
return state
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
onClick(state, e) {
|
|
66
|
-
if (e.originalEvent.button > 0) {
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
const snap = getSnapInstance(this.map)
|
|
70
|
-
if (isSnapEnabled(state) && isSnapActive(snap)) {
|
|
71
|
-
// Use snapped coordinates when snap is enabled and active
|
|
72
|
-
e = createSnappedEvent(e, snap)
|
|
73
|
-
} else {
|
|
74
|
-
// When snap is disabled, ensure polygon uses actual click coordinates
|
|
75
|
-
// (not stale snapped coordinates from previous mouse moves)
|
|
76
|
-
const coords = state.polygon.coordinates[0]
|
|
77
|
-
if (coords.length > 0) {
|
|
78
|
-
coords[coords.length - 1] = [e.lngLat.lng, e.lngLat.lat]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
DrawPolygon.onClick.call(this, state, e)
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
onTap() {
|
|
85
|
-
return
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
doClick(state) {
|
|
89
|
-
const coords = state.polygon.coordinates
|
|
90
|
-
this.dispatchVertexChange(coords[0])
|
|
91
|
-
if (!isValidClick(coords)) {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
// Use snap coordinates if snapping is enabled and active
|
|
95
|
-
const snap = getSnapInstance(this.map)
|
|
96
|
-
const snappedEvent = isSnapEnabled(state) && createSnappedClickEvent(this.map, snap)
|
|
97
|
-
|
|
98
|
-
if (snappedEvent) {
|
|
99
|
-
DrawPolygon.onClick.call(this, state, snappedEvent)
|
|
100
|
-
this._ctx.store.render()
|
|
101
|
-
} else {
|
|
102
|
-
this._simulateMouse('click', DrawPolygon.onClick, state)
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
dispatchVertexChange(coords) {
|
|
107
|
-
this.map.fire('draw.vertexchange', {
|
|
108
|
-
numVertecies: coords.length
|
|
109
|
-
})
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
_simulateMouse(type, fn, state) {
|
|
113
|
-
const { map } = this
|
|
114
|
-
const center = map.getCenter()
|
|
115
|
-
const point = map.project(center)
|
|
116
|
-
fn.call(this, state, {
|
|
117
|
-
lngLat: center,
|
|
118
|
-
point,
|
|
119
|
-
originalEvent: new MouseEvent(type, {
|
|
120
|
-
clientX: point.x,
|
|
121
|
-
clientY: point.y,
|
|
122
|
-
bubbles: true,
|
|
123
|
-
cancelable: true
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
this._ctx.store.render()
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
_setInterface(state, type, show = true) {
|
|
130
|
-
state.interfaceType = type
|
|
131
|
-
if (show) {
|
|
132
|
-
state.vertexMarker.style.display = 'block'
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
onCreate(state, e) {
|
|
137
|
-
const draw = this._ctx.api
|
|
138
|
-
const feature = e.features[0]
|
|
139
|
-
draw.delete(feature.id)
|
|
140
|
-
feature.id = state.featureId
|
|
141
|
-
draw.add(feature)
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
onVertexButtonClick(state, e) {
|
|
145
|
-
if (e.target.closest(`#${state.addVertexButtonId}`)) {
|
|
146
|
-
this.doClick(state)
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
onTouchStart(state, e) {
|
|
151
|
-
this._setInterface(state, 'touch')
|
|
152
|
-
this.onMove(state, e)
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
onTouchEnd(state, e) {
|
|
156
|
-
this._setInterface(state, 'touch')
|
|
157
|
-
this.onMove(state, e)
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
onKeydown(state, e) {
|
|
161
|
-
if (document.activeElement !== state.container) {
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
if (e.key === 'Escape') {
|
|
165
|
-
return e.preventDefault()
|
|
166
|
-
}
|
|
167
|
-
if (e.key === 'Enter') {
|
|
168
|
-
state.isActive = true
|
|
169
|
-
}
|
|
170
|
-
this._setInterface(state, 'keyboard')
|
|
171
|
-
this.onMove(state, e)
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
onKeyup(state, e) {
|
|
175
|
-
if (e.key === 'Escape') {
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
this._setInterface(state, 'keyboard')
|
|
179
|
-
this.onMove(state, e)
|
|
180
|
-
if (e.key === 'Enter' && state.isActive) {
|
|
181
|
-
this.doClick(state)
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
onFocus(state) {
|
|
186
|
-
const { vertexMarker, interfaceType } = state
|
|
187
|
-
vertexMarker.style.display = ['touch', 'keyboard'].includes(interfaceType) ? 'block' : 'none'
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
onBlur(state, e) {
|
|
191
|
-
if (e.target !== state.container) {
|
|
192
|
-
state.vertexMarker.style.display = 'none'
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
onMouseMove(state, e) {
|
|
197
|
-
// Trigger snap detection at mouse position
|
|
198
|
-
if (isSnapEnabled(state)) {
|
|
199
|
-
const snap = getSnapInstance(this.map)
|
|
200
|
-
triggerSnapAtPoint(snap, this.map, e.point)
|
|
201
|
-
|
|
202
|
-
// Use snapped coordinates for rubber band if snap is active
|
|
203
|
-
const snappedLngLat = getSnapLngLat(snap)
|
|
204
|
-
if (snappedLngLat) {
|
|
205
|
-
e = { ...e, lngLat: snappedLngLat }
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
DrawPolygon.onMouseMove.call(this, state, e)
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
onMove(state) {
|
|
213
|
-
if (['touch', 'keyboard'].includes(state.interfaceType)) {
|
|
214
|
-
// Trigger snap detection at center point for touch/keyboard mode
|
|
215
|
-
if (isSnapEnabled(state)) {
|
|
216
|
-
triggerSnapAtCenter(getSnapInstance(this.map), this.map)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Use snapped coordinates if available, otherwise use center
|
|
220
|
-
const snap = getSnapInstance(this.map)
|
|
221
|
-
const snappedLngLat = isSnapEnabled(state) && getSnapLngLat(snap)
|
|
222
|
-
|
|
223
|
-
if (snappedLngLat) {
|
|
224
|
-
const point = this.map.project([snappedLngLat.lng, snappedLngLat.lat])
|
|
225
|
-
DrawPolygon.onMouseMove.call(this, state, {
|
|
226
|
-
lngLat: snappedLngLat,
|
|
227
|
-
point,
|
|
228
|
-
originalEvent: new MouseEvent('mousemove', {
|
|
229
|
-
clientX: point.x,
|
|
230
|
-
clientY: point.y,
|
|
231
|
-
bubbles: true,
|
|
232
|
-
cancelable: true
|
|
233
|
-
})
|
|
234
|
-
})
|
|
235
|
-
this._ctx.store.render()
|
|
236
|
-
} else {
|
|
237
|
-
this._simulateMouse('mousemove', DrawPolygon.onMouseMove, state)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
onPointerdown(state, e) {
|
|
243
|
-
if (e.pointerType !== 'touch') {
|
|
244
|
-
this._setInterface(state, 'pointer', false)
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
onPointermove(state, e) {
|
|
249
|
-
if (e.pointerType !== 'touch') {
|
|
250
|
-
state.vertexMarker.style.display = 'none'
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
onPointerup(state) {
|
|
255
|
-
this.dispatchVertexChange(state.polygon.coordinates[0])
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
toDisplayFeatures(state, geojson, display) {
|
|
259
|
-
DrawPolygon.toDisplayFeatures.call(this, state, geojson, display)
|
|
260
|
-
|
|
261
|
-
// Create vertex
|
|
262
|
-
if (geojson.geometry.type === 'Polygon' && geojson.id === state.polygon.id) {
|
|
263
|
-
const ring = geojson.geometry.coordinates[0]
|
|
264
|
-
for (let i = 1; i < ring.length - 2; i++) {
|
|
265
|
-
display(createVertex(geojson.id, ring[i], `0.${i}`))
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
onStop(state) {
|
|
271
|
-
DrawPolygon.onStop.call(this, state)
|
|
272
|
-
this._listeners.forEach(([t, e, h]) => t.removeEventListener ? t.removeEventListener(e, h) : t.off(e, h))
|
|
273
|
-
state.vertexMarker.style.display = 'none'
|
|
274
|
-
}
|
|
275
|
-
}
|