@defra/interactive-map 0.0.22-alpha → 0.0.24-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/light-raster-thumb.jpg +0 -0
- package/assets/images/outdoor-raster-thumb.jpg +0 -0
- package/assets/images/road-raster-thumb.jpg +0 -0
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +39 -0
- package/docs/api/context.md +4 -4
- package/docs/api/map-style-config.md +11 -2
- package/docs/api/marker-config.md +38 -7
- package/docs/api/panel-definition.md +7 -3
- package/docs/api/symbol-config.md +10 -26
- package/docs/api/symbol-registry.md +28 -13
- package/docs/api.md +24 -2
- package/docs/assets/css/{docusaurus.css → docusaurus.scss} +18 -12
- package/docs/assets/images/toggle-marker-label.jpg +0 -0
- package/docs/examples/index.mdx +12 -0
- package/docs/examples/toggle-marker-label.mdx +89 -0
- package/docs/plugins/interact.md +4 -11
- package/docs/plugins/search.md +70 -0
- package/docusaurus.config.cjs +2 -1
- package/package.json +23 -9
- package/plugins/beta/datasets/dist/adapters/maplibre/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/beta/datasets/dist/css/index.css +2 -2
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/maplibre/im-datasets-maplibre-adapter.js +1 -1
- package/plugins/beta/datasets/dist/umd/maplibre/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/maplibre/index.js +1 -1
- package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +5 -5
- package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +24 -29
- package/plugins/beta/datasets/src/adapters/maplibre/patternImages.js +2 -2
- package/plugins/beta/datasets/src/adapters/maplibre/symbolImages.js +3 -3
- package/plugins/beta/datasets/src/components/KeySvg.jsx +2 -2
- package/plugins/beta/datasets/src/components/KeySvgPattern.jsx +1 -2
- package/plugins/beta/datasets/src/components/svgProperties.js +2 -2
- package/plugins/beta/datasets/src/panels/Key.module.scss +2 -2
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/css/index.css +1 -21
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/api/editFeature.js +9 -4
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +11 -3
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/src/manifest.js +1 -0
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +23 -55
- package/plugins/interact/src/InteractInit.test.js +58 -80
- package/plugins/interact/src/defaults.js +1 -3
- package/plugins/interact/src/hooks/useAttachEvents.js +46 -0
- package/plugins/interact/src/hooks/useAttachEvents.test.js +68 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +47 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +54 -0
- package/plugins/interact/src/hooks/useHighlightSync.js +30 -8
- package/plugins/interact/src/hooks/useHighlightSync.test.js +127 -80
- package/plugins/interact/src/hooks/useInteractionHandlers.js +18 -17
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +22 -61
- package/plugins/interact/src/hooks/useMapItemList.js +187 -0
- package/plugins/interact/src/hooks/useMapItemList.test.js +584 -0
- package/plugins/interact/src/index.js +0 -2
- package/plugins/interact/src/index.test.js +0 -2
- package/plugins/interact/src/manifest.js +37 -6
- package/plugins/interact/src/reducer.js +8 -4
- package/plugins/interact/src/reducer.test.js +18 -3
- package/plugins/interact/src/utils/buildStylesMap.js +21 -10
- package/plugins/interact/src/utils/buildStylesMap.test.js +29 -29
- package/plugins/interact/src/utils/spatial.js +0 -15
- package/plugins/interact/src/utils/spatial.test.js +1 -13
- 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 -1
- package/plugins/search/src/components/CloseButton/CloseButton.module.scss +2 -0
- package/plugins/search/src/components/Form/Form.jsx +11 -7
- package/plugins/search/src/components/Form/Form.test.jsx +23 -1
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +1 -1
- package/plugins/search/src/components/OpenButton/OpenButton.module.scss +3 -0
- package/plugins/search/src/datasets.js +2 -2
- package/plugins/search/src/datasets.test.js +1 -1
- package/plugins/search/src/defaults.js +7 -1
- package/plugins/search/src/events/fetchSuggestions.js +13 -10
- package/plugins/search/src/events/fetchSuggestions.test.js +14 -1
- package/plugins/search/src/events/formHandlers.js +2 -4
- package/plugins/search/src/events/formHandlers.test.js +3 -3
- package/plugins/search/src/events/inputHandlers.js +1 -1
- package/plugins/search/src/events/inputHandlers.test.js +1 -1
- package/plugins/search/src/events/suggestionHandlers.js +2 -1
- package/plugins/search/src/events/suggestionHandlers.test.js +7 -1
- package/plugins/search/src/index.js +3 -7
- package/plugins/search/src/reducer.js +10 -5
- package/plugins/search/src/reducer.test.js +2 -1
- package/plugins/search/src/search.scss +1 -0
- package/plugins/search/src/utils/parseOsNamesResults.js +3 -3
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +4 -0
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -0
- package/providers/beta/openlayers/dist/esm/index.js +1 -0
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js.LICENSE.txt +1 -0
- package/providers/beta/openlayers/dist/umd/index.js +2 -0
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +1 -0
- package/providers/beta/openlayers/src/appEvents.js +50 -0
- package/providers/beta/openlayers/src/appEvents.test.js +140 -0
- package/providers/beta/openlayers/src/defaults.js +36 -0
- package/providers/beta/openlayers/src/index.js +21 -0
- package/providers/beta/openlayers/src/mapEvents.js +132 -0
- package/providers/beta/openlayers/src/mapEvents.test.js +197 -0
- package/providers/beta/openlayers/src/openlayersProvider.js +234 -0
- package/providers/beta/openlayers/src/openlayersProvider.test.js +331 -0
- package/providers/beta/openlayers/src/utils/spatial.js +142 -0
- package/providers/beta/openlayers/src/utils/spatial.test.js +117 -0
- package/providers/beta/openlayers/src/utils/zoom.js +26 -0
- package/providers/beta/openlayers/src/utils/zoom.test.js +23 -0
- 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-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +1 -1
- package/providers/maplibre/src/index.test.js +9 -14
- package/providers/maplibre/src/mapEvents.js +11 -5
- package/providers/maplibre/src/mapEvents.test.js +14 -3
- package/providers/maplibre/src/maplibreProvider.js +18 -11
- package/providers/maplibre/src/maplibreProvider.test.js +43 -36
- package/providers/maplibre/src/utils/highlightFeatures.js +112 -57
- package/providers/maplibre/src/utils/highlightFeatures.test.js +179 -51
- package/providers/maplibre/src/utils/maplibreFixes.js +10 -0
- package/providers/maplibre/src/utils/maplibreFixes.test.js +31 -0
- package/providers/maplibre/src/utils/patternImages.js +22 -19
- package/providers/maplibre/src/utils/patternImages.test.js +146 -167
- package/providers/maplibre/src/utils/rasteriseToImageData.js +1 -4
- package/providers/maplibre/src/utils/rasteriseToImageData.test.js +23 -24
- package/providers/maplibre/src/utils/symbolImages.js +23 -86
- package/providers/maplibre/src/utils/symbolImages.test.js +60 -105
- package/rollup.esm.mjs +14 -3
- package/src/App/components/Actions/Actions.module.scss +1 -0
- package/src/App/components/Actions/Actions.test.jsx +17 -4
- package/src/App/components/Hints/Hints.jsx +52 -0
- package/src/App/components/Hints/Hints.module.scss +37 -0
- package/src/App/components/Hints/Hints.test.jsx +104 -0
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +57 -19
- package/src/App/components/KeyboardHelp/KeyboardHelp.module.scss +10 -0
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +140 -31
- package/src/App/components/Markers/LabelMarker.jsx +14 -0
- package/src/App/components/Markers/LabelMarker.test.jsx +36 -0
- package/src/App/components/Markers/Markers.jsx +44 -75
- package/src/App/components/Markers/Markers.module.scss +58 -0
- package/src/App/components/Markers/Markers.test.jsx +90 -113
- package/src/App/components/Markers/SymbolLabelMarker.jsx +43 -0
- package/src/App/components/Markers/SymbolLabelMarker.test.jsx +56 -0
- package/src/App/components/Markers/SymbolMarker.jsx +31 -0
- package/src/App/components/Markers/SymbolMarker.test.jsx +72 -0
- package/src/App/components/Panel/Panel.jsx +1 -1
- package/src/App/components/Panel/Panel.module.scss +1 -0
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +117 -1
- package/src/App/components/PopupMenu/usePopupMenu.js +132 -85
- package/src/App/components/Tabs/Tabs.jsx +68 -0
- package/src/App/components/Tabs/Tabs.module.scss +57 -0
- package/src/App/components/Tabs/Tabs.test.jsx +121 -0
- package/src/App/components/Tooltip/Tooltip.module.scss +1 -1
- package/src/App/components/Viewport/Features.jsx +35 -0
- package/src/App/components/Viewport/Features.module.scss +31 -0
- package/src/App/components/Viewport/Features.test.jsx +124 -0
- package/src/App/components/Viewport/MapStatus.jsx +0 -4
- package/src/App/components/Viewport/Viewport.jsx +35 -29
- package/src/App/components/Viewport/Viewport.module.scss +7 -21
- package/src/App/components/Viewport/Viewport.test.jsx +108 -65
- package/src/App/controls/keyboardActions.js +9 -3
- package/src/App/controls/keyboardActions.test.js +122 -87
- package/src/App/controls/keyboardShortcuts.js +1 -14
- package/src/App/hooks/useFeatureFocus.js +199 -0
- package/src/App/hooks/useFeatureFocus.test.js +635 -0
- package/src/App/hooks/useFeatureItems.js +30 -0
- package/src/App/hooks/useFeatureItems.test.js +98 -0
- package/src/App/hooks/useFocusVisible.js +4 -7
- package/src/App/hooks/useFocusVisible.test.js +6 -6
- package/src/App/hooks/useKeyboardHint.js +9 -34
- package/src/App/hooks/useKeyboardHint.test.js +34 -84
- package/src/App/hooks/useKeyboardShortcuts.js +8 -5
- package/src/App/hooks/useKeyboardShortcuts.test.js +16 -12
- package/src/App/hooks/useLayoutMeasurements.js +10 -4
- package/src/App/hooks/useLayoutMeasurements.test.js +30 -1
- package/src/App/hooks/useMarkerCursor.js +33 -0
- package/src/App/hooks/useMarkerCursor.test.js +87 -0
- package/src/App/hooks/useMarkersAPI.js +32 -9
- package/src/App/hooks/useMarkersAPI.test.js +163 -94
- package/src/App/hooks/useModalPanelBehaviour.test.js +2 -1
- package/src/App/layout/Layout.jsx +2 -0
- package/src/App/layout/Layout.test.jsx +3 -0
- package/src/App/registry/keyboardShortcutRegistry.js +3 -2
- package/src/App/registry/keyboardShortcutRegistry.test.js +6 -8
- package/src/App/renderer/mapButtons.js +5 -1
- package/src/App/renderer/mapButtons.test.js +37 -1
- package/src/App/store/AppProvider.test.jsx +5 -0
- package/src/App/store/MapProvider.test.jsx +8 -1
- package/src/App/store/ServiceProvider.jsx +4 -1
- package/src/App/store/ServiceProvider.test.jsx +11 -0
- package/src/App/store/appActionsMap.js +5 -1
- package/src/App/store/appActionsMap.test.js +13 -0
- package/src/App/store/appReducer.js +1 -0
- package/src/App/store/mapActionsMap.js +2 -1
- package/src/InteractiveMap/InteractiveMap.js +12 -0
- package/src/InteractiveMap/InteractiveMap.test.js +2 -0
- package/src/config/appConfig.js +3 -1
- package/src/config/appConfig.test.js +4 -0
- package/src/config/defaults.js +1 -1
- package/src/config/events.js +8 -0
- package/src/config/mapTheme.js +8 -4
- package/src/config/symbolConfig.js +23 -16
- package/src/scss/main.scss +3 -0
- package/src/scss/tools/_border-focus.scss +0 -1
- package/src/services/announcer.test.js +5 -7
- package/src/services/eventBus.js +15 -0
- package/src/services/eventBus.test.js +11 -0
- package/src/services/hints.js +47 -0
- package/src/services/hints.test.js +110 -0
- package/src/services/patternRegistry.js +69 -1
- package/src/services/patternRegistry.test.js +112 -1
- package/src/services/reverseGeocode.js +4 -0
- package/src/services/reverseGeocode.test.js +11 -1
- package/src/services/symbolRegistry.js +152 -17
- package/src/services/symbolRegistry.test.js +141 -31
- package/src/types.js +71 -14
- package/src/utils/constrainKeyboardFocus.js +5 -5
- package/src/utils/detectInterfaceType.js +27 -5
- package/src/utils/detectInterfaceType.test.js +29 -3
- package/src/utils/patternUtils.js +4 -67
- package/src/utils/patternUtils.test.js +1 -123
- package/src/utils/symbolUtils.js +11 -13
- package/src/utils/symbolUtils.test.js +18 -26
- package/webpack.dev.mjs +6 -1
- package/webpack.umd.mjs +1 -0
- package/plugins/interact/dist/css/index.css +0 -1
- package/plugins/interact/src/interact.scss +0 -24
|
@@ -19,7 +19,7 @@ export const createInputHandlers = ({ dispatch, debouncedFetchSuggestions }) =>
|
|
|
19
19
|
|
|
20
20
|
if (value.length < DEFAULTS.minSearchLength) {
|
|
21
21
|
debouncedFetchSuggestions.cancel()
|
|
22
|
-
dispatch({ type: 'UPDATE_SUGGESTIONS', payload: [] })
|
|
22
|
+
dispatch({ type: 'UPDATE_SUGGESTIONS', payload: { results: [], hasError: false } })
|
|
23
23
|
dispatch({ type: 'HIDE_SUGGESTIONS' })
|
|
24
24
|
return
|
|
25
25
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { updateMap } from '../utils/updateMap.js'
|
|
2
2
|
|
|
3
|
-
export const createSuggestionHandlers = ({ dispatch, services, mapProvider, markers, showMarker, markerOptions }) => {
|
|
3
|
+
export const createSuggestionHandlers = ({ dispatch, services, mapProvider, markers, showMarker, markerOptions, viewportRef }) => {
|
|
4
4
|
const selectionMessage = (suggestions, index) =>
|
|
5
5
|
index >= 0
|
|
6
6
|
? `${suggestions[index]?.text}. ${index + 1} of ${suggestions.length} is highlighted`
|
|
@@ -17,6 +17,7 @@ export const createSuggestionHandlers = ({ dispatch, services, mapProvider, mark
|
|
|
17
17
|
services.eventBus.emit('search:close')
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
viewportRef.current?.focus()
|
|
20
21
|
updateMap({ mapProvider, bounds: suggestion.bounds, point: suggestion.point, markers, showMarker, markerOptions })
|
|
21
22
|
services.eventBus.emit('search:match', { query: suggestion.text, ...suggestion })
|
|
22
23
|
},
|
|
@@ -9,6 +9,7 @@ jest.mock('../utils/updateMap.js')
|
|
|
9
9
|
describe('createSuggestionHandlers', () => {
|
|
10
10
|
let dispatch
|
|
11
11
|
let services
|
|
12
|
+
let viewportRef
|
|
12
13
|
let handlers
|
|
13
14
|
|
|
14
15
|
beforeEach(() => {
|
|
@@ -19,13 +20,16 @@ describe('createSuggestionHandlers', () => {
|
|
|
19
20
|
announce: jest.fn()
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
viewportRef = { current: { focus: jest.fn() } }
|
|
24
|
+
|
|
22
25
|
handlers = createSuggestionHandlers({
|
|
23
26
|
dispatch,
|
|
24
27
|
services,
|
|
25
28
|
mapProvider: 'map',
|
|
26
29
|
markers: 'markers',
|
|
27
30
|
showMarker: true,
|
|
28
|
-
markerOptions: { backgroundColor: 'blue' }
|
|
31
|
+
markerOptions: { backgroundColor: 'blue' },
|
|
32
|
+
viewportRef
|
|
29
33
|
})
|
|
30
34
|
|
|
31
35
|
jest.clearAllMocks()
|
|
@@ -41,6 +45,7 @@ describe('createSuggestionHandlers', () => {
|
|
|
41
45
|
expect(dispatch).toHaveBeenCalledWith({ type: 'SET_VALUE', payload: 'Paris' })
|
|
42
46
|
expect(dispatch).toHaveBeenCalledWith({ type: 'HIDE_SUGGESTIONS' })
|
|
43
47
|
expect(dispatch).toHaveBeenCalledWith({ type: 'SET_SELECTED', payload: -1 })
|
|
48
|
+
expect(viewportRef.current.focus).toHaveBeenCalled()
|
|
44
49
|
expect(updateMap).toHaveBeenCalledWith(expect.objectContaining({ bounds: 'b', point: 'p' }))
|
|
45
50
|
expect(services.eventBus.emit).toHaveBeenCalledWith(
|
|
46
51
|
'search:match',
|
|
@@ -55,6 +60,7 @@ describe('createSuggestionHandlers', () => {
|
|
|
55
60
|
|
|
56
61
|
expect(dispatch).toHaveBeenCalledWith({ type: 'TOGGLE_EXPANDED', payload: false })
|
|
57
62
|
expect(services.eventBus.emit).toHaveBeenCalledWith('search:close')
|
|
63
|
+
expect(viewportRef.current.focus).toHaveBeenCalled()
|
|
58
64
|
})
|
|
59
65
|
|
|
60
66
|
// ---------- ArrowDown ----------
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
// /plugins/search/index.js
|
|
2
2
|
import './search.scss'
|
|
3
|
+
import { DEFAULTS } from './defaults.js'
|
|
3
4
|
|
|
4
5
|
export default function createPlugin (options = {}) {
|
|
5
|
-
// If search is open then we need to overirde the mobile slot
|
|
6
|
-
if (options.expanded) {
|
|
7
|
-
options.manifest = { controls: [{ id: 'search', mobile: { slot: 'banner' } }] }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
return {
|
|
11
|
-
|
|
12
|
-
placeholder: 'Search',
|
|
7
|
+
...DEFAULTS,
|
|
13
8
|
...options,
|
|
9
|
+
...(options.expanded && { manifest: { controls: [{ id: 'search', mobile: { slot: 'banner' } }] } }),
|
|
14
10
|
id: 'search',
|
|
15
11
|
load: async () => {
|
|
16
12
|
const module = (await import(/* webpackChunkName: "im-search-plugin" */ './manifest.js')).manifest
|
|
@@ -5,6 +5,7 @@ const initialState = {
|
|
|
5
5
|
suggestions: [],
|
|
6
6
|
areSuggestionsVisible: false,
|
|
7
7
|
hasFetchedSuggestions: false,
|
|
8
|
+
hasSearchError: false,
|
|
8
9
|
selectedIndex: -1
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -13,7 +14,8 @@ const toggleExpanded = (state, payload) => {
|
|
|
13
14
|
...state,
|
|
14
15
|
isExpanded: payload,
|
|
15
16
|
areSuggestionsVisible: payload,
|
|
16
|
-
hasFetchedSuggestions: false
|
|
17
|
+
hasFetchedSuggestions: false,
|
|
18
|
+
hasSearchError: false
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -44,8 +46,9 @@ const setValue = (state, payload) => {
|
|
|
44
46
|
const updateSuggestions = (state, payload) => {
|
|
45
47
|
return {
|
|
46
48
|
...state,
|
|
47
|
-
suggestions: payload,
|
|
48
|
-
hasFetchedSuggestions: true
|
|
49
|
+
suggestions: payload.results,
|
|
50
|
+
hasFetchedSuggestions: true,
|
|
51
|
+
hasSearchError: payload.hasError
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -53,7 +56,8 @@ const showSuggestions = (state) => {
|
|
|
53
56
|
return {
|
|
54
57
|
...state,
|
|
55
58
|
areSuggestionsVisible: true,
|
|
56
|
-
hasFetchedSuggestions: false
|
|
59
|
+
hasFetchedSuggestions: false,
|
|
60
|
+
hasSearchError: false
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -61,7 +65,8 @@ const hideSuggestions = (state) => {
|
|
|
61
65
|
return {
|
|
62
66
|
...state,
|
|
63
67
|
areSuggestionsVisible: false,
|
|
64
|
-
hasFetchedSuggestions: false
|
|
68
|
+
hasFetchedSuggestions: false,
|
|
69
|
+
hasSearchError: false
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
|
|
@@ -52,9 +52,10 @@ describe('search state actions', () => {
|
|
|
52
52
|
it('UPDATE_SUGGESTIONS updates the suggestions array and sets hasFetchedSuggestions', () => {
|
|
53
53
|
const state = { ...initialState }
|
|
54
54
|
const suggestions = [{ id: 1 }, { id: 2 }]
|
|
55
|
-
const newState = actions.UPDATE_SUGGESTIONS(state, suggestions)
|
|
55
|
+
const newState = actions.UPDATE_SUGGESTIONS(state, { results: suggestions, hasError: false })
|
|
56
56
|
expect(newState.suggestions).toEqual(suggestions)
|
|
57
57
|
expect(newState.hasFetchedSuggestions).toBe(true)
|
|
58
|
+
expect(newState.hasSearchError).toBe(false)
|
|
58
59
|
})
|
|
59
60
|
|
|
60
61
|
it('SHOW_SUGGESTIONS sets areSuggestionsVisible to true and resets hasFetchedSuggestions', () => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// Components, using 'CSS in Component' pattern
|
|
4
4
|
@use './components/Form/Form.module';
|
|
5
|
+
@use './components/OpenButton/OpenButton.module';
|
|
5
6
|
@use './components/CloseButton/CloseButton.module';
|
|
6
7
|
@use './components/SubmitButton/SubmitButton.module';
|
|
7
8
|
@use './components/Suggestions/Suggestions.module';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import OsGridRef from 'geodesy/osgridref.js'
|
|
3
3
|
|
|
4
4
|
const POINT_BUFFER = 500
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_MAX_RESULTS = 8
|
|
6
6
|
|
|
7
7
|
const isPostcode = (value) => {
|
|
8
8
|
value = value.replace(/\s/g, '')
|
|
@@ -100,7 +100,7 @@ const label = (query, { NAME1, COUNTY_UNITARY, DISTRICT_BOROUGH, POSTCODE_DISTRI
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const parseOsNamesResults = (json, query, regions, crs) => {
|
|
103
|
+
const parseOsNamesResults = (json, query, regions, crs, maxSuggestions = DEFAULT_MAX_RESULTS) => {
|
|
104
104
|
if (!json || json.error || json.header?.totalresults === 0) {
|
|
105
105
|
return []
|
|
106
106
|
}
|
|
@@ -108,7 +108,7 @@ const parseOsNamesResults = (json, query, regions, crs) => {
|
|
|
108
108
|
results = removeTenuousResults(results, query)
|
|
109
109
|
results = removeDuplicates(results)
|
|
110
110
|
results = removeRegions(results, regions)
|
|
111
|
-
results = results.slice(0,
|
|
111
|
+
results = results.slice(0, maxSuggestions)
|
|
112
112
|
|
|
113
113
|
return results.map(l => ({
|
|
114
114
|
id: l.GAZETTEER_ENTRY.ID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/asyncToGenerator";import r from"@arcgis/core/config.js";import n from"@arcgis/core/layers/support/TileInfo.js";import
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/asyncToGenerator";import r from"@arcgis/core/config.js";import n from"@arcgis/core/layers/support/TileInfo.js";import i from"@arcgis/core/Map.js";import o from"@arcgis/core/views/MapView.js";import a from"@arcgis/core/layers/VectorTileLayer.js";import s from"@arcgis/core/geometry/Point.js";import{when as m,once as l,watch as u}from"@arcgis/core/core/reactiveUtils.js";import c from"@arcgis/core/geometry/Extent.js";var p={animationDuration:200},v=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom"];var y=(e,t)=>{var r=null,n=function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];clearTimeout(r),r=setTimeout(()=>{e(...i)},t)};return n.cancel=()=>{r&&(clearTimeout(r),r=null)},n};function h(e){var{mapProvider:t,view:r,baseTileLayer:n,events:i,eventBus:o,getZoom:a,getCenter:s,getBounds:c,getResolution:p}=e,v=!1,h=[],d=[],f=e=>{var t=(()=>{if(v||!r||r.destroyed||!r.extent)return null;var{maxZoom:e,minZoom:t}=r.constraints;return{center:s(),bounds:c(),resolution:p(),zoom:a(),isAtMaxZoom:r.zoom+.01>=e,isAtMinZoom:r.zoom-.01<=t}})();t&&o.emit(e,t)};m(()=>n.loaded&&r.resolution>0,()=>f(i.MAP_LOADED)),l(()=>r.ready).then(()=>{v||o.emit(i.MAP_READY,{map:t.map,view:t.view,mapStyleId:t.mapStyleId,mapSize:t.mapSize,crs:t.crs})}),l(()=>r.stationary).then(()=>f(i.MAP_FIRST_IDLE));var g=y(()=>f(i.MAP_MOVE_END),500);d.push(g),h.push(u(()=>[r.interacting,r.animation],e=>{var[t,r]=e;(t||r)&&o.emit(i.MAP_MOVE_START),t||r||g()}));var w,x,b,M=(w=()=>f(i.MAP_MOVE),x=10,b=0,function(){var e=Date.now();e-b>=x&&(b=e,w(...arguments))});d.push(M),h.push(u(()=>r.zoom,M)),h.push(u(()=>r.extent,()=>o.emit(i.MAP_RENDER),{initial:!1}));var E=y(()=>f(i.MAP_DATA_CHANGE),500);d.push(E),h.push(u(()=>r.updating,e=>!e&&E()));var A=null,T=null;return h.push(r.on("pointer-down",e=>{A=e.x,T=e.y})),h.push(r.on("pointer-up",e=>{var n;if(0===e.button&&!(Math.hypot(e.x-A,e.y-T)>6)&&"active"!==(null===(n=t.sketchViewModel)||void 0===n?void 0:n.state)){var a={x:e.x,y:e.y},s=r.toMap(a);s&&o.emit(i.MAP_CLICK,{point:a,coords:[s.x,s.y]})}})),{remove(){v=!0,d.forEach(e=>e.cancel()),h.forEach(e=>e.remove())}}}var d=e=>e?new c({xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:{wkid:27700}}):void 0,f=e=>e?new s({x:e[0],y:e[1],spatialReference:{wkid:27700}}):void 0,g=(e,t)=>{if(e)if("FeatureCollection"===e.type)e.features.forEach(e=>g(e,t));else if("Feature"===e.type)g(e.geometry,t);else if("GeometryCollection"===e.type)e.geometries.forEach(e=>g(e,t));else{var r=e=>{Array.isArray(e)&&("number"==typeof e[0]?t.push(e):e.forEach(r))};r(e.coordinates)}},w=e=>{var t=[];g(e,t);var r=t.map(e=>e[0]),n=t.map(e=>e[1]);return d([Math.min(...r),Math.min(...n),Math.max(...r),Math.max(...n)])},x=e=>{var t=1609.344,r=e/t;if(r<.5/t)return"".concat(Math.round(e),"m");if(r<10){var n=Number.parseFloat(r.toFixed(1)),i=1===n?"mile":"miles";return"".concat(n," ").concat(i)}var o=Math.round(r),a=1===o?"mile":"miles";return"".concat(o," ").concat(a)};var b={top:0,right:0,bottom:0,left:0};function M(){return(M=t(function*(e,t){if(!e||!t)return[];var r=e.map.layers.filter(e=>e instanceof a);return r.length?(yield e.hitTest(t,{include:r.toArray()})).results.map(e=>({layerId:e.layer.id,layerTitle:e.layer.title||e.layer.id,type:e.layer.type,geometry:e.graphic.geometry,symbol:e.graphic.symbol})):[]})).apply(this,arguments)}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function A(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?E(Object(n),!0).forEach(function(r){e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}class T{constructor(e){var{mapProviderConfig:t={},events:r,eventBus:n}=e;this.events=r,this.eventBus=n,this.capabilities={supportedShortcuts:v,supportsMapSizes:!1},Object.assign(this,t),this.mapEventHandles=[],this.appEventHandles=[]}initMap(e){var s=this;return t(function*(){var{container:t,padding:m,mapStyle:l,mapSize:u,maxExtent:c}=e;s.mapStyleId=null==l?void 0:l.id,s.mapSize=u;var{events:p,eventBus:v}=s;s.setupConfig&&(yield s.setupConfig(r));var y=new a({id:"baselayer",url:l.url,visible:!0}),g=new i({layers:[y]}),w=c?d(c):null,x=new o({spatialReference:27700,container:t,map:g,zoom:e.zoom,center:f(e.center),maxExtent:c,constraints:{lods:n.create({spatialReference:{wkid:27700}}).lods,snapToZoom:!1,minZoom:e.minZoom,maxZoom:e.maxZoom,maxScale:0,geometry:w,rotationEnabled:!1},ui:{components:[]},popupEnabled:!1});(e=>{if(e){var t=e.querySelector(".esri-view-surface");t.removeAttribute("role"),t.tabIndex=-1,t.style["outline-color"]="transparent",t.style.touchAction="none"}})(x.container),x.padding=m,e.bounds&&x.when(()=>x.goTo(d(e.bounds),{duration:0})),s.mapEventHandles=h({mapProvider:s,view:x,baseTileLayer:y,events:p,eventBus:v,getZoom:s.getZoom.bind(s),getCenter:s.getCenter.bind(s),getBounds:s.getBounds.bind(s),getResolution:s.getResolution.bind(s)}),s.appEventHandles=function(e){var{baseTileLayer:t,events:r,eventBus:n}=e,i=e=>{t.loadStyle(e.url).then(()=>{n.emit(r.MAP_STYLE_CHANGE,{mapStyleId:e.id})})};return n.on(r.MAP_SET_STYLE,i),{remove(){n.off(r.MAP_SET_STYLE,i)}}}({baseTileLayer:y,events:p,eventBus:v})||[],s.map=g,s.view=x,s.baseTileLayer=y})()}destroyMap(){var e,t;null===(e=this.mapEvents)||void 0===e||e.remove(),null===(t=this.appEvents)||void 0===t||t.remove(),this.mapEvents=null,this.appEvents=null,this.view&&(this.view.container=null,this.view.destroy(),this.view=null),this.map&&(this.map.removeAll(),this.map=null)}setView(e){var t,{center:r,zoom:n}=e;null===(t=this.view.animation)||void 0===t||t.destroy();var i={center:r?new s({x:r[0],y:r[1],spatialReference:{wkid:27700}}):this.view.center,zoom:null!=n?n:this.view.zoom};this.view.goTo(A(A({},i),{},{duration:p.animationDuration}))}zoomIn(e){var t;null===(t=this.view.animation)||void 0===t||t.destroy(),this.view.goTo({zoom:this.view.zoom+e,duration:p.animationDuration})}zoomOut(e){var t;null===(t=this.view.animation)||void 0===t||t.destroy(),this.view.goTo({zoom:this.view.zoom-e,duration:p.animationDuration})}panBy(e){var{x:t,y:r}=this.view.toScreen(this.view.center),n={x:t+e[0],y:r+e[1]},i=this.view.toMap(n);this.view.goTo({center:i,duration:p.animationDuration})}fitToBounds(e){var t=Array.isArray(e)?d(e):w(e);this.view.goTo(t,{duration:p.DELAY})}setPadding(e){this.view.padding=e}getCenter(){var e=this.view.center;return[e.x,e.y].map(e=>Math.round(100*e)/100)}getZoom(){return this.view.zoom}getBounds(){var{xmin:e,ymin:t,xmax:r,ymax:n}=this.view.extent;return[e,t,r,n].map(e=>Math.round(100*e)/100)}getFeaturesAtPoint(e,t){return function(e,t){return M.apply(this,arguments)}(this.view,e)}getVisibleFeatures(e){return[]}getAreaDimensions(){return(e=>{if(!(e&&e instanceof c))return"";var t=e.xmin,r=e.ymin,n=e.xmax,i=e.ymax-r,o=x(n-t),a=x(i);return"".concat(a," by ").concat(o)})(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b;if(!e.container)return null;var{width:r,height:n}=e.container.getBoundingClientRect(),i={x:t.left,y:n-t.bottom},o={x:r-t.right,y:t.top},a=e.toMap(i),s=e.toMap(o);return new c({xmin:a.x,ymin:a.y,xmax:s.x,ymax:s.y,spatialReference:a.spatialReference})}(this.view))}getCardinalMove(e,t){return function(e,t){var[r,n]=e,[i,o]=t,a=i-r,s=o-n,m=[];return Math.abs(s)>.1&&m.push("".concat(s>0?"north":"south"," ").concat(x(Math.abs(s)))),Math.abs(a)>.1&&m.push("".concat(a>0?"east":"west"," ").concat(x(Math.abs(a)))),m.join(", ")}(e,t)}getResolution(){return this.view.resolution}mapToScreen(e){var t=f(e),r=this.view.toScreen(t);return{x:r.x,y:r.y}}screenToMap(e){var t=this.view.toMap(e);return[t.x,t.y]}isGeometryObscured(e,t){return((e,t,r)=>{if(null==r||!r.container)return!1;var n=r.container.getBoundingClientRect(),i=w(e),o=[r.toScreen(new s({x:i.xmin,y:i.ymin,spatialReference:i.spatialReference})),r.toScreen(new s({x:i.xmin,y:i.ymax,spatialReference:i.spatialReference})),r.toScreen(new s({x:i.xmax,y:i.ymin,spatialReference:i.spatialReference})),r.toScreen(new s({x:i.xmax,y:i.ymax,spatialReference:i.spatialReference}))],a=Math.min(...o.map(e=>e.x)),m=Math.max(...o.map(e=>e.x)),l=Math.min(...o.map(e=>e.y)),u=Math.max(...o.map(e=>e.y)),c=t.left-n.left,p=t.top-n.top,v=t.right-n.left,y=t.bottom-n.top;return a<v&&m>c&&l<y&&u>p})(e,t,this.view)}}export{T as default};
|
|
@@ -182,6 +182,10 @@ export default class EsriProvider {
|
|
|
182
182
|
return queryVectorTileFeatures(this.view, point)
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
getVisibleFeatures (_layerIds) {
|
|
186
|
+
return []
|
|
187
|
+
}
|
|
188
|
+
|
|
185
189
|
// ==========================
|
|
186
190
|
// Spatial helpers
|
|
187
191
|
// ==========================
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@babel/runtime/helpers/asyncToGenerator";import t from"ol/Map.js";import o from"ol/View.js";import r from"ol/layer/Tile.js";import{defaults as n}from"ol/interaction/defaults.js";import i from"proj4";import{register as a}from"ol/proj/proj4.js";import s from"ol/source/XYZ.js";import l from"ol/tilegrid/TileGrid.js";import u from"ol/TileState.js";import{transformExtent as m}from"ol/proj.js";var p=[896,448,224,112,56,28,14,7,3.5,1.75,.875,.4375,.21875,.109375],c=[156543.03392800014,78271.51696400007,39135.758482000034,19567.879241000017,9783.939620500008,4891.969810250004,2445.984905125002,1222.992452562501,611.4962262812505,305.74811314062526,152.87405657031263,76.43702828515632,38.21851414257816,19.10925707128908,9.55462853564454,4.77731426782227,2.388657133911135,1.1943285669555674,.5971642834777837,.29858214173889186,.14929107086944593,.07464553543472296,.03732276771736148,.01866138385868074],v=[-238375,1376256],d=300,g=2,h=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom"],f="uk",M="world";var w=(e,t)=>{var o=null,r=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];clearTimeout(o),o=setTimeout(()=>{e(...n)},t)};return r.cancel=()=>{o&&(clearTimeout(o),o=null)},r};function y(e){var{map:t,view:o,emit:r,eventBus:n,events:i,on:a,debouncers:s}=e,l=!1,u=w(()=>{l=!1,r(i.MAP_MOVE_END)},500);s.push(u);var m,p,c,v=(m=()=>r(i.MAP_MOVE),p=10,c=0,function(){var e=Date.now();e-c>=p&&(c=e,m(...arguments))});a(o,"change",()=>{l||(l=!0,n.emit(i.MAP_MOVE_START)),u()}),a(t,"postrender",()=>{l&&v()})}function b(e){var{map:t,source:o,events:r,eventBus:n,getZoom:i,getCenter:a,getBounds:s,getResolution:l}=e,u=!1,m=[],p=[],c=t.getView(),v=c.getMinZoom(),d=c.getMaxZoom(),g=e=>{var t=(()=>{if(u)return null;var e=i();return{center:a(),bounds:s(),resolution:l(),zoom:e,isAtMaxZoom:e+.01>=d,isAtMinZoom:e-.01<=v}})();t&&n.emit(e,t)},h=(e,t,o)=>{e.on(t,o),m.push([e,t,o])};!function(e){var{source:t,map:o,emit:r,eventBus:n,events:i,on:a}=e,s=!1;a(t,"tileloadend",()=>{s||(s=!0,n.emit(i.MAP_LOADED))}),o.once("rendercomplete",()=>r(i.MAP_FIRST_IDLE))}({source:o,map:t,emit:g,eventBus:n,events:r,on:h}),y({map:t,view:t.getView(),emit:g,eventBus:n,events:r,on:h,debouncers:p}),function(e){var{map:t,eventBus:o,events:r,on:n}=e,i=null;n(t,"pointerdown",e=>{i=e.pixel}),n(t,"click",e=>{if(i){var t=e.pixel[0]-i[0],n=e.pixel[1]-i[1];if(Math.hypot(t,n)>6)return}o.emit(r.MAP_CLICK,{point:{x:e.pixel[0],y:e.pixel[1]},coords:e.coordinate})})}({map:t,eventBus:n,events:r,on:h}),h(t,"postrender",()=>n.emit(r.MAP_RENDER));var f=w(()=>g(r.MAP_DATA_CHANGE),500);return p.push(f),h(o,"tileloadend",f),{remove(){u=!0,p.forEach(e=>e.cancel()),m.forEach(e=>{var[t,o,r]=e;return t.un(o,r)})}}}var S=e=>(t,o)=>{var r=e(o,"Tile")||{},n=r.url||o,i=r.headers||{};fetch(n,{headers:i}).then(e=>e.blob()).then(e=>{t.getImage().src=URL.createObjectURL(e)}).catch(()=>t.setState(u.ERROR))};function x(e,t){var o=new l({resolutions:p,origin:v,tileSize:256});return new s({projection:"EPSG:27700",tileGrid:o,tileUrlFunction:t=>{var[o,r,n]=t;return e.replace("{z}",o).replace("{x}",r).replace("{y}",n)},tileLoadFunction:t?S(t):void 0})}function E(e,t,o){if(null!==e)for(var r,n,i,a,s,l,u,m,p=0,c=0,v=e.type,d="FeatureCollection"===v,g="Feature"===v,h=d?e.features.length:1,f=0;f<h;f++){s=(m=!!(u=d?e.features[f].geometry:g?e.geometry:e)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var M=0;M<s;M++){var w=0,y=0;if(null!==(a=m?u.geometries[M]:u)){l=a.coordinates;var b=a.type;switch(p=0,b){case null:break;case"Point":if(!1===t(l,c,f,w,y))return!1;c++,w++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===t(l[r],c,f,w,y))return!1;c++,"MultiPoint"===b&&w++}"LineString"===b&&w++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-p;n++){if(!1===t(l[r][n],c,f,w,y))return!1;c++}"MultiLineString"===b&&w++,"Polygon"===b&&y++}"Polygon"===b&&w++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(y=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-p;i++){if(!1===t(l[r][n][i],c,f,w,y))return!1;c++}y++}w++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(!1===E(a.geometries[r],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var P=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const o=[1/0,1/0,-1/0,-1/0];return E(e,e=>{o[0]>e[0]&&(o[0]=e[0]),o[1]>e[1]&&(o[1]=e[1]),o[2]<e[0]&&(o[2]=e[0]),o[3]<e[1]&&(o[3]=e[1])}),o},A=e=>{var t=e/1609.344;if(t<.5)return"".concat(Math.round(e),"m");if(t<10){var o=Number.parseFloat(t.toFixed(1)),r=1===o?"mile":"miles";return"".concat(o," ").concat(r)}var n=Math.round(t);return"".concat(n," miles")},Z=(e,t,o)=>{var r=o.getTargetElement().getBoundingClientRect(),[n,i,a,s]=(e=>P(e))(e),l=[[n,i],[n,s],[a,i],[a,s]].map(e=>o.getPixelFromCoordinate(e)).filter(Boolean);if(!l.length)return!1;var u=Math.min(...l.map(e=>e[0])),m=Math.max(...l.map(e=>e[0])),p=Math.min(...l.map(e=>e[1])),c=Math.max(...l.map(e=>e[1])),v=t.left-r.left,d=t.top-r.top,g=t.right-r.left,h=t.bottom-r.top;return u<g&&m>v&&p<h&&c>d},C="EPSG:27700",_=e=>{if(e){var{top:t=0,right:o=0,bottom:r=0,left:n=0}=e;return[t,o,r,n]}};i.defs(C,"+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs"),a(i);class T{constructor(e){var{mapProviderConfig:t={},events:o,eventBus:r}=e;this.events=o,this.eventBus=r,this.capabilities={supportedShortcuts:h,supportsMapSizes:!1},Object.assign(this,t)}initMap(i){var a=this;return e(function*(){var e,{container:s,padding:l,mapStyle:u,mapSize:m,center:v,zoom:d,bounds:g,minZoom:h,maxZoom:w,transformRequest:y}=i;a.mapStyleId=null==u?void 0:u.id,a.mapSize=m;var{events:S,eventBus:E}=a,P=x(u.url,y),A=new r({source:P}),Z=(null!==(e=a.zoomAlignment)&&void 0!==e?e:f)===M?{resolutions:c,defaultMinZoom:6,maxZoom:20}:{resolutions:p,defaultMinZoom:0,maxZoom:p.length-1},T=new o({projection:C,center:v,zoom:null!=d?d:Z.defaultMinZoom,minZoom:Math.max(null!=h?h:Z.defaultMinZoom,Z.defaultMinZoom),maxZoom:null!=w?w:Z.maxZoom,resolutions:Z.resolutions,constrainResolution:!1,padding:_(l)}),z=new t({target:s,layers:[A],view:T,controls:[],interactions:n({doubleClickZoom:!1})});g&&z.once("rendercomplete",()=>{T.fit(g,{size:z.getSize(),duration:0})}),a.mapEventHandles=b({map:z,source:P,events:S,eventBus:E,getZoom:a.getZoom.bind(a),getCenter:a.getCenter.bind(a),getBounds:a.getBounds.bind(a),getResolution:a.getResolution.bind(a)}),a.appEventHandles=function(e){var{tileLayer:t,transformRequest:o,events:r,eventBus:n}=e,i=e=>{var i=x(e.url,o);t.setSource(i),n.emit(r.MAP_STYLE_CHANGE,{mapStyleId:e.id})};return n.on(r.MAP_SET_STYLE,i),{remove(){n.off(r.MAP_SET_STYLE,i)}}}({tileLayer:A,transformRequest:y,events:S,eventBus:E})||[],a.map=z,a.view=T,a.tileLayer=A,a.source=P,E.emit(S.MAP_READY,{map:a.map,mapStyleId:a.mapStyleId,mapSize:a.mapSize,crs:a.crs})})()}destroyMap(){var e,t;null===(e=this.mapEventHandles)||void 0===e||e.remove(),null===(t=this.appEventHandles)||void 0===t||t.remove(),this.mapEventHandles=null,this.appEventHandles=null,this.map&&(this.map.setTarget(null),this.map=null),this.view=null,this.tileLayer=null,this.source=null}setView(e){var{center:t,zoom:o}=e;this.view.animate({center:null!=t?t:this.view.getCenter(),zoom:null!=o?o:this.view.getZoom(),duration:d})}zoomIn(e){this.view.animate({zoom:this.view.getZoom()+e,duration:d})}zoomOut(e){this.view.animate({zoom:this.view.getZoom()-e,duration:d})}panBy(e){var t=this.view.getCenter(),o=this.view.getResolution();this.view.animate({center:[t[0]+e[0]*o,t[1]-e[1]*o],duration:d})}fitToBounds(e){var t,o=Array.isArray(e)?e:(t=P(e),m(t,"EPSG:4326","EPSG:27700"));this.view.fit(o,{duration:d})}setPadding(e){this.view.padding=_(e)}getCenter(){var e=this.view.getCenter(),t=g;return[Math.round(e[0]*Math.pow(10,t))/Math.pow(10,t),Math.round(e[1]*Math.pow(10,t))/Math.pow(10,t)]}getZoom(){return this.view.getZoom()}getBounds(){return this.view.calculateExtent(this.map.getSize()).map(e=>Math.round(100*e)/100)}getFeaturesAtPoint(e,t){return[]}getVisibleFeatures(e){return[]}getAreaDimensions(){return(e=>{if(!e)return"";var[t,o,r,n]=e,i=r-t;return"".concat(A(n-o)," by ").concat(A(i))})((e=>{var t=e.getSize(),o=e.getView().padding||[0,0,0,0],[r,n,i,a]=o,s=[a,t[1]-i],l=[t[0]-n,r],u=e.getCoordinateFromPixel(s),m=e.getCoordinateFromPixel(l);return u&&m?[u[0],u[1],m[0],m[1]]:null})(this.map))}getCardinalMove(e,t){return((e,t)=>{var o=t[0]-e[0],r=t[1]-e[1],n=[];return Math.abs(r)>1&&n.push("".concat(r>0?"north":"south"," ").concat(A(Math.abs(r)))),Math.abs(o)>1&&n.push("".concat(o>0?"east":"west"," ").concat(A(Math.abs(o)))),n.join(", ")})(e,t)}getResolution(){return this.view.getResolution()}mapToScreen(e){if(!this.map)return{x:0,y:0};var t=this.map.getPixelFromCoordinate(e);return t?{x:t[0],y:t[1]}:{x:0,y:0}}screenToMap(e){return this.map.getCoordinateFromPixel([e.x,e.y])}isGeometryObscured(e,t){return Z(e,t,this.map)}}export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@babel/runtime/helpers/asyncToGenerator";function r(){var r,{zoomAlignment:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{checkDeviceCapabilities:()=>({isSupported:!!document.createElement("canvas").getContext,error:"Canvas is not supported in this browser"}),load:(r=e(function*(){return{MapProvider:(yield import(/* webpackChunkName: "im-openlayers-provider" */ "./im-openlayers-provider.js")).default,mapProviderConfig:{zoomAlignment:t,crs:"EPSG:27700"}}}),function(){return r.apply(this,arguments)})}}export{r as default};
|