@defra/interactive-map 0.0.53-alpha → 0.0.55-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/add-polygons.njk +1 -1
- package/assets/templates/add-symbols.njk +4 -4
- package/assets/templates/draw-tools.njk +7 -7
- package/assets/templates/marker-panel.njk +5 -5
- package/assets/templates/place-marker.njk +8 -8
- package/assets/templates/search-control.njk +1 -1
- package/assets/templates/select-feature.njk +7 -7
- package/assets/templates/style-switcher.njk +4 -4
- package/assets/templates/toggle-marker-label.njk +3 -3
- 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/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/im-core.js.LICENSE.txt +0 -30
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.LICENSE.txt +0 -20
- package/docs/api/context.md +12 -0
- package/docs/api.md +14 -16
- package/docs/building-a-plugin.md +2 -2
- package/docs/examples/add-marker-with-panel.mdx +46 -44
- package/docs/examples/add-polygons.mdx +100 -98
- package/docs/examples/add-symbols.mdx +75 -73
- package/docs/examples/basic-map.mdx +16 -14
- package/docs/examples/button-map.mdx +16 -14
- package/docs/examples/draw-tools.mdx +119 -117
- package/docs/examples/place-marker.mdx +51 -49
- package/docs/examples/search-control.mdx +22 -20
- package/docs/examples/select-feature.mdx +107 -105
- package/docs/examples/style-switcher.mdx +47 -45
- package/docs/examples/toggle-marker-label.mdx +30 -28
- package/docs/getting-started.md +26 -24
- package/docs/plugins/datasets.md +2 -0
- package/docs/plugins/draw.md +10 -10
- package/docs/plugins/interact.md +9 -9
- package/docs/plugins/map-key.md +41 -0
- package/docs/plugins/plugin-descriptor.md +1 -1
- package/docs/plugins/search.md +3 -3
- package/docusaurus.config.cjs +23 -0
- package/package.json +3 -7
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/dist/esm/index.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +1 -1
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/esm/index.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/index.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/esm/index.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/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/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/esm/index.js +1 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/umd/index.js +1 -1
- 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/layerAdapter.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 +6 -6
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/layerBuilders.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/layerBuilders.test.js +3 -3
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.js +1 -3
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +0 -12
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +1 -2
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +3 -3
- package/plugins/datasets/src/fetch/createDynamicSource.js +2 -2
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +2 -2
- package/plugins/datasets/src/initialise/defaults.js +12 -24
- package/plugins/datasets/src/initialise/defaults.test.js +25 -57
- package/plugins/datasets/src/initialise/initialiseDatasets.js +1 -4
- package/plugins/datasets/src/reducers/mappedDatasetsReducer.test.js +1 -1
- package/plugins/datasets/src/registry/dataset.js +21 -16
- package/plugins/datasets/src/registry/dataset.test.js +101 -11
- 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/adapters/maplibre/styles.js +3 -2
- package/plugins/draw/src/adapters/maplibre/styles.test.js +3 -3
- 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/map-key/dist/css/index.css +1 -1
- 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/Key.module.scss +144 -53
- package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +34 -3
- package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +44 -2
- package/plugins/map-key/src/components/Key/KeySvg.jsx +5 -5
- package/plugins/map-key/src/components/Key/KeySvg.test.jsx +4 -4
- package/plugins/map-key/src/components/Key/KeySvgRamp.jsx +35 -6
- package/plugins/map-key/src/components/Key/KeySvgRamp.test.jsx +56 -16
- package/plugins/map-key/src/components/Key/useRampOrientation.js +61 -0
- package/plugins/map-key/src/components/Key/useRampOrientation.test.jsx +155 -0
- package/plugins/map-key/src/index.js +34 -0
- package/plugins/map-key/src/utils/groupStyles.js +5 -2
- package/plugins/menu/dist/esm/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/umd/index.js +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 +0 -1
- package/plugins/search/src/components/Form/Form.jsx +3 -3
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +2 -0
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +6 -0
- package/plugins/search/src/defaults.js +3 -0
- package/plugins/search/src/events/formHandlers.js +3 -9
- package/plugins/search/src/events/formHandlers.test.js +6 -9
- package/plugins/search/src/events/inputHandlers.js +8 -2
- package/plugins/search/src/events/inputHandlers.test.js +20 -0
- package/plugins/search/src/events/suggestionHandlers.js +3 -5
- package/plugins/search/src/events/suggestionHandlers.test.js +5 -8
- package/plugins/search/src/utils/showResult.js +9 -0
- package/plugins/search/src/utils/showResult.test.js +16 -0
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/dist/esm/index.js +1 -1
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +1 -1
- package/providers/beta/open-names/dist/esm/index.js +1 -1
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/beta/open-names/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/esm/index.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/src/index.js +27 -4
- package/providers/beta/openlayers/src/index.test.js +47 -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-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +3 -3
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-worker.js +2 -0
- package/providers/maplibre/dist/umd/im-maplibre-worker.js.LICENSE.txt +4 -0
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +41 -12
- package/providers/maplibre/src/index.test.js +43 -12
- package/providers/maplibre/src/utils/detectModuleWorker.js +25 -0
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +40 -0
- package/providers/maplibre/src/utils/spatial.js +22 -12
- package/providers/maplibre/src/utils/spatial.test.js +6 -6
- package/providers/maplibre/src/utils/workerUrl.js +15 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -0
- package/rollup.esm.mjs +38 -1
- package/src/App/components/Hints/Hints.module.scss +1 -1
- package/src/App/components/Viewport/Viewport.jsx +6 -4
- package/src/App/components/Viewport/Viewport.test.jsx +18 -1
- package/src/App/hooks/useMapAnnouncements.js +7 -2
- package/src/App/hooks/useMapAnnouncements.test.js +13 -2
- package/src/App/hooks/useModalPanelBehaviour.js +3 -1
- package/src/App/initialiseApp.js +1 -1
- package/src/App/store/ServiceProvider.jsx +7 -1
- package/src/App/store/ServiceProvider.test.jsx +15 -0
- package/src/InteractiveMap/InteractiveMap.js +5 -4
- package/src/InteractiveMap/InteractiveMap.test.js +9 -2
- package/src/InteractiveMap/domStateManager.js +21 -1
- package/src/InteractiveMap/domStateManager.test.js +48 -1
- package/src/InteractiveMap/polyfills.js +4 -3
- package/src/InteractiveMap/polyfills.test.js +12 -0
- package/src/services/mapFocus.js +64 -0
- package/src/services/mapFocus.test.js +76 -0
- package/src/types.js +5 -7
- package/src/utils/detectInterfaceType.js +16 -5
- package/src/utils/detectInterfaceType.test.js +32 -0
- package/webpack.dev.mjs +2 -0
- package/webpack.umd.mjs +28 -7
package/docs/plugins/interact.md
CHANGED
|
@@ -288,15 +288,15 @@ Emitted when the user confirms their selection (clicks "Done").
|
|
|
288
288
|
```
|
|
289
289
|
|
|
290
290
|
```js
|
|
291
|
-
interactiveMap.on('interact:done', (
|
|
292
|
-
if (
|
|
293
|
-
console.log('Location selected:',
|
|
291
|
+
interactiveMap.on('interact:done', (event) => {
|
|
292
|
+
if (event.coords) {
|
|
293
|
+
console.log('Location selected:', event.coords)
|
|
294
294
|
}
|
|
295
|
-
if (
|
|
296
|
-
console.log('Features selected:',
|
|
295
|
+
if (event.selectedFeatures) {
|
|
296
|
+
console.log('Features selected:', event.selectedFeatures)
|
|
297
297
|
}
|
|
298
|
-
if (
|
|
299
|
-
console.log('Markers selected:',
|
|
298
|
+
if (event.selectedMarkers) {
|
|
299
|
+
console.log('Markers selected:', event.selectedMarkers)
|
|
300
300
|
}
|
|
301
301
|
})
|
|
302
302
|
```
|
|
@@ -333,8 +333,8 @@ Emitted whenever the selected features or selected markers change.
|
|
|
333
333
|
```
|
|
334
334
|
|
|
335
335
|
```js
|
|
336
|
-
interactiveMap.on('interact:selectionchange', (
|
|
337
|
-
console.log('Selected features:',
|
|
336
|
+
interactiveMap.on('interact:selectionchange', (event) => {
|
|
337
|
+
console.log('Selected features:', event.selectedFeatures)
|
|
338
338
|
})
|
|
339
339
|
```
|
|
340
340
|
|
package/docs/plugins/map-key.md
CHANGED
|
@@ -99,6 +99,47 @@ createMapKeyPlugin({ noKeyItemText: 'No layers to show' })
|
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
+
### `groups`
|
|
103
|
+
|
|
104
|
+
**Type:** `Record<string, MapKeyGroupConfig>`
|
|
105
|
+
|
|
106
|
+
Display options for groups of key entries, keyed by group id.
|
|
107
|
+
|
|
108
|
+
A dataset's group id is its `groupId`, or otherwise its group label in lower case with spaces replaced by hyphens. Sublayers are grouped under their parent dataset, so a dataset labelled `'Land covers'` with sublayers has the group id `'land-covers'`.
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
createMapKeyPlugin({
|
|
112
|
+
groups: {
|
|
113
|
+
'land-covers': { groupStyle: 'ramp' }
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### `groupLabel`
|
|
119
|
+
|
|
120
|
+
**Type:** `string`
|
|
121
|
+
|
|
122
|
+
Heading shown above the group. Replaces the heading the group's entries provide.
|
|
123
|
+
|
|
124
|
+
#### `groupStyle`
|
|
125
|
+
|
|
126
|
+
**Type:** `'ramp'`
|
|
127
|
+
|
|
128
|
+
How the group's entries are laid out. Without a `groupStyle`, each entry shows its symbol beside its label.
|
|
129
|
+
|
|
130
|
+
`'ramp'` shows the entries as touching bands, in order. Each band is filled with the entry's `fill` or fill pattern, and outlined in its `stroke` colour:
|
|
131
|
+
|
|
132
|
+
- **Horizontal** — bands of equal width in a row, with each label centred below its band. Used when every label fits on one line under its band.
|
|
133
|
+
- **Vertical** — bands stacked with each label beside its band. Used when any label doesn't fit.
|
|
134
|
+
|
|
135
|
+
The layout is chosen again when the key panel resizes, or when the text size changes.
|
|
136
|
+
|
|
137
|
+
When any entry in the group has a `stroke`, the bands are separated by a small gap.
|
|
138
|
+
|
|
139
|
+
A ramp suits polygon entries. If any entry in the group has a `symbol` or `symbolSvgContent`, the group is shown without a `groupStyle`.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
102
143
|
## Key display properties
|
|
103
144
|
|
|
104
145
|
These properties control how an entry looks in the key panel — they have no effect on how a feature renders on the map itself. Today the only way to set them is via a dataset's [`style`](./datasets.md#style) object, since Datasets is the only plugin feeding this key panel.
|
|
@@ -24,7 +24,7 @@ Any properties passed to the factory (except `id` and `load`) are available as [
|
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
26
|
// Registering the plugin with configuration
|
|
27
|
-
import createScaleBarPlugin from '@defra/interactive-map
|
|
27
|
+
import createScaleBarPlugin from '@defra/interactive-map/plugins/scale-bar'
|
|
28
28
|
|
|
29
29
|
const interactiveMap = new InteractiveMap({
|
|
30
30
|
plugins: [
|
package/docs/plugins/search.md
CHANGED
|
@@ -340,9 +340,9 @@ The full suggestion object returned by the dataset's `parseResults` function, pl
|
|
|
340
340
|
```
|
|
341
341
|
|
|
342
342
|
```js
|
|
343
|
-
interactiveMap.on('search:match', (
|
|
344
|
-
if (
|
|
345
|
-
interactPlugin.selectFeature({ featureId:
|
|
343
|
+
interactiveMap.on('search:match', (event) => {
|
|
344
|
+
if (event.type === 'parcel') {
|
|
345
|
+
interactPlugin.selectFeature({ featureId: event.properties.id, layerId: 'parcels' })
|
|
346
346
|
}
|
|
347
347
|
})
|
|
348
348
|
```
|
package/docusaurus.config.cjs
CHANGED
|
@@ -58,6 +58,29 @@ const config = {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
},
|
|
61
|
+
// Maps only render in the browser, and maplibre-gl only exports an `import`
|
|
62
|
+
// condition, which the server build doesn't resolve.
|
|
63
|
+
//
|
|
64
|
+
// The client build must emit MapLibre's worker as a file. The GOV.UK theme types
|
|
65
|
+
// every .mjs file as `javascript/auto`, which would bundle the worker as a module
|
|
66
|
+
// instead, so this rule is added last, after all plugins' rules, to take precedence.
|
|
67
|
+
function maplibrePlugin() {
|
|
68
|
+
return {
|
|
69
|
+
name: 'maplibre',
|
|
70
|
+
configureWebpack(_webpackConfig, isServer) {
|
|
71
|
+
if (isServer) {
|
|
72
|
+
return { resolve: { alias: { 'maplibre-gl$': false } } };
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
plugins: [{
|
|
76
|
+
apply(compiler) {
|
|
77
|
+
compiler.options.module.rules.push({ test: /maplibre-gl-worker\.mjs$/, type: 'asset/resource' });
|
|
78
|
+
},
|
|
79
|
+
}],
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
61
84
|
[
|
|
62
85
|
'@docusaurus/plugin-content-docs',
|
|
63
86
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra/interactive-map",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55-alpha",
|
|
4
4
|
"description": "An accessible map component",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -53,9 +53,6 @@
|
|
|
53
53
|
"./plugins/map-key": {
|
|
54
54
|
"import": "./plugins/map-key/dist/esm/index.js"
|
|
55
55
|
},
|
|
56
|
-
"./plugins/datasets/adapters/maplibre": {
|
|
57
|
-
"import": "./plugins/datasets/dist/adapters/maplibre/esm/index.js"
|
|
58
|
-
},
|
|
59
56
|
"./plugins/map-styles": {
|
|
60
57
|
"import": "./plugins/beta/map-styles/dist/esm/index.js",
|
|
61
58
|
"require": "./plugins/beta/map-styles/dist/umd/index.js"
|
|
@@ -76,7 +73,6 @@
|
|
|
76
73
|
"require": "./plugins/beta/frame/dist/umd/index.js"
|
|
77
74
|
},
|
|
78
75
|
"./css": "./dist/css/index.css",
|
|
79
|
-
"./plugins/draw-ml/css": "./plugins/beta/draw-ml/dist/css/index.css",
|
|
80
76
|
"./plugins/draw/css": "./plugins/draw/dist/css/index.css",
|
|
81
77
|
"./plugins/scale-bar/css": "./plugins/beta/scale-bar/dist/css/index.css",
|
|
82
78
|
"./plugins/datasets/css": "./plugins/datasets/dist/css/index.css",
|
|
@@ -85,7 +81,6 @@
|
|
|
85
81
|
"./plugins/frame/css": "./plugins/beta/frame/dist/css/index.css",
|
|
86
82
|
"./plugins/map-styles/css": "./plugins/beta/map-styles/dist/css/index.css",
|
|
87
83
|
"./plugins/search/css": "./plugins/search/dist/css/index.css",
|
|
88
|
-
"./plugins/interact/css": "./plugins/interact/dist/css/index.css",
|
|
89
84
|
"./providers/esri/css": "./providers/beta/esri/dist/css/index.css"
|
|
90
85
|
},
|
|
91
86
|
"type": "module",
|
|
@@ -177,6 +172,7 @@
|
|
|
177
172
|
"@types/react": "^19.1.8",
|
|
178
173
|
"@types/react-dom": "^19.1.6",
|
|
179
174
|
"babel-loader": "^10.0.0",
|
|
175
|
+
"babel-plugin-transform-import-meta": "^3.0.0",
|
|
180
176
|
"compression-webpack-plugin": "^12.0.0",
|
|
181
177
|
"copy-webpack-plugin": "^13.0.1",
|
|
182
178
|
"css-loader": "^7.1.2",
|
|
@@ -248,7 +244,7 @@
|
|
|
248
244
|
"@turf/union": "^7.3.5",
|
|
249
245
|
"accessible-autocomplete": "^3.0.1",
|
|
250
246
|
"govuk-frontend": "^5.13.0",
|
|
251
|
-
"maplibre-gl": "^
|
|
247
|
+
"maplibre-gl": "^6.14.0",
|
|
252
248
|
"polygon-splitter": "^0.0.11",
|
|
253
249
|
"preact": "^10.27.2",
|
|
254
250
|
"tslib": "^2.8.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import{useEffect as t}from"preact/compat";import r from"@arcgis/core/widgets/Sketch/SketchViewModel.js";import a from"@arcgis/core/layers/GraphicsLayer.js";import o from"@babel/runtime/helpers/asyncToGenerator";import*as n from"@arcgis/core/geometry/operators/simplifyOperator.js";import i from"@arcgis/core/Graphic.js";function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function l(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?p(Object(a),!0).forEach(function(r){e(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):p(Object(a)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))})}return t}var c={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_SET_APPLICATION_MODE:"app:setapplicationmode",APP_CLEAR_APPLICATION_MODE:"app:clearapplicationmode",APP_SHOW_HINT:"app:showhint",APP_DISMISS_HINT:"app:dismisshint",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_SPATIAL_LIST:"map:setspatiallist",MAP_SET_SPATIAL_LIST_SUPPRESSED:"map:setspatiallistsuppressed",MAP_SET_ACTIVE_ITEM:"map:setactiveitem",MAP_SELECT_ITEM:"map:selectitem",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"},s="[interactive-map]",u=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return console.warn(s,...t)},d=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return console.error(s,...t)};function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function y(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?m(Object(a),!0).forEach(function(r){e(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):m(Object(a)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))})}return t}function v(e){return{type:"simple-fill",color:[0,120,255,.2],style:"none",outline:{color:"dark"===e?"#ffffff":"#d4351c",width:2}}}function E(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},{simplify:o=!0,allowHoles:p=!1}=a,l=new i({geometry:{type:"polygon",rings:t,spatialReference:27700},attributes:{id:e},symbol:v(r)});return o||!1===p?((e,t)=>{var{simplify:r=!0,allowHoles:a=!1}=t;return!r||n.isSimple(e.geometry)||(u("Feature geometry is not simple, attempting to simplify"),e.geometry=n.execute(e.geometry),n.isSimple(e.geometry))?!1===a&&(null==e?void 0:e.geometry.rings.length)>1?(d("Feature contains multiple polygons, which are not supported."),null):e:(d("Failed to simplify geometry, cannot add feature"),null)})(l,a):l}function g(e){if(null==e||!e.geometry)throw new Error("Invalid graphic");var{geometry:t,attributes:r={}}=e;switch(t.type){case"point":return{type:"Feature",geometry:{type:"Point",coordinates:[t.x,t.y]},properties:y({},r)};case"polyline":return{type:"Feature",geometry:{type:"LineString",coordinates:t.paths[0]},properties:y({},r)};case"polygon":return{type:"Feature",geometry:{type:"Polygon",coordinates:t.rings},properties:y({},r)};default:throw new Error("Unsupported geometry type: ".concat(t.type))}}var h=(e,t)=>{var{top:r,right:a,bottom:o,left:n}=e.padding,i=e.extent.clone(),{resolution:p}=e;i.xmin-=n*p,i.xmax+=a*p,i.ymin-=o*p,i.ymax+=r*p;var l={top:0,right:0,bottom:0,left:0};e.padding=l,e.extent=i,t({type:"SET_SAFE_ZONE_INSET",payload:{safeZoneInset:l,syncMapPadding:!1}})};function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function P(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?f(Object(a),!0).forEach(function(r){e(t,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):f(Object(a)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))})}return t}var _={mobile:{slot:"actions",showLabel:!0},tablet:{slot:"actions",showLabel:!0},desktop:{slot:"actions",showLabel:!0}},S={reducer:{initialState:{mode:null,feature:null,featureId:null,tempFeature:null},actions:{SET_MODE:(e,t)=>{var r=t?e.featureId:null;return l(l({},e),{},{featureId:r,mode:t})},SET_FEATURE:(e,t)=>l(l({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature}),SET_FEATURE_ID:(e,t)=>l(l({},e),{},{featureId:t})}},InitComponent:e=>{var{appState:i,mapState:p,pluginConfig:l,pluginState:s,services:u,mapProvider:d,buttonConfig:m}=e,{eventBus:y}=u,{mapColorScheme:h}=p.mapStyle||{},f=p.isMapReady;t(()=>{if(f&&!d.sketchViewModel){var{sketchViewModel:e,sketchLayer:t,emptySketchLayer:o}=(e=>{var{mapProvider:t}=e,{view:o}=t,n=new a({id:"sketchLayer"});o.map.add(n);var i=new a({id:"emptySketchLayer"});return o.map.add(i),{sketchViewModel:new r({view:o,layer:i,defaultUpdateOptions:{tool:"reshape",updateOnGraphicClick:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,highlightOptions:{enabled:!1}}}),emptySketchLayer:i,sketchLayer:n}})({mapProvider:d});return d.sketchViewModel=e,d.sketchLayer=t,d.emptySketchLayer=o,y.emit("draw:ready"),()=>{d.sketchViewModel=null,d.sketchLayer=null,d.emptySketchLayer=null}}},[p.isMapReady]),t(()=>{if(f&&d.sketchViewModel){var e=function(e){var{pluginState:t,mapProvider:r,events:a,eventBus:i,buttonConfig:p,mapColorScheme:l}=e,{view:c,sketchViewModel:s,sketchLayer:u,emptySketchLayer:d}=r;if(!s)return null;var{drawDone:m,drawCancel:y}=p,{dispatch:h,mode:f,feature:P}=t,_=function(){var e=o(function*(){var e,r=null===(e=t.feature)||void 0===e||null===(e=e.properties)||void 0===e?void 0:e.id,a=null,o="active"===s.state&&!r;if("active"===s.state&&r&&(s.cancel(),yield new Promise(e=>setTimeout(e,50))),s.polygonSymbol=v(l),null==u||u.graphics.items.forEach(e=>{var t=E(e.attributes.id,e.geometry.rings,l);t&&(e.symbol=t.symbol),r===e.attributes.id&&(a=e)}),a&&!o&&s.layer===u)try{yield s.update(a,{tool:"reshape",toggleToolOnClick:!1})}catch(e){"AbortError"!==e.name&&console.error("Error updating sketch:",e)}});return function(){return e.apply(this,arguments)}}(),S=()=>{var e,t,r=null!==(e=null===(t=u.graphics)||void 0===t||null===(t=t.items)||void 0===t?void 0:t[0])&&void 0!==e?e:null;r&&setTimeout(()=>s.update(r),0)},A=()=>_(),O=e=>{if(e){var t=g(e);i.emit("draw:updated",t),h({type:"SET_FEATURE",payload:{tempFeature:t}})}},T=function(){var e=o(function*(){f&&((s.updateGraphics||[]).length||S())});return function(){return e.apply(this,arguments)}}(),b=function(){var e=o(function*(e){var{toolEventInfo:t}=e,r=null==e?void 0:e.graphic;if(r&&"vertex-add"===(null==t?void 0:t.type)){var a,o,n=null===(a=r.geometry)||void 0===a?void 0:a.rings;(null==n?void 0:n.length)>1?setTimeout(()=>s.undo(),0):(null==n||null===(o=n[0])||void 0===o?void 0:o.length)>3&&O(r)}});return function(t){return e.apply(this,arguments)}}(),w=function(){var e=o(function*(e){var t,r=null==e||null===(t=e.graphics)||void 0===t?void 0:t[0];O(r)});return function(t){return e.apply(this,arguments)}}(),M=e=>{var r=E(e.id||e.properties.id||t.featureId,e.geometry.coordinates,l);r&&u.add(r)};i.on(a.MAP_STYLE_CHANGE,A);var k=s.on("update",e=>{var t,r=null===(t=e.toolEventInfo)||void 0===t?void 0:t.type,a=e.graphics[0];"move-start"===r&&(s.cancel(),S()),"reshape-stop"===r&&(n.isSimple(a.geometry)&&1===a.geometry.rings.length||s.undo()),"reshape-stop"!==r&&"vertex-remove"!==r||O(a)}),D=c.on("click",T),L=s.on("create",b),C=s.on("undo",w),I=m.onClick,j=y.onClick;return m.onClick=()=>{var e;null!=s&&null!==(e=s.layer)&&void 0!==e&&null!==(e=e.graphics)&&void 0!==e&&null!==(e=e.items)&&void 0!==e&&e.length||M(t.tempFeature),s.cancel(),s.layer=d,h({type:"SET_MODE",payload:null}),h({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),i.emit("draw:done",{newFeature:t.tempFeature})},y.onClick=()=>{s.cancel(),u.removeAll(),P&&M(P),s.layer=d,h({type:"SET_MODE",payload:null}),i.emit("draw:cancelled")},()=>{i.off(a.MAP_STYLE_CHANGE,A),k.remove(),D.remove(),L.remove(),C.remove(),m.onClick=I,y.onClick=j}}({pluginState:s,mapProvider:d,events:c,eventBus:y,buttonConfig:m,mapColorScheme:h});return()=>{e()}}},[f,h,s])},buttons:[P({id:"drawDone",label:"Done",variant:"primary",hiddenWhen:e=>{var{pluginState:t}=e;return!t.mode},enableWhen:e=>{var{pluginState:t}=e;return!!t.tempFeature}},_),P({id:"drawCancel",label:"Cancel",variant:"tertiary",hiddenWhen:e=>{var{pluginState:t}=e;return!t.mode}},_)],api:{newPolygon:(e,t)=>{var{appState:r,mapState:a,pluginState:o,mapProvider:n,services:i}=e,{dispatch:p}=o,{sketchViewModel:l,sketchLayer:c,view:s}=n,{eventBus:u}=i;l.layer=c,h(s,r.dispatch);var d=l.on("create",e=>{if("complete"===e.state){e.graphic.attributes={id:t},requestAnimationFrame(()=>{l.update(e.graphic,{tool:"reshape",toggleToolOnClick:!1})});var r=g(e.graphic);u.emit("draw:created",r),p({type:"SET_FEATURE",payload:{tempFeature:r}}),d.remove()}});l.polygonSymbol=v(a.mapStyle.mapColorScheme),l.create("polygon"),p({type:"SET_MODE",payload:"new-polygon"}),p({type:"SET_FEATURE_ID",payload:t})},editFeature:(e,t)=>{var{appState:r,pluginState:a,mapProvider:o}=e,{dispatch:n}=a,{sketchViewModel:i,sketchLayer:p,view:l}=o,c=p.graphics.items.find(e=>e.attributes.id===t),s=c.geometry.extent.clone();h(l,r.dispatch),s.expand(2),l.goTo(s),i.layer=p,i.update(c,{tool:"reshape",toggleToolOnClick:!1,enableRotation:!1,enableScaling:!1}),n({type:"SET_FEATURE",payload:{feature:g(c)}}),n({type:"SET_MODE",payload:"edit-feature"})},addFeature:function(e,t){var{pluginState:r,mapState:a,mapProvider:o,services:n}=e,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{dispatch:p}=r,{mapStyle:l}=a,{sketchViewModel:c,sketchLayer:s,emptySketchLayer:u}=o,{eventBus:d}=n,m=E(t.id,t.geometry.coordinates,l.mapColorScheme,i),y={success:!0};return m?(s.add(m),c.layer=u,p({type:"SET_FEATURE",payload:{feature:t}}),d.emit("draw:add",t),y):(y.success=!1,y)},deleteFeature:(e,t)=>{var{pluginState:r,mapProvider:a,services:o}=e,{dispatch:n}=r,{sketchViewModel:i,sketchLayer:p,emptySketchLayer:l}=a,{eventBus:c}=o,s=p.graphics.items.find(e=>e.attributes.id===t);i.cancel(),p.remove(s),i.layer=l,n({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),c.emit("draw:delete",{featureId:t}),n({type:"SET_MODE",payload:null})}}};export{S as manifest};
|
|
1
|
+
import{useEffect as e}from"preact/compat";import t from"@arcgis/core/widgets/Sketch/SketchViewModel.js";import a from"@arcgis/core/layers/GraphicsLayer.js";import*as o from"@arcgis/core/geometry/operators/simplifyOperator.js";import r from"@arcgis/core/Graphic.js";const n={MAP_STYLE_CHANGE:"map:stylechange"},i="[interactive-map]",l=(...e)=>console.warn(i,...e),p=(...e)=>console.error(i,...e);function s(e){return{type:"simple-fill",color:[0,120,255,.2],style:"none",outline:{color:"dark"===e?"#ffffff":"#d4351c",width:2}}}function c(e,t,a,n={}){const{simplify:i=!0,allowHoles:c=!1}=n,d=new r({geometry:{type:"polygon",rings:t,spatialReference:27700},attributes:{id:e},symbol:s(a)});return i||!1===c?((e,{simplify:t=!0,allowHoles:a=!1})=>!t||o.isSimple(e.geometry)||(l("Feature geometry is not simple, attempting to simplify"),e.geometry=o.execute(e.geometry),o.isSimple(e.geometry))?!1===a&&e?.geometry.rings.length>1?(p("Feature contains multiple polygons, which are not supported."),null):e:(p("Failed to simplify geometry, cannot add feature"),null))(d,n):d}function d(e){if(!e?.geometry)throw new Error("Invalid graphic");const{geometry:t,attributes:a={}}=e;switch(t.type){case"point":return{type:"Feature",geometry:{type:"Point",coordinates:[t.x,t.y]},properties:{...a}};case"polyline":return{type:"Feature",geometry:{type:"LineString",coordinates:t.paths[0]},properties:{...a}};case"polygon":return{type:"Feature",geometry:{type:"Polygon",coordinates:t.rings},properties:{...a}};default:throw new Error(`Unsupported geometry type: ${t.type}`)}}function m({pluginState:e,mapProvider:t,events:a,eventBus:r,buttonConfig:n,mapColorScheme:i}){const{view:l,sketchViewModel:p,sketchLayer:m,emptySketchLayer:y}=t;if(!p)return null;const{drawDone:u,drawCancel:g}=n,{dispatch:h,mode:f,feature:S}=e,E=()=>{const e=m.graphics?.items?.[0]??null;e&&setTimeout(()=>p.update(e),0)},w=()=>(async()=>{const t=e.feature?.properties?.id;let a=null;const o="active"===p.state&&!t;if("active"===p.state&&t&&(p.cancel(),await new Promise(e=>setTimeout(e,50))),p.polygonSymbol=s(i),m?.graphics.items.forEach(e=>{const o=c(e.attributes.id,e.geometry.rings,i);o&&(e.symbol=o.symbol),t===e.attributes.id&&(a=e)}),a&&!o&&p.layer===m)try{await p.update(a,{tool:"reshape",toggleToolOnClick:!1})}catch(e){"AbortError"!==e.name&&console.error("Error updating sketch:",e)}})(),v=e=>{if(!e)return;const t=d(e);r.emit("draw:updated",t),h({type:"SET_FEATURE",payload:{tempFeature:t}})},k=t=>{const a=c(t.id||t.properties.id||e.featureId,t.geometry.coordinates,i);a&&m.add(a)};r.on(a.MAP_STYLE_CHANGE,w);const T=p.on("update",e=>{const t=e.toolEventInfo?.type,a=e.graphics[0];if("move-start"===t&&(p.cancel(),E()),"reshape-stop"===t){o.isSimple(a.geometry)&&1===a.geometry.rings.length||p.undo()}"reshape-stop"!==t&&"vertex-remove"!==t||v(a)}),F=l.on("click",async()=>{if(!f)return;(p.updateGraphics||[]).length||E()}),b=p.on("create",async e=>{const{toolEventInfo:t}=e,a=e?.graphic;if(a&&"vertex-add"===t?.type){const e=a.geometry?.rings;e?.length>1?setTimeout(()=>p.undo(),0):e?.[0]?.length>3&&v(a)}}),C=p.on("undo",async e=>{const t=e?.graphics?.[0];v(t)}),L=u.onClick,_=g.onClick;return u.onClick=()=>{p?.layer?.graphics?.items?.length||k(e.tempFeature),p.cancel(),p.layer=y,h({type:"SET_MODE",payload:null}),h({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),r.emit("draw:done",{newFeature:e.tempFeature})},g.onClick=()=>{p.cancel(),m.removeAll(),S&&k(S),p.layer=y,h({type:"SET_MODE",payload:null}),r.emit("draw:cancelled")},()=>{r.off(a.MAP_STYLE_CHANGE,w),T.remove(),F.remove(),b.remove(),C.remove(),u.onClick=L,g.onClick=_}}const y=(e,t)=>{const{top:a,right:o,bottom:r,left:n}=e.padding,i=e.extent.clone(),{resolution:l}=e;i.xmin-=n*l,i.xmax+=o*l,i.ymin-=r*l,i.ymax+=a*l;const p={top:0,right:0,bottom:0,left:0};e.padding=p,e.extent=i,t({type:"SET_SAFE_ZONE_INSET",payload:{safeZoneInset:p,syncMapPadding:!1}})},u={mobile:{slot:"actions",showLabel:!0},tablet:{slot:"actions",showLabel:!0},desktop:{slot:"actions",showLabel:!0}},g={reducer:{initialState:{mode:null,feature:null,featureId:null,tempFeature:null},actions:{SET_MODE:(e,t)=>{const a=t?e.featureId:null;return{...e,featureId:a,mode:t}},SET_FEATURE:(e,t)=>({...e,feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature}),SET_FEATURE_ID:(e,t)=>({...e,featureId:t})}},InitComponent:({appState:o,mapState:r,pluginConfig:i,pluginState:l,services:p,mapProvider:s,buttonConfig:c})=>{const{eventBus:d}=p,{mapColorScheme:y}=r.mapStyle||{},u=r.isMapReady;e(()=>{if(!u||s.sketchViewModel)return;const{sketchViewModel:e,sketchLayer:o,emptySketchLayer:r}=(({mapProvider:e})=>{const{view:o}=e,r=new a({id:"sketchLayer"});o.map.add(r);const n=new a({id:"emptySketchLayer"});return o.map.add(n),{sketchViewModel:new t({view:o,layer:n,defaultUpdateOptions:{tool:"reshape",updateOnGraphicClick:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,highlightOptions:{enabled:!1}}}),emptySketchLayer:n,sketchLayer:r}})({mapProvider:s});return s.sketchViewModel=e,s.sketchLayer=o,s.emptySketchLayer=r,d.emit("draw:ready"),()=>{s.sketchViewModel=null,s.sketchLayer=null,s.emptySketchLayer=null}},[r.isMapReady]),e(()=>{if(!u||!s.sketchViewModel)return;const e=m({pluginState:l,mapProvider:s,events:n,eventBus:d,buttonConfig:c,mapColorScheme:y});return()=>{e()}},[u,y,l])},buttons:[{id:"drawDone",label:"Done",variant:"primary",hiddenWhen:({pluginState:e})=>!e.mode,enableWhen:({pluginState:e})=>!!e.tempFeature,...u},{id:"drawCancel",label:"Cancel",variant:"tertiary",hiddenWhen:({pluginState:e})=>!e.mode,...u}],api:{newPolygon:({appState:e,mapState:t,pluginState:a,mapProvider:o,services:r},n)=>{const{dispatch:i}=a,{sketchViewModel:l,sketchLayer:p,view:c}=o,{eventBus:m}=r;l.layer=p,y(c,e.dispatch);const u=l.on("create",e=>{if("complete"===e.state){e.graphic.attributes={id:n},requestAnimationFrame(()=>{l.update(e.graphic,{tool:"reshape",toggleToolOnClick:!1})});const t=d(e.graphic);m.emit("draw:created",t),i({type:"SET_FEATURE",payload:{tempFeature:t}}),u.remove()}});l.polygonSymbol=s(t.mapStyle.mapColorScheme),l.create("polygon"),i({type:"SET_MODE",payload:"new-polygon"}),i({type:"SET_FEATURE_ID",payload:n})},editFeature:({appState:e,pluginState:t,mapProvider:a},o)=>{const{dispatch:r}=t,{sketchViewModel:n,sketchLayer:i,view:l}=a,p=i.graphics.items.find(e=>e.attributes.id===o),s=p.geometry.extent.clone();y(l,e.dispatch),s.expand(2),l.goTo(s),n.layer=i,n.update(p,{tool:"reshape",toggleToolOnClick:!1,enableRotation:!1,enableScaling:!1});r({type:"SET_FEATURE",payload:{feature:d(p)}}),r({type:"SET_MODE",payload:"edit-feature"})},addFeature:({pluginState:e,mapState:t,mapProvider:a,services:o},r,n={})=>{const{dispatch:i}=e,{mapStyle:l}=t,{sketchViewModel:p,sketchLayer:s,emptySketchLayer:d}=a,{eventBus:m}=o,y=c(r.id,r.geometry.coordinates,l.mapColorScheme,n),u={success:!0};return y?(s.add(y),p.layer=d,i({type:"SET_FEATURE",payload:{feature:r}}),m.emit("draw:add",r),u):(u.success=!1,u)},deleteFeature:({pluginState:e,mapProvider:t,services:a},o)=>{const{dispatch:r}=e,{sketchViewModel:n,sketchLayer:i,emptySketchLayer:l}=t,{eventBus:p}=a,s=i.graphics.items.find(e=>e.attributes.id===o);n.cancel(),i.remove(s),n.layer=l,r({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),p.emit("draw:delete",{featureId:o}),r({type:"SET_MODE",payload:null})}}};export{g as manifest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/defineProperty";function
|
|
1
|
+
import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/regenerator";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach(function(t){r(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function i(){var r;return o(o({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(r=e(t.mark(function e(){var r;return t.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,import(/* webpackChunkName: "im-draw-es-plugin" */ "./im-draw-es-plugin.js");case 1:return r=e.sent.manifest,e.abrupt("return",r);case 2:case"end":return e.stop()}},e)})),function(){return r.apply(this,arguments)})})}export{i as default};
|