@defra/interactive-map 0.0.19-alpha → 0.0.21-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.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/im-shell.js +1 -1
  3. package/dist/umd/index.js +1 -1
  4. package/docs/api/button-definition.md +22 -5
  5. package/docs/api/map-style-config.md +2 -11
  6. package/docs/api/marker-config.md +19 -5
  7. package/docs/api.md +75 -46
  8. package/docs/architecture.md +0 -2
  9. package/{assets → docs/assets}/css/docusaurus.css +78 -1
  10. package/docs/assets/images/basic-map.jpg +0 -0
  11. package/docs/assets/images/button-first.jpg +0 -0
  12. package/{assets → docs/assets}/images/hero.png +0 -0
  13. package/docs/assets/images/marker-panel.jpg +0 -0
  14. package/docs/examples/add-marker-with-panel.mdx +112 -48
  15. package/docs/examples/basic-map.mdx +43 -14
  16. package/docs/examples/button-map.mdx +43 -14
  17. package/docs/examples/index.mdx +5 -5
  18. package/docs/getting-started.md +80 -53
  19. package/docs/plugins/datasets.md +11 -11
  20. package/docusaurus.config.cjs +5 -4
  21. package/package.json +7 -3
  22. package/plugins/beta/datasets/adapters/maplibre/dist/esm/im-datasets-ml-adapter.js +1 -0
  23. package/plugins/beta/datasets/adapters/maplibre/dist/esm/index.js +1 -0
  24. package/plugins/beta/datasets/adapters/maplibre/dist/umd/im-datasets-ml-adapter.js +2 -0
  25. package/plugins/beta/datasets/adapters/maplibre/dist/umd/im-datasets-ml-adapter.js.LICENSE.txt +1 -0
  26. package/plugins/beta/datasets/adapters/maplibre/dist/umd/index.js +1 -0
  27. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
  28. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
  29. package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +4 -4
  30. package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +26 -7
  31. package/plugins/beta/datasets/src/defaults.js +1 -1
  32. package/plugins/beta/datasets/src/manifest.js +1 -1
  33. package/plugins/beta/datasets/src/panels/Layers.jsx +4 -4
  34. package/plugins/beta/datasets/src/utils/mergeSublayer.js +1 -1
  35. package/plugins/beta/draw-ml/dist/css/index.css +19 -2
  36. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  37. package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
  38. package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
  39. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  40. package/providers/maplibre/src/maplibreProvider.js +5 -3
  41. package/providers/maplibre/src/maplibreProvider.test.js +44 -2
  42. package/providers/maplibre/src/utils/patternImages.js +16 -10
  43. package/providers/maplibre/src/utils/patternImages.test.js +50 -19
  44. package/rollup.esm.mjs +9 -0
  45. package/src/InteractiveMap/InteractiveMap.js +2 -2
  46. package/src/InteractiveMap/InteractiveMap.test.js +4 -4
  47. package/src/services/eventBus.js +61 -0
  48. package/src/services/eventBus.test.js +70 -0
  49. package/src/utils/patternUtils.js +8 -3
  50. package/src/utils/patternUtils.test.js +17 -0
  51. package/webpack.umd.mjs +1 -0
  52. package/docs/assets/basic-map.jpg +0 -0
  53. package/docs/assets/button-first.jpg +0 -0
  54. package/docs/assets/maker-panel.jpg +0 -0
  55. /package/docs/assets/{screens-blue.jpg → images/screens-blue.jpg} +0 -0
  56. /package/docs/assets/{screens-white.jpg → images/screens-white.jpg} +0 -0
  57. /package/{assets → docs/assets}/images/slot-map.svg +0 -0
@@ -1,4 +1,5 @@
1
1
  import DemoMapBasic from '../../demo/DemoMapBasic.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
2
3
 
3
4
  # Basic map
4
5
 
@@ -6,19 +7,47 @@ Embed an interactive map directly on the page, allowing users to explore and int
6
7
 
7
8
  <DemoMapBasic />
8
9
 
9
- ```js
10
- import InteractiveMap from '@defra/interactive-map'
11
- import maplibreProvider from '@defra/interactive-map/providers/maplibre'
10
+ <CodeTabs tabs={[
11
+ {
12
+ label: 'ESM',
13
+ language: 'js',
14
+ code: `
15
+ import InteractiveMap from '@defra/interactive-map'
16
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
12
17
 
13
- new InteractiveMap('my-map', {
14
- behaviour: 'inline',
15
- mapProvider: maplibreProvider(),
16
- mapStyle: {
17
- url: 'https://your-tile-url/style.json',
18
- attribution: 'Your tile attribution'
18
+ new InteractiveMap('my-map', {
19
+ behaviour: 'inline',
20
+ mapProvider: maplibreProvider(),
21
+ mapStyle: {
22
+ url: 'https://your-tile-url/style.json',
23
+ attribution: 'Your tile attribution'
24
+ },
25
+ center: [-1.6, 53.1],
26
+ zoom: 6,
27
+ containerHeight: '500px'
28
+ })
29
+ `
19
30
  },
20
- center: [-1.6, 53.1],
21
- zoom: 6,
22
- containerHeight: '500px'
23
- })
24
- ```
31
+ {
32
+ label: 'UMD',
33
+ language: 'html',
34
+ code: `
35
+ <script src="/your-assets-path/interactive-map/index.js"></script>
36
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
37
+
38
+ <script>
39
+ new defra.InteractiveMap('my-map', {
40
+ behaviour: 'inline',
41
+ mapProvider: defra.maplibreProvider(),
42
+ mapStyle: {
43
+ url: 'https://your-tile-url/style.json',
44
+ attribution: 'Your tile attribution'
45
+ },
46
+ center: [-1.6, 53.1],
47
+ zoom: 6,
48
+ containerHeight: '500px'
49
+ })
50
+ </script>
51
+ `
52
+ }
53
+ ]} />
@@ -1,4 +1,5 @@
1
1
  import DemoMapButton from '../../demo/DemoMapButton.js'
2
+ import CodeTabs from '../../demo/js/codeTabs.js'
2
3
 
3
4
  # Button-triggered map
4
5
 
@@ -6,19 +7,47 @@ Trigger the map to show on button press, allowing users to access the map when n
6
7
 
7
8
  <DemoMapButton />
8
9
 
9
- ```js
10
- import InteractiveMap from '@defra/interactive-map'
11
- import maplibreProvider from '@defra/interactive-map/providers/maplibre'
10
+ <CodeTabs tabs={[
11
+ {
12
+ label: 'ESM',
13
+ language: 'js',
14
+ code: `
15
+ import InteractiveMap from '@defra/interactive-map'
16
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
12
17
 
13
- new InteractiveMap('my-map', {
14
- behaviour: 'buttonFirst',
15
- mapProvider: maplibreProvider(),
16
- mapStyle: {
17
- url: 'https://your-tile-url/style.json',
18
- attribution: 'Your tile attribution'
18
+ new InteractiveMap('my-map', {
19
+ behaviour: 'buttonFirst',
20
+ mapProvider: maplibreProvider(),
21
+ mapStyle: {
22
+ url: 'https://your-tile-url/style.json',
23
+ attribution: 'Your tile attribution'
24
+ },
25
+ center: [-1.6, 53.1],
26
+ zoom: 6,
27
+ hasExitButton: true
28
+ })
29
+ `
19
30
  },
20
- center: [-1.6, 53.1],
21
- zoom: 6,
22
- hasExitButton: true
23
- })
24
- ```
31
+ {
32
+ label: 'UMD',
33
+ language: 'html',
34
+ code: `
35
+ <script src="/your-assets-path/interactive-map/index.js"></script>
36
+ <script src="/your-assets-path/maplibre-provider/index.js"></script>
37
+
38
+ <script>
39
+ new defra.InteractiveMap('my-map', {
40
+ behaviour: 'buttonFirst',
41
+ mapProvider: defra.maplibreProvider(),
42
+ mapStyle: {
43
+ url: 'https://your-tile-url/style.json',
44
+ attribution: 'Your tile attribution'
45
+ },
46
+ center: [-1.6, 53.1],
47
+ zoom: 6,
48
+ hasExitButton: true
49
+ })
50
+ </script>
51
+ `
52
+ }
53
+ ]} />
@@ -1,7 +1,7 @@
1
1
  import useBaseUrl from '@docusaurus/useBaseUrl'
2
- import basicMapImg from '../assets/basic-map.jpg'
3
- import buttonFirstImg from '../assets/button-first.jpg'
4
- import makerPanelImg from '../assets/maker-panel.jpg'
2
+ import basicMapImg from '../assets/images/basic-map.jpg'
3
+ import buttonFirstImg from '../assets/images/button-first.jpg'
4
+ import markerPanelImg from '../assets/images/marker-panel.jpg'
5
5
 
6
6
  export function ExampleCards() {
7
7
  const basicHref = useBaseUrl('/examples/basic-map')
@@ -32,8 +32,8 @@ export function ExampleCards() {
32
32
  </div>
33
33
  <div className='govuk-grid-column-one-half'>
34
34
  <div className='app-example-card'>
35
- <img src={makerPanelImg} alt='' />
36
- <div className='app-example-card__body' style={{ 'border-top': '1px solid #cecece'}}>
35
+ <img src={markerPanelImg} alt='' />
36
+ <div className='app-example-card__body'>
37
37
  <h2 className='govuk-heading-m'>
38
38
  <a href={interactHref}>Add a marker with a panel</a>
39
39
  </h2>
@@ -3,62 +3,61 @@
3
3
  ## Installation
4
4
 
5
5
  ```shell
6
- npm i @defra/interactive-map@x.y.z-alpha
6
+ npm install @defra/interactive-map@x.y.z-alpha
7
7
  ```
8
8
 
9
- [!NOTE]
10
- Install using a fixed version (e.g. npm install @defra/interactive-map@x.y.z-alpha) as this package is currently in alpha and may introduce breaking changes. Check the GitHub releases page for the latest available [version](https://github.com/DEFRA/interactive-map/tags).
9
+ > [!NOTE]
10
+ Install using a fixed version (e.g. `npm install @defra/interactive-map@x.y.z-alpha`) as this package is currently in alpha and may introduce breaking changes. Check the GitHub releases page for the latest available [version](https://github.com/DEFRA/interactive-map/tags).
11
11
 
12
- ### MapLibre provider (recommended)
12
+ ## GOV.UK Prototype kit
13
13
 
14
- **ESM:** `maplibre-gl` is a peer dependency, install it separately:
14
+ The quickest way to get started is via the GOV.UK Prototype Kit. Once installed, the map component is available immediately — no build step or manual asset setup required.
15
15
 
16
- ```shell
17
- npm i maplibre-gl
18
- ```
16
+ The plugin automatically serves the required scripts and styles, and provides a ready-made map page template to build from.
19
17
 
20
- **UMD:** `maplibre-gl` is bundled no separate install needed.
18
+ See [GOV.UK Prototype Kit - Install and use plugins](https://prototype-kit.service.gov.uk/docs/install-and-use-plugins) for how to install plugins.
21
19
 
22
- ### ESRI provider (optional)
20
+ ## Manual setup
23
21
 
24
- If you are using the ESRI map provider instead, install `@arcgis/core`:
22
+ The package is distributed in two formats:
25
23
 
26
- ```shell
27
- npm i @arcgis/core
28
- ```
24
+ - **ESM** (ECMAScript Modules) — for projects using a bundler such as Webpack or Rollup. Import directly from the package in your JavaScript.
25
+ - **UMD** (Universal Module Definition) — for projects without a bundler. Copy the built files to your assets and load them via `<script>` tags.
29
26
 
30
- ### Include in your project
27
+ The map component also requires a **map provider** — a separate library that handles the underlying tile rendering engine. The provider is passed in at initialisation, which keeps the core package lean and lets you choose the engine that fits your needs.
31
28
 
32
- **ESM** import in your JavaScript:
29
+ ### MapLibre provider (recommended)
33
30
 
34
- ```js
35
- import InteractiveMap from '@defra/interactive-map'
36
- import maplibreProvider from '@defra/interactive-map/providers/maplibre'
31
+ **ESM:** `maplibre-gl` is a peer dependency, install it separately:
37
32
 
38
- import '@defra/interactive-map/css'
33
+ ```shell
34
+ npm install maplibre-gl
39
35
  ```
40
36
 
41
- **UMD** — copy the `dist/umd/` folders to your assets and include via script and link tags in your `<head>`:
37
+ **UMD:** `maplibre-gl` is bundled no separate install needed.
38
+
39
+ ### ESRI provider (optional)
42
40
 
43
- ```html
44
- <link rel="stylesheet" href="/assets/interactive-map.css">
45
- <script defer src="/assets/interactive-map/index.js"></script>
46
- <script defer src="/assets/maplibre-provider/index.js"></script>
47
- ```
41
+ The ESRI provider is available for ESM projects only. Install `@arcgis/core` separately:
48
42
 
49
- > Chunks are loaded dynamically — all files in each `umd/` folder must be served from the same directory as their `index.js`.
43
+ ```shell
44
+ npm install @arcgis/core
45
+ ```
50
46
 
51
47
  ## Basic usage
52
48
 
53
- Add a container element in your HTML:
49
+ **ESM** — add a container element to your HTML and initialise the map in your JavaScript:
54
50
 
55
51
  ```html
56
52
  <div id="map"></div>
57
53
  ```
58
54
 
59
- Initialise the map in your JavaScript. UMD users replace `InteractiveMap` and `maplibreProvider` with `defra.InteractiveMap` and `defra.maplibreProvider`:
60
-
61
55
  ```js
56
+ import InteractiveMap from '@defra/interactive-map'
57
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre'
58
+
59
+ import '@defra/interactive-map/css'
60
+
62
61
  const interactiveMap = new InteractiveMap('map', {
63
62
  mapProvider: maplibreProvider(),
64
63
  behaviour: 'hybrid',
@@ -74,44 +73,72 @@ const interactiveMap = new InteractiveMap('map', {
74
73
  })
75
74
  ```
76
75
 
76
+ **UMD** — copy the `dist/umd/` folders to your assets, then use this page skeleton as a starting point:
77
+
78
+ ```html
79
+ <!DOCTYPE html>
80
+ <html lang="en">
81
+ <head>
82
+ <meta charset="UTF-8">
83
+ <title>Map</title>
84
+ <link rel="stylesheet" href="/your-assets-path/interactive-map.css">
85
+ <script defer src="/your-assets-path/interactive-map/index.js"></script>
86
+ <script defer src="/your-assets-path/maplibre-provider/index.js"></script>
87
+ <script defer>
88
+ document.addEventListener('DOMContentLoaded', function () {
89
+ const interactiveMap = new defra.InteractiveMap('map', {
90
+ mapProvider: defra.maplibreProvider(),
91
+ behaviour: 'hybrid',
92
+ mapLabel: 'Ambleside',
93
+ zoom: 14,
94
+ center: [-2.968, 54.425],
95
+ containerHeight: '650px',
96
+ mapStyle: {
97
+ url: 'https://tiles.openfreemap.org/styles/liberty',
98
+ attribution: 'OpenFreeMap © OpenMapTiles Data from OpenStreetMap',
99
+ backgroundColor: '#f5f5f0'
100
+ }
101
+ })
102
+ })
103
+ </script>
104
+ </head>
105
+ <body>
106
+ <div id="map"></div>
107
+ </body>
108
+ </html>
109
+ ```
110
+
111
+ > [!NOTE]
112
+ > Scripts are loaded dynamically — all files in each `umd/` folder must be served from the same directory as their `index.js`.
113
+
77
114
  ## Using plugins
78
115
 
79
- **ESM** — import each plugin and its CSS:
116
+ **ESM** — add the plugin import and its CSS alongside your existing core imports, then pass it to `plugins`:
80
117
 
81
118
  ```js
82
- import createSearchPlugin from '@defra/interactive-map/plugins/search'
83
119
  import createInteractPlugin from '@defra/interactive-map/plugins/interact'
84
-
85
- import '@defra/interactive-map/plugins/search/css'
86
120
  import '@defra/interactive-map/plugins/interact/css'
121
+
122
+ const interactiveMap = new InteractiveMap('map', {
123
+ // ...your existing options
124
+ plugins: [createInteractPlugin()]
125
+ })
87
126
  ```
88
127
 
89
- **UMD** — copy each plugin's `dist/umd/` folder and CSS file to your assets:
128
+ **UMD** — copy the plugin's `dist/umd/` folder to your assets if you haven't already, then add its script and CSS to your page skeleton:
90
129
 
91
130
  ```html
92
- <link rel="stylesheet" href="/assets/search-plugin.css">
93
- <link rel="stylesheet" href="/assets/interact-plugin.css">
94
- <script src="/assets/search-plugin/index.js"></script>
95
- <script src="/assets/interact-plugin/index.js"></script>
131
+ <link rel="stylesheet" href="/your-assets-path/interact-plugin.css">
132
+ <script defer src="/your-assets-path/interact-plugin/index.js"></script>
96
133
  ```
97
134
 
98
- Then pass plugins when initialising. UMD users replace `createSearchPlugin` and `createInteractPlugin` with `defra.searchPlugin` and `defra.interactPlugin`:
135
+ Then pass the plugin in your initialisation:
99
136
 
100
137
  ```js
101
- const interactiveMap = new InteractiveMap('map', {
102
- mapProvider: maplibreProvider(),
103
- plugins: [
104
- createSearchPlugin(),
105
- createInteractPlugin()
106
- ],
107
- // ... other options
138
+ const interactiveMap = new defra.InteractiveMap('map', {
139
+ // ...your existing options
140
+ plugins: [defra.interactPlugin()]
108
141
  })
109
142
  ```
110
143
 
111
144
  Each plugin distributes its own CSS. Import or copy only the CSS for the plugins you use. See [Plugins](./plugins.md) for the full list including their CSS paths.
112
-
113
- ## GOV.UK Prototype kit plugin
114
-
115
- Following installation the InteractiveMap plugin will be added to your prototype. You can now create pages with a map, and configure for specific use cases.
116
-
117
- See [GOV.UK Prototype Kit - Install and use plugins](https://prototype-kit.service.gov.uk/docs/install-and-use-plugins).
@@ -5,8 +5,8 @@ The datasets plugin renders GeoJSON and vector tile datasets on the map, with su
5
5
  ## Usage
6
6
 
7
7
  ```js
8
- import createDatasetsPlugin from '@defra/interactive-map/plugins/beta/datasets'
9
- import { maplibreLayerAdapter } from '@defra/interactive-map/plugins/beta/datasets/adapters/maplibre'
8
+ import createDatasetsPlugin from '@defra/interactive-map/plugins/datasets'
9
+ import { maplibreLayerAdapter } from '@defra/interactive-map/plugins/datasets/adapters/maplibre'
10
10
 
11
11
  const datasetsPlugin = createDatasetsPlugin({
12
12
  layerAdapter: maplibreLayerAdapter,
@@ -18,7 +18,7 @@ const datasetsPlugin = createDatasetsPlugin({
18
18
  minZoom: 10,
19
19
  maxZoom: 24,
20
20
  showInKey: true,
21
- toggleVisibility: true,
21
+ showInMenu: true,
22
22
  style: {
23
23
  stroke: '#d4351c',
24
24
  strokeWidth: 2,
@@ -47,7 +47,7 @@ Options are passed to the factory function when creating the plugin.
47
47
  The map provider adapter responsible for rendering datasets. Import `maplibreLayerAdapter` for MapLibre GL JS, or supply a custom adapter.
48
48
 
49
49
  ```js
50
- import { maplibreLayerAdapter } from '@defra/interactive-map/plugins/beta/datasets/adapters/maplibre'
50
+ import { maplibreLayerAdapter } from '@defra/interactive-map/plugins/datasets/adapters/maplibre'
51
51
  ```
52
52
 
53
53
  ---
@@ -232,7 +232,7 @@ When `true`, the dataset appears in the Key panel with its style symbol and labe
232
232
 
233
233
  ---
234
234
 
235
- ### `toggleVisibility`
235
+ ### `showInMenu`
236
236
 
237
237
  **Type:** `boolean`
238
238
  **Default:** `false`
@@ -353,7 +353,7 @@ Sublayers inherit the parent dataset's style and only override what they specify
353
353
  | `filter` | `FilterExpression` | MapLibre filter expression to match features for this sublayer |
354
354
  | `style` | `Object` | Style overrides. Accepts the same properties as the dataset `style` object |
355
355
  | `showInKey` | `boolean` | Shows this sublayer in the Key panel. Inherits from dataset if not set |
356
- | `toggleVisibility` | `boolean` | Shows this sublayer in the Layers panel. **Default:** `false` |
356
+ | `showInMenu` | `boolean` | Shows this sublayer in the Layers panel. **Default:** `false` |
357
357
 
358
358
  **Polygon/line example:**
359
359
 
@@ -363,7 +363,7 @@ sublayers: [
363
363
  id: 'active',
364
364
  label: 'Active parcels',
365
365
  filter: ['==', ['get', 'status'], 'active'],
366
- toggleVisibility: true,
366
+ showInMenu: true,
367
367
  style: {
368
368
  stroke: '#00703c',
369
369
  fill: 'rgba(0,112,60,0.1)',
@@ -374,7 +374,7 @@ sublayers: [
374
374
  id: 'inactive',
375
375
  label: 'Inactive parcels',
376
376
  filter: ['==', ['get', 'status'], 'inactive'],
377
- toggleVisibility: true,
377
+ showInMenu: true,
378
378
  style: {
379
379
  stroke: '#d4351c',
380
380
  fillPattern: 'diagonal-cross-hatch',
@@ -399,7 +399,7 @@ When the parent dataset has `symbol` set, each sublayer can override individual
399
399
  label: 'Prehistoric sites',
400
400
  filter: ['==', ['get', 'type'], 'prehistoric'],
401
401
  showInKey: true,
402
- toggleVisibility: true,
402
+ showInMenu: true,
403
403
  style: { symbolBackgroundColor: '#0f7a52' }
404
404
  },
405
405
  {
@@ -407,7 +407,7 @@ When the parent dataset has `symbol` set, each sublayer can override individual
407
407
  label: 'Roman sites',
408
408
  filter: ['==', ['get', 'type'], 'roman'],
409
409
  showInKey: true,
410
- toggleVisibility: true,
410
+ showInMenu: true,
411
411
  style: { symbolBackgroundColor: '#54319f' }
412
412
  },
413
413
  {
@@ -415,7 +415,7 @@ When the parent dataset has `symbol` set, each sublayer can override individual
415
415
  label: 'Medieval sites',
416
416
  filter: ['==', ['get', 'type'], 'medieval'],
417
417
  showInKey: true,
418
- toggleVisibility: true,
418
+ showInMenu: true,
419
419
  style: { symbolBackgroundColor: '#ca357c' }
420
420
  }
421
421
  ]
@@ -2,7 +2,7 @@
2
2
 
3
3
  /** @type {import('@docusaurus/types').Config} */
4
4
  const config = {
5
- staticDirectories: ['assets'],
5
+ staticDirectories: ['assets', 'docs/assets'],
6
6
  title: 'Defra Interactive Map',
7
7
  tagline: 'An accessibility-first interactive map component for government frontends',
8
8
  favicon: 'images/favicon.svg',
@@ -45,7 +45,7 @@ const config = {
45
45
  return {
46
46
  name: 'custom-css',
47
47
  getClientModules() {
48
- return [require.resolve('./assets/css/docusaurus.css')];
48
+ return [require.resolve('./docs/assets/css/docusaurus.css')];
49
49
  },
50
50
  };
51
51
  },
@@ -79,9 +79,10 @@ const config = {
79
79
  href: '/getting-started',
80
80
  sidebar: [
81
81
  { text: 'Installation', href: '/getting-started#installation' },
82
+ { text: 'GOV.UK Prototype kit', href: '/getting-started#govuk-prototype-kit' },
83
+ { text: 'Manual setup', href: '/getting-started#manual-setup' },
82
84
  { text: 'Basic usage', href: '/getting-started#basic-usage' },
83
- { text: 'Using plugins', href: '/getting-started#using-plugins' },
84
- { text: 'GOV.UK Prototype kit', href: '/getting-started#govuk-prototype-kit-plugin' }
85
+ { text: 'Using plugins', href: '/getting-started#using-plugins' }
85
86
  ],
86
87
  },
87
88
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/interactive-map",
3
- "version": "0.0.19-alpha",
3
+ "version": "0.0.21-alpha",
4
4
  "description": "An accessible map component",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,6 +44,10 @@
44
44
  "import": "./plugins/beta/datasets/dist/esm/index.js",
45
45
  "require": "./plugins/beta/datasets/dist/umd/index.js"
46
46
  },
47
+ "./plugins/datasets/adapters/maplibre": {
48
+ "import": "./plugins/beta/datasets/adapters/maplibre/dist/esm/index.js",
49
+ "require": "./plugins/beta/datasets/adapters/maplibre/dist/umd/index.js"
50
+ },
47
51
  "./plugins/map-styles": {
48
52
  "import": "./plugins/beta/map-styles/dist/esm/index.js",
49
53
  "require": "./plugins/beta/map-styles/dist/umd/index.js"
@@ -127,7 +131,7 @@
127
131
  "@babel/plugin-transform-runtime": "^7.29.0",
128
132
  "@babel/preset-env": "^7.28.0",
129
133
  "@babel/preset-react": "^7.27.1",
130
- "@defra/docusaurus-theme-govuk": "^0.0.16-alpha",
134
+ "@defra/docusaurus-theme-govuk": "^0.0.19-alpha",
131
135
  "@docusaurus/core": "^3.9.2",
132
136
  "@docusaurus/module-type-aliases": "^3.9.2",
133
137
  "@docusaurus/plugin-content-docs": "^3.9.2",
@@ -218,7 +222,7 @@
218
222
  "@turf/polygon-to-line": "^7.3.3",
219
223
  "accessible-autocomplete": "^3.0.1",
220
224
  "govuk-frontend": "^5.13.0",
221
- "maplibre-gl": "^5.21.1",
225
+ "maplibre-gl": "^5.23.0",
222
226
  "polygon-splitter": "^0.0.11",
223
227
  "preact": "^10.27.2",
224
228
  "tslib": "^2.8.1"
@@ -0,0 +1 @@
1
+ import{useContext as e,createContext as r}from"preact/compat";import{jsx as t,jsxs as i}from"preact/jsx-runtime";import o from"@babel/runtime/helpers/asyncToGenerator";import a from"@babel/runtime/helpers/defineProperty";var l=(e,r,t,i,o)=>{if(e.getLayer(r)){var a=((e,r,t)=>{if(!t||0===t.length)return e;var i=["!",["in",r?["to-string",["get",r]]:["to-string",["id"]],["literal",t.map(String)]]];return e?["all",e,i]:i})(t,i,o);e.setFilter(r,a)}},s=(e,r)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(r&&e[r])return e[r];var t=Object.values(e)[0];return null!=t?t:null}return null},n=e=>!(!e.fillPattern&&!e.fillPatternSvgContent),y=function(e,r,t){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=((e,r)=>{return e.fillPatternSvgContent?e.fillPatternSvgContent:e.fillPattern&&null!==(t=null==r||null===(i=r.get(e.fillPattern))||void 0===i?void 0:i.svgContent)&&void 0!==t?t:null;var t,i})(e,t);if(!o)return null;var a=s(e.fillPatternForegroundColor,r)||"black",l=s(e.fillPatternBackgroundColor,r)||"transparent",n=Math.max(2,i);return"pattern-".concat((e=>{var r=0;for(var t of e)r=(r<<5)-r+t.codePointAt(0),r&=r;return Math.abs(r).toString(36)})(o+a+l),"-").concat(n,"x")},d=e=>"string"==typeof e.geojson&&!!e.idProperty&&"function"==typeof e.transformRequest,m=e=>{var r=0;for(var t of e)r=Math.trunc((r<<5)-r+t.codePointAt(0));return Math.abs(r).toString(36)},p=e=>{if(e.tiles){var r=Array.isArray(e.tiles)?e.tiles.join(","):e.tiles;return"tiles-".concat(m(r))}return e.geojson?d(e)?"geojson-dynamic-".concat(e.id):"string"==typeof e.geojson?"geojson-".concat(m(e.geojson)):"geojson-".concat(e.id):"source-".concat(e.id)},c=e=>{if((e=>!!e.symbol)(e))return{fillLayerId:null,strokeLayerId:null,symbolLayerId:e.id};var r=!!e.fill&&"transparent"!==e.fill||n(e),t=!!e.stroke,i=r?e.id:null,o=null;return t&&(o=r?"".concat(e.id,"-stroke"):e.id),{fillLayerId:i,strokeLayerId:o,symbolLayerId:null}},u=(e,r)=>({fillLayerId:"".concat(e,"-").concat(r),strokeLayerId:"".concat(e,"-").concat(r,"-stroke"),symbolLayerId:"".concat(e,"-").concat(r,"-symbol")}),f=e=>{var r;if(null!==(r=e.sublayers)&&void 0!==r&&r.length)return e.sublayers.flatMap(r=>{var{fillLayerId:t,strokeLayerId:i,symbolLayerId:o}=u(e.id,r.id);return[i,t,o]});var{fillLayerId:t,strokeLayerId:i,symbolLayerId:o}=c(e);return[i,t,o].filter(Boolean)},v=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"];function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,i)}return t}var g=(e,r)=>{return"symbolDescription"in r?r.symbolDescription:(t=r,v.some(e=>e in t)?void 0:e.symbolDescription);var t},h=(e,r)=>{var t,i,o,l,s,n,y,d,m,p,c,u,f,v,h,_,P,L=r.style||{},S=(_=e.filter,P=r.filter,_&&P?["all",_,P]:P||_||null);return function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?b(Object(t),!0).forEach(function(r){a(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}({id:r.id,label:r.label,stroke:null!==(t=L.stroke)&&void 0!==t?t:e.stroke,strokeWidth:null!==(i=L.strokeWidth)&&void 0!==i?i:e.strokeWidth,strokeDashArray:null!==(o=L.strokeDashArray)&&void 0!==o?o:e.strokeDashArray,opacity:null!==(l=L.opacity)&&void 0!==l?l:e.opacity,keySymbolShape:null!==(s=L.keySymbolShape)&&void 0!==s?s:e.keySymbolShape,symbolDescription:g(e,L),showInKey:null!==(n=r.showInKey)&&void 0!==n?n:e.showInKey,showInMenu:null!==(y=r.showInMenu)&&void 0!==y&&y,filter:S,minZoom:e.minZoom,maxZoom:e.maxZoom,symbol:null!==(d=L.symbol)&&void 0!==d?d:e.symbol,symbolSvgContent:null!==(m=L.symbolSvgContent)&&void 0!==m?m:e.symbolSvgContent,symbolViewBox:null!==(p=L.symbolViewBox)&&void 0!==p?p:e.symbolViewBox,symbolAnchor:null!==(c=L.symbolAnchor)&&void 0!==c?c:e.symbolAnchor,symbolBackgroundColor:null!==(u=L.symbolBackgroundColor)&&void 0!==u?u:e.symbolBackgroundColor,symbolForegroundColor:null!==(f=L.symbolForegroundColor)&&void 0!==f?f:e.symbolForegroundColor,symbolHaloWidth:null!==(v=L.symbolHaloWidth)&&void 0!==v?v:e.symbolHaloWidth,symbolGraphic:null!==(h=L.symbolGraphic)&&void 0!==h?h:e.symbolGraphic},((e,r)=>{var t,i;return r.fillPattern||r.fillPatternSvgContent?{fillPattern:r.fillPattern,fillPatternSvgContent:r.fillPatternSvgContent,fillPatternForegroundColor:null!==(t=r.fillPatternForegroundColor)&&void 0!==t?t:e.fillPatternForegroundColor,fillPatternBackgroundColor:null!==(i=r.fillPatternBackgroundColor)&&void 0!==i?i:e.fillPatternBackgroundColor}:"fill"in r?{fill:r.fill}:{fill:e.fill,fillPattern:e.fillPattern,fillPatternSvgContent:e.fillPatternSvgContent,fillPatternForegroundColor:e.fillPatternForegroundColor,fillPatternBackgroundColor:e.fillPatternBackgroundColor}})(e,L))},_=(e,r)=>e.flatMap(e=>{var r,t=n(e)?[e]:[];return null!==(r=e.sublayers)&&void 0!==r&&r.length&&e.sublayers.forEach(r=>{var i=h(e,r);n(i)&&t.push(i)}),t}),P=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),L=e=>!(!e.symbol&&!e.symbolSvgContent),S=(e,r)=>e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol?r.get(e.symbol):void 0,I=e=>{var[r,t]=e,i=(e=>e<=.25?"left":e>=.75?"right":"")(r),o=(e=>e<=.25?"top":e>=.75?"bottom":"")(t);return o+(i&&o?"-":"")+i||"center"},O=function(e,r,t){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,a=S(e,t);if(!a)return null;var l=(e=>{if(!L(e))return{};var r={};return P.forEach(t=>{if(null!=e[t]){var i=t.charAt(6).toLowerCase()+t.slice(7);r[i]=e[t]}}),r})(e),s=i?t.resolveSelected(a,l,r):t.resolve(a,l,r);return"symbol-".concat(i?"sel-":"").concat((e=>{var r=0;for(var t of e)r=Math.trunc((r<<5)-r+t.codePointAt(0));return Math.abs(r).toString(36)})(s),"-").concat(o,"x")},R=e=>e.flatMap(e=>{var r,t=L(e)?[e]:[];return null!==(r=e.sublayers)&&void 0!==r&&r.length&&e.sublayers.forEach(r=>{var i=h(e,r);L(i)&&t.push(i)}),t});function j(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,i)}return t}function k(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?j(Object(t),!0).forEach(function(r){a(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):j(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var w=(e,r,t,i,o,a,l)=>{var{mapStyleId:d,patternRegistry:m,pixelRatio:p=1}=l;if(t&&!e.getLayer(t)&&(r.fill||n(r))){var c=n(r)?y(r,d,m,p):null,u=c?{"fill-pattern":c,"fill-opacity":r.opacity||1}:{"fill-color":s(r.fill,d),"fill-opacity":r.opacity||1};e.addLayer(k({id:t,type:"fill",source:i,"source-layer":o,minzoom:r.minZoom,maxzoom:r.maxZoom,layout:{visibility:a},paint:u},r.filter?{filter:r.filter}:{}))}},C=(e,r,t,i,o,a,l)=>{t&&r.stroke&&!e.getLayer(t)&&e.addLayer(k({id:t,type:"line",source:i,"source-layer":o,minzoom:r.minZoom,maxzoom:r.maxZoom,layout:{visibility:a},paint:k({"line-color":s(r.stroke,l),"line-width":r.strokeWidth||1,"line-opacity":r.opacity||1},r.strokeDashArray?{"line-dasharray":r.strokeDashArray}:{})},r.filter?{filter:r.filter}:{}))},x=(e,r,t,i,o,a,l)=>{var{mapStyle:s,symbolRegistry:n,pixelRatio:y}=l;if(t&&!e.getLayer(t)){var d=S(r,n);if(d){var m=O(r,s,n,!1,y);if(m){var p=((e,r)=>{var t;return e.symbolAnchor?e.symbolAnchor:null!==(t=null==r?void 0:r.anchor)&&void 0!==t?t:[.5,.5]})(r,d);e.addLayer(k({id:t,type:"symbol",source:i,"source-layer":o,minzoom:r.minZoom,maxzoom:r.maxZoom,layout:{visibility:a,"icon-image":m,"icon-anchor":I(p),"icon-allow-overlap":!0}},r.filter?{filter:r.filter}:{}))}}}},D=(e,r,t,i,o,a)=>{var l,{mapStyle:s,symbolRegistry:n,patternRegistry:y,pixelRatio:d}=a,m=s.id,p=h(r,t),{fillLayerId:c,strokeLayerId:f,symbolLayerId:v}=u(r.id,t.id),b="hidden"===r.visibility,g="hidden"===(null===(l=r.sublayerVisibility)||void 0===l?void 0:l[t.id]),_=b||g?"none":"visible";L(p)&&n?x(e,p,v,i,o,_,{mapStyle:s,symbolRegistry:n,pixelRatio:d}):(w(e,p,c,i,o,_,{mapStyleId:m,patternRegistry:y,pixelRatio:d}),C(e,p,f,i,o,_,m))},E=(e,r,t,i,o,a)=>{var l,s,n=t.id,y=p(r);((e,r,t)=>{if(!e.getSource(t))if(r.tiles)e.addSource(t,{type:"vector",tiles:r.tiles,minzoom:r.minZoom||0,maxzoom:r.maxZoom||22});else if(r.geojson){var i=d(r)?{type:"FeatureCollection",features:[]}:r.geojson;e.addSource(t,{type:"geojson",data:i,generateId:!0})}})(e,r,y);var m=null!==(l=r.tiles)&&void 0!==l&&l.length?r.sourceLayer:void 0;if(null!==(s=r.sublayers)&&void 0!==s&&s.length)return r.sublayers.forEach(l=>{D(e,r,l,y,m,{mapStyle:t,symbolRegistry:i,patternRegistry:o,pixelRatio:a})}),y;var{fillLayerId:u,strokeLayerId:f,symbolLayerId:v}=c(r),b="hidden"===r.visibility?"none":"visible";return L(r)&&i?(x(e,r,v,y,m,b,{mapStyle:t,symbolRegistry:i,pixelRatio:a}),y):(w(e,r,u,y,m,b,{mapStyleId:n,patternRegistry:o,pixelRatio:a}),C(e,r,f,y,m,b,n),y)};new Set;function F(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,i)}return t}function M(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?F(Object(t),!0).forEach(function(r){a(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):F(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}var A={slot:"middle",open:!1,dismissible:!0,modal:!0};M({},A),M(M({},A),{},{width:"500px"}),M(M({},A),{},{width:"500px"});var B={small:1,medium:1.5,large:2};class Z{constructor(e,r,t){this._mapProvider=e,this._map=e.map,this._symbolRegistry=r,this._patternRegistry=t,this._datasetSourceMap=new Map,this._symbolLayerIds=new Set}init(e,r){var t=this;return o(function*(){var i=r.id,o=t._pixelRatio;yield Promise.all([t._mapProvider.registerPatterns(_(e,t._patternRegistry),i,t._patternRegistry),t._mapProvider.registerSymbols(R(e),r,t._symbolRegistry)]),t._symbolLayerIds.clear(),e.forEach(e=>t._addLayers(e,r,o)),yield new Promise(e=>t._map.once("idle",e))})()}destroy(e){var r=new Set;e.forEach(e=>{var t=p(e);this._getLayersUsingSource(t).forEach(e=>{this._map.getLayer(e)&&this._map.removeLayer(e)}),!r.has(t)&&this._map.getSource(t)&&(this._map.removeSource(t),r.add(t))}),this._datasetSourceMap.clear()}onStyleChange(e,r,t,i){var a=this;return o(function*(){yield new Promise(e=>a._map.once("idle",e));var o=r.id,l=a._pixelRatio;yield Promise.all([a._mapProvider.registerPatterns(_(e,a._patternRegistry),o,a._patternRegistry),a._mapProvider.registerSymbols(R(e),r,a._symbolRegistry)]),a._symbolLayerIds.clear(),e.forEach(e=>a._addLayers(e,r,l)),i.forEach(e=>e.reapply()),Object.entries(t).forEach(r=>{var[t,{idProperty:i,ids:o}]=r,l=e.find(e=>e.id===t);l&&a._applyFeatureFilter(l,i,o)})})()}onSizeChange(e,r){var t=this;return o(function*(){var i=t._pixelRatio;yield Promise.all([t._mapProvider.registerSymbols(R(e),r,t._symbolRegistry),t._mapProvider.registerPatterns(_(e,t._patternRegistry),r.id,t._patternRegistry)]),e.forEach(e=>{var o;if(f(e).forEach(o=>{if(t._symbolLayerIds.has(o)&&t._map.getLayer(o)){var a=O(e,r,t._symbolRegistry,!1,i);a&&t._map.setLayoutProperty(o,"icon-image",a)}}),n(e)){var{fillLayerId:a}=c(e);if(t._map.getLayer(a)){var l=y(e,r.id,t._patternRegistry,i);l&&t._map.setPaintProperty(a,"fill-pattern",l)}}null===(o=e.sublayers)||void 0===o||o.forEach(o=>{var a=h(e,o),{symbolLayerId:l,fillLayerId:s}=u(e.id,o.id);if(t._map.getLayer(l)){var d=O(a,r,t._symbolRegistry,!1,i);d&&t._map.setLayoutProperty(l,"icon-image",d)}if(n(a)&&t._map.getLayer(s)){var m=y(a,r.id,t._patternRegistry,i);m&&t._map.setPaintProperty(s,"fill-pattern",m)}})})})()}addDataset(e,r){this._addLayers(e,r,this._pixelRatio)}removeDataset(e,r){var t=p(e);f(e).forEach(e=>{this._map.getLayer(e)&&this._map.removeLayer(e),this._symbolLayerIds.delete(e)}),!r.some(r=>r.id!==e.id&&p(r)===t)&&this._map.getSource(t)&&this._map.removeSource(t),this._datasetSourceMap.delete(e.id)}showDataset(e){this._setDatasetVisibility(e,"visible")}hideDataset(e){this._setDatasetVisibility(e,"none")}showSublayer(e,r){var{fillLayerId:t,strokeLayerId:i,symbolLayerId:o}=u(e,r);[t,i,o].forEach(e=>{this._map.getLayer(e)&&this._map.setLayoutProperty(e,"visibility","visible")})}hideSublayer(e,r){var{fillLayerId:t,strokeLayerId:i,symbolLayerId:o}=u(e,r);[t,i,o].forEach(e=>{this._map.getLayer(e)&&this._map.setLayoutProperty(e,"visibility","none")})}showFeatures(e,r,t){this._applyFeatureFilter(e,r,t)}hideFeatures(e,r,t){this._applyFeatureFilter(e,r,t)}setStyle(e,r){var t=this;return o(function*(){var i=r.id,o=t._pixelRatio;f(e).forEach(e=>{t._map.getLayer(e)&&t._map.removeLayer(e),t._symbolLayerIds.delete(e)}),yield Promise.all([t._mapProvider.registerPatterns(_([e],t._patternRegistry),i,t._patternRegistry),t._mapProvider.registerSymbols(R([e]),r,t._symbolRegistry)]),t._addLayers(e,r,o)})()}setSublayerStyle(e,r,t){var i=this;return o(function*(){var o,a,l=t.id,s=i._pixelRatio,{fillLayerId:n,strokeLayerId:y,symbolLayerId:d}=u(e.id,r);[n,y,d].forEach(e=>{i._map.getLayer(e)&&i._map.removeLayer(e),i._symbolLayerIds.delete(e)});var m=null===(o=e.sublayers)||void 0===o?void 0:o.find(e=>e.id===r);if(m){yield Promise.all([i._mapProvider.registerPatterns(_([e],i._patternRegistry),l,i._patternRegistry),i._mapProvider.registerSymbols(R([e]),t,i._symbolRegistry)]);var p=i._datasetSourceMap.get(e.id),c=null!==(a=e.tiles)&&void 0!==a&&a.length?e.sourceLayer:void 0;D(i._map,e,m,p,c,{mapStyle:t,symbolRegistry:i._symbolRegistry,patternRegistry:i._patternRegistry,pixelRatio:s}),i._maintainSymbolOrdering(e)}})()}setOpacity(e,r){var t=this._map.getStyle();null!=t&&t.layers&&t.layers.filter(r=>r.id===e||r.id.startsWith("".concat(e,"-"))).forEach(e=>this._setPaintOpacity(e.id,r))}setSublayerOpacity(e,r,t){var{fillLayerId:i,strokeLayerId:o}=u(e,r);this._setPaintOpacity(i,t),this._setPaintOpacity(o,t)}setData(e,r){var t=this._datasetSourceMap.get(e);if(t){var i=this._map.getSource(t);i&&"function"==typeof i.setData&&i.setData(r)}}get _pixelRatio(){return this._mapProvider.map.getPixelRatio()*(B[this._mapProvider.mapSize]||1)}_addLayers(e,r,t){var i=E(this._map,e,r,this._symbolRegistry,this._patternRegistry,t);this._datasetSourceMap.set(e.id,i),this._maintainSymbolOrdering(e)}_getFirstSymbolLayerId(){var e,r=this._map.getStyle();if(null==r||!r.layers)return null;var t=r.layers.find(e=>this._symbolLayerIds.has(e.id));return null!==(e=null==t?void 0:t.id)&&void 0!==e?e:null}_maintainSymbolOrdering(e){var r=f(e).filter(e=>e&&this._map.getLayer(e));r.forEach(e=>{var r;"symbol"===(null===(r=this._map.getLayer(e))||void 0===r?void 0:r.type)?this._symbolLayerIds.add(e):this._symbolLayerIds.delete(e)});var t=this._getFirstSymbolLayerId();t&&r.forEach(e=>{this._symbolLayerIds.has(e)||this._map.moveLayer(e,t)})}_setDatasetVisibility(e,r){var t=this._map.getStyle();null!=t&&t.layers&&t.layers.filter(r=>r.id===e||r.id.startsWith("".concat(e,"-"))).forEach(e=>this._map.setLayoutProperty(e.id,"visibility",r))}_applyFeatureFilter(e,r,t){var i;if(null!==(i=e.sublayers)&&void 0!==i&&i.length)e.sublayers.forEach(i=>{var{fillLayerId:o,strokeLayerId:a}=u(e.id,i.id),s=e.filter&&i.filter?["all",e.filter,i.filter]:i.filter||e.filter||null;l(this._map,o,s,r,t),l(this._map,a,s,r,t)});else{var{fillLayerId:o,strokeLayerId:a,symbolLayerId:s}=c(e),n=e.filter||null;[o,a,s].filter(Boolean).forEach(e=>{l(this._map,e,n,r,t)})}}_setPaintOpacity(e,r){var t=this._map.getLayer(e);if(t){var i={line:"line-opacity",symbol:"icon-opacity"}[t.type]||"fill-opacity";this._map.setPaintProperty(e,i,r)}}_getLayersUsingSource(e){var r=this._map.getStyle();return null!=r&&r.layers?r.layers.filter(r=>r.source===e).map(e=>e.id):[]}}export{Z as default};
@@ -0,0 +1 @@
1
+ var a={load:()=>import(/* webpackChunkName: "im-datasets-ml-adapter" */ "./im-datasets-ml-adapter.js")};export{a as maplibreLayerAdapter};
@@ -0,0 +1,2 @@
1
+ /*! For license information please see im-datasets-ml-adapter.js.LICENSE.txt */
2
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[563],{168(t,r,e){e.r(r),e.d(r,{default:()=>tt});var n=function(t,r,e,n,o){if(t.getLayer(r)){var i=function(t,r,e){if(!e||0===e.length)return t;var n=["!",["in",r?["to-string",["get",r]]:["to-string",["id"]],["literal",e.map(String)]]];return t?["all",t,n]:n}(e,n,o);t.setFilter(r,i)}};function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var i=function(t,r){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===o(t)){if(r&&t[r])return t[r];var e=Object.values(t)[0];return null!=e?e:null}return null};function a(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var l=function(t){return!(!t.fillPattern&&!t.fillPatternSvgContent)},u=function(t,r,e){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=function(t,r){return t.fillPatternSvgContent?t.fillPatternSvgContent:t.fillPattern&&null!==(e=null==r||null===(n=r.get(t.fillPattern))||void 0===n?void 0:n.svgContent)&&void 0!==e?e:null;var e,n}(t,e);if(!o)return null;var l=i(t.fillPatternForegroundColor,r)||"black",u=i(t.fillPatternBackgroundColor,r)||"transparent",s=Math.max(2,n);return"pattern-".concat(function(t){var r,e=0,n=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return a(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return l=t.done,t},e:function(t){u=!0,i=t},f:function(){try{l||null==e.return||e.return()}finally{if(u)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;)e=(e<<5)-e+r.value.codePointAt(0),e&=e}catch(t){n.e(t)}finally{n.f()}return Math.abs(e).toString(36)}(o+l+u),"-").concat(s,"x")};function s(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var y=function(t){return"string"==typeof t.geojson&&!!t.idProperty&&"function"==typeof t.transformRequest},c=function(t){var r,e=0,n=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return s(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?s(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;e=Math.trunc((e<<5)-e+o.codePointAt(0))}}catch(t){n.e(t)}finally{n.f()}return Math.abs(e).toString(36)},f=function(t){if(t.tiles){var r=Array.isArray(t.tiles)?t.tiles.join(","):t.tiles;return"tiles-".concat(c(r))}return t.geojson?y(t)?"geojson-dynamic-".concat(t.id):"string"==typeof t.geojson?"geojson-".concat(c(t.geojson)):"geojson-".concat(t.id):"source-".concat(t.id)},m=function(t){if(function(t){return!!t.symbol}(t))return{fillLayerId:null,strokeLayerId:null,symbolLayerId:t.id};var r=!!t.fill&&"transparent"!==t.fill||l(t),e=!!t.stroke,n=r?t.id:null,o=null;return e&&(o=r?"".concat(t.id,"-stroke"):t.id),{fillLayerId:n,strokeLayerId:o,symbolLayerId:null}},p=function(t,r){return{fillLayerId:"".concat(t,"-").concat(r),strokeLayerId:"".concat(t,"-").concat(r,"-stroke"),symbolLayerId:"".concat(t,"-").concat(r,"-symbol")}},d=function(t){var r;if(null!==(r=t.sublayers)&&void 0!==r&&r.length)return t.sublayers.flatMap(function(r){var e=p(t.id,r.id),n=e.fillLayerId;return[e.strokeLayerId,n,e.symbolLayerId]});var e=m(t),n=e.fillLayerId;return[e.strokeLayerId,n,e.symbolLayerId].filter(Boolean)},v=["stroke","fill","fillPattern","fillPatternSvgContent","symbol","symbolSvgContent"];function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function h(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function g(t,r,e){return(r=function(t){var r=function(t){if("object"!=b(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=b(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==b(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var S=function(t,r){return"symbolDescription"in r?r.symbolDescription:(e=r,v.some(function(t){return t in e})?void 0:t.symbolDescription);var e},_=function(t,r){var e,n,o,i,a,l,u,s,y,c,f,m,p,d,v,b,_,P=r.style||{},w=(b=t.filter,_=r.filter,b&&_?["all",b,_]:_||b||null);return function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?h(Object(e),!0).forEach(function(r){g(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):h(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}({id:r.id,label:r.label,stroke:null!==(e=P.stroke)&&void 0!==e?e:t.stroke,strokeWidth:null!==(n=P.strokeWidth)&&void 0!==n?n:t.strokeWidth,strokeDashArray:null!==(o=P.strokeDashArray)&&void 0!==o?o:t.strokeDashArray,opacity:null!==(i=P.opacity)&&void 0!==i?i:t.opacity,keySymbolShape:null!==(a=P.keySymbolShape)&&void 0!==a?a:t.keySymbolShape,symbolDescription:S(t,P),showInKey:null!==(l=r.showInKey)&&void 0!==l?l:t.showInKey,showInMenu:null!==(u=r.showInMenu)&&void 0!==u&&u,filter:w,minZoom:t.minZoom,maxZoom:t.maxZoom,symbol:null!==(s=P.symbol)&&void 0!==s?s:t.symbol,symbolSvgContent:null!==(y=P.symbolSvgContent)&&void 0!==y?y:t.symbolSvgContent,symbolViewBox:null!==(c=P.symbolViewBox)&&void 0!==c?c:t.symbolViewBox,symbolAnchor:null!==(f=P.symbolAnchor)&&void 0!==f?f:t.symbolAnchor,symbolBackgroundColor:null!==(m=P.symbolBackgroundColor)&&void 0!==m?m:t.symbolBackgroundColor,symbolForegroundColor:null!==(p=P.symbolForegroundColor)&&void 0!==p?p:t.symbolForegroundColor,symbolHaloWidth:null!==(d=P.symbolHaloWidth)&&void 0!==d?d:t.symbolHaloWidth,symbolGraphic:null!==(v=P.symbolGraphic)&&void 0!==v?v:t.symbolGraphic},function(t,r){var e,n;return r.fillPattern||r.fillPatternSvgContent?{fillPattern:r.fillPattern,fillPatternSvgContent:r.fillPatternSvgContent,fillPatternForegroundColor:null!==(e=r.fillPatternForegroundColor)&&void 0!==e?e:t.fillPatternForegroundColor,fillPatternBackgroundColor:null!==(n=r.fillPatternBackgroundColor)&&void 0!==n?n:t.fillPatternBackgroundColor}:"fill"in r?{fill:r.fill}:{fill:t.fill,fillPattern:t.fillPattern,fillPatternSvgContent:t.fillPatternSvgContent,fillPatternForegroundColor:t.fillPatternForegroundColor,fillPatternBackgroundColor:t.fillPatternBackgroundColor}}(t,P))},P=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),w=function(t){return!(!t.symbol&&!t.symbolSvgContent)},L=function(t,r){return t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?r.get(t.symbol):void 0};function O(t,r){if(t){if("string"==typeof t)return j(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?j(t,r):void 0}}function j(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var k=function(t){var r,e,n=(e=2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,s=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}(r,e)||O(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=n[0],i=n[1],a=function(t){return t<=.25?"left":t>=.75?"right":""}(o),l=function(t){return t<=.25?"top":t>=.75?"bottom":""}(i);return l+(a&&l?"-":"")+a||"center"},I=function(t,r,e){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,i=L(t,e);if(!i)return null;var a=function(t){if(!w(t))return{};var r={};return P.forEach(function(e){if(null!=t[e]){var n=e.charAt(6).toLowerCase()+e.slice(7);r[n]=t[e]}}),r}(t),l=n?e.resolveSelected(i,a,r):e.resolve(i,a,r);return"symbol-".concat(n?"sel-":"").concat(function(t){var r,e=0,n=function(t){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=O(t))){r&&(t=r);var e=0,n=function(){};return{s:n,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;e=Math.trunc((e<<5)-e+o.codePointAt(0))}}catch(t){n.e(t)}finally{n.f()}return Math.abs(e).toString(36)}(l),"-").concat(o,"x")};function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function C(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function x(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?C(Object(e),!0).forEach(function(r){E(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):C(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function E(t,r,e){return(r=function(t){var r=function(t){if("object"!=R(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=R(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}new Map;var A=function(t,r,e,n,o,a,s){var y=s.mapStyleId,c=s.patternRegistry,f=s.pixelRatio,m=void 0===f?1:f;if(e&&!t.getLayer(e)&&(r.fill||l(r))){var p=l(r)?u(r,y,c,m):null,d=p?{"fill-pattern":p,"fill-opacity":r.opacity||1}:{"fill-color":i(r.fill,y),"fill-opacity":r.opacity||1};t.addLayer(x({id:e,type:"fill",source:n,"source-layer":o,minzoom:r.minZoom,maxzoom:r.maxZoom,layout:{visibility:a},paint:d},r.filter?{filter:r.filter}:{}))}},D=function(t,r,e,n,o,a,l){e&&r.stroke&&!t.getLayer(e)&&t.addLayer(x({id:e,type:"line",source:n,"source-layer":o,minzoom:r.minZoom,maxzoom:r.maxZoom,layout:{visibility:a},paint:x({"line-color":i(r.stroke,l),"line-width":r.strokeWidth||1,"line-opacity":r.opacity||1},r.strokeDashArray?{"line-dasharray":r.strokeDashArray}:{})},r.filter?{filter:r.filter}:{}))},F=function(t,r,e,n,o,i,a){var l=a.mapStyle,u=a.symbolRegistry,s=a.pixelRatio;if(e&&!t.getLayer(e)){var y=L(r,u);if(y){var c=I(r,l,u,!1,s);if(c){var f=function(t,r){var e;return t.symbolAnchor?t.symbolAnchor:null!==(e=null==r?void 0:r.anchor)&&void 0!==e?e:[.5,.5]}(r,y);t.addLayer(x({id:e,type:"symbol",source:n,"source-layer":o,minzoom:r.minZoom,maxzoom:r.maxZoom,layout:{visibility:i,"icon-image":c,"icon-anchor":k(f),"icon-allow-overlap":!0}},r.filter?{filter:r.filter}:{}))}}}},M=function(t,r,e,n,o,i){var a,l=i.mapStyle,u=i.symbolRegistry,s=i.patternRegistry,y=i.pixelRatio,c=l.id,f=_(r,e),m=p(r.id,e.id),d=m.fillLayerId,v=m.strokeLayerId,b=m.symbolLayerId,h="hidden"===r.visibility,g="hidden"===(null===(a=r.sublayerVisibility)||void 0===a?void 0:a[e.id]),S=h||g?"none":"visible";w(f)&&u?F(t,f,b,n,o,S,{mapStyle:l,symbolRegistry:u,pixelRatio:y}):(A(t,f,d,n,o,S,{mapStyleId:c,patternRegistry:s,pixelRatio:y}),D(t,f,v,n,o,S,c))},T=function(t,r){return t.flatMap(function(t){var r,e=l(t)?[t]:[];return null!==(r=t.sublayers)&&void 0!==r&&r.length&&t.sublayers.forEach(function(r){var n=_(t,r);l(n)&&e.push(n)}),e})},B=function(t){return t.flatMap(function(t){var r,e=w(t)?[t]:[];return null!==(r=t.sublayers)&&void 0!==r&&r.length&&t.sublayers.forEach(function(r){var n=_(t,r);w(n)&&e.push(n)}),e})};e(738);new Set,new Set,e(287);function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function z(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function G(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?z(Object(e),!0).forEach(function(r){W(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):z(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function W(t,r,e){return(r=function(t){var r=function(t){if("object"!=Z(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=Z(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Z(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var V={slot:"middle",open:!1,dismissible:!0,modal:!0},U=(G({},V),G(G({},V),{},{width:"500px"}),G(G({},V),{},{width:"500px"}),{small:1,medium:1.5,large:2});function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}function $(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,s=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return K(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?K(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function q(){var t,r,e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function i(e,n,o,i){var u=n&&n.prototype instanceof l?n:l,s=Object.create(u.prototype);return N(s,"_invoke",function(e,n,o){var i,l,u,s=0,y=o||[],c=!1,f={p:0,n:0,v:t,a:m,f:m.bind(t,4),d:function(r,e){return i=r,l=0,u=t,f.n=e,a}};function m(e,n){for(l=e,u=n,r=0;!c&&s&&!o&&r<y.length;r++){var o,i=y[r],m=f.p,p=i[2];e>3?(o=p===n)&&(u=i[(l=i[4])?5:(l=3,3)],i[4]=i[5]=t):i[0]<=m&&((o=e<2&&m<i[1])?(l=0,f.v=n,f.n=i[1]):m<p&&(o=e<3||i[0]>n||n>p)&&(i[4]=e,i[5]=n,f.n=p,l=0))}if(o||e>1)return a;throw c=!0,n}return function(o,y,p){if(s>1)throw TypeError("Generator is already running");for(c&&1===y&&m(y,p),l=y,u=p;(r=l<2?t:u)||!c;){i||(l?l<3?(l>1&&(f.n=-1),m(l,u)):f.n=u:f.v=u);try{if(s=2,i){if(l||(o="next"),r=i[o]){if(!(r=r.call(i,u)))throw TypeError("iterator result is not an object");if(!r.done)return r;u=r.value,l<2&&(l=0)}else 1===l&&(r=i.return)&&r.call(i),l<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),l=1);i=t}else if((r=(c=f.n<0)?u:e.call(n,f))!==a)break}catch(r){i=t,l=1,u=r}finally{s=1}}return{value:r,done:c}}}(e,o,i),!0),s}var a={};function l(){}function u(){}function s(){}r=Object.getPrototypeOf;var y=[][n]?r(r([][n]())):(N(r={},n,function(){return this}),r),c=s.prototype=l.prototype=Object.create(y);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,N(t,o,"GeneratorFunction")),t.prototype=Object.create(c),t}return u.prototype=s,N(c,"constructor",s),N(s,"constructor",u),u.displayName="GeneratorFunction",N(s,o,"GeneratorFunction"),N(c),N(c,o,"Generator"),N(c,n,function(){return this}),N(c,"toString",function(){return"[object Generator]"}),(q=function(){return{w:i,m:f}})()}function N(t,r,e,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}N=function(t,r,e,n){function i(r,e){N(t,r,function(t){return this._invoke(r,e,t)})}r?o?o(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n}):t[r]=e:(i("next",0),i("throw",1),i("return",2))},N(t,r,e,n)}function J(t,r,e,n,o,i,a){try{var l=t[i](a),u=l.value}catch(t){return void e(t)}l.done?r(u):Promise.resolve(u).then(n,o)}function Q(t){return function(){var r=this,e=arguments;return new Promise(function(n,o){var i=t.apply(r,e);function a(t){J(i,n,o,a,l,"next",t)}function l(t){J(i,n,o,a,l,"throw",t)}a(void 0)})}}function X(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Y(n.key),n)}}function Y(t){var r=function(t){if("object"!=H(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=H(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(r)?r:r+""}var tt=function(){return t=function t(r,e,n){!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),this._mapProvider=r,this._map=r.map,this._symbolRegistry=e,this._patternRegistry=n,this._datasetSourceMap=new Map,this._symbolLayerIds=new Set},r=[{key:"init",value:(s=Q(q().m(function t(r,e){var n,o,i=this;return q().w(function(t){for(;;)switch(t.n){case 0:return n=e.id,o=this._pixelRatio,t.n=1,Promise.all([this._mapProvider.registerPatterns(T(r,this._patternRegistry),n,this._patternRegistry),this._mapProvider.registerSymbols(B(r),e,this._symbolRegistry)]);case 1:return this._symbolLayerIds.clear(),r.forEach(function(t){return i._addLayers(t,e,o)}),t.n=2,new Promise(function(t){return i._map.once("idle",t)});case 2:return t.a(2)}},t,this)})),function(t,r){return s.apply(this,arguments)})},{key:"destroy",value:function(t){var r=this,e=new Set;t.forEach(function(t){var n=f(t);r._getLayersUsingSource(n).forEach(function(t){r._map.getLayer(t)&&r._map.removeLayer(t)}),!e.has(n)&&r._map.getSource(n)&&(r._map.removeSource(n),e.add(n))}),this._datasetSourceMap.clear()}},{key:"onStyleChange",value:(a=Q(q().m(function t(r,e,n,o){var i,a,l=this;return q().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,new Promise(function(t){return l._map.once("idle",t)});case 1:return i=e.id,a=this._pixelRatio,t.n=2,Promise.all([this._mapProvider.registerPatterns(T(r,this._patternRegistry),i,this._patternRegistry),this._mapProvider.registerSymbols(B(r),e,this._symbolRegistry)]);case 2:this._symbolLayerIds.clear(),r.forEach(function(t){return l._addLayers(t,e,a)}),o.forEach(function(t){return t.reapply()}),Object.entries(n).forEach(function(t){var e=$(t,2),n=e[0],o=e[1],i=o.idProperty,a=o.ids,u=r.find(function(t){return t.id===n});u&&l._applyFeatureFilter(u,i,a)});case 3:return t.a(2)}},t,this)})),function(t,r,e,n){return a.apply(this,arguments)})},{key:"onSizeChange",value:(i=Q(q().m(function t(r,e){var n,o=this;return q().w(function(t){for(;;)switch(t.n){case 0:return n=this._pixelRatio,t.n=1,Promise.all([this._mapProvider.registerSymbols(B(r),e,this._symbolRegistry),this._mapProvider.registerPatterns(T(r,this._patternRegistry),e.id,this._patternRegistry)]);case 1:r.forEach(function(t){var r;if(d(t).forEach(function(r){if(o._symbolLayerIds.has(r)&&o._map.getLayer(r)){var i=I(t,e,o._symbolRegistry,!1,n);i&&o._map.setLayoutProperty(r,"icon-image",i)}}),l(t)){var i=m(t).fillLayerId;if(o._map.getLayer(i)){var a=u(t,e.id,o._patternRegistry,n);a&&o._map.setPaintProperty(i,"fill-pattern",a)}}null===(r=t.sublayers)||void 0===r||r.forEach(function(r){var i=_(t,r),a=p(t.id,r.id),s=a.symbolLayerId,y=a.fillLayerId;if(o._map.getLayer(s)){var c=I(i,e,o._symbolRegistry,!1,n);c&&o._map.setLayoutProperty(s,"icon-image",c)}if(l(i)&&o._map.getLayer(y)){var f=u(i,e.id,o._patternRegistry,n);f&&o._map.setPaintProperty(y,"fill-pattern",f)}})});case 2:return t.a(2)}},t,this)})),function(t,r){return i.apply(this,arguments)})},{key:"addDataset",value:function(t,r){this._addLayers(t,r,this._pixelRatio)}},{key:"removeDataset",value:function(t,r){var e=this,n=f(t);d(t).forEach(function(t){e._map.getLayer(t)&&e._map.removeLayer(t),e._symbolLayerIds.delete(t)}),!r.some(function(r){return r.id!==t.id&&f(r)===n})&&this._map.getSource(n)&&this._map.removeSource(n),this._datasetSourceMap.delete(t.id)}},{key:"showDataset",value:function(t){this._setDatasetVisibility(t,"visible")}},{key:"hideDataset",value:function(t){this._setDatasetVisibility(t,"none")}},{key:"showSublayer",value:function(t,r){var e=this,n=p(t,r);[n.fillLayerId,n.strokeLayerId,n.symbolLayerId].forEach(function(t){e._map.getLayer(t)&&e._map.setLayoutProperty(t,"visibility","visible")})}},{key:"hideSublayer",value:function(t,r){var e=this,n=p(t,r);[n.fillLayerId,n.strokeLayerId,n.symbolLayerId].forEach(function(t){e._map.getLayer(t)&&e._map.setLayoutProperty(t,"visibility","none")})}},{key:"showFeatures",value:function(t,r,e){this._applyFeatureFilter(t,r,e)}},{key:"hideFeatures",value:function(t,r,e){this._applyFeatureFilter(t,r,e)}},{key:"setStyle",value:(o=Q(q().m(function t(r,e){var n,o,i=this;return q().w(function(t){for(;;)switch(t.n){case 0:return n=e.id,o=this._pixelRatio,d(r).forEach(function(t){i._map.getLayer(t)&&i._map.removeLayer(t),i._symbolLayerIds.delete(t)}),t.n=1,Promise.all([this._mapProvider.registerPatterns(T([r],this._patternRegistry),n,this._patternRegistry),this._mapProvider.registerSymbols(B([r]),e,this._symbolRegistry)]);case 1:this._addLayers(r,e,o);case 2:return t.a(2)}},t,this)})),function(t,r){return o.apply(this,arguments)})},{key:"setSublayerStyle",value:(e=Q(q().m(function t(r,e,n){var o,i,a,l,u,s,y,c,f,m,d,v=this;return q().w(function(t){for(;;)switch(t.n){case 0:if(a=n.id,l=this._pixelRatio,u=p(r.id,e),s=u.fillLayerId,y=u.strokeLayerId,c=u.symbolLayerId,[s,y,c].forEach(function(t){v._map.getLayer(t)&&v._map.removeLayer(t),v._symbolLayerIds.delete(t)}),f=null===(o=r.sublayers)||void 0===o?void 0:o.find(function(t){return t.id===e})){t.n=1;break}return t.a(2);case 1:return t.n=2,Promise.all([this._mapProvider.registerPatterns(T([r],this._patternRegistry),a,this._patternRegistry),this._mapProvider.registerSymbols(B([r]),n,this._symbolRegistry)]);case 2:m=this._datasetSourceMap.get(r.id),d=null!==(i=r.tiles)&&void 0!==i&&i.length?r.sourceLayer:void 0,M(this._map,r,f,m,d,{mapStyle:n,symbolRegistry:this._symbolRegistry,patternRegistry:this._patternRegistry,pixelRatio:l}),this._maintainSymbolOrdering(r);case 3:return t.a(2)}},t,this)})),function(t,r,n){return e.apply(this,arguments)})},{key:"setOpacity",value:function(t,r){var e=this,n=this._map.getStyle();null!=n&&n.layers&&n.layers.filter(function(r){return r.id===t||r.id.startsWith("".concat(t,"-"))}).forEach(function(t){return e._setPaintOpacity(t.id,r)})}},{key:"setSublayerOpacity",value:function(t,r,e){var n=p(t,r),o=n.fillLayerId,i=n.strokeLayerId;this._setPaintOpacity(o,e),this._setPaintOpacity(i,e)}},{key:"setData",value:function(t,r){var e=this._datasetSourceMap.get(t);if(e){var n=this._map.getSource(e);n&&"function"==typeof n.setData&&n.setData(r)}}},{key:"_pixelRatio",get:function(){return this._mapProvider.map.getPixelRatio()*(U[this._mapProvider.mapSize]||1)}},{key:"_addLayers",value:function(t,r,e){var n=function(t,r,e,n,o,i){var a,l,u=e.id,s=f(r);!function(t,r,e){if(!t.getSource(e))if(r.tiles)t.addSource(e,{type:"vector",tiles:r.tiles,minzoom:r.minZoom||0,maxzoom:r.maxZoom||22});else if(r.geojson){var n=y(r)?{type:"FeatureCollection",features:[]}:r.geojson;t.addSource(e,{type:"geojson",data:n,generateId:!0})}}(t,r,s);var c=null!==(a=r.tiles)&&void 0!==a&&a.length?r.sourceLayer:void 0;if(null!==(l=r.sublayers)&&void 0!==l&&l.length)return r.sublayers.forEach(function(a){M(t,r,a,s,c,{mapStyle:e,symbolRegistry:n,patternRegistry:o,pixelRatio:i})}),s;var p=m(r),d=p.fillLayerId,v=p.strokeLayerId,b=p.symbolLayerId,h="hidden"===r.visibility?"none":"visible";return w(r)&&n?(F(t,r,b,s,c,h,{mapStyle:e,symbolRegistry:n,pixelRatio:i}),s):(A(t,r,d,s,c,h,{mapStyleId:u,patternRegistry:o,pixelRatio:i}),D(t,r,v,s,c,h,u),s)}(this._map,t,r,this._symbolRegistry,this._patternRegistry,e);this._datasetSourceMap.set(t.id,n),this._maintainSymbolOrdering(t)}},{key:"_getFirstSymbolLayerId",value:function(){var t,r=this,e=this._map.getStyle();if(null==e||!e.layers)return null;var n=e.layers.find(function(t){return r._symbolLayerIds.has(t.id)});return null!==(t=null==n?void 0:n.id)&&void 0!==t?t:null}},{key:"_maintainSymbolOrdering",value:function(t){var r=this,e=d(t).filter(function(t){return t&&r._map.getLayer(t)});e.forEach(function(t){var e;"symbol"===(null===(e=r._map.getLayer(t))||void 0===e?void 0:e.type)?r._symbolLayerIds.add(t):r._symbolLayerIds.delete(t)});var n=this._getFirstSymbolLayerId();n&&e.forEach(function(t){r._symbolLayerIds.has(t)||r._map.moveLayer(t,n)})}},{key:"_setDatasetVisibility",value:function(t,r){var e=this,n=this._map.getStyle();null!=n&&n.layers&&n.layers.filter(function(r){return r.id===t||r.id.startsWith("".concat(t,"-"))}).forEach(function(t){return e._map.setLayoutProperty(t.id,"visibility",r)})}},{key:"_applyFeatureFilter",value:function(t,r,e){var o,i=this;if(null!==(o=t.sublayers)&&void 0!==o&&o.length)t.sublayers.forEach(function(o){var a=p(t.id,o.id),l=a.fillLayerId,u=a.strokeLayerId,s=t.filter&&o.filter?["all",t.filter,o.filter]:o.filter||t.filter||null;n(i._map,l,s,r,e),n(i._map,u,s,r,e)});else{var a=m(t),l=a.fillLayerId,u=a.strokeLayerId,s=a.symbolLayerId,y=t.filter||null;[l,u,s].filter(Boolean).forEach(function(t){n(i._map,t,y,r,e)})}}},{key:"_setPaintOpacity",value:function(t,r){var e=this._map.getLayer(t);if(e){var n={line:"line-opacity",symbol:"icon-opacity"}[e.type]||"fill-opacity";this._map.setPaintProperty(t,n,r)}}},{key:"_getLayersUsingSource",value:function(t){var r=this._map.getStyle();return null!=r&&r.layers?r.layers.filter(function(r){return r.source===t}).map(function(t){return t.id}):[]}}],r&&X(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e,o,i,a,s}()}}]);
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.datasetsMaplibreAdapter=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime}},o={};function a(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,a),n.exports}a.m=r,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>"im-datasets-ml-adapter.js",a.miniCssF=e=>{},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.datasetsMaplibreAdapter:",a.l=(r,o,n,i)=>{if(e[r])e[r].push(o);else{var p,s;if(void 0!==n)for(var d=document.getElementsByTagName("script"),c=0;c<d.length;c++){var u=d[c];if(u.getAttribute("src")==r||u.getAttribute("data-webpack")==t+n){p=u;break}}p||(s=!0,(p=document.createElement("script")).charset="utf-8",a.nc&&p.setAttribute("nonce",a.nc),p.setAttribute("data-webpack",t+n),p.src=r),e[r]=[o];var l=(t,o)=>{p.onerror=p.onload=null,clearTimeout(f);var a=e[r];if(delete e[r],p.parentNode&&p.parentNode.removeChild(p),a&&a.forEach(e=>e(o)),t)return t(o)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:p}),12e4);p.onerror=l.bind(null,p.onerror),p.onload=l.bind(null,p.onload),s&&document.head.appendChild(p)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={57:0};a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,a)=>o=e[t]=[r,a]);r.push(o[2]=n);var i=a.p+a.u(t),p=new Error;a.l(i,r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;p.message="Loading chunk "+t+" failed.\n("+n+": "+i+")",p.name="ChunkLoadError",p.type=n,p.request=i,o[1](p)}},"chunk-"+t,t)}};var t=(t,r)=>{var o,n,[i,p,s]=r,d=0;if(i.some(t=>0!==e[t])){for(o in p)a.o(p,o)&&(a.m[o]=p[o]);s&&s(a)}for(t&&t(r);d<i.length;d++)n=i[d],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n={};return n.default})());