@defra/interactive-map 0.0.19-alpha → 0.0.20-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +22 -5
- package/docs/api/map-style-config.md +2 -11
- package/docs/api/marker-config.md +19 -5
- package/docs/api.md +75 -46
- package/docs/architecture.md +0 -2
- package/{assets → docs/assets}/css/docusaurus.css +78 -1
- package/docs/assets/images/basic-map.jpg +0 -0
- package/docs/assets/images/button-first.jpg +0 -0
- package/{assets → docs/assets}/images/hero.png +0 -0
- package/docs/assets/images/marker-panel.jpg +0 -0
- package/docs/examples/add-marker-with-panel.mdx +112 -48
- package/docs/examples/basic-map.mdx +43 -14
- package/docs/examples/button-map.mdx +43 -14
- package/docs/examples/index.mdx +6 -6
- package/docs/getting-started.md +80 -53
- package/docusaurus.config.cjs +5 -4
- package/package.json +3 -3
- package/plugins/beta/draw-ml/dist/css/index.css +19 -2
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/src/maplibreProvider.js +3 -2
- package/providers/maplibre/src/maplibreProvider.test.js +22 -0
- package/src/InteractiveMap/InteractiveMap.js +2 -2
- package/src/InteractiveMap/InteractiveMap.test.js +4 -4
- package/src/services/eventBus.js +61 -0
- package/src/services/eventBus.test.js +70 -0
- package/docs/assets/basic-map.jpg +0 -0
- package/docs/assets/button-first.jpg +0 -0
- package/docs/assets/maker-panel.jpg +0 -0
- /package/docs/assets/{screens-blue.jpg → images/screens-blue.jpg} +0 -0
- /package/docs/assets/{screens-white.jpg → images/screens-white.jpg} +0 -0
- /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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
]} />
|
package/docs/examples/index.mdx
CHANGED
|
@@ -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
|
|
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')
|
|
@@ -23,7 +23,7 @@ export function ExampleCards() {
|
|
|
23
23
|
<div className='govuk-grid-column-one-half'>
|
|
24
24
|
<div className='app-example-card'>
|
|
25
25
|
<img src={buttonFirstImg} alt='' />
|
|
26
|
-
<div className='app-example-card__body'>
|
|
26
|
+
<div className='app-example-card__body' style={{ borderTop: '1px solid #f4f8fb'}}>
|
|
27
27
|
<h2 className='govuk-heading-m'>
|
|
28
28
|
<a href={buttonHref}>Button-triggered map</a>
|
|
29
29
|
</h2>
|
|
@@ -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={
|
|
36
|
-
<div className='app-example-card__body' style={{
|
|
35
|
+
<img src={markerPanelImg} alt='' />
|
|
36
|
+
<div className='app-example-card__body' style={{ borderTop: '1px solid #f4f8fb'}}>
|
|
37
37
|
<h2 className='govuk-heading-m'>
|
|
38
38
|
<a href={interactHref}>Add a marker with a panel</a>
|
|
39
39
|
</h2>
|
package/docs/getting-started.md
CHANGED
|
@@ -3,62 +3,61 @@
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
5
5
|
```shell
|
|
6
|
-
npm
|
|
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
|
-
|
|
12
|
+
## GOV.UK Prototype kit
|
|
13
13
|
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
20
|
+
## Manual setup
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
The package is distributed in two formats:
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
+
### MapLibre provider (recommended)
|
|
33
30
|
|
|
34
|
-
|
|
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
|
-
|
|
33
|
+
```shell
|
|
34
|
+
npm install maplibre-gl
|
|
39
35
|
```
|
|
40
36
|
|
|
41
|
-
**UMD
|
|
37
|
+
**UMD:** `maplibre-gl` is bundled — no separate install needed.
|
|
38
|
+
|
|
39
|
+
### ESRI provider (optional)
|
|
42
40
|
|
|
43
|
-
|
|
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
|
-
|
|
43
|
+
```shell
|
|
44
|
+
npm install @arcgis/core
|
|
45
|
+
```
|
|
50
46
|
|
|
51
47
|
## Basic usage
|
|
52
48
|
|
|
53
|
-
|
|
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** —
|
|
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
|
|
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/
|
|
93
|
-
<
|
|
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
|
|
135
|
+
Then pass the plugin in your initialisation:
|
|
99
136
|
|
|
100
137
|
```js
|
|
101
|
-
const interactiveMap = new InteractiveMap('map', {
|
|
102
|
-
|
|
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).
|
package/docusaurus.config.cjs
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.0.20-alpha",
|
|
4
4
|
"description": "An accessible map component",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"@babel/plugin-transform-runtime": "^7.29.0",
|
|
128
128
|
"@babel/preset-env": "^7.28.0",
|
|
129
129
|
"@babel/preset-react": "^7.27.1",
|
|
130
|
-
"@defra/docusaurus-theme-govuk": "^0.0.
|
|
130
|
+
"@defra/docusaurus-theme-govuk": "^0.0.18-alpha",
|
|
131
131
|
"@docusaurus/core": "^3.9.2",
|
|
132
132
|
"@docusaurus/module-type-aliases": "^3.9.2",
|
|
133
133
|
"@docusaurus/plugin-content-docs": "^3.9.2",
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
"@turf/polygon-to-line": "^7.3.3",
|
|
219
219
|
"accessible-autocomplete": "^3.0.1",
|
|
220
220
|
"govuk-frontend": "^5.13.0",
|
|
221
|
-
"maplibre-gl": "^5.
|
|
221
|
+
"maplibre-gl": "^5.23.0",
|
|
222
222
|
"polygon-splitter": "^0.0.11",
|
|
223
223
|
"preact": "^10.27.2",
|
|
224
224
|
"tslib": "^2.8.1"
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
.touch-vertex-target circle
|
|
2
|
-
|
|
1
|
+
.touch-vertex-target circle {
|
|
2
|
+
fill: var(--map-overlay-foreground-color);
|
|
3
|
+
}
|
|
4
|
+
.touch-vertex-target path {
|
|
5
|
+
fill: var(--map-overlay-halo-color);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.im-c-actions .im-c-button-wrapper--draw-done,
|
|
9
|
+
.im-c-actions .im-c-button-wrapper--draw-menu,
|
|
10
|
+
.im-c-actions .im-c-button-wrapper--draw-cancel {
|
|
11
|
+
width: 33.33%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.im-o-app--tablet .im-c-actions .im-c-button-wrapper--draw-done,
|
|
15
|
+
.im-o-app--tablet .im-c-actions .im-c-button-wrapper--draw-menu,
|
|
16
|
+
.im-o-app--tablet .im-c-actions .im-c-button-wrapper--draw-cancel,
|
|
17
|
+
.im-o-app--desktop .im-c-actions .im-c-button-wrapper--draw-done,
|
|
18
|
+
.im-o-app--desktop .im-c-actions .im-c-button-wrapper--draw-menu,
|
|
19
|
+
.im-o-app--desktop .im-c-actions .im-c-button-wrapper--draw-cancel {
|
|
3
20
|
width: 100px;
|
|
4
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t,createContext as e}from"preact/compat";import{jsx as r,jsxs as a}from"preact/jsx-runtime";import n from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/asyncToGenerator";var s=400,l=7,u=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];new Set;function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var d={slot:"middle",open:!1,dismissible:!0,modal:!0};h({},d),h(h({},d),{},{width:"500px"}),h(h({},d),{},{width:"500px"});var p={small:1,medium:1.5,large:2};var g=(t,e)=>{var r=null,a=function(){for(var a=arguments.length,n=new Array(a),o=0;o<a;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(()=>{t(...n)},e)};return a.cancel=()=>{r&&(clearTimeout(r),r=null)},a};function f(t){var{map:e,events:r,eventBus:a,getCenter:n,getZoom:o,getBounds:i,getResolution:s}=t,l=[],u=[],c=()=>{var t=o();return{center:n(),bounds:i(),resolution:s(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},h=(t,e)=>a.emit(t,e),d=()=>h(r.MAP_LOADED);e.on("load",d),l.push(["load",d]);e.once("idle",()=>h(r.MAP_FIRST_IDLE,c()));var p=()=>h(r.MAP_MOVE_START);e.on("movestart",p),l.push(["movestart",p]);var f=g(()=>{h(r.MAP_MOVE_END,c())},500);e.on("moveend",f),l.push(["moveend",f]),u.push(f);var y,m,v,M=(y=()=>{h(r.MAP_MOVE,c())},m=10,v=0,function(){var t=Date.now();t-v>=m&&(v=t,y(...arguments))});e.on("zoom",M),l.push(["zoom",M]),u.push(M);var b=()=>h(r.MAP_RENDER);e.on("render",b),l.push(["render",b]);var w=g(()=>{h(r.MAP_DATA_CHANGE,c())},500);e.on("styledata",w),l.push(["styledata",w]),u.push(w);var x=()=>h(r.MAP_STYLE_CHANGE);e.on("style.load",x),l.push(["style.load",x]);var P=t=>h(r.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]});return e.on("click",P),l.push(["click",P]),{remove(){u.forEach(t=>t.cancel()),l.forEach(t=>{var[r,a]=t;return e.off(r,a)})}}}let y=" ";class m{static get separator(){return y}static set separator(t){y=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let r=null;switch(e.length){case 3:r=e[0]/1+e[1]/60+e[2]/3600;break;case 2:r=e[0]/1+e[1]/60;break;case 1:r=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(r=-r),Number(r)}static toDms(t,e="d",r=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===r)switch(e){case"d":case"deg":r=4;break;case"dm":case"deg+min":r=2;break;case"dms":case"deg+min+sec":r=0;break;default:e="d",r=4}t=Math.abs(t);let a=null,n=null,o=null,i=null;switch(e){default:case"d":case"deg":n=t.toFixed(r),n<100&&(n="0"+n),n<10&&(n="0"+n),a=n+"°";break;case"dm":case"deg+min":n=Math.floor(t),o=(60*t%60).toFixed(r),60==o&&(o=(0).toFixed(r),n++),n=("000"+n).slice(-3),o<10&&(o="0"+o),a=n+"°"+m.separator+o+"′";break;case"dms":case"deg+min+sec":n=Math.floor(t),o=Math.floor(3600*t/60)%60,i=(3600*t%60).toFixed(r),60==i&&(i=(0).toFixed(r),o++),60==o&&(o=0,n++),n=("000"+n).slice(-3),o=("00"+o).slice(-2),i<10&&(i="0"+i),a=n+"°"+m.separator+o+"′"+m.separator+i+"″"}return a}static toLat(t,e,r){const a=m.toDms(m.wrap90(t),e,r);return null===a?"–":a.slice(1)+m.separator+(t<0?"S":"N")}static toLon(t,e,r){const a=m.toDms(m.wrap180(t),e,r);return null===a?"–":a+m.separator+(t<0?"W":"E")}static toBrng(t,e,r){const a=m.toDms(m.wrap360(t),e,r);return null===a?"–":a.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=m.wrap360(t);const r=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*r/360)%r*16/r]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,r=360;return 1*Math.abs(((e-90)%r+r)%r-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const v=Math.PI;class M{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=m.wrap90(Number(t)),this._lon=m.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?m.wrap90(m.parse(t)):m.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?m.wrap90(m.parse(t)):m.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?m.wrap180(m.parse(t)):m.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?m.wrap180(m.parse(t)):m.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?m.wrap180(m.parse(t)):m.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,r;if(2==t.length&&([e,r]=t,e=m.wrap90(m.parse(e)),r=m.wrap180(m.parse(r)),isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,r]=t[0].split(","),e=m.wrap90(m.parse(e)),r=m.wrap180(m.parse(r)),isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const a=t[0];if("Point"==a.type&&Array.isArray(a.coordinates)?[r,e]=a.coordinates:(null!=a.latitude&&(e=a.latitude),null!=a.lat&&(e=a.lat),null!=a.longitude&&(r=a.longitude),null!=a.lng&&(r=a.lng),null!=a.lon&&(r=a.lon),e=m.wrap90(m.parse(e)),r=m.wrap180(m.parse(r))),isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${t.toString()}’`);return new M(e,r)}distanceTo(t,e=6371e3){if(t instanceof M||(t=M.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const r=e,a=this.lat.toRadians(),n=this.lon.toRadians(),o=t.lat.toRadians(),i=o-a,s=t.lon.toRadians()-n,l=Math.sin(i/2)*Math.sin(i/2)+Math.cos(a)*Math.cos(o)*Math.sin(s/2)*Math.sin(s/2);return r*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(t){if(t instanceof M||(t=M.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),r=t.lat.toRadians(),a=(t.lon-this.lon).toRadians(),n=Math.cos(e)*Math.sin(r)-Math.sin(e)*Math.cos(r)*Math.cos(a),o=Math.sin(a)*Math.cos(r),i=Math.atan2(o,n).toDegrees();return m.wrap360(i)}finalBearingTo(t){t instanceof M||(t=M.parse(t));const e=t.initialBearingTo(this)+180;return m.wrap360(e)}midpointTo(t){t instanceof M||(t=M.parse(t));const e=this.lat.toRadians(),r=this.lon.toRadians(),a=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),o=Math.cos(e),i=0,s=Math.sin(e),l={x:o+Math.cos(a)*Math.cos(n),y:i+Math.cos(a)*Math.sin(n),z:s+Math.sin(a)},u=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),c=r+Math.atan2(l.y,l.x),h=u.toDegrees(),d=c.toDegrees();return new M(h,d)}intermediatePointTo(t,e){if(t instanceof M||(t=M.parse(t)),this.equals(t))return new M(this.lat,this.lon);const r=this.lat.toRadians(),a=this.lon.toRadians(),n=t.lat.toRadians(),o=t.lon.toRadians(),i=n-r,s=o-a,l=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2),u=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),c=Math.sin((1-e)*u)/Math.sin(u),h=Math.sin(e*u)/Math.sin(u),d=c*Math.cos(r)*Math.cos(a)+h*Math.cos(n)*Math.cos(o),p=c*Math.cos(r)*Math.sin(a)+h*Math.cos(n)*Math.sin(o),g=c*Math.sin(r)+h*Math.sin(n),f=Math.atan2(g,Math.sqrt(d*d+p*p)),y=Math.atan2(p,d),m=f.toDegrees(),v=y.toDegrees();return new M(m,v)}destinationPoint(t,e,r=6371e3){const a=t/r,n=Number(e).toRadians(),o=this.lat.toRadians(),i=this.lon.toRadians(),s=Math.sin(o)*Math.cos(a)+Math.cos(o)*Math.sin(a)*Math.cos(n),l=Math.asin(s),u=Math.sin(n)*Math.sin(a)*Math.cos(o),c=Math.cos(a)-Math.sin(o)*s,h=i+Math.atan2(u,c),d=l.toDegrees(),p=h.toDegrees();return new M(d,p)}static intersection(t,e,r,a){if(t instanceof M||(t=M.parse(t)),r instanceof M||(r=M.parse(r)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(a))throw new TypeError(`invalid brng2 ‘${a}’`);const n=t.lat.toRadians(),o=t.lon.toRadians(),i=r.lat.toRadians(),s=r.lon.toRadians(),l=Number(e).toRadians(),u=Number(a).toRadians(),c=i-n,h=s-o,d=2*Math.asin(Math.sqrt(Math.sin(c/2)*Math.sin(c/2)+Math.cos(n)*Math.cos(i)*Math.sin(h/2)*Math.sin(h/2)));if(Math.abs(d)<Number.EPSILON)return new M(t.lat,t.lon);const p=(Math.sin(i)-Math.sin(n)*Math.cos(d))/(Math.sin(d)*Math.cos(n)),g=(Math.sin(n)-Math.sin(i)*Math.cos(d))/(Math.sin(d)*Math.cos(i)),f=Math.acos(Math.min(Math.max(p,-1),1)),y=Math.acos(Math.min(Math.max(g,-1),1)),m=l-(Math.sin(s-o)>0?f:2*v-f),b=(Math.sin(s-o)>0?2*v-y:y)-u;if(0==Math.sin(m)&&0==Math.sin(b))return null;if(Math.sin(m)*Math.sin(b)<0)return null;const w=-Math.cos(m)*Math.cos(b)+Math.sin(m)*Math.sin(b)*Math.cos(d),x=Math.atan2(Math.sin(d)*Math.sin(m)*Math.sin(b),Math.cos(b)+Math.cos(m)*w),P=Math.asin(Math.min(Math.max(Math.sin(n)*Math.cos(x)+Math.cos(n)*Math.sin(x)*Math.cos(l),-1),1)),N=o+Math.atan2(Math.sin(l)*Math.sin(x)*Math.cos(n),Math.cos(x)-Math.sin(n)*Math.sin(P)),S=P.toDegrees(),E=N.toDegrees();return new M(S,E)}crossTrackDistanceTo(t,e,r=6371e3){t instanceof M||(t=M.parse(t)),e instanceof M||(e=M.parse(e));const a=r;if(this.equals(t))return 0;const n=t.distanceTo(this,a)/a,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(n)*Math.sin(o-i))*a}alongTrackDistanceTo(t,e,r=6371e3){t instanceof M||(t=M.parse(t)),e instanceof M||(e=M.parse(e));const a=r;if(this.equals(t))return 0;const n=t.distanceTo(this,a)/a,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians(),s=Math.asin(Math.sin(n)*Math.sin(o-i));return Math.acos(Math.cos(n)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(i-o))*a}maxLatitude(t){const e=Number(t).toRadians(),r=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(r))).toDegrees()}static crossingParallels(t,e,r){if(t.equals(e))return null;const a=Number(r).toRadians(),n=t.lat.toRadians(),o=t.lon.toRadians(),i=e.lat.toRadians(),s=e.lon.toRadians()-o,l=Math.sin(n)*Math.cos(i)*Math.cos(a)*Math.sin(s),u=Math.sin(n)*Math.cos(i)*Math.cos(a)*Math.cos(s)-Math.cos(n)*Math.sin(i)*Math.cos(a),c=Math.cos(n)*Math.cos(i)*Math.sin(a)*Math.sin(s);if(c*c>l*l+u*u)return null;const h=Math.atan2(-u,l),d=Math.acos(c/Math.sqrt(l*l+u*u)),p=o+h+d,g=(o+h-d).toDegrees(),f=p.toDegrees();return{lon1:m.wrap180(g),lon2:m.wrap180(f)}}rhumbDistanceTo(t,e=6371e3){t instanceof M||(t=M.parse(t));const r=e,a=this.lat.toRadians(),n=t.lat.toRadians(),o=n-a;let i=Math.abs(t.lon-this.lon).toRadians();Math.abs(i)>v&&(i=i>0?-(2*v-i):2*v+i);const s=Math.log(Math.tan(n/2+v/4)/Math.tan(a/2+v/4)),l=Math.abs(s)>1e-11?o/s:Math.cos(a);return Math.sqrt(o*o+l*l*i*i)*r}rhumbBearingTo(t){if(t instanceof M||(t=M.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),r=t.lat.toRadians();let a=(t.lon-this.lon).toRadians();Math.abs(a)>v&&(a=a>0?-(2*v-a):2*v+a);const n=Math.log(Math.tan(r/2+v/4)/Math.tan(e/2+v/4)),o=Math.atan2(a,n).toDegrees();return m.wrap360(o)}rhumbDestinationPoint(t,e,r=6371e3){const a=this.lat.toRadians(),n=this.lon.toRadians(),o=Number(e).toRadians(),i=t/r,s=i*Math.cos(o);let l=a+s;Math.abs(l)>v/2&&(l=l>0?v-l:-v-l);const u=Math.log(Math.tan(l/2+v/4)/Math.tan(a/2+v/4)),c=Math.abs(u)>1e-11?s/u:Math.cos(a),h=n+i*Math.sin(o)/c,d=l.toDegrees(),p=h.toDegrees();return new M(d,p)}rhumbMidpointTo(t){t instanceof M||(t=M.parse(t));const e=this.lat.toRadians();let r=this.lon.toRadians();const a=t.lat.toRadians(),n=t.lon.toRadians();Math.abs(n-r)>v&&(r+=2*v);const o=(e+a)/2,i=Math.tan(v/4+e/2),s=Math.tan(v/4+a/2),l=Math.tan(v/4+o/2);let u=((n-r)*Math.log(l)+r*Math.log(s)-n*Math.log(i))/Math.log(s/i);isFinite(u)||(u=(r+n)/2);const c=o.toDegrees(),h=u.toDegrees();return new M(c,h)}static areaOf(t,e=6371e3){const r=e,a=t[0].equals(t[t.length-1]);a||t.push(t[0]);const n=t.length-1;let o=0;for(let e=0;e<n;e++){const r=t[e].lat.toRadians(),a=t[e+1].lat.toRadians(),n=(t[e+1].lon-t[e].lon).toRadians();o+=2*Math.atan2(Math.tan(n/2)*(Math.tan(r/2)+Math.tan(a/2)),1+Math.tan(r/2)*Math.tan(a/2))}(function(t){let e=0,r=t[0].initialBearingTo(t[1]);for(let a=0;a<t.length-1;a++){const n=t[a].initialBearingTo(t[a+1]),o=t[a].finalBearingTo(t[a+1]);e+=(n-r+540)%360-180,e+=(o-n+540)%360-180,r=o}const a=t[0].initialBearingTo(t[1]);e+=(a-r+540)%360-180;return Math.abs(e)<90})(t)&&(o=Math.abs(o)-2*v);const i=Math.abs(o*r*r);return a||t.pop(),i}equals(t){return t instanceof M||(t=M.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${m.toLat(this.lat,t,e)}, ${m.toLon(this.lon,t,e)}`}}function b(t,e,r){if(null!==t)for(var a,n,o,i,s,l,u,c,h=0,d=0,p=t.type,g="FeatureCollection"===p,f="Feature"===p,y=g?t.features.length:1,m=0;m<y;m++){s=(c=!!(u=g?t.features[m].geometry:f?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;v<s;v++){var M=0,w=0;if(null!==(i=c?u.geometries[v]:u)){l=i.coordinates;var x=i.type;switch(h=0,x){case null:break;case"Point":if(!1===e(l,d,m,M,w))return!1;d++,M++;break;case"LineString":case"MultiPoint":for(a=0;a<l.length;a++){if(!1===e(l[a],d,m,M,w))return!1;d++,"MultiPoint"===x&&M++}"LineString"===x&&M++;break;case"Polygon":case"MultiLineString":for(a=0;a<l.length;a++){for(n=0;n<l[a].length-h;n++){if(!1===e(l[a][n],d,m,M,w))return!1;d++}"MultiLineString"===x&&M++,"Polygon"===x&&w++}"Polygon"===x&&M++;break;case"MultiPolygon":for(a=0;a<l.length;a++){for(w=0,n=0;n<l[a].length;n++){for(o=0;o<l[a][n].length-h;o++){if(!1===e(l[a][n][o],d,m,M,w))return!1;d++}w++}M++}break;case"GeometryCollection":for(a=0;a<i.geometries.length;a++)if(!1===b(i.geometries[a],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var w=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const r=[1/0,1/0,-1/0,-1/0];return b(t,t=>{r[0]>t[0]&&(r[0]=t[0]),r[1]>t[1]&&(r[1]=t[1]),r[2]<t[0]&&(r[2]=t[0]),r[3]<t[1]&&(r[3]=t[1])}),r},x=(t,e)=>{var[r,a]=t,[n,o]=e,i=new M(a,r),s=new M(o,n);return i.distanceTo(s)},P=t=>{var e=t/1609.344;if(e<.5)return"".concat(Math.round(t),"m");if(e<10){var r=Number.parseFloat(e.toFixed(1)),a=1===r?"mile":"miles";return"".concat(r," ").concat(a)}var n=Math.round(e);return"".concat(n," miles")},N=(t,e,r)=>{var[a,n]=e,o=r.filter(e=>{var[r,o]=e;return(r!==a||o!==n)&&((t,e,r)=>{switch(t){case"ArrowUp":return r<0&&Math.abs(r)>=Math.abs(e);case"ArrowDown":return r>0&&Math.abs(r)>=Math.abs(e);case"ArrowLeft":return e<0&&Math.abs(e)>Math.abs(r);case"ArrowRight":return e>0&&Math.abs(e)>Math.abs(r);default:return!1}})(t,r-a,o-n)});if(!o.length)return r.findIndex(t=>t[0]===a&&t[1]===n);var i=-1,s=1/0;return o.forEach(t=>{var e=t[0]-a,o=t[1]-n,l=e*e+o*o;l<s&&(s=l,i=r.indexOf(t))}),i},S=t=>w(t);function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var O="highlighted-label";function R(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var{stops:r}=t;if(r.length<2)return r.length>0?r[0][1]:0;for(var a=r[0],n=r[r.length-1],o=1;o<r.length;o++){var i=r[o];if(i[0]>e){n=i,a=r[o-1];break}a=r[o-1],n=i}var[s,l]=a,[u,c]=n;return e<=s?l:e>=u?c:l+(e-s)/(u-s)*(c-l)}(t,e);var[,,r,...a]=t;if("zoom"!==r[0])throw new Error("Only zoom-based expressions supported");for(var n=0;n<a.length-2;n+=2){var o=a[n],i=a[n+1],s=a[n+2],l=a[n+3];if(e<=o)return i;if(e<=s)return i+(e-o)/(s-o)*(l-i)}return a[a.length-1]}function j(t,e,r){return e.flatMap(e=>{var a,n=function(t){var e,r;return"string"==typeof t?null===(e=/^{(.+)}$/.exec(t))||void 0===e?void 0:e[1]:Array.isArray(t)?null===(r=t.find(t=>Array.isArray(t)&&"get"===t[0]))||void 0===r?void 0:r[1]:null}(null===(a=e.layout)||void 0===a?void 0:a["text-field"]);return n?r.filter(t=>{var r;return t.layer.id===e.id&&(null===(r=t.properties)||void 0===r?void 0:r[n])}).map(r=>function(t,e,r,a){var n=function(t){var{type:e,coordinates:r}=t;if("Point"===e)return r;if("MultiPoint"===e)return r[0];if(e.includes("LineString")){var a="LineString"===e?r:r[0];return[(a[0][0]+a[a.length-1][0])/2,(a[0][1]+a[a.length-1][1])/2]}if(e.includes("Polygon")){var n="Polygon"===e?r[0]:r[0][0],o=n.reduce((t,e)=>[t[0]+e[0],t[1]+e[1]],[0,0]);return[o[0]/n.length,o[1]/n.length]}return null}(t.geometry);if(!n)return null;var o=a.project({lng:n[0],lat:n[1]});return{text:t.properties[r],x:o.x,y:o.y,feature:t,layer:e}}(r,e,n,t)).filter(Boolean):[]})}function T(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function D(t,e,r){var a;if(null!=e&&null!==(a=e.feature)&&void 0!==a&&a.layer){T(t,r);var{feature:n,layer:o}=e;r.highlightLayerId="highlight-".concat(o.id);var{id:i,type:s,properties:l,geometry:u}=n;t.getSource(O).setData({id:i,type:s,properties:l,geometry:u}),r.highlightedExpr=o.layout["text-size"];var c=t.getZoom(),h=function(t,e,r){return{id:"highlight-".concat(t.id),type:t.type,source:O,layout:L(L({},t.layout),{},{"text-size":e,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:L(L({},t.paint),{},{"text-color":r.text,"text-halo-color":r.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(o,1.5*R(r.highlightedExpr,c),r.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});t.addLayer(h),t.moveLayer(r.highlightLayerId)}}function A(t){t.getSource(O)||t.addSource(O,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function C(t){t.getStyle().layers.filter(t=>{var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(e=>t.setLayoutProperty(e.id,"symbol-placement","line-center"))}function I(t,e,r,a){var n={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function o(){var e=t.getStyle().layers.filter(t=>"symbol"===t.type),r=t.queryRenderedFeatures({layers:e.map(t=>t.id)});n.labels=j(t,e,r)}function i(){if(o(),!n.labels.length)return null;var e=t.project(t.getCenter()),r=function(t,e){var r;return null===(r=t.reduce((t,r)=>{var a=(r.x-e.x)**2+(r.y-e.y)**2;return!t||a<t.dist?{label:r,dist:a}:t},null))||void 0===r?void 0:r.label}(n.labels,e);return n.currentPixel={x:r.x,y:r.y},D(t,r,n),"".concat(r.text," (").concat(r.layer.id,")")}return C(t),A(t),null==a||a.on(r.MAP_SET_STYLE,e=>{t.once("styledata",()=>t.once("idle",()=>{C(t),A(t),n.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)}))}),t.on("zoom",()=>{if(n.highlightLayerId&&n.highlightedExpr){var e=R(n.highlightedExpr,t.getZoom());t.setLayoutProperty(n.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(t=>"symbol"===t.type).forEach(e=>{t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:o,highlightNextLabel:function(e){if(o(),!n.labels.length)return null;if(!n.currentPixel)return i();var r=function(t,e){if(!e.currentPixel)return null;var r=e.labels.map((t,e)=>({pixel:[t.x,t.y],index:e})).filter(t=>t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y);if(!r.length)return null;var a=r.map(t=>t.pixel),n=N(t,[e.currentPixel.x,e.currentPixel.y],a);return(null==n||n<0||n>=r.length)&&(n=0),e.labels[r[n].index]}(e,n);return r?(n.currentPixel={x:r.x,y:r.y},D(t,r,n),"".concat(r.text," (").concat(r.layer.id,")")):null},highlightLabelAtCenter:i,clearHighlightedLabel:()=>T(t,n)}}function _(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function k(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?_(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var B=(t,e,r,a,n,o,i)=>{t.getLayer(e)||t.addLayer(k(k({id:e,type:r,source:a},n&&{"source-layer":n}),{},{paint:o})),Object.entries(o).forEach(r=>{var[a,n]=r;t.setPaintProperty(e,a,n)}),t.setFilter(e,i),t.moveLayer(e)};function F(t){var{LngLatBounds:e,map:r,selectedFeatures:a,stylesMap:n}=t;if(!r)return null;var o=((t,e)=>{var r={};return null==e||e.forEach(e=>{var{featureId:a,layerId:n,idProperty:o,geometry:i}=e,s=t.getLayer(n);if(s){var l=s.source;r[l]||(r[l]={ids:new Set,fillIds:new Set,idProperty:o,layerId:n,hasFillGeometry:!1}),!i||"Polygon"!==i.type&&"MultiPolygon"!==i.type||(r[l].hasFillGeometry=!0,r[l].fillIds.add(a)),r[l].ids.add(a)}}),r})(r,a),i=[],s=new Set(Object.keys(o)),l=r._highlightedSources||new Set;return((t,e,r)=>{e.forEach(e=>{if(!r.has(e)){var a="highlight-".concat(e);["".concat(a,"-fill"),"".concat(a,"-line"),"".concat(a,"-symbol")].forEach(e=>{t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})})(r,l,s),r._highlightedSources=s,s.forEach(t=>{var{ids:e,fillIds:a,idProperty:s,layerId:l,hasFillGeometry:u}=o[t],c=r.getLayer(l),h=c.sourceLayer,d=u?"fill":c.type,p="highlight-".concat(t),g=s?["get",s]:["id"],f=["in",g,["literal",[...e]]];if("fill"===d){var{stroke:y,strokeWidth:m,fill:v}=n[l],M=["in",g,["literal",[...a]]],b={"line-color":y,"line-width":m};B(r,"".concat(p,"-fill"),"fill",t,h,{"fill-color":v},M),B(r,"".concat(p,"-line"),"line",t,h,b,f)}if("line"===d){var{stroke:w,strokeWidth:x}=n[l],P={"line-color":w,"line-width":x};r.getLayer("".concat(p,"-fill"))&&r.setFilter("".concat(p,"-fill"),["==","id",""]),B(r,"".concat(p,"-line"),"line",t,h,P,f)}if("symbol"===d){var N=r.getLayoutProperty(l,"icon-image"),S=((t,e)=>{var r,a;return null!==(r=null===(a=t._symbolImageMap)||void 0===a?void 0:a[e])&&void 0!==r?r:null})(r,N);S&&((t,e,r,a,n,o,i)=>{var s;t.getLayer(e)||t.addLayer(k(k({id:e,type:"symbol",source:r},a&&{"source-layer":a}),{},{layout:{"icon-image":o,"icon-anchor":null!==(s=t.getLayoutProperty(n,"icon-anchor"))&&void 0!==s?s:"center","icon-allow-overlap":!0}})),t.setLayoutProperty(e,"icon-image",o),t.setFilter(e,i),t.moveLayer(e)})(r,"".concat(p,"-symbol"),t,h,l,S,f)}i.push(...r.queryRenderedFeatures({layers:[l]}).filter(t=>{var r;return e.has(s?null===(r=t.properties)||void 0===r?void 0:r[s]:t.id)}))}),((t,e)=>{if(!e.length)return null;var r=new t;return e.forEach(t=>{var e=t=>"number"==typeof t[0]?r.extend(t):t.forEach(e);e(t.geometry.coordinates)}),[r.getWest(),r.getSouth(),r.getEast(),r.getNorth()]})(e,i)}var z=(t,e,r)=>{var a=(e.x-r.x)**2+(e.y-r.y)**2;if(0===a)return(t.x-e.x)**2+(t.y-e.y)**2;var n=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/a;return n=Math.max(0,Math.min(1,n)),(t.x-(e.x+n*(r.x-e.x)))**2+(t.y-(e.y+n*(r.y-e.y)))**2},$=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:a=10}=r,n=[[e.x-a,e.y-a],[e.x+a,e.y+a]],o=t.queryRenderedFeatures(n);if(0===o.length)return[];var i=new Set(t.queryRenderedFeatures([e.x,e.y]).map(t=>{var e,r=void 0===t.id?JSON.stringify(t.properties):t.id;return"".concat(null===(e=t.layer)||void 0===e?void 0:e.source,":").concat(r)})),s=[];o.forEach(t=>{!1===s.includes(t.layer.id)&&s.push(t.layer.id)});for(var l=new Set,u=[],c=o.length-1;c>=0;c--){var h,d=o[c],p=void 0===d.id?JSON.stringify(d.properties):d.id,g="".concat(null===(h=d.layer)||void 0===h?void 0:h.source,":").concat(p);!1===l.has(g)&&(l.add(g),u.push(d))}var f=t.unproject(e),y=[f.lng,f.lat],m=u.filter(t=>{var e=t.geometry.type;if(e.includes("Polygon"))return("Polygon"===e?[t.geometry.coordinates]:t.geometry.coordinates).some(t=>((t,e)=>{for(var[r,a]=t,n=!1,o=0,i=e.length-1;o<e.length;i=o,o++){var[s,l]=e[o],[u,c]=e[i];l>a!=c>a&&r<(u-s)*(a-l)/(c-l)+s&&(n=!n)}return n})(y,t[0]));if("Point"===e||"MultiPoint"===e){var r,a=void 0===t.id?JSON.stringify(t.properties):t.id;return i.has("".concat(null===(r=t.layer)||void 0===r?void 0:r.source,":").concat(a))}return!0});return m.map(r=>{var a=0,n=r.geometry.type,o=((t,e,r)=>{var{coordinates:a,type:n}=r,o=1/0,i=e=>t.project(e),s=t=>{for(var r=0;r<t.length-1;r++){var a=z(e,i(t[r]),i(t[r+1]));a<o&&(o=a)}};if("Point"===n){var l=i(a);o=(e.x-l.x)**2+(e.y-l.y)**2}else"LineString"===n||"MultiPoint"===n?"LineString"===n?s(a):a.forEach(t=>{var r=i(t),a=(e.x-r.x)**2+(e.y-r.y)**2;a<o&&(o=a)}):"Polygon"===n||"MultiLineString"===n?a.forEach(s):"MultiPolygon"===n&&a.forEach(t=>t.forEach(s));return o})(t,e,r.geometry);return a+=1e6*s.indexOf(r.layer.id),n.includes("Polygon")&&(a-=5e5),{f:r,score:a+=o}}).sort((t,e)=>t.score-e.score).map(t=>{var{f:e}=t;return e})},q=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),W=(t,e)=>t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?e.get(t.symbol):void 0,Z=t=>{if(!(t=>!(!t.symbol&&!t.symbolSvgContent))(t))return{};var e={};return q.forEach(r=>{if(null!=t[r]){var a=r.charAt(6).toLowerCase()+r.slice(7);e[a]=t[r]}}),e},G=(t,e,r)=>new Promise((a,n)=>{var o=new Blob([t],{type:"image/svg+xml"}),i=URL.createObjectURL(o),s=new Image(e,r);s.onload=()=>{var t=document.createElement("canvas");t.width=e,t.height=r;var n=t.getContext("2d");n.drawImage(s,0,0,e,r),URL.revokeObjectURL(i),a(n.getImageData(0,0,e,r))},s.onerror=()=>{URL.revokeObjectURL(i),n(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},s.src=i}),H=t=>{var e=0;for(var r of t)e=Math.trunc((e<<5)-e+r.codePointAt(0));return Math.abs(e).toString(36)},U=function(t,e,r){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,o=W(t,r);if(!o)return null;var i=Z(t),s=a?r.resolveSelected(o,i,e):r.resolve(o,i,e);return"symbol-".concat(a?"sel-":"").concat(H(s),"-").concat(n,"x")},V=new Map,J=function(){var t=i(function*(t,e,r,a,n){var o=W(t,r);if(!o)return null;var i=Z(t),s=a?r.resolveSelected(o,i,e):r.resolve(o,i,e),l="symbol-".concat(a?"sel-":"").concat(H(s),"-").concat(n,"x"),u=V.get(l);if(!u){var c=((t,e)=>{var r;return t.symbolViewBox?t.symbolViewBox:null!==(r=null==e?void 0:e.viewBox)&&void 0!==r?r:"0 0 38 38"})(t,o),[,,h,d]=c.split(" ").map(Number),p='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(h*n,'" height="').concat(d*n,'" viewBox="').concat(c,'">').concat(s,"</svg>");u=yield G(p,h*n,d*n),V.set(l,u)}return{imageId:l,imageData:u}});return function(e,r,a,n,o){return t.apply(this,arguments)}}(),Y=function(){var t=i(function*(t,e,r,a){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;e.length&&(t._symbolImageMap={},yield Promise.all(e.flatMap(e=>{var o=U(e,r,a,!1,n),s=U(e,r,a,!0,n);return o&&s&&(t._symbolImageMap[o]=s),[!1,!0].map(function(){var l=i(function*(i){var l=i?s:o;if(l&&!t.hasImage(l)){var u=yield J(e,r,a,i,n);u&&!t.hasImage(u.imageId)&&t.addImage(u.imageId,u.imageData,{pixelRatio:n})}});return function(t){return l.apply(this,arguments)}}())})))});return function(e,r,a,n){return t.apply(this,arguments)}}(),K=(t,e)=>{if(!t)return null;if("string"==typeof t)return t.trim();if("object"==typeof t){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null},X=(t,e)=>{return t.fillPatternSvgContent?t.fillPatternSvgContent:t.fillPattern&&null!==(r=null==e||null===(a=e.get(t.fillPattern))||void 0===a?void 0:a.svgContent)&&void 0!==r?r:null;var r,a},Q=(t,e,r)=>{var a=X(t,r);if(!a)return null;var n=K(t.fillPatternForegroundColor,e)||"black",o=K(t.fillPatternBackgroundColor,e)||"transparent";return"pattern-".concat((t=>{var e=0;for(var r of t)e=(e<<5)-e+r.codePointAt(0),e&=e;return Math.abs(e).toString(36)})(a+n+o))},tt=new Map,et=function(){var t=i(function*(t,e,r){var a=X(t,r);if(!a)return null;var n=Q(t,e,r);if(!n)return null;var o,i,s=tt.get(n);if(!s){var l=K(t.fillPatternForegroundColor,e)||"black",u=K(t.fillPatternBackgroundColor,e)||"transparent",c=(o=l,i=u,a.replace(/\{\{foregroundColor\}\}/g,o||"black").replace(/\{\{backgroundColor\}\}/g,i||"transparent")),h='<rect width="16" height="16" fill="'.concat(u,'"/>'),d='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">'.concat(h).concat(c,"</svg>");s=yield G(d,16,16),tt.set(n,s)}return{imageId:n,imageData:s}});return function(e,r,a){return t.apply(this,arguments)}}(),rt=function(){var t=i(function*(t,e,r,a){e.length&&(yield Promise.all(e.map(function(){var e=i(function*(e){var n=Q(e,r,a);if(n&&!t.hasImage(n)){var o=yield et(e,r,a);o&&t.addImage(o.imageId,o.imageData,{pixelRatio:2})}});return function(t){return e.apply(this,arguments)}}())))});return function(e,r,a,n){return t.apply(this,arguments)}}(),at=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function ot(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?nt(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):nt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}class it{constructor(t){var{mapFramework:e,mapProviderConfig:r={},events:a,eventBus:n}=t;this.maplibreModule=e,this.events=a,this.eventBus=n,this.capabilities={supportedShortcuts:u,supportsMapSizes:!0},Object.assign(this,r)}initMap(t){var e=this;return i(function*(){var{container:r,padding:a,mapStyle:n,mapSize:i,center:s,zoom:l,bounds:u,pixelRatio:c}=t,h=o(t,at);e.mapStyleId=null==n?void 0:n.id,e.mapSize=i;var{Map:d}=e.maplibreModule,{events:p,eventBus:g}=e,y=new d(ot(ot({},h),{},{container:r,style:null==n?void 0:n.url,pixelRatio:c,padding:a,center:s,zoom:l,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));y.touchZoomRotate.disableRotation(),e.map=y,e.map.setPadding(a),u&&y.fitBounds(u,{duration:0}),function(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var r=t.getCanvas();if(r&&(this.target===r||r.contains(this.target)))return}e.call(this)}}(y),function(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block"}(y),f({map:y,events:p,eventBus:g,getCenter:e.getCenter.bind(e),getZoom:e.getZoom.bind(e),getBounds:e.getBounds.bind(e),getResolution:e.getResolution.bind(e)}),function(t){var{mapProvider:e,map:r,events:a,eventBus:n}=t,o=t=>{r.once("style.load",()=>{n.emit(a.MAP_STYLE_CHANGE,{mapStyleId:t.id})}),r.setStyle(t.url,{diff:!1})},i=t=>{r.setPixelRatio(t)},s=t=>{var{mapSize:r}=t;e.mapSize=r};n.on(a.MAP_SET_STYLE,o),n.on(a.MAP_SET_PIXEL_RATIO,i),n.on(a.MAP_SIZE_CHANGE,s)}({mapProvider:e,map:y,events:p,eventBus:g}),y.on("load",()=>{e.labelNavigator=I(y,null==n?void 0:n.mapColorScheme,p,g)}),e.eventBus.emit(p.MAP_READY,{map:e.map,mapStyleId:e.mapStyleId,mapSize:e.mapSize,crs:e.crs})})()}destroyMap(){var t,e;this.setHoverCursor([]),null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(t){this.map&&(this._onHoverMove=((t,e,r)=>{var a=t.getCanvas();if(r&&t.off("mousemove",r),null==e||!e.length)return a.style.cursor="",null;var n=r=>{var n=e.filter(e=>t.getLayer(e));if(0!==n.length){var{lineLayers:o,otherLayers:i}=((t,e)=>{var r=[],a=[];for(var n of e)if("line"===t.getLayer(n).type){var o=n.endsWith("-stroke")?n.slice(0,-7):null;null!==o&&e.includes(o)||r.push(n)}else a.push(n);return{lineLayers:r,otherLayers:a}})(t,n),{x:s,y:l}=r.point,u=[[s-10,l-10],[s+10,l+10]],c=o.length>0&&t.queryRenderedFeatures(u,{layers:o}).length>0,h=i.length>0&&t.queryRenderedFeatures(r.point,{layers:i}).length>0;a.style.cursor=c||h?"pointer":""}else a.style.cursor=""};return t.on("mousemove",n),n})(this.map,t,this._onHoverMove))}setView(t){var{center:e,zoom:r}=t;this.map.flyTo({center:e||this.getCenter(),zoom:r||this.getZoom(),duration:s})}zoomIn(t){this.map.easeTo({zoom:this.getZoom()+t,duration:s})}zoomOut(t){this.map.easeTo({zoom:this.getZoom()-t,duration:s})}panBy(t){this.map.panBy(t,{duration:s})}fitToBounds(t){var e=Array.isArray(t)?t:S(t);this.map.fitBounds(e,{duration:s})}setPadding(t){this.map.setPadding(t)}updateHighlightedFeatures(t,e){var{LngLatBounds:r}=this.maplibreModule;return F({LngLatBounds:r,map:this.map,selectedFeatures:t,stylesMap:e})}highlightNextLabel(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}highlightLabelAtCenter(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}clearHighlightedLabel(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}getCenter(){var t=this.map.getCenter();return[Number(t.lng.toFixed(l)),Number(t.lat.toFixed(l))]}getZoom(){return Number(this.map.getZoom().toFixed(l))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(t,e){return $(this.map,t,e)}registerSymbols(t,e,r){var a=this;return i(function*(){var n=(a.map.getPixelRatio()||1)*(p[a.mapSize]||1);return Y(a.map,t,e,r,n)})()}registerPatterns(t,e,r){var a=this;return i(function*(){return rt(a.map,t,e,r)})()}getAreaDimensions(){var{LngLatBounds:t}=this.maplibreModule;return(t=>{var e,r,a,n;if(t&&"function"==typeof t.getWest)e=t.getWest(),r=t.getSouth(),a=t.getEast(),n=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";[[e,r],[a,n]]=t}var o=x([e,r],[a,r]),i=x([e,r],[e,n]),s=P(o),l=P(i);return"".concat(l," by ").concat(s)})(((t,e)=>{var{width:r,height:a}=e.getContainer().getBoundingClientRect(),n=e.getPadding(),o=[n.left,a-n.bottom],i=[r-n.right,n.top];return new t(e.unproject(o),e.unproject(i))})(t,this.map))}getCardinalMove(t,e){return((t,e)=>{var[r,a]=t,[n,o]=e,i=o-a,s=n-r,l=[];if(Math.abs(i)>1e-4){var u=Math.round(x([r,a],[r,o]));l.push("".concat(i>0?"north":"south"," ").concat(P(u)))}if(Math.abs(s)>1e-4){var c=Math.round(x([r,a],[n,a]));l.push("".concat(s>0?"east":"west"," ").concat(P(c)))}return l.join(", ")})(t,e)}getResolution(){return t=this.map.getCenter(),e=this.map.getZoom(),r=t.lat,a=Math.pow(2,e),40075016.686*Math.cos(r*Math.PI/180)/(512*a);var t,e,r,a}mapToScreen(t){return this.map.project(t)}screenToMap(t){var{lng:e,lat:r}=this.map.unproject([t.x,t.y]);return[e,r]}isGeometryObscured(t,e){return((t,e,r)=>{var a=r.getContainer().getBoundingClientRect(),[n,o,i,s]=S(t),l=[r.project([n,o]),r.project([n,s]),r.project([i,o]),r.project([i,s])],u=Math.min(...l.map(t=>t.x)),c=Math.max(...l.map(t=>t.x)),h=Math.min(...l.map(t=>t.y)),d=Math.max(...l.map(t=>t.y)),p=e.left-a.left,g=e.top-a.top,f=e.right-a.left,y=e.bottom-a.top;return u<f&&c>p&&h<y&&d>g})(t,e,this.map)}}export{it as default};
|
|
1
|
+
import{useContext as t,createContext as e}from"preact/compat";import{jsx as r,jsxs as a}from"preact/jsx-runtime";import n from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/asyncToGenerator";var s=400,l=7,u=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];new Set;function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var d={slot:"middle",open:!1,dismissible:!0,modal:!0};h({},d),h(h({},d),{},{width:"500px"}),h(h({},d),{},{width:"500px"});var p={small:1,medium:1.5,large:2};var g=(t,e)=>{var r=null,a=function(){for(var a=arguments.length,n=new Array(a),o=0;o<a;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout(()=>{t(...n)},e)};return a.cancel=()=>{r&&(clearTimeout(r),r=null)},a};function f(t){var{map:e,events:r,eventBus:a,getCenter:n,getZoom:o,getBounds:i,getResolution:s}=t,l=[],u=[],c=()=>{var t=o();return{center:n(),bounds:i(),resolution:s(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},h=(t,e)=>a.emit(t,e),d=()=>h(r.MAP_LOADED);e.on("load",d),l.push(["load",d]);e.once("idle",()=>h(r.MAP_FIRST_IDLE,c()));var p=()=>h(r.MAP_MOVE_START);e.on("movestart",p),l.push(["movestart",p]);var f=g(()=>{h(r.MAP_MOVE_END,c())},500);e.on("moveend",f),l.push(["moveend",f]),u.push(f);var y,m,v,M=(y=()=>{h(r.MAP_MOVE,c())},m=10,v=0,function(){var t=Date.now();t-v>=m&&(v=t,y(...arguments))});e.on("zoom",M),l.push(["zoom",M]),u.push(M);var b=()=>h(r.MAP_RENDER);e.on("render",b),l.push(["render",b]);var w=g(()=>{h(r.MAP_DATA_CHANGE,c())},500);e.on("styledata",w),l.push(["styledata",w]),u.push(w);var x=()=>h(r.MAP_STYLE_CHANGE);e.on("style.load",x),l.push(["style.load",x]);var P=t=>h(r.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]});return e.on("click",P),l.push(["click",P]),{remove(){u.forEach(t=>t.cancel()),l.forEach(t=>{var[r,a]=t;return e.off(r,a)})}}}let y=" ";class m{static get separator(){return y}static set separator(t){y=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let r=null;switch(e.length){case 3:r=e[0]/1+e[1]/60+e[2]/3600;break;case 2:r=e[0]/1+e[1]/60;break;case 1:r=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(r=-r),Number(r)}static toDms(t,e="d",r=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===r)switch(e){case"d":case"deg":r=4;break;case"dm":case"deg+min":r=2;break;case"dms":case"deg+min+sec":r=0;break;default:e="d",r=4}t=Math.abs(t);let a=null,n=null,o=null,i=null;switch(e){default:case"d":case"deg":n=t.toFixed(r),n<100&&(n="0"+n),n<10&&(n="0"+n),a=n+"°";break;case"dm":case"deg+min":n=Math.floor(t),o=(60*t%60).toFixed(r),60==o&&(o=(0).toFixed(r),n++),n=("000"+n).slice(-3),o<10&&(o="0"+o),a=n+"°"+m.separator+o+"′";break;case"dms":case"deg+min+sec":n=Math.floor(t),o=Math.floor(3600*t/60)%60,i=(3600*t%60).toFixed(r),60==i&&(i=(0).toFixed(r),o++),60==o&&(o=0,n++),n=("000"+n).slice(-3),o=("00"+o).slice(-2),i<10&&(i="0"+i),a=n+"°"+m.separator+o+"′"+m.separator+i+"″"}return a}static toLat(t,e,r){const a=m.toDms(m.wrap90(t),e,r);return null===a?"–":a.slice(1)+m.separator+(t<0?"S":"N")}static toLon(t,e,r){const a=m.toDms(m.wrap180(t),e,r);return null===a?"–":a+m.separator+(t<0?"W":"E")}static toBrng(t,e,r){const a=m.toDms(m.wrap360(t),e,r);return null===a?"–":a.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(r.thousands,"⁜").replace(r.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),r={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",r.decimal).replace("⁜",r.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=m.wrap360(t);const r=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*r/360)%r*16/r]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,r=360;return 1*Math.abs(((e-90)%r+r)%r-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const v=Math.PI;class M{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=m.wrap90(Number(t)),this._lon=m.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?m.wrap90(m.parse(t)):m.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?m.wrap90(m.parse(t)):m.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?m.wrap180(m.parse(t)):m.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?m.wrap180(m.parse(t)):m.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?m.wrap180(m.parse(t)):m.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,r;if(2==t.length&&([e,r]=t,e=m.wrap90(m.parse(e)),r=m.wrap180(m.parse(r)),isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,r]=t[0].split(","),e=m.wrap90(m.parse(e)),r=m.wrap180(m.parse(r)),isNaN(e)||isNaN(r)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const a=t[0];if("Point"==a.type&&Array.isArray(a.coordinates)?[r,e]=a.coordinates:(null!=a.latitude&&(e=a.latitude),null!=a.lat&&(e=a.lat),null!=a.longitude&&(r=a.longitude),null!=a.lng&&(r=a.lng),null!=a.lon&&(r=a.lon),e=m.wrap90(m.parse(e)),r=m.wrap180(m.parse(r))),isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(r))throw new TypeError(`invalid point ‘${t.toString()}’`);return new M(e,r)}distanceTo(t,e=6371e3){if(t instanceof M||(t=M.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const r=e,a=this.lat.toRadians(),n=this.lon.toRadians(),o=t.lat.toRadians(),i=o-a,s=t.lon.toRadians()-n,l=Math.sin(i/2)*Math.sin(i/2)+Math.cos(a)*Math.cos(o)*Math.sin(s/2)*Math.sin(s/2);return r*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(t){if(t instanceof M||(t=M.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),r=t.lat.toRadians(),a=(t.lon-this.lon).toRadians(),n=Math.cos(e)*Math.sin(r)-Math.sin(e)*Math.cos(r)*Math.cos(a),o=Math.sin(a)*Math.cos(r),i=Math.atan2(o,n).toDegrees();return m.wrap360(i)}finalBearingTo(t){t instanceof M||(t=M.parse(t));const e=t.initialBearingTo(this)+180;return m.wrap360(e)}midpointTo(t){t instanceof M||(t=M.parse(t));const e=this.lat.toRadians(),r=this.lon.toRadians(),a=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),o=Math.cos(e),i=0,s=Math.sin(e),l={x:o+Math.cos(a)*Math.cos(n),y:i+Math.cos(a)*Math.sin(n),z:s+Math.sin(a)},u=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),c=r+Math.atan2(l.y,l.x),h=u.toDegrees(),d=c.toDegrees();return new M(h,d)}intermediatePointTo(t,e){if(t instanceof M||(t=M.parse(t)),this.equals(t))return new M(this.lat,this.lon);const r=this.lat.toRadians(),a=this.lon.toRadians(),n=t.lat.toRadians(),o=t.lon.toRadians(),i=n-r,s=o-a,l=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2),u=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),c=Math.sin((1-e)*u)/Math.sin(u),h=Math.sin(e*u)/Math.sin(u),d=c*Math.cos(r)*Math.cos(a)+h*Math.cos(n)*Math.cos(o),p=c*Math.cos(r)*Math.sin(a)+h*Math.cos(n)*Math.sin(o),g=c*Math.sin(r)+h*Math.sin(n),f=Math.atan2(g,Math.sqrt(d*d+p*p)),y=Math.atan2(p,d),m=f.toDegrees(),v=y.toDegrees();return new M(m,v)}destinationPoint(t,e,r=6371e3){const a=t/r,n=Number(e).toRadians(),o=this.lat.toRadians(),i=this.lon.toRadians(),s=Math.sin(o)*Math.cos(a)+Math.cos(o)*Math.sin(a)*Math.cos(n),l=Math.asin(s),u=Math.sin(n)*Math.sin(a)*Math.cos(o),c=Math.cos(a)-Math.sin(o)*s,h=i+Math.atan2(u,c),d=l.toDegrees(),p=h.toDegrees();return new M(d,p)}static intersection(t,e,r,a){if(t instanceof M||(t=M.parse(t)),r instanceof M||(r=M.parse(r)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(a))throw new TypeError(`invalid brng2 ‘${a}’`);const n=t.lat.toRadians(),o=t.lon.toRadians(),i=r.lat.toRadians(),s=r.lon.toRadians(),l=Number(e).toRadians(),u=Number(a).toRadians(),c=i-n,h=s-o,d=2*Math.asin(Math.sqrt(Math.sin(c/2)*Math.sin(c/2)+Math.cos(n)*Math.cos(i)*Math.sin(h/2)*Math.sin(h/2)));if(Math.abs(d)<Number.EPSILON)return new M(t.lat,t.lon);const p=(Math.sin(i)-Math.sin(n)*Math.cos(d))/(Math.sin(d)*Math.cos(n)),g=(Math.sin(n)-Math.sin(i)*Math.cos(d))/(Math.sin(d)*Math.cos(i)),f=Math.acos(Math.min(Math.max(p,-1),1)),y=Math.acos(Math.min(Math.max(g,-1),1)),m=l-(Math.sin(s-o)>0?f:2*v-f),b=(Math.sin(s-o)>0?2*v-y:y)-u;if(0==Math.sin(m)&&0==Math.sin(b))return null;if(Math.sin(m)*Math.sin(b)<0)return null;const w=-Math.cos(m)*Math.cos(b)+Math.sin(m)*Math.sin(b)*Math.cos(d),x=Math.atan2(Math.sin(d)*Math.sin(m)*Math.sin(b),Math.cos(b)+Math.cos(m)*w),P=Math.asin(Math.min(Math.max(Math.sin(n)*Math.cos(x)+Math.cos(n)*Math.sin(x)*Math.cos(l),-1),1)),N=o+Math.atan2(Math.sin(l)*Math.sin(x)*Math.cos(n),Math.cos(x)-Math.sin(n)*Math.sin(P)),S=P.toDegrees(),E=N.toDegrees();return new M(S,E)}crossTrackDistanceTo(t,e,r=6371e3){t instanceof M||(t=M.parse(t)),e instanceof M||(e=M.parse(e));const a=r;if(this.equals(t))return 0;const n=t.distanceTo(this,a)/a,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(n)*Math.sin(o-i))*a}alongTrackDistanceTo(t,e,r=6371e3){t instanceof M||(t=M.parse(t)),e instanceof M||(e=M.parse(e));const a=r;if(this.equals(t))return 0;const n=t.distanceTo(this,a)/a,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians(),s=Math.asin(Math.sin(n)*Math.sin(o-i));return Math.acos(Math.cos(n)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(i-o))*a}maxLatitude(t){const e=Number(t).toRadians(),r=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(r))).toDegrees()}static crossingParallels(t,e,r){if(t.equals(e))return null;const a=Number(r).toRadians(),n=t.lat.toRadians(),o=t.lon.toRadians(),i=e.lat.toRadians(),s=e.lon.toRadians()-o,l=Math.sin(n)*Math.cos(i)*Math.cos(a)*Math.sin(s),u=Math.sin(n)*Math.cos(i)*Math.cos(a)*Math.cos(s)-Math.cos(n)*Math.sin(i)*Math.cos(a),c=Math.cos(n)*Math.cos(i)*Math.sin(a)*Math.sin(s);if(c*c>l*l+u*u)return null;const h=Math.atan2(-u,l),d=Math.acos(c/Math.sqrt(l*l+u*u)),p=o+h+d,g=(o+h-d).toDegrees(),f=p.toDegrees();return{lon1:m.wrap180(g),lon2:m.wrap180(f)}}rhumbDistanceTo(t,e=6371e3){t instanceof M||(t=M.parse(t));const r=e,a=this.lat.toRadians(),n=t.lat.toRadians(),o=n-a;let i=Math.abs(t.lon-this.lon).toRadians();Math.abs(i)>v&&(i=i>0?-(2*v-i):2*v+i);const s=Math.log(Math.tan(n/2+v/4)/Math.tan(a/2+v/4)),l=Math.abs(s)>1e-11?o/s:Math.cos(a);return Math.sqrt(o*o+l*l*i*i)*r}rhumbBearingTo(t){if(t instanceof M||(t=M.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),r=t.lat.toRadians();let a=(t.lon-this.lon).toRadians();Math.abs(a)>v&&(a=a>0?-(2*v-a):2*v+a);const n=Math.log(Math.tan(r/2+v/4)/Math.tan(e/2+v/4)),o=Math.atan2(a,n).toDegrees();return m.wrap360(o)}rhumbDestinationPoint(t,e,r=6371e3){const a=this.lat.toRadians(),n=this.lon.toRadians(),o=Number(e).toRadians(),i=t/r,s=i*Math.cos(o);let l=a+s;Math.abs(l)>v/2&&(l=l>0?v-l:-v-l);const u=Math.log(Math.tan(l/2+v/4)/Math.tan(a/2+v/4)),c=Math.abs(u)>1e-11?s/u:Math.cos(a),h=n+i*Math.sin(o)/c,d=l.toDegrees(),p=h.toDegrees();return new M(d,p)}rhumbMidpointTo(t){t instanceof M||(t=M.parse(t));const e=this.lat.toRadians();let r=this.lon.toRadians();const a=t.lat.toRadians(),n=t.lon.toRadians();Math.abs(n-r)>v&&(r+=2*v);const o=(e+a)/2,i=Math.tan(v/4+e/2),s=Math.tan(v/4+a/2),l=Math.tan(v/4+o/2);let u=((n-r)*Math.log(l)+r*Math.log(s)-n*Math.log(i))/Math.log(s/i);isFinite(u)||(u=(r+n)/2);const c=o.toDegrees(),h=u.toDegrees();return new M(c,h)}static areaOf(t,e=6371e3){const r=e,a=t[0].equals(t[t.length-1]);a||t.push(t[0]);const n=t.length-1;let o=0;for(let e=0;e<n;e++){const r=t[e].lat.toRadians(),a=t[e+1].lat.toRadians(),n=(t[e+1].lon-t[e].lon).toRadians();o+=2*Math.atan2(Math.tan(n/2)*(Math.tan(r/2)+Math.tan(a/2)),1+Math.tan(r/2)*Math.tan(a/2))}(function(t){let e=0,r=t[0].initialBearingTo(t[1]);for(let a=0;a<t.length-1;a++){const n=t[a].initialBearingTo(t[a+1]),o=t[a].finalBearingTo(t[a+1]);e+=(n-r+540)%360-180,e+=(o-n+540)%360-180,r=o}const a=t[0].initialBearingTo(t[1]);e+=(a-r+540)%360-180;return Math.abs(e)<90})(t)&&(o=Math.abs(o)-2*v);const i=Math.abs(o*r*r);return a||t.pop(),i}equals(t){return t instanceof M||(t=M.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${m.toLat(this.lat,t,e)}, ${m.toLon(this.lon,t,e)}`}}function b(t,e,r){if(null!==t)for(var a,n,o,i,s,l,u,c,h=0,d=0,p=t.type,g="FeatureCollection"===p,f="Feature"===p,y=g?t.features.length:1,m=0;m<y;m++){s=(c=!!(u=g?t.features[m].geometry:f?t.geometry:t)&&"GeometryCollection"===u.type)?u.geometries.length:1;for(var v=0;v<s;v++){var M=0,w=0;if(null!==(i=c?u.geometries[v]:u)){l=i.coordinates;var x=i.type;switch(h=0,x){case null:break;case"Point":if(!1===e(l,d,m,M,w))return!1;d++,M++;break;case"LineString":case"MultiPoint":for(a=0;a<l.length;a++){if(!1===e(l[a],d,m,M,w))return!1;d++,"MultiPoint"===x&&M++}"LineString"===x&&M++;break;case"Polygon":case"MultiLineString":for(a=0;a<l.length;a++){for(n=0;n<l[a].length-h;n++){if(!1===e(l[a][n],d,m,M,w))return!1;d++}"MultiLineString"===x&&M++,"Polygon"===x&&w++}"Polygon"===x&&M++;break;case"MultiPolygon":for(a=0;a<l.length;a++){for(w=0,n=0;n<l[a].length;n++){for(o=0;o<l[a][n].length-h;o++){if(!1===e(l[a][n][o],d,m,M,w))return!1;d++}w++}M++}break;case"GeometryCollection":for(a=0;a<i.geometries.length;a++)if(!1===b(i.geometries[a],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var w=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const r=[1/0,1/0,-1/0,-1/0];return b(t,t=>{r[0]>t[0]&&(r[0]=t[0]),r[1]>t[1]&&(r[1]=t[1]),r[2]<t[0]&&(r[2]=t[0]),r[3]<t[1]&&(r[3]=t[1])}),r},x=(t,e)=>{var[r,a]=t,[n,o]=e,i=new M(a,r),s=new M(o,n);return i.distanceTo(s)},P=t=>{var e=t/1609.344;if(e<.5)return"".concat(Math.round(t),"m");if(e<10){var r=Number.parseFloat(e.toFixed(1)),a=1===r?"mile":"miles";return"".concat(r," ").concat(a)}var n=Math.round(e);return"".concat(n," miles")},N=(t,e,r)=>{var[a,n]=e,o=r.filter(e=>{var[r,o]=e;return(r!==a||o!==n)&&((t,e,r)=>{switch(t){case"ArrowUp":return r<0&&Math.abs(r)>=Math.abs(e);case"ArrowDown":return r>0&&Math.abs(r)>=Math.abs(e);case"ArrowLeft":return e<0&&Math.abs(e)>Math.abs(r);case"ArrowRight":return e>0&&Math.abs(e)>Math.abs(r);default:return!1}})(t,r-a,o-n)});if(!o.length)return r.findIndex(t=>t[0]===a&&t[1]===n);var i=-1,s=1/0;return o.forEach(t=>{var e=t[0]-a,o=t[1]-n,l=e*e+o*o;l<s&&(s=l,i=r.indexOf(t))}),i},S=t=>w(t);function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var O="highlighted-label";function R(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var{stops:r}=t;if(r.length<2)return r.length>0?r[0][1]:0;for(var a=r[0],n=r[r.length-1],o=1;o<r.length;o++){var i=r[o];if(i[0]>e){n=i,a=r[o-1];break}a=r[o-1],n=i}var[s,l]=a,[u,c]=n;return e<=s?l:e>=u?c:l+(e-s)/(u-s)*(c-l)}(t,e);var[,,r,...a]=t;if("zoom"!==r[0])throw new Error("Only zoom-based expressions supported");for(var n=0;n<a.length-2;n+=2){var o=a[n],i=a[n+1],s=a[n+2],l=a[n+3];if(e<=o)return i;if(e<=s)return i+(e-o)/(s-o)*(l-i)}return a[a.length-1]}function j(t,e,r){return e.flatMap(e=>{var a,n=function(t){var e,r;return"string"==typeof t?null===(e=/^{(.+)}$/.exec(t))||void 0===e?void 0:e[1]:Array.isArray(t)?null===(r=t.find(t=>Array.isArray(t)&&"get"===t[0]))||void 0===r?void 0:r[1]:null}(null===(a=e.layout)||void 0===a?void 0:a["text-field"]);return n?r.filter(t=>{var r;return t.layer.id===e.id&&(null===(r=t.properties)||void 0===r?void 0:r[n])}).map(r=>function(t,e,r,a){var n=function(t){var{type:e,coordinates:r}=t;if("Point"===e)return r;if("MultiPoint"===e)return r[0];if(e.includes("LineString")){var a="LineString"===e?r:r[0];return[(a[0][0]+a[a.length-1][0])/2,(a[0][1]+a[a.length-1][1])/2]}if(e.includes("Polygon")){var n="Polygon"===e?r[0]:r[0][0],o=n.reduce((t,e)=>[t[0]+e[0],t[1]+e[1]],[0,0]);return[o[0]/n.length,o[1]/n.length]}return null}(t.geometry);if(!n)return null;var o=a.project({lng:n[0],lat:n[1]});return{text:t.properties[r],x:o.x,y:o.y,feature:t,layer:e}}(r,e,n,t)).filter(Boolean):[]})}function T(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function D(t,e,r){var a;if(null!=e&&null!==(a=e.feature)&&void 0!==a&&a.layer){T(t,r);var{feature:n,layer:o}=e;r.highlightLayerId="highlight-".concat(o.id);var{id:i,type:s,properties:l,geometry:u}=n;t.getSource(O).setData({id:i,type:s,properties:l,geometry:u}),r.highlightedExpr=o.layout["text-size"];var c=t.getZoom(),h=function(t,e,r){return{id:"highlight-".concat(t.id),type:t.type,source:O,layout:L(L({},t.layout),{},{"text-size":e,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:L(L({},t.paint),{},{"text-color":r.text,"text-halo-color":r.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(o,1.5*R(r.highlightedExpr,c),r.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});t.addLayer(h),t.moveLayer(r.highlightLayerId)}}function A(t){t.getSource(O)||t.addSource(O,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function C(t){t.getStyle().layers.filter(t=>{var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(e=>t.setLayoutProperty(e.id,"symbol-placement","line-center"))}function I(t,e,r,a){var n={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function o(){var e=t.getStyle().layers.filter(t=>"symbol"===t.type),r=t.queryRenderedFeatures({layers:e.map(t=>t.id)});n.labels=j(t,e,r)}function i(){if(o(),!n.labels.length)return null;var e=t.project(t.getCenter()),r=function(t,e){var r;return null===(r=t.reduce((t,r)=>{var a=(r.x-e.x)**2+(r.y-e.y)**2;return!t||a<t.dist?{label:r,dist:a}:t},null))||void 0===r?void 0:r.label}(n.labels,e);return n.currentPixel={x:r.x,y:r.y},D(t,r,n),"".concat(r.text," (").concat(r.layer.id,")")}return C(t),A(t),null==a||a.on(r.MAP_SET_STYLE,e=>{t.once("styledata",()=>t.once("idle",()=>{C(t),A(t),n.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)}))}),t.on("zoom",()=>{if(n.highlightLayerId&&n.highlightedExpr){var e=R(n.highlightedExpr,t.getZoom());t.setLayoutProperty(n.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(t=>"symbol"===t.type).forEach(e=>{t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:o,highlightNextLabel:function(e){if(o(),!n.labels.length)return null;if(!n.currentPixel)return i();var r=function(t,e){if(!e.currentPixel)return null;var r=e.labels.map((t,e)=>({pixel:[t.x,t.y],index:e})).filter(t=>t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y);if(!r.length)return null;var a=r.map(t=>t.pixel),n=N(t,[e.currentPixel.x,e.currentPixel.y],a);return(null==n||n<0||n>=r.length)&&(n=0),e.labels[r[n].index]}(e,n);return r?(n.currentPixel={x:r.x,y:r.y},D(t,r,n),"".concat(r.text," (").concat(r.layer.id,")")):null},highlightLabelAtCenter:i,clearHighlightedLabel:()=>T(t,n)}}function _(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function k(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?_(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var B=(t,e,r,a,n,o,i)=>{t.getLayer(e)||t.addLayer(k(k({id:e,type:r,source:a},n&&{"source-layer":n}),{},{paint:o})),Object.entries(o).forEach(r=>{var[a,n]=r;t.setPaintProperty(e,a,n)}),t.setFilter(e,i),t.moveLayer(e)};function F(t){var{LngLatBounds:e,map:r,selectedFeatures:a,stylesMap:n}=t;if(!r)return null;var o=((t,e)=>{var r={};return null==e||e.forEach(e=>{var{featureId:a,layerId:n,idProperty:o,geometry:i}=e,s=t.getLayer(n);if(s){var l=s.source;r[l]||(r[l]={ids:new Set,fillIds:new Set,idProperty:o,layerId:n,hasFillGeometry:!1}),!i||"Polygon"!==i.type&&"MultiPolygon"!==i.type||(r[l].hasFillGeometry=!0,r[l].fillIds.add(a)),r[l].ids.add(a)}}),r})(r,a),i=[],s=new Set(Object.keys(o)),l=r._highlightedSources||new Set;return((t,e,r)=>{e.forEach(e=>{if(!r.has(e)){var a="highlight-".concat(e);["".concat(a,"-fill"),"".concat(a,"-line"),"".concat(a,"-symbol")].forEach(e=>{t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})})(r,l,s),r._highlightedSources=s,s.forEach(t=>{var{ids:e,fillIds:a,idProperty:s,layerId:l,hasFillGeometry:u}=o[t],c=r.getLayer(l),h=c.sourceLayer,d=u?"fill":c.type,p="highlight-".concat(t),g=s?["get",s]:["id"],f=["in",g,["literal",[...e]]];if("fill"===d){var{stroke:y,strokeWidth:m,fill:v}=n[l],M=["in",g,["literal",[...a]]],b={"line-color":y,"line-width":m};B(r,"".concat(p,"-fill"),"fill",t,h,{"fill-color":v},M),B(r,"".concat(p,"-line"),"line",t,h,b,f)}if("line"===d){var{stroke:w,strokeWidth:x}=n[l],P={"line-color":w,"line-width":x};r.getLayer("".concat(p,"-fill"))&&r.setFilter("".concat(p,"-fill"),["==","id",""]),B(r,"".concat(p,"-line"),"line",t,h,P,f)}if("symbol"===d){var N=r.getLayoutProperty(l,"icon-image"),S=((t,e)=>{var r,a;return null!==(r=null===(a=t._symbolImageMap)||void 0===a?void 0:a[e])&&void 0!==r?r:null})(r,N);S&&((t,e,r,a,n,o,i)=>{var s;t.getLayer(e)||t.addLayer(k(k({id:e,type:"symbol",source:r},a&&{"source-layer":a}),{},{layout:{"icon-image":o,"icon-anchor":null!==(s=t.getLayoutProperty(n,"icon-anchor"))&&void 0!==s?s:"center","icon-allow-overlap":!0}})),t.setLayoutProperty(e,"icon-image",o),t.setFilter(e,i),t.moveLayer(e)})(r,"".concat(p,"-symbol"),t,h,l,S,f)}i.push(...r.queryRenderedFeatures({layers:[l]}).filter(t=>{var r;return e.has(s?null===(r=t.properties)||void 0===r?void 0:r[s]:t.id)}))}),((t,e)=>{if(!e.length)return null;var r=new t;return e.forEach(t=>{var e=t=>"number"==typeof t[0]?r.extend(t):t.forEach(e);e(t.geometry.coordinates)}),[r.getWest(),r.getSouth(),r.getEast(),r.getNorth()]})(e,i)}var z=(t,e,r)=>{var a=(e.x-r.x)**2+(e.y-r.y)**2;if(0===a)return(t.x-e.x)**2+(t.y-e.y)**2;var n=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/a;return n=Math.max(0,Math.min(1,n)),(t.x-(e.x+n*(r.x-e.x)))**2+(t.y-(e.y+n*(r.y-e.y)))**2},$=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:a=10}=r,n=[[e.x-a,e.y-a],[e.x+a,e.y+a]],o=t.queryRenderedFeatures(n);if(0===o.length)return[];var i=new Set(t.queryRenderedFeatures([e.x,e.y]).map(t=>{var e,r=void 0===t.id?JSON.stringify(t.properties):t.id;return"".concat(null===(e=t.layer)||void 0===e?void 0:e.source,":").concat(r)})),s=[];o.forEach(t=>{!1===s.includes(t.layer.id)&&s.push(t.layer.id)});for(var l=new Set,u=[],c=o.length-1;c>=0;c--){var h,d=o[c],p=void 0===d.id?JSON.stringify(d.properties):d.id,g="".concat(null===(h=d.layer)||void 0===h?void 0:h.source,":").concat(p);!1===l.has(g)&&(l.add(g),u.push(d))}var f=t.unproject(e),y=[f.lng,f.lat],m=u.filter(t=>{var e=t.geometry.type;if(e.includes("Polygon"))return("Polygon"===e?[t.geometry.coordinates]:t.geometry.coordinates).some(t=>((t,e)=>{for(var[r,a]=t,n=!1,o=0,i=e.length-1;o<e.length;i=o,o++){var[s,l]=e[o],[u,c]=e[i];l>a!=c>a&&r<(u-s)*(a-l)/(c-l)+s&&(n=!n)}return n})(y,t[0]));if("Point"===e||"MultiPoint"===e){var r,a=void 0===t.id?JSON.stringify(t.properties):t.id;return i.has("".concat(null===(r=t.layer)||void 0===r?void 0:r.source,":").concat(a))}return!0});return m.map(r=>{var a=0,n=r.geometry.type,o=((t,e,r)=>{var{coordinates:a,type:n}=r,o=1/0,i=e=>t.project(e),s=t=>{for(var r=0;r<t.length-1;r++){var a=z(e,i(t[r]),i(t[r+1]));a<o&&(o=a)}};if("Point"===n){var l=i(a);o=(e.x-l.x)**2+(e.y-l.y)**2}else"LineString"===n||"MultiPoint"===n?"LineString"===n?s(a):a.forEach(t=>{var r=i(t),a=(e.x-r.x)**2+(e.y-r.y)**2;a<o&&(o=a)}):"Polygon"===n||"MultiLineString"===n?a.forEach(s):"MultiPolygon"===n&&a.forEach(t=>t.forEach(s));return o})(t,e,r.geometry);return a+=1e6*s.indexOf(r.layer.id),n.includes("Polygon")&&(a-=5e5),{f:r,score:a+=o}}).sort((t,e)=>t.score-e.score).map(t=>{var{f:e}=t;return e})},q=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),W=(t,e)=>t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?e.get(t.symbol):void 0,Z=t=>{if(!(t=>!(!t.symbol&&!t.symbolSvgContent))(t))return{};var e={};return q.forEach(r=>{if(null!=t[r]){var a=r.charAt(6).toLowerCase()+r.slice(7);e[a]=t[r]}}),e},G=(t,e,r)=>new Promise((a,n)=>{var o=new Blob([t],{type:"image/svg+xml"}),i=URL.createObjectURL(o),s=new Image(e,r);s.onload=()=>{var t=document.createElement("canvas");t.width=e,t.height=r;var n=t.getContext("2d");n.drawImage(s,0,0,e,r),URL.revokeObjectURL(i),a(n.getImageData(0,0,e,r))},s.onerror=()=>{URL.revokeObjectURL(i),n(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},s.src=i}),H=t=>{var e=0;for(var r of t)e=Math.trunc((e<<5)-e+r.codePointAt(0));return Math.abs(e).toString(36)},U=function(t,e,r){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,o=W(t,r);if(!o)return null;var i=Z(t),s=a?r.resolveSelected(o,i,e):r.resolve(o,i,e);return"symbol-".concat(a?"sel-":"").concat(H(s),"-").concat(n,"x")},V=new Map,J=function(){var t=i(function*(t,e,r,a,n){var o=W(t,r);if(!o)return null;var i=Z(t),s=a?r.resolveSelected(o,i,e):r.resolve(o,i,e),l="symbol-".concat(a?"sel-":"").concat(H(s),"-").concat(n,"x"),u=V.get(l);if(!u){var c=((t,e)=>{var r;return t.symbolViewBox?t.symbolViewBox:null!==(r=null==e?void 0:e.viewBox)&&void 0!==r?r:"0 0 38 38"})(t,o),[,,h,d]=c.split(" ").map(Number),p='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(h*n,'" height="').concat(d*n,'" viewBox="').concat(c,'">').concat(s,"</svg>");u=yield G(p,h*n,d*n),V.set(l,u)}return{imageId:l,imageData:u}});return function(e,r,a,n,o){return t.apply(this,arguments)}}(),Y=function(){var t=i(function*(t,e,r,a){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;e.length&&(t._symbolImageMap={},yield Promise.all(e.flatMap(e=>{var o=U(e,r,a,!1,n),s=U(e,r,a,!0,n);return o&&s&&(t._symbolImageMap[o]=s),[!1,!0].map(function(){var l=i(function*(i){var l=i?s:o;if(l&&!t.hasImage(l)){var u=yield J(e,r,a,i,n);u&&!t.hasImage(u.imageId)&&t.addImage(u.imageId,u.imageData,{pixelRatio:n})}});return function(t){return l.apply(this,arguments)}}())})))});return function(e,r,a,n){return t.apply(this,arguments)}}(),K=(t,e)=>{if(!t)return null;if("string"==typeof t)return t.trim();if("object"==typeof t){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null},X=(t,e)=>{return t.fillPatternSvgContent?t.fillPatternSvgContent:t.fillPattern&&null!==(r=null==e||null===(a=e.get(t.fillPattern))||void 0===a?void 0:a.svgContent)&&void 0!==r?r:null;var r,a},Q=(t,e,r)=>{var a=X(t,r);if(!a)return null;var n=K(t.fillPatternForegroundColor,e)||"black",o=K(t.fillPatternBackgroundColor,e)||"transparent";return"pattern-".concat((t=>{var e=0;for(var r of t)e=(e<<5)-e+r.codePointAt(0),e&=e;return Math.abs(e).toString(36)})(a+n+o))},tt=new Map,et=function(){var t=i(function*(t,e,r){var a=X(t,r);if(!a)return null;var n=Q(t,e,r);if(!n)return null;var o,i,s=tt.get(n);if(!s){var l=K(t.fillPatternForegroundColor,e)||"black",u=K(t.fillPatternBackgroundColor,e)||"transparent",c=(o=l,i=u,a.replace(/\{\{foregroundColor\}\}/g,o||"black").replace(/\{\{backgroundColor\}\}/g,i||"transparent")),h='<rect width="16" height="16" fill="'.concat(u,'"/>'),d='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">'.concat(h).concat(c,"</svg>");s=yield G(d,16,16),tt.set(n,s)}return{imageId:n,imageData:s}});return function(e,r,a){return t.apply(this,arguments)}}(),rt=function(){var t=i(function*(t,e,r,a){e.length&&(yield Promise.all(e.map(function(){var e=i(function*(e){var n=Q(e,r,a);if(n&&!t.hasImage(n)){var o=yield et(e,r,a);o&&t.addImage(o.imageId,o.imageData,{pixelRatio:2})}});return function(t){return e.apply(this,arguments)}}())))});return function(e,r,a,n){return t.apply(this,arguments)}}(),at=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,a)}return r}function ot(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?nt(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):nt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}class it{constructor(t){var{mapFramework:e,mapProviderConfig:r={},events:a,eventBus:n}=t;this.maplibreModule=e,this.events=a,this.eventBus=n,this.capabilities={supportedShortcuts:u,supportsMapSizes:!0},Object.assign(this,r)}initMap(t){var e=this;return i(function*(){var{container:r,padding:a,mapStyle:n,mapSize:i,center:s,zoom:l,bounds:u,pixelRatio:c}=t,h=o(t,at);e.mapStyleId=null==n?void 0:n.id,e.mapSize=i;var{Map:d}=e.maplibreModule,{events:p,eventBus:g}=e,y=new d(ot(ot({},h),{},{container:r,style:null==n?void 0:n.url,pixelRatio:c,padding:a,center:s,zoom:l,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));y.touchZoomRotate.disableRotation(),e.map=y,e.map.setPadding(a),u&&y.fitBounds(u,{duration:0}),function(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var r=t.getCanvas();if(r&&(this.target===r||r.contains(this.target)))return}e.call(this)}}(y),function(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block"}(y),f({map:y,events:p,eventBus:g,getCenter:e.getCenter.bind(e),getZoom:e.getZoom.bind(e),getBounds:e.getBounds.bind(e),getResolution:e.getResolution.bind(e)}),function(t){var{mapProvider:e,map:r,events:a,eventBus:n}=t,o=t=>{r.once("style.load",()=>{n.emit(a.MAP_STYLE_CHANGE,{mapStyleId:t.id})}),r.setStyle(t.url,{diff:!1})},i=t=>{r.setPixelRatio(t)},s=t=>{var{mapSize:r}=t;e.mapSize=r};n.on(a.MAP_SET_STYLE,o),n.on(a.MAP_SET_PIXEL_RATIO,i),n.on(a.MAP_SIZE_CHANGE,s)}({mapProvider:e,map:y,events:p,eventBus:g}),y.on("load",()=>{e.labelNavigator=I(y,null==n?void 0:n.mapColorScheme,p,g)}),e.eventBus.emit(p.MAP_READY,{map:e.map,mapStyleId:e.mapStyleId,mapSize:e.mapSize,crs:e.crs})})()}destroyMap(){var t,e;this.setHoverCursor([]),null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(t){this.map&&(this._onHoverMove=((t,e,r)=>{var a=t.getCanvas();if(r&&t.off("mousemove",r),null==e||!e.length)return a.style.cursor="",null;var n=r=>{var n=e.filter(e=>t.getLayer(e));if(0!==n.length){var{lineLayers:o,otherLayers:i}=((t,e)=>{var r=[],a=[];for(var n of e)if("line"===t.getLayer(n).type){var o=n.endsWith("-stroke")?n.slice(0,-7):null;null!==o&&e.includes(o)||r.push(n)}else a.push(n);return{lineLayers:r,otherLayers:a}})(t,n),{x:s,y:l}=r.point,u=[[s-10,l-10],[s+10,l+10]],c=o.length>0&&t.queryRenderedFeatures(u,{layers:o}).length>0,h=i.length>0&&t.queryRenderedFeatures(r.point,{layers:i}).length>0;a.style.cursor=c||h?"pointer":""}else a.style.cursor=""};return t.on("mousemove",n),n})(this.map,t,this._onHoverMove))}setView(t){var{center:e,zoom:r}=t;this.map.flyTo({center:e||this.getCenter(),zoom:r||this.getZoom(),duration:this.map.isStyleLoaded()?s:0})}zoomIn(t){this.map.easeTo({zoom:this.getZoom()+t,duration:s})}zoomOut(t){this.map.easeTo({zoom:this.getZoom()-t,duration:s})}panBy(t){this.map.panBy(t,{duration:s})}fitToBounds(t){var e=Array.isArray(t)?t:S(t),r=this.map.isStyleLoaded()?s:0;this.map.fitBounds(e,{duration:r})}setPadding(t){this.map.setPadding(t)}updateHighlightedFeatures(t,e){var{LngLatBounds:r}=this.maplibreModule;return F({LngLatBounds:r,map:this.map,selectedFeatures:t,stylesMap:e})}highlightNextLabel(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}highlightLabelAtCenter(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}clearHighlightedLabel(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}getCenter(){var t=this.map.getCenter();return[Number(t.lng.toFixed(l)),Number(t.lat.toFixed(l))]}getZoom(){return Number(this.map.getZoom().toFixed(l))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(t,e){return $(this.map,t,e)}registerSymbols(t,e,r){var a=this;return i(function*(){var n=(a.map.getPixelRatio()||1)*(p[a.mapSize]||1);return Y(a.map,t,e,r,n)})()}registerPatterns(t,e,r){var a=this;return i(function*(){return rt(a.map,t,e,r)})()}getAreaDimensions(){var{LngLatBounds:t}=this.maplibreModule;return(t=>{var e,r,a,n;if(t&&"function"==typeof t.getWest)e=t.getWest(),r=t.getSouth(),a=t.getEast(),n=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";[[e,r],[a,n]]=t}var o=x([e,r],[a,r]),i=x([e,r],[e,n]),s=P(o),l=P(i);return"".concat(l," by ").concat(s)})(((t,e)=>{var{width:r,height:a}=e.getContainer().getBoundingClientRect(),n=e.getPadding(),o=[n.left,a-n.bottom],i=[r-n.right,n.top];return new t(e.unproject(o),e.unproject(i))})(t,this.map))}getCardinalMove(t,e){return((t,e)=>{var[r,a]=t,[n,o]=e,i=o-a,s=n-r,l=[];if(Math.abs(i)>1e-4){var u=Math.round(x([r,a],[r,o]));l.push("".concat(i>0?"north":"south"," ").concat(P(u)))}if(Math.abs(s)>1e-4){var c=Math.round(x([r,a],[n,a]));l.push("".concat(s>0?"east":"west"," ").concat(P(c)))}return l.join(", ")})(t,e)}getResolution(){return t=this.map.getCenter(),e=this.map.getZoom(),r=t.lat,a=Math.pow(2,e),40075016.686*Math.cos(r*Math.PI/180)/(512*a);var t,e,r,a}mapToScreen(t){return this.map.project(t)}screenToMap(t){var{lng:e,lat:r}=this.map.unproject([t.x,t.y]);return[e,r]}isGeometryObscured(t,e){return((t,e,r)=>{var a=r.getContainer().getBoundingClientRect(),[n,o,i,s]=S(t),l=[r.project([n,o]),r.project([n,s]),r.project([i,o]),r.project([i,s])],u=Math.min(...l.map(t=>t.x)),c=Math.max(...l.map(t=>t.x)),h=Math.min(...l.map(t=>t.y)),d=Math.max(...l.map(t=>t.y)),p=e.left-a.left,g=e.top-a.top,f=e.right-a.left,y=e.bottom-a.top;return u<f&&c>p&&h<y&&d>g})(t,e,this.map)}}export{it as default};
|