maplair 4.0.0-alpha.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +22 -38
  2. package/LICENSE +1 -1
  3. package/README.md +10 -9
  4. package/dist/esm/control/SearchControl.js +1 -1
  5. package/dist/esm/control/SearchControl.js.map +1 -1
  6. package/dist/esm/geo/LatLng.js +20 -2
  7. package/dist/esm/geo/LatLng.js.map +1 -1
  8. package/dist/esm/geo/LatLngBounds.js +19 -7
  9. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  10. package/dist/esm/geo/crs/CRS.js +4 -3
  11. package/dist/esm/geo/crs/CRS.js.map +1 -1
  12. package/dist/esm/geo/projection/Projection.LonLat.js +2 -2
  13. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  14. package/dist/esm/geo/projection/Projection.Mercator.js +2 -2
  15. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  16. package/dist/esm/geo/projection/Projection.SphericalMercator.js +2 -2
  17. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  18. package/dist/esm/geometry/Bounds.js +19 -7
  19. package/dist/esm/geometry/Bounds.js.map +1 -1
  20. package/dist/esm/geometry/Point.js +23 -5
  21. package/dist/esm/geometry/Point.js.map +1 -1
  22. package/dist/esm/geometry/PolyUtil.js +1 -1
  23. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  24. package/dist/esm/layer/DivOverlay.js +1 -1
  25. package/dist/esm/layer/DivOverlay.js.map +1 -1
  26. package/dist/esm/layer/GeoJSON.js +1 -1
  27. package/dist/esm/layer/GeoJSON.js.map +1 -1
  28. package/dist/esm/layer/Popup.js +1 -1
  29. package/dist/esm/layer/Popup.js.map +1 -1
  30. package/dist/esm/layer/marker/DivIcon.js +1 -1
  31. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  32. package/dist/esm/layer/marker/Icon.js +2 -2
  33. package/dist/esm/layer/marker/Icon.js.map +1 -1
  34. package/dist/esm/layer/marker/Marker.Move.js +1 -1
  35. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  36. package/dist/esm/layer/marker/Marker.js +2 -2
  37. package/dist/esm/layer/marker/Marker.js.map +1 -1
  38. package/dist/esm/layer/tile/GridLayer.js +1 -1
  39. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  40. package/dist/esm/layer/vector/Polyline.js +1 -1
  41. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  42. package/dist/esm/map/Map.Rotation.js +5 -5
  43. package/dist/esm/map/Map.Rotation.js.map +1 -1
  44. package/dist/esm/map/Map.js +19 -19
  45. package/dist/esm/map/Map.js.map +1 -1
  46. package/dist/esm/map/handler/DragHandler.js +1 -1
  47. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  48. package/dist/esm/map/handler/KeyboardHandler.js +2 -2
  49. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  50. package/dist/esm/package.js +1 -1
  51. package/dist/maplair-global-src.js +134 -73
  52. package/dist/maplair-global-src.js.map +1 -1
  53. package/dist/maplair-global.js +3 -3
  54. package/dist/maplair-global.js.map +1 -1
  55. package/dist/maplair-src.js +134 -73
  56. package/dist/maplair-src.js.map +1 -1
  57. package/dist/maplair.js +3 -3
  58. package/dist/maplair.js.map +1 -1
  59. package/package.json +4 -4
  60. package/src/control/SearchControl.js +2 -2
  61. package/src/geo/LatLng.js +21 -2
  62. package/src/geo/LatLngBounds.js +20 -7
  63. package/src/geo/crs/CRS.js +4 -3
  64. package/src/geo/projection/Projection.LonLat.js +2 -2
  65. package/src/geo/projection/Projection.Mercator.js +2 -2
  66. package/src/geo/projection/Projection.SphericalMercator.js +2 -2
  67. package/src/geometry/Bounds.js +20 -7
  68. package/src/geometry/Point.js +24 -5
  69. package/src/geometry/PolyUtil.js +1 -1
  70. package/src/layer/DivOverlay.js +1 -1
  71. package/src/layer/GeoJSON.js +1 -1
  72. package/src/layer/Popup.js +3 -3
  73. package/src/layer/marker/DivIcon.js +1 -1
  74. package/src/layer/marker/Icon.js +2 -2
  75. package/src/layer/marker/Marker.Move.js +1 -1
  76. package/src/layer/marker/Marker.js +2 -2
  77. package/src/layer/tile/GridLayer.js +1 -1
  78. package/src/layer/vector/Polyline.js +1 -1
  79. package/src/map/Map.Rotation.js +7 -7
  80. package/src/map/Map.js +21 -21
  81. package/src/map/handler/DragHandler.js +1 -1
  82. package/src/map/handler/KeyboardHandler.js +2 -2
package/CHANGELOG.md CHANGED
@@ -3,14 +3,25 @@ Maplair Changelog
3
3
 
4
4
  (all changes of Leaflet without author notice are by [@mourner](https://github.com/mourner))
5
5
 
6
- ## 4.0.0-alpha.2 (2026-10-17)
6
+ ## 4.0.0 (2026-10-19) 🍁 Maplair, a fork of Leaflet
7
7
 
8
- For an overview and a migration guide from Leaflet 1.9.4, see the blog post: https://maplair.org/2026/10/17/maplair-4.0.0-alpha.2.html
8
+ The first release of Maplair, a fork of Leaflet. It contains all changes since Leaflet 1.9.4: those of Leaflet 2.0.0-alpha and 2.0.0-alpha.1 (see below), the unreleased changes of Leaflet until the fork, and Maplair's own changes.
9
+
10
+ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: https://maplair.org/2026/10/19/maplair-4.0.0.html
11
+
12
+ ### Maplair
9
13
 
10
14
  (changes without author notice are by [@simon04](https://github.com/simon04))
11
15
 
12
16
  #### ❇️ New Features
13
17
 
18
+ * Translations of the built-in strings with `I18n` (cherry-picked from https://github.com/Leaflet/Leaflet/pull/9845), translated on Transifex: https://app.transifex.com/simon04/maplair/
19
+ * Translations to German, Spanish, French, Czech, Slovak, Hungarian, Slovenian, Italian and Romansh
20
+ * Map: new option `markerCulling` to take markers far outside of the view off the page
21
+ * Marker: new option `shadow` to disable icon shadows for performance
22
+ * Publish one ES module per source file (`dist/esm`) and declare `sideEffects`, so that bundlers can drop unused features
23
+ * Bring back `L.noConflict()` in the global build `maplair-global.js`
24
+ * New logo, maple leaf marker icon with zigzag outline, and favicon
14
25
  * Add `FullscreenControl` with `toggleFullscreen()`, `isFullscreen()` and the events `enterfullscreen`, `exitfullscreen` and `fullscreenchange`
15
26
  * Add `SearchControl` with custom geocoders and `SearchControl.nominatim()`, complying with the Nominatim usage policy (`acceptUsagePolicy`)
16
27
  * Add `ButtonControl`, `ButtonBarControl` and `TextControl`, and the Control option `order`
@@ -25,6 +36,7 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
25
36
  * Add `DisplaceHandler` for the displacement of overlapping circle markers
26
37
  * Add `TapDragZoomHandler` to zoom by double tapping and dragging up/down
27
38
  * Add `LatLng.parse()` for coordinates in decimal degrees and geo URIs
39
+ * Add `LatLng.from()`, `Point.from()`, `Bounds.from()` and `LatLngBounds.from()`, which return instances as they are, unlike the constructors
28
40
  * Map: add rotation with `bearing`, `setBearing()`, `pinchRotate` and `RotateControl` (optional module `maplair/map-rotation`)
29
41
  * Marker: add the options `rotationAngle` and `rotationOrigin` (optional module `maplair/marker-rotation`)
30
42
  * Animate markers along routes with `moveTo()`/`moveAlong()` (optional module `maplair/marker-movement`) and dashes along paths with `dashSpeed` (optional module `maplair/dash-animation`)
@@ -47,42 +59,6 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
47
59
  * Use CSS variables for the colors, borders, shadows, fonts and spacing
48
60
  * Ship TypeScript type declarations (`dist/types/`)
49
61
 
50
- #### 🐞 Bugfixes
51
-
52
- * TileLayer: with `detectRetina`, no longer request tiles beyond `maxNativeZoom`
53
- * Release the pointer capture only if it is still active
54
-
55
- #### 📝 Docs
56
-
57
- * Replace Leafdoc with JSDoc, and generate the API reference from the type declarations
58
- * Explain the name Maplair, mention tree-shaking and update the bundle sizes on the homepage
59
-
60
- #### 🔧 Workflow
61
-
62
- * Migrate from npm to pnpm 12, upgrade Vite+ to 1.3.0 and Vitest to 5.0.5
63
- * Check that optional features are dropped by tree-shaking unless imported (`pnpm run test:tree-shaking`)
64
- * Type-check the type declarations and the debug pages (`pnpm run types:check`)
65
-
66
- ## 4.0.0-alpha.1 (2026-10-15) 🍁 Maplair, a fork of Leaflet
67
-
68
- The first pre-release of Maplair, a fork of Leaflet. It contains all changes since Leaflet 1.9.4: those of Leaflet 2.0.0-alpha and 2.0.0-alpha.1 (see below), the unreleased changes of Leaflet until the fork, and Maplair's own changes.
69
-
70
- For an overview and a migration guide from Leaflet 1.9.4, see the blog post: https://maplair.org/2026/10/17/maplair-4.0.0-alpha.2.html
71
-
72
- ### Maplair
73
-
74
- (changes without author notice are by [@simon04](https://github.com/simon04))
75
-
76
- #### ❇️ New Features
77
-
78
- * Translations of the built-in strings with `I18n` (cherry-picked from https://github.com/Leaflet/Leaflet/pull/9845), translated on Transifex: https://app.transifex.com/simon04/maplair/
79
- * Translations to German, Spanish, French, Czech, Slovak, Hungarian, Slovenian, Italian and Romansh
80
- * Map: new option `markerCulling` to take markers far outside of the view off the page
81
- * Marker: new option `shadow` to disable icon shadows for performance
82
- * Publish one ES module per source file (`dist/esm`) and declare `sideEffects`, so that bundlers can drop unused features
83
- * Bring back `L.noConflict()` in the global build `maplair-global.js`
84
- * New logo, maple leaf marker icon with zigzag outline, and favicon
85
-
86
62
  #### ✨ Refactorings (⚠️ Breaking Changes)
87
63
 
88
64
  * Rename Leaflet to Maplair: npm package `maplair`, files `maplair*.js`/`maplair.css`, CSS classes `maplair-*`, `LeafletMap` to `MaplairMap`
@@ -102,11 +78,14 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
102
78
  * Popup: avoid a second forced layout when opening a popup
103
79
  * Events: index listeners by function and context, and store them in Sets, so that adding and removing many layers isn't quadratic
104
80
  * Skip unchanged transform and z-index style writes
81
+ * Don't copy points and bounds which are only read, e.g. in the projections and `Point#add()`
105
82
 
106
83
  #### 🐞 Bugfixes
107
84
 
108
85
  * DomEvent.stopPropagation: keep feature detection for DOM events of other windows (e.g. iframes)
109
86
  * Fix the `Map.addInitHook` example in the controls tutorial
87
+ * TileLayer: with `detectRetina`, no longer request tiles beyond `maxNativeZoom`
88
+ * Release the pointer capture only if it is still active
110
89
 
111
90
  #### 📝 Docs
112
91
 
@@ -115,12 +94,17 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
115
94
  * Credit major contributors in `CITATION.cff`, `package.json`, `README.md`, `LICENSE` and the website footer
116
95
  * Document standard constructors, init hooks and translations
117
96
  * Remove the Ukraine appeal, Leaflet's social media links and the "Trusted by the best" logos
97
+ * Replace Leafdoc with JSDoc, and generate the API reference from the type declarations
98
+ * Explain the name Maplair, mention tree-shaking and update the bundle sizes on the homepage
118
99
 
119
100
  #### 🔧 Workflow
120
101
 
121
102
  * Test, build, lint and run commit hooks with Vite+ (`vp test`, `vp pack`, `vp lint`, `vp staged`), replacing Vitest, Rollup, ESLint, husky and lint-staged
122
103
  * Serve the debug pages with `vp dev`; remove bundlemon, `http-server` and `ssri`
123
104
  * Upgrade `eslint-plugin-baseline-js` to 0.7.5, `@e18e/eslint-plugin` to 0.8.1 and Playwright to 1.64
105
+ * Migrate from npm to pnpm 12, upgrade Vite+ to 1.3.0 and Vitest to 5.0.5
106
+ * Check that optional features are dropped by tree-shaking unless imported (`pnpm run test:tree-shaking`)
107
+ * Type-check the type declarations and the debug pages (`pnpm run types:check`)
124
108
 
125
109
  #### 🧪 Tests
126
110
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 2-Clause License
2
2
 
3
- Copyright (c) 2026, Maplair contributors
3
+ Copyright (c) 2026, Simon Legner and Maplair contributors
4
4
  Copyright (c) 2010-2026, Volodymyr Agafonkin
5
5
  Copyright (c) 2010-2011, CloudMade
6
6
  All rights reserved.
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  <img width="600" src="src/images/logo.svg" alt="Maplair" />
2
2
 
3
- Maplair is the leading open-source JavaScript library for **building powerful interactive maps**.
3
+ Maplair is an open-source JavaScript library for **building powerful interactive maps**, a fork of [Leaflet](https://leafletjs.com), the leading library for this.
4
4
 
5
- Weighing just about 39 kB of gzipped JS plus 3.1 kB of gzipped CSS code, it has all the mapping [features][] most developers ever need.
6
- And since Maplair supports tree-shaking, your bundler shakes off the leaves you don't use 🍁
7
- (a map with just a tile layer comes out about a quarter smaller).
5
+ Since Maplair supports tree-shaking, your bundler shakes off the leaves you don't use 🍁
6
+ A map with just a tile layer weighs about 34 kB of gzipped JS plus 5.3 kB of gzipped CSS code.
7
+ With everything included, about 63 kB of gzipped JS, it has all the mapping [features][] most developers ever need.
8
8
 
9
9
  Maplair is designed with *simplicity*, *performance* and *usability* in mind.
10
10
  It works efficiently across all major desktop and mobile platforms out of the box,
11
- taking advantage of modern browser features while being accessible on older ones too.
12
- It can be extended with a huge amount of [plugins][],
11
+ using only web features that are [Baseline Widely available](https://web.dev/baseline).
12
+ It is easy to [extend][],
13
13
  has a beautiful, easy to use and [well-documented][] API
14
14
  and a simple, readable [source code][] that is a joy to [contribute][] to.
15
15
 
@@ -23,16 +23,17 @@ and push the limits of what's possible with online maps!
23
23
 
24
24
  ## Authors
25
25
 
26
- Maplair is a fork of [Leaflet](https://leafletjs.com), created in 2010 by [Volodymyr Agafonkin](https://agafonkin.com).
26
+ Maplair is developed by [Simon Legner](https://github.com/simon04)
27
+ as a fork of [Leaflet](https://leafletjs.com), created in 2010 by [Volodymyr Agafonkin](https://agafonkin.com).
27
28
  Major contributors include Iván Sánchez Ortega, Dave Leaver, Yohan Boniface, Jon Koops,
28
- Florian Bischof, Per Liedman, John Firebaugh and Simon Legner,
29
+ Florian Bischof, Per Liedman and John Firebaugh,
29
30
  along with [hundreds of other contributors][contributors].
30
31
 
31
32
  [![CI](https://github.com/maplair/maplair/actions/workflows/main.yml/badge.svg)](https://github.com/maplair/maplair/actions/workflows/main.yml)
32
33
 
33
34
  [contributors]: https://github.com/maplair/maplair/graphs/contributors
34
35
  [features]: https://maplair.org/#features
35
- [plugins]: https://maplair.org/plugins.html
36
+ [extend]: https://maplair.org/examples/extending-1-classes/
36
37
  [well-documented]: https://maplair.org/reference.html "Maplair API reference"
37
38
  [source code]: https://github.com/maplair/maplair "Maplair GitHub repository"
38
39
  [hosted on GitHub]: https://github.com/maplair/maplair
@@ -320,7 +320,7 @@ var SearchControl = class SearchControl extends Control {
320
320
  * @returns {this}
321
321
  */
322
322
  select(result) {
323
- const map = this._map, latlng = new LatLng(result.latlng), bounds = result.bounds ? new LatLngBounds(result.bounds) : void 0;
323
+ const map = this._map, latlng = LatLng.from(result.latlng), bounds = result.bounds ? LatLngBounds.from(result.bounds) : void 0;
324
324
  this._input.value = result.label;
325
325
  this._showResults([]);
326
326
  if (bounds?.isValid() && !bounds.getNorthWest().equals(bounds.getSouthEast())) map.fitBounds(bounds, { maxZoom: this.options.zoom });
@@ -1 +1 @@
1
- {"version":3,"file":"SearchControl.js","names":["DomUtil.create","Util.stamp","Util.falseFn"],"sources":["../../../src/control/SearchControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\nimport {LatLng} from '../geo/LatLng.js';\nimport {LatLngBounds} from '../geo/LatLngBounds.js';\nimport {Marker} from '../layer/marker/Marker.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n/** @import {LatLngExpression} from '../geo/LatLng.js' */\n/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */\n\nconst searchIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><circle cx=\"6.5\" cy=\"6.5\" r=\"4.5\"/><path d=\"M10 10l4.5 4.5\"/></svg>';\n\n// the time of the next allowed request to each Nominatim server, shared by all geocoders\nconst nextRequests = new Map();\n\n// Resolves after `ms` milliseconds, rejects when the signal aborts\nfunction delay(ms, signal) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tsignal.addEventListener('abort', () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(signal.reason);\n\t\t}, {once: true});\n\t});\n}\n\n/**\n * A result of a search, returned by a [geocoder](#searchcontrol-geocoder).\n * @typedef {object} SearchResult\n * @property {string} label The text shown in the list of results, e.g. an address.\n * @property {LatLngExpression} latlng The position of the result.\n * @property {LatLngBoundsExpression} [bounds] The extent of the result, e.g. of a city,\n * which the map fits to instead of zooming to the position.\n * @property {any} [raw] The original result of the service, for use in event listeners.\n */\n\n/**\n * A function searching places for a query, see the [`geocoder`](#searchcontrol-geocoder)\n * option. It should pass the `signal` to `fetch()`: searches are aborted when the user\n * starts another one. Optional properties of the function: `attribution`, an attribution\n * text which the control adds to the map, and `autoComplete: false` if the service\n * forbids searching while typing (overriding the\n * [`autoComplete`](#searchcontrol-autocomplete) option).\n * @typedef {((query: string, options: {signal: AbortSignal}) => Promise<SearchResult[]>) & {attribution?: string, autoComplete?: boolean}} Geocoder\n */\n\n/**\n * Options of `SearchControl`.\n * @typedef {object} SearchControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {Geocoder} geocoder The function searching places (required), e.g.\n * [Nominatim](#searchcontrol-nominatim). Coordinates (see\n * [`LatLng.parse()`](#latlng-parse)) are found without it.\n * @property {boolean} [collapsed=true] If `true`, the control is collapsed into a button\n * and expanded on click.\n * @property {boolean} [autoComplete=false] Whether to search while typing instead of\n * on <kbd>Enter</kbd>. Not with the public Nominatim service, its\n * [usage policy](https://operations.osmfoundation.org/policies/nominatim/) forbids\n * auto-complete.\n * @property {number} [autoCompleteDelay=250] The delay in milliseconds after typing\n * before searching with [`autoComplete`](#searchcontrol-autocomplete).\n * @property {number} [minLength=3] The minimum length of queries searched with\n * [`autoComplete`](#searchcontrol-autocomplete).\n * @property {number} [zoom=16] The zoom level for results without bounds, and the\n * maximum zoom level for fitting the bounds of results.\n * @property {boolean} [marker=true] Whether to show a marker at the selected result.\n * @property {string} [placeholder] The placeholder of the search field, by default\n * the translation of \"Search\".\n * @extends ControlOptions\n */\n\n/**\n * The event object of `searchresult`.\n * @typedef {object} SearchResultEvent\n * @property {SearchResult} result The selected result.\n * @property {LatLng} latlng The position of the result.\n * @property {LatLngBounds|undefined} bounds The extent of the result, if any.\n * @extends MaplairEvent\n */\n\n/**\n * A control with a search field for places, showing the results in a list to select\n * one with the pointer or the keyboard. The selected result is shown on the map with a\n * marker. It searches with a [`geocoder`](#searchcontrol-geocoder), e.g.\n * [Nominatim](#searchcontrol-nominatim) of OpenStreetMap or any other service.\n * Coordinates like `47.27, 11.4` or `geo:47.27,11.4` are found without a service.\n *\n * The public Nominatim service is free, but limited by its\n * [usage policy](https://operations.osmfoundation.org/policies/nominatim/): it is for\n * occasional searches of users, not for heavy use (an absolute maximum of one request\n * per second for all users of an app), and forbids auto-complete. The\n * [Nominatim geocoder](#searchcontrol-nominatim) follows the technical requirements,\n * but you are responsible for your use of the service, which you confirm with the\n * `acceptUsagePolicy` option: for more traffic, use your own Nominatim server or a\n * commercial provider.\n *\n * @example\n * ```js\n * new SearchControl({\n * geocoder: SearchControl.nominatim({acceptUsagePolicy: true})\n * }).addTo(map);\n *\n * // Photon of Komoot, which allows auto-complete\n * new SearchControl({\n * autoComplete: true,\n * async geocoder(query, {signal}) {\n * const response = await fetch(`https://photon.komoot.io/api/?q=${encodeURIComponent(query)}`, {signal});\n * const {features} = await response.json();\n * return features.map(({geometry, properties}) => ({\n * label: [properties.name, properties.city, properties.country].filter(Boolean).join(', '),\n * latlng: [geometry.coordinates[1], geometry.coordinates[0]],\n * raw: properties\n * }));\n * }\n * }).addTo(map);\n * ```\n *\n * @fires MaplairMap#searchresult {SearchResultEvent} Fired when a result of the\n * [search control](#searchcontrol) is selected.\n */\nexport class SearchControl extends Control {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tposition: 'topleft',\n\t\t\tgeocoder: undefined,\n\t\t\tcollapsed: true,\n\t\t\tautoComplete: false,\n\t\t\tautoCompleteDelay: 250,\n\t\t\tminLength: 3,\n\t\t\tzoom: 16,\n\t\t\tmarker: true,\n\t\t\tplaceholder: undefined\n\t\t});\n\t}\n\n\t/**\n\t * Returns a [geocoder](#searchcontrol-geocoder) searching with\n\t * [Nominatim](https://nominatim.org/release-docs/latest/api/Search/), by default the\n\t * public service of OpenStreetMap. Using it requires that you read and accept its\n\t * [usage policy](https://operations.osmfoundation.org/policies/nominatim/) with the\n\t * `acceptUsagePolicy` option, otherwise this throws an error. The geocoder sends at most one request per second, caches the results of the last 100\n\t * queries, adds the OpenStreetMap attribution to the map and does not search while\n\t * typing with the public service. For more traffic, use your own Nominatim server or a\n\t * commercial provider.\n\t *\n\t * @example\n\t * ```js\n\t * new SearchControl({\n\t * geocoder: SearchControl.nominatim({acceptUsagePolicy: true, params: {countrycodes: 'at,de'}})\n\t * }).addTo(map);\n\t * ```\n\t * @param {object} [options]\n\t * @param {string} [options.url='https://nominatim.openstreetmap.org/search'] The URL\n\t * of the search endpoint.\n\t * @param {Record<string, string>} [options.params] Further query parameters, e.g.\n\t * `countrycodes`, `viewbox` or `limit` (5 by default).\n\t * @param {boolean} [options.acceptUsagePolicy=false] Confirms that your use of the\n\t * public service complies with its\n\t * [usage policy](https://operations.osmfoundation.org/policies/nominatim/), required\n\t * for the public service.\n\t * @returns {Geocoder}\n\t */\n\tstatic nominatim({url = 'https://nominatim.openstreetmap.org/search', params = {}, acceptUsagePolicy = false} = {}) {\n\t\tconst {host} = new URL(url),\n\t\tpublicService = host === 'nominatim.openstreetmap.org';\n\t\tif (publicService && !acceptUsagePolicy) {\n\t\t\tthrow new Error('Using the public Nominatim service requires that you read and accept its usage policy (https://operations.osmfoundation.org/policies/nominatim/) with the acceptUsagePolicy option.');\n\t\t}\n\t\t// the results of recent queries\n\t\tconst cache = new Map();\n\n\t\tasync function geocoder(query, {signal}) {\n\t\t\tconst search = new URLSearchParams({q: query, format: 'jsonv2', limit: '5', ...params}),\n\t\t\trequestUrl = `${url}?${search}`;\n\t\t\tif (cache.has(requestUrl)) {\n\t\t\t\treturn cache.get(requestUrl);\n\t\t\t}\n\n\t\t\t// at most one request per second\n\t\t\tconst now = Date.now(), next = nextRequests.get(host) ?? 0, wait = next - now;\n\t\t\tnextRequests.set(host, Math.max(now, next) + 1000);\n\t\t\tif (wait > 0) {\n\t\t\t\tawait delay(wait, signal);\n\t\t\t}\n\n\t\t\tconst response = await fetch(requestUrl, {signal});\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Nominatim: ${response.status} ${response.statusText}`);\n\t\t\t}\n\t\t\tconst results = (await response.json()).map((place) => {\n\t\t\t\t// [south, north, west, east]\n\t\t\t\tconst [s, n, w, e] = place.boundingbox.map(Number);\n\t\t\t\treturn {\n\t\t\t\t\tlabel: place.display_name,\n\t\t\t\t\tlatlng: [Number(place.lat), Number(place.lon)],\n\t\t\t\t\tbounds: [[s, w], [n, e]],\n\t\t\t\t\traw: place\n\t\t\t\t};\n\t\t\t});\n\t\t\tcache.set(requestUrl, results);\n\t\t\tif (cache.size > 100) {\n\t\t\t\tcache.delete(cache.keys().next().value);\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\n\t\treturn Object.defineProperties(geocoder, {\n\t\t\t// the same as of OpenStreetMap tiles, translated when added\n\t\t\tattribution: {get: () => `&copy; <a href=\"https://www.openstreetmap.org/copyright\">${I18n.translate('OpenStreetMap contributors')}</a>`},\n\t\t\tautoComplete: {value: !publicService}\n\t\t});\n\t}\n\n\t/**\n\t * Creates a search control.\n\t * @param {...SearchControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tif (!this.options.geocoder) {\n\t\t\tthrow new Error('SearchControl: the geocoder option is required, e.g. SearchControl.nominatim().');\n\t\t}\n\t\tthis.callInitHooks(SearchControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst className = 'maplair-control-search',\n\t\tcontainer = this._container = DomUtil.create('div', `${className} maplair-bar`),\n\t\tform = DomUtil.create('form', `${className}-form`, container),\n\t\ttoggle = this._toggle = DomUtil.create('button', `${className}-toggle`, form),\n\t\tinput = this._input = DomUtil.create('input', `${className}-input`, form),\n\t\treset = DomUtil.create('button', `${className}-reset`, form),\n\t\tlist = this._list = DomUtil.create('ul', `${className}-results`, container),\n\t\tlistId = `${className}-results-${Util.stamp(this)}`,\n\t\ttitle = I18n.translate('Search');\n\n\t\tform.role = 'search';\n\t\ttoggle.type = 'button';\n\t\ttoggle.innerHTML = searchIcon;\n\t\ttoggle.title = title;\n\t\ttoggle.setAttribute('aria-label', title);\n\n\t\tinput.type = 'search';\n\t\tinput.placeholder = this.options.placeholder ?? title;\n\t\tinput.autocomplete = 'off';\n\t\tinput.enterKeyHint = 'search';\n\t\tinput.role = 'combobox';\n\t\tinput.setAttribute('aria-label', title);\n\t\tinput.setAttribute('aria-autocomplete', 'list');\n\t\tinput.setAttribute('aria-controls', listId);\n\n\t\treset.type = 'reset';\n\t\treset.innerHTML = '<span aria-hidden=\"true\">&times;</span>';\n\t\treset.title = I18n.translate('Clear the search');\n\t\treset.setAttribute('aria-label', reset.title);\n\n\t\tlist.id = listId;\n\t\tlist.role = 'listbox';\n\t\tlist.setAttribute('aria-label', I18n.translate('Search results'));\n\n\t\tthis._message = DomUtil.create('div', `${className}-message`, container);\n\t\tthis._message.role = 'status';\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(container);\n\t\tDomEvent.on(toggle, 'click', this._onToggle, this);\n\t\tDomEvent.on(form, 'submit', this._onSubmit, this);\n\t\tDomEvent.on(form, 'reset', this._onReset, this);\n\t\tDomEvent.on(input, 'input', this._onInput, this);\n\t\tDomEvent.on(input, 'keydown', this._onKeyDown, this);\n\t\tDomEvent.on(list, 'click', this._onListClick, this);\n\t\tmap.on('click', this._onMapClick, this);\n\t\tthis._attribution = this.options.geocoder.attribution;\n\t\tmap.attributionControl?.addAttribution(this._attribution);\n\n\t\tthis._showResults([]);\n\t\tthis._setExpanded(!this.options.collapsed);\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('click', this._onMapClick, this);\n\t\tmap.attributionControl?.removeAttribution(this._attribution);\n\t\tthis._abort();\n\t\tthis._marker?.remove();\n\t}\n\n\t/**\n\t * Expands the search field of a [collapsed](#searchcontrol-collapsed) control and\n\t * focuses it.\n\t * @returns {this}\n\t */\n\texpand() {\n\t\tthis._setExpanded(true);\n\t\tthis._input.focus();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Collapses the control into its button, if [collapsed](#searchcontrol-collapsed),\n\t * and hides the results.\n\t * @returns {this}\n\t */\n\tcollapse() {\n\t\tthis._showResults([]);\n\t\tthis._setExpanded(!this.options.collapsed);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches the given text and shows the results in the list. Resolves to the results.\n\t * @param {string} query\n\t * @returns {Promise<SearchResult[]>}\n\t */\n\tasync search(query) {\n\t\tthis._abort();\n\t\tthis._input.value = query;\n\t\tquery = query.trim();\n\t\tif (!query) {\n\t\t\tthis._showResults([]);\n\t\t\treturn [];\n\t\t}\n\n\t\tconst latlng = LatLng.parse(query);\n\t\tif (latlng) {\n\t\t\tconst results = [{label: query, latlng}];\n\t\t\tthis._showResults(results);\n\t\t\treturn results;\n\t\t}\n\n\t\tconst controller = this._controller = new AbortController();\n\t\tthis._container.classList.add('maplair-control-search-loading');\n\t\ttry {\n\t\t\tconst results = await this.options.geocoder(query, {signal: controller.signal});\n\t\t\tif (!controller.signal.aborted) {\n\t\t\t\tthis._showResults(results, I18n.translate('No results'));\n\t\t\t}\n\t\t\treturn results;\n\t\t} catch (error) {\n\t\t\tif (controller.signal.aborted) { return []; }\n\t\t\tthis._showResults([], I18n.translate('The search failed'));\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this._controller === controller) {\n\t\t\t\tthis._controller = null;\n\t\t\t\tthis._container.classList.remove('maplair-control-search-loading');\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Shows the given result on the map: zooms to it, shows a\n\t * [marker](#searchcontrol-marker) and fires `searchresult` on the map.\n\t * @param {SearchResult} result\n\t * @returns {this}\n\t */\n\tselect(result) {\n\t\tconst map = this._map,\n\t\tlatlng = new LatLng(result.latlng),\n\t\tbounds = result.bounds ? new LatLngBounds(result.bounds) : undefined;\n\n\t\tthis._input.value = result.label;\n\t\tthis._showResults([]);\n\n\t\tif (bounds?.isValid() && !bounds.getNorthWest().equals(bounds.getSouthEast())) {\n\t\t\tmap.fitBounds(bounds, {maxZoom: this.options.zoom});\n\t\t} else {\n\t\t\tmap.setView(latlng, this.options.zoom);\n\t\t}\n\n\t\tthis._marker?.remove();\n\t\tif (this.options.marker) {\n\t\t\tthis._marker = new Marker(latlng, {title: result.label}).addTo(map);\n\t\t}\n\n\t\tmap.fire('searchresult', {result, latlng, bounds});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears the search field, the results and the marker.\n\t * @returns {this}\n\t */\n\tclear() {\n\t\tthis._abort();\n\t\tthis._input.value = '';\n\t\tthis._showResults([]);\n\t\tthis._marker?.remove();\n\t\tthis._marker = null;\n\t\treturn this;\n\t}\n\n\t_setExpanded(expanded) {\n\t\tthis._container.classList.toggle('maplair-control-search-expanded', expanded);\n\t\tthis._toggle.setAttribute('aria-expanded', expanded);\n\t}\n\n\t_abort() {\n\t\tclearTimeout(this._autoCompleteTimeout);\n\t\tthis._controller?.abort();\n\t\tthis._controller = null;\n\t\tthis._container?.classList.remove('maplair-control-search-loading');\n\t}\n\n\t// Shows the results, or the message if there are none\n\t_showResults(results, message = '') {\n\t\tthis._results = results;\n\t\tthis._list.replaceChildren(...results.map((result, i) => {\n\t\t\tconst item = DomUtil.create('li', 'maplair-control-search-result');\n\t\t\titem.id = `${this._list.id}-${i}`;\n\t\t\titem.role = 'option';\n\t\t\titem.textContent = result.label;\n\t\t\treturn item;\n\t\t}));\n\t\tthis._list.hidden = !results.length;\n\t\tthis._message.textContent = results.length ? '' : message;\n\t\tthis._message.hidden = !this._message.textContent;\n\t\tthis._input.setAttribute('aria-expanded', !!results.length);\n\t\tthis._setActive(-1);\n\t}\n\n\t_setActive(index) {\n\t\tthis._active = index;\n\t\tfor (const [i, item] of [...this._list.children].entries()) {\n\t\t\titem.setAttribute('aria-selected', i === index);\n\t\t}\n\t\tif (index < 0) {\n\t\t\tthis._input.removeAttribute('aria-activedescendant');\n\t\t} else {\n\t\t\tconst item = this._list.children[index];\n\t\t\tthis._input.setAttribute('aria-activedescendant', item.id);\n\t\t\titem.scrollIntoView({block: 'nearest'});\n\t\t}\n\t}\n\n\t_onToggle() {\n\t\tif (this.options.collapsed && !this._container.classList.contains('maplair-control-search-expanded')) {\n\t\t\tthis.expand();\n\t\t} else {\n\t\t\tthis._onSubmit();\n\t\t}\n\t}\n\n\t_onSubmit(e) {\n\t\tif (e) { DomEvent.preventDefault(e); }\n\t\tconst query = this._input.value,\n\t\tresult = this._results[this._active],\n\t\tlatlng = LatLng.parse(query);\n\t\tif (result) {\n\t\t\tthis.select(result);\n\t\t} else if (latlng) {\n\t\t\tthis.select({label: query.trim(), latlng});\n\t\t} else {\n\t\t\t// errors are shown in the control\n\t\t\tthis.search(query).catch(Util.falseFn);\n\t\t}\n\t}\n\n\t_onReset() {\n\t\tthis.clear();\n\t\tthis._input.focus();\n\t}\n\n\t_onInput() {\n\t\tclearTimeout(this._autoCompleteTimeout);\n\t\tconst query = this._input.value.trim();\n\t\tif (!this.options.autoComplete || this.options.geocoder.autoComplete === false) {\n\t\t\tthis._showResults([]);\n\t\t} else if (query.length >= this.options.minLength || LatLng.parse(query)) {\n\t\t\tthis._autoCompleteTimeout = setTimeout(() => {\n\t\t\t\tthis.search(this._input.value).catch(Util.falseFn);\n\t\t\t}, this.options.autoCompleteDelay);\n\t\t} else {\n\t\t\tthis._abort();\n\t\t\tthis._showResults([]);\n\t\t}\n\t}\n\n\t_onKeyDown(e) {\n\t\tconst n = this._results.length;\n\t\tif ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && n) {\n\t\t\tDomEvent.preventDefault(e);\n\t\t\tconst step = e.key === 'ArrowDown' ? 1 : -1;\n\t\t\t// from no active result, the first or the last one\n\t\t\tthis._setActive(((this._active < 0 && step < 0 ? n : this._active) + step + n) % n);\n\t\t} else if (e.key === 'Escape') {\n\t\t\tDomEvent.preventDefault(e);\n\t\t\tif (n || !this._message.hidden) {\n\t\t\t\tthis._showResults([]);\n\t\t\t} else if (this._input.value) {\n\t\t\t\tthis.clear();\n\t\t\t} else if (this.options.collapsed) {\n\t\t\t\tthis.collapse();\n\t\t\t\tthis._map.getContainer().focus();\n\t\t\t}\n\t\t}\n\t}\n\n\t_onListClick(e) {\n\t\tconst item = e.target.closest('.maplair-control-search-result'),\n\t\tindex = [...this._list.children].indexOf(item);\n\t\tif (index >= 0) {\n\t\t\tthis.select(this._results[index]);\n\t\t}\n\t}\n\n\t_onMapClick() {\n\t\tif (this._input.value) {\n\t\t\tthis._showResults([]);\n\t\t} else {\n\t\t\tthis.collapse();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,aAAa;AAGnB,MAAM,+BAAe,IAAI,IAAI;AAG7B,SAAS,MAAM,IAAI,QAAQ;CAC1B,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,MAAM,UAAU,WAAW,SAAS,EAAE;EACtC,OAAO,iBAAiB,eAAe;GACtC,aAAa,OAAO;GACpB,OAAO,OAAO,MAAM;EACrB,GAAG,EAAC,MAAM,KAAI,CAAC;CAChB,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGA,IAAa,gBAAb,MAAa,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Q,cAAc,IAAI;GAEzC,KAAK,aAAa,KAAK,UAAU,KAAK,OAAO,IAAI,IAAI,KAAK,WAAW,OAAO,KAAK,CAAC;EACnF,OAAO,IAAI,EAAE,QAAQ,UAAU;GAC9B,eAAwB,CAAC;GACzB,IAAI,KAAK,CAAC,KAAK,SAAS,QACvB,KAAK,aAAa,CAAC,CAAC;QACd,IAAI,KAAK,OAAO,OACtB,KAAK,MAAM;QACL,IAAI,KAAK,QAAQ,WAAW;IAClC,KAAK,SAAS;IACd,KAAK,KAAK,aAAa,CAAC,CAAC,MAAM;GAChC;EACD;CACD;CAEA,aAAa,GAAG;EACf,MAAM,OAAO,EAAE,OAAO,QAAQ,gCAAgC,GAC9D,QAAQ,CAAC,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC,QAAQ,IAAI;EAC7C,IAAI,SAAS,GACZ,KAAK,OAAO,KAAK,SAAS,MAAM;CAElC;CAEA,cAAc;EACb,IAAI,KAAK,OAAO,OACf,KAAK,aAAa,CAAC,CAAC;OAEpB,KAAK,SAAS;CAEhB;AACD"}
1
+ {"version":3,"file":"SearchControl.js","names":["DomUtil.create","Util.stamp","Util.falseFn"],"sources":["../../../src/control/SearchControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\nimport {LatLng} from '../geo/LatLng.js';\nimport {LatLngBounds} from '../geo/LatLngBounds.js';\nimport {Marker} from '../layer/marker/Marker.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n/** @import {LatLngExpression} from '../geo/LatLng.js' */\n/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */\n\nconst searchIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><circle cx=\"6.5\" cy=\"6.5\" r=\"4.5\"/><path d=\"M10 10l4.5 4.5\"/></svg>';\n\n// the time of the next allowed request to each Nominatim server, shared by all geocoders\nconst nextRequests = new Map();\n\n// Resolves after `ms` milliseconds, rejects when the signal aborts\nfunction delay(ms, signal) {\n\treturn new Promise((resolve, reject) => {\n\t\tconst timeout = setTimeout(resolve, ms);\n\t\tsignal.addEventListener('abort', () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(signal.reason);\n\t\t}, {once: true});\n\t});\n}\n\n/**\n * A result of a search, returned by a [geocoder](#searchcontrol-geocoder).\n * @typedef {object} SearchResult\n * @property {string} label The text shown in the list of results, e.g. an address.\n * @property {LatLngExpression} latlng The position of the result.\n * @property {LatLngBoundsExpression} [bounds] The extent of the result, e.g. of a city,\n * which the map fits to instead of zooming to the position.\n * @property {any} [raw] The original result of the service, for use in event listeners.\n */\n\n/**\n * A function searching places for a query, see the [`geocoder`](#searchcontrol-geocoder)\n * option. It should pass the `signal` to `fetch()`: searches are aborted when the user\n * starts another one. Optional properties of the function: `attribution`, an attribution\n * text which the control adds to the map, and `autoComplete: false` if the service\n * forbids searching while typing (overriding the\n * [`autoComplete`](#searchcontrol-autocomplete) option).\n * @typedef {((query: string, options: {signal: AbortSignal}) => Promise<SearchResult[]>) & {attribution?: string, autoComplete?: boolean}} Geocoder\n */\n\n/**\n * Options of `SearchControl`.\n * @typedef {object} SearchControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {Geocoder} geocoder The function searching places (required), e.g.\n * [Nominatim](#searchcontrol-nominatim). Coordinates (see\n * [`LatLng.parse()`](#latlng-parse)) are found without it.\n * @property {boolean} [collapsed=true] If `true`, the control is collapsed into a button\n * and expanded on click.\n * @property {boolean} [autoComplete=false] Whether to search while typing instead of\n * on <kbd>Enter</kbd>. Not with the public Nominatim service, its\n * [usage policy](https://operations.osmfoundation.org/policies/nominatim/) forbids\n * auto-complete.\n * @property {number} [autoCompleteDelay=250] The delay in milliseconds after typing\n * before searching with [`autoComplete`](#searchcontrol-autocomplete).\n * @property {number} [minLength=3] The minimum length of queries searched with\n * [`autoComplete`](#searchcontrol-autocomplete).\n * @property {number} [zoom=16] The zoom level for results without bounds, and the\n * maximum zoom level for fitting the bounds of results.\n * @property {boolean} [marker=true] Whether to show a marker at the selected result.\n * @property {string} [placeholder] The placeholder of the search field, by default\n * the translation of \"Search\".\n * @extends ControlOptions\n */\n\n/**\n * The event object of `searchresult`.\n * @typedef {object} SearchResultEvent\n * @property {SearchResult} result The selected result.\n * @property {LatLng} latlng The position of the result.\n * @property {LatLngBounds|undefined} bounds The extent of the result, if any.\n * @extends MaplairEvent\n */\n\n/**\n * A control with a search field for places, showing the results in a list to select\n * one with the pointer or the keyboard. The selected result is shown on the map with a\n * marker. It searches with a [`geocoder`](#searchcontrol-geocoder), e.g.\n * [Nominatim](#searchcontrol-nominatim) of OpenStreetMap or any other service.\n * Coordinates like `47.27, 11.4` or `geo:47.27,11.4` are found without a service.\n *\n * The public Nominatim service is free, but limited by its\n * [usage policy](https://operations.osmfoundation.org/policies/nominatim/): it is for\n * occasional searches of users, not for heavy use (an absolute maximum of one request\n * per second for all users of an app), and forbids auto-complete. The\n * [Nominatim geocoder](#searchcontrol-nominatim) follows the technical requirements,\n * but you are responsible for your use of the service, which you confirm with the\n * `acceptUsagePolicy` option: for more traffic, use your own Nominatim server or a\n * commercial provider.\n *\n * @example\n * ```js\n * new SearchControl({\n * geocoder: SearchControl.nominatim({acceptUsagePolicy: true})\n * }).addTo(map);\n *\n * // Photon of Komoot, which allows auto-complete\n * new SearchControl({\n * autoComplete: true,\n * async geocoder(query, {signal}) {\n * const response = await fetch(`https://photon.komoot.io/api/?q=${encodeURIComponent(query)}`, {signal});\n * const {features} = await response.json();\n * return features.map(({geometry, properties}) => ({\n * label: [properties.name, properties.city, properties.country].filter(Boolean).join(', '),\n * latlng: [geometry.coordinates[1], geometry.coordinates[0]],\n * raw: properties\n * }));\n * }\n * }).addTo(map);\n * ```\n *\n * @fires MaplairMap#searchresult {SearchResultEvent} Fired when a result of the\n * [search control](#searchcontrol) is selected.\n */\nexport class SearchControl extends Control {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tposition: 'topleft',\n\t\t\tgeocoder: undefined,\n\t\t\tcollapsed: true,\n\t\t\tautoComplete: false,\n\t\t\tautoCompleteDelay: 250,\n\t\t\tminLength: 3,\n\t\t\tzoom: 16,\n\t\t\tmarker: true,\n\t\t\tplaceholder: undefined\n\t\t});\n\t}\n\n\t/**\n\t * Returns a [geocoder](#searchcontrol-geocoder) searching with\n\t * [Nominatim](https://nominatim.org/release-docs/latest/api/Search/), by default the\n\t * public service of OpenStreetMap. Using it requires that you read and accept its\n\t * [usage policy](https://operations.osmfoundation.org/policies/nominatim/) with the\n\t * `acceptUsagePolicy` option, otherwise this throws an error. The geocoder sends at most one request per second, caches the results of the last 100\n\t * queries, adds the OpenStreetMap attribution to the map and does not search while\n\t * typing with the public service. For more traffic, use your own Nominatim server or a\n\t * commercial provider.\n\t *\n\t * @example\n\t * ```js\n\t * new SearchControl({\n\t * geocoder: SearchControl.nominatim({acceptUsagePolicy: true, params: {countrycodes: 'at,de'}})\n\t * }).addTo(map);\n\t * ```\n\t * @param {object} [options]\n\t * @param {string} [options.url='https://nominatim.openstreetmap.org/search'] The URL\n\t * of the search endpoint.\n\t * @param {Record<string, string>} [options.params] Further query parameters, e.g.\n\t * `countrycodes`, `viewbox` or `limit` (5 by default).\n\t * @param {boolean} [options.acceptUsagePolicy=false] Confirms that your use of the\n\t * public service complies with its\n\t * [usage policy](https://operations.osmfoundation.org/policies/nominatim/), required\n\t * for the public service.\n\t * @returns {Geocoder}\n\t */\n\tstatic nominatim({url = 'https://nominatim.openstreetmap.org/search', params = {}, acceptUsagePolicy = false} = {}) {\n\t\tconst {host} = new URL(url),\n\t\tpublicService = host === 'nominatim.openstreetmap.org';\n\t\tif (publicService && !acceptUsagePolicy) {\n\t\t\tthrow new Error('Using the public Nominatim service requires that you read and accept its usage policy (https://operations.osmfoundation.org/policies/nominatim/) with the acceptUsagePolicy option.');\n\t\t}\n\t\t// the results of recent queries\n\t\tconst cache = new Map();\n\n\t\tasync function geocoder(query, {signal}) {\n\t\t\tconst search = new URLSearchParams({q: query, format: 'jsonv2', limit: '5', ...params}),\n\t\t\trequestUrl = `${url}?${search}`;\n\t\t\tif (cache.has(requestUrl)) {\n\t\t\t\treturn cache.get(requestUrl);\n\t\t\t}\n\n\t\t\t// at most one request per second\n\t\t\tconst now = Date.now(), next = nextRequests.get(host) ?? 0, wait = next - now;\n\t\t\tnextRequests.set(host, Math.max(now, next) + 1000);\n\t\t\tif (wait > 0) {\n\t\t\t\tawait delay(wait, signal);\n\t\t\t}\n\n\t\t\tconst response = await fetch(requestUrl, {signal});\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Nominatim: ${response.status} ${response.statusText}`);\n\t\t\t}\n\t\t\tconst results = (await response.json()).map((place) => {\n\t\t\t\t// [south, north, west, east]\n\t\t\t\tconst [s, n, w, e] = place.boundingbox.map(Number);\n\t\t\t\treturn {\n\t\t\t\t\tlabel: place.display_name,\n\t\t\t\t\tlatlng: [Number(place.lat), Number(place.lon)],\n\t\t\t\t\tbounds: [[s, w], [n, e]],\n\t\t\t\t\traw: place\n\t\t\t\t};\n\t\t\t});\n\t\t\tcache.set(requestUrl, results);\n\t\t\tif (cache.size > 100) {\n\t\t\t\tcache.delete(cache.keys().next().value);\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\n\t\treturn Object.defineProperties(geocoder, {\n\t\t\t// the same as of OpenStreetMap tiles, translated when added\n\t\t\tattribution: {get: () => `&copy; <a href=\"https://www.openstreetmap.org/copyright\">${I18n.translate('OpenStreetMap contributors')}</a>`},\n\t\t\tautoComplete: {value: !publicService}\n\t\t});\n\t}\n\n\t/**\n\t * Creates a search control.\n\t * @param {...SearchControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tif (!this.options.geocoder) {\n\t\t\tthrow new Error('SearchControl: the geocoder option is required, e.g. SearchControl.nominatim().');\n\t\t}\n\t\tthis.callInitHooks(SearchControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst className = 'maplair-control-search',\n\t\tcontainer = this._container = DomUtil.create('div', `${className} maplair-bar`),\n\t\tform = DomUtil.create('form', `${className}-form`, container),\n\t\ttoggle = this._toggle = DomUtil.create('button', `${className}-toggle`, form),\n\t\tinput = this._input = DomUtil.create('input', `${className}-input`, form),\n\t\treset = DomUtil.create('button', `${className}-reset`, form),\n\t\tlist = this._list = DomUtil.create('ul', `${className}-results`, container),\n\t\tlistId = `${className}-results-${Util.stamp(this)}`,\n\t\ttitle = I18n.translate('Search');\n\n\t\tform.role = 'search';\n\t\ttoggle.type = 'button';\n\t\ttoggle.innerHTML = searchIcon;\n\t\ttoggle.title = title;\n\t\ttoggle.setAttribute('aria-label', title);\n\n\t\tinput.type = 'search';\n\t\tinput.placeholder = this.options.placeholder ?? title;\n\t\tinput.autocomplete = 'off';\n\t\tinput.enterKeyHint = 'search';\n\t\tinput.role = 'combobox';\n\t\tinput.setAttribute('aria-label', title);\n\t\tinput.setAttribute('aria-autocomplete', 'list');\n\t\tinput.setAttribute('aria-controls', listId);\n\n\t\treset.type = 'reset';\n\t\treset.innerHTML = '<span aria-hidden=\"true\">&times;</span>';\n\t\treset.title = I18n.translate('Clear the search');\n\t\treset.setAttribute('aria-label', reset.title);\n\n\t\tlist.id = listId;\n\t\tlist.role = 'listbox';\n\t\tlist.setAttribute('aria-label', I18n.translate('Search results'));\n\n\t\tthis._message = DomUtil.create('div', `${className}-message`, container);\n\t\tthis._message.role = 'status';\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(container);\n\t\tDomEvent.on(toggle, 'click', this._onToggle, this);\n\t\tDomEvent.on(form, 'submit', this._onSubmit, this);\n\t\tDomEvent.on(form, 'reset', this._onReset, this);\n\t\tDomEvent.on(input, 'input', this._onInput, this);\n\t\tDomEvent.on(input, 'keydown', this._onKeyDown, this);\n\t\tDomEvent.on(list, 'click', this._onListClick, this);\n\t\tmap.on('click', this._onMapClick, this);\n\t\tthis._attribution = this.options.geocoder.attribution;\n\t\tmap.attributionControl?.addAttribution(this._attribution);\n\n\t\tthis._showResults([]);\n\t\tthis._setExpanded(!this.options.collapsed);\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('click', this._onMapClick, this);\n\t\tmap.attributionControl?.removeAttribution(this._attribution);\n\t\tthis._abort();\n\t\tthis._marker?.remove();\n\t}\n\n\t/**\n\t * Expands the search field of a [collapsed](#searchcontrol-collapsed) control and\n\t * focuses it.\n\t * @returns {this}\n\t */\n\texpand() {\n\t\tthis._setExpanded(true);\n\t\tthis._input.focus();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Collapses the control into its button, if [collapsed](#searchcontrol-collapsed),\n\t * and hides the results.\n\t * @returns {this}\n\t */\n\tcollapse() {\n\t\tthis._showResults([]);\n\t\tthis._setExpanded(!this.options.collapsed);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches the given text and shows the results in the list. Resolves to the results.\n\t * @param {string} query\n\t * @returns {Promise<SearchResult[]>}\n\t */\n\tasync search(query) {\n\t\tthis._abort();\n\t\tthis._input.value = query;\n\t\tquery = query.trim();\n\t\tif (!query) {\n\t\t\tthis._showResults([]);\n\t\t\treturn [];\n\t\t}\n\n\t\tconst latlng = LatLng.parse(query);\n\t\tif (latlng) {\n\t\t\tconst results = [{label: query, latlng}];\n\t\t\tthis._showResults(results);\n\t\t\treturn results;\n\t\t}\n\n\t\tconst controller = this._controller = new AbortController();\n\t\tthis._container.classList.add('maplair-control-search-loading');\n\t\ttry {\n\t\t\tconst results = await this.options.geocoder(query, {signal: controller.signal});\n\t\t\tif (!controller.signal.aborted) {\n\t\t\t\tthis._showResults(results, I18n.translate('No results'));\n\t\t\t}\n\t\t\treturn results;\n\t\t} catch (error) {\n\t\t\tif (controller.signal.aborted) { return []; }\n\t\t\tthis._showResults([], I18n.translate('The search failed'));\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this._controller === controller) {\n\t\t\t\tthis._controller = null;\n\t\t\t\tthis._container.classList.remove('maplair-control-search-loading');\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Shows the given result on the map: zooms to it, shows a\n\t * [marker](#searchcontrol-marker) and fires `searchresult` on the map.\n\t * @param {SearchResult} result\n\t * @returns {this}\n\t */\n\tselect(result) {\n\t\tconst map = this._map,\n\t\tlatlng = LatLng.from(result.latlng),\n\t\tbounds = result.bounds ? LatLngBounds.from(result.bounds) : undefined;\n\n\t\tthis._input.value = result.label;\n\t\tthis._showResults([]);\n\n\t\tif (bounds?.isValid() && !bounds.getNorthWest().equals(bounds.getSouthEast())) {\n\t\t\tmap.fitBounds(bounds, {maxZoom: this.options.zoom});\n\t\t} else {\n\t\t\tmap.setView(latlng, this.options.zoom);\n\t\t}\n\n\t\tthis._marker?.remove();\n\t\tif (this.options.marker) {\n\t\t\tthis._marker = new Marker(latlng, {title: result.label}).addTo(map);\n\t\t}\n\n\t\tmap.fire('searchresult', {result, latlng, bounds});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears the search field, the results and the marker.\n\t * @returns {this}\n\t */\n\tclear() {\n\t\tthis._abort();\n\t\tthis._input.value = '';\n\t\tthis._showResults([]);\n\t\tthis._marker?.remove();\n\t\tthis._marker = null;\n\t\treturn this;\n\t}\n\n\t_setExpanded(expanded) {\n\t\tthis._container.classList.toggle('maplair-control-search-expanded', expanded);\n\t\tthis._toggle.setAttribute('aria-expanded', expanded);\n\t}\n\n\t_abort() {\n\t\tclearTimeout(this._autoCompleteTimeout);\n\t\tthis._controller?.abort();\n\t\tthis._controller = null;\n\t\tthis._container?.classList.remove('maplair-control-search-loading');\n\t}\n\n\t// Shows the results, or the message if there are none\n\t_showResults(results, message = '') {\n\t\tthis._results = results;\n\t\tthis._list.replaceChildren(...results.map((result, i) => {\n\t\t\tconst item = DomUtil.create('li', 'maplair-control-search-result');\n\t\t\titem.id = `${this._list.id}-${i}`;\n\t\t\titem.role = 'option';\n\t\t\titem.textContent = result.label;\n\t\t\treturn item;\n\t\t}));\n\t\tthis._list.hidden = !results.length;\n\t\tthis._message.textContent = results.length ? '' : message;\n\t\tthis._message.hidden = !this._message.textContent;\n\t\tthis._input.setAttribute('aria-expanded', !!results.length);\n\t\tthis._setActive(-1);\n\t}\n\n\t_setActive(index) {\n\t\tthis._active = index;\n\t\tfor (const [i, item] of [...this._list.children].entries()) {\n\t\t\titem.setAttribute('aria-selected', i === index);\n\t\t}\n\t\tif (index < 0) {\n\t\t\tthis._input.removeAttribute('aria-activedescendant');\n\t\t} else {\n\t\t\tconst item = this._list.children[index];\n\t\t\tthis._input.setAttribute('aria-activedescendant', item.id);\n\t\t\titem.scrollIntoView({block: 'nearest'});\n\t\t}\n\t}\n\n\t_onToggle() {\n\t\tif (this.options.collapsed && !this._container.classList.contains('maplair-control-search-expanded')) {\n\t\t\tthis.expand();\n\t\t} else {\n\t\t\tthis._onSubmit();\n\t\t}\n\t}\n\n\t_onSubmit(e) {\n\t\tif (e) { DomEvent.preventDefault(e); }\n\t\tconst query = this._input.value,\n\t\tresult = this._results[this._active],\n\t\tlatlng = LatLng.parse(query);\n\t\tif (result) {\n\t\t\tthis.select(result);\n\t\t} else if (latlng) {\n\t\t\tthis.select({label: query.trim(), latlng});\n\t\t} else {\n\t\t\t// errors are shown in the control\n\t\t\tthis.search(query).catch(Util.falseFn);\n\t\t}\n\t}\n\n\t_onReset() {\n\t\tthis.clear();\n\t\tthis._input.focus();\n\t}\n\n\t_onInput() {\n\t\tclearTimeout(this._autoCompleteTimeout);\n\t\tconst query = this._input.value.trim();\n\t\tif (!this.options.autoComplete || this.options.geocoder.autoComplete === false) {\n\t\t\tthis._showResults([]);\n\t\t} else if (query.length >= this.options.minLength || LatLng.parse(query)) {\n\t\t\tthis._autoCompleteTimeout = setTimeout(() => {\n\t\t\t\tthis.search(this._input.value).catch(Util.falseFn);\n\t\t\t}, this.options.autoCompleteDelay);\n\t\t} else {\n\t\t\tthis._abort();\n\t\t\tthis._showResults([]);\n\t\t}\n\t}\n\n\t_onKeyDown(e) {\n\t\tconst n = this._results.length;\n\t\tif ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && n) {\n\t\t\tDomEvent.preventDefault(e);\n\t\t\tconst step = e.key === 'ArrowDown' ? 1 : -1;\n\t\t\t// from no active result, the first or the last one\n\t\t\tthis._setActive(((this._active < 0 && step < 0 ? n : this._active) + step + n) % n);\n\t\t} else if (e.key === 'Escape') {\n\t\t\tDomEvent.preventDefault(e);\n\t\t\tif (n || !this._message.hidden) {\n\t\t\t\tthis._showResults([]);\n\t\t\t} else if (this._input.value) {\n\t\t\t\tthis.clear();\n\t\t\t} else if (this.options.collapsed) {\n\t\t\t\tthis.collapse();\n\t\t\t\tthis._map.getContainer().focus();\n\t\t\t}\n\t\t}\n\t}\n\n\t_onListClick(e) {\n\t\tconst item = e.target.closest('.maplair-control-search-result'),\n\t\tindex = [...this._list.children].indexOf(item);\n\t\tif (index >= 0) {\n\t\t\tthis.select(this._results[index]);\n\t\t}\n\t}\n\n\t_onMapClick() {\n\t\tif (this._input.value) {\n\t\t\tthis._showResults([]);\n\t\t} else {\n\t\t\tthis.collapse();\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,aAAa;AAGnB,MAAM,+BAAe,IAAI,IAAI;AAG7B,SAAS,MAAM,IAAI,QAAQ;CAC1B,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,MAAM,UAAU,WAAW,SAAS,EAAE;EACtC,OAAO,iBAAiB,eAAe;GACtC,aAAa,OAA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;OAC3B;GACN,KAAK,OAAO;GACZ,KAAK,aAAa,CAAC,CAAC;EACrB;CACD;CAEA,WAAW,GAAG;EACb,MAAM,IAAI,KAAK,SAAS;EACxB,KAAK,EAAE,QAAQ,eAAe,EAAE,QAAQ,cAAc,GAAG;GACxD,eAAwB,CAAC;GACzB,MAAM,OAAO,EAAE,QAAQ,cAAc,IAAI;GAEzC,KAAK,aAAa,KAAK,UAAU,KAAK,OAAO,IAAI,IAAI,KAAK,WAAW,OAAO,KAAK,CAAC;EACnF,OAAO,IAAI,EAAE,QAAQ,UAAU;GAC9B,eAAwB,CAAC;GACzB,IAAI,KAAK,CAAC,KAAK,SAAS,QACvB,KAAK,aAAa,CAAC,CAAC;QACd,IAAI,KAAK,OAAO,OACtB,KAAK,MAAM;QACL,IAAI,KAAK,QAAQ,WAAW;IAClC,KAAK,SAAS;IACd,KAAK,KAAK,aAAa,CAAC,CAAC,MAAM;GAChC;EACD;CACD;CAEA,aAAa,GAAG;EACf,MAAM,OAAO,EAAE,OAAO,QAAQ,gCAAgC,GAC9D,QAAQ,CAAC,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC,QAAQ,IAAI;EAC7C,IAAI,SAAS,GACZ,KAAK,OAAO,KAAK,SAAS,MAAM;CAElC;CAEA,cAAc;EACb,IAAI,KAAK,OAAO,OACf,KAAK,aAAa,CAAC,CAAC;OAEpB,KAAK,SAAS;CAEhB;AACD"}
@@ -92,6 +92,24 @@ var LatLng = class LatLng {
92
92
  this.alt = +_alt;
93
93
  }
94
94
  /**
95
+ * Returns the given `LatLng` object as it is, or else a new `LatLng` object created
96
+ * from the given arguments (the same as of the constructor) — unlike the
97
+ * constructor, which always creates a new object.
98
+ *
99
+ * @example
100
+ * ```js
101
+ * LatLng.from(latlng) === latlng; // true
102
+ * LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)
103
+ * ```
104
+ * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.
105
+ * @param {number} [lng] Longitude in degrees.
106
+ * @param {number} [alt] Altitude in meters.
107
+ * @returns {LatLng}
108
+ */
109
+ static from(lat, lng, alt) {
110
+ return lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);
111
+ }
112
+ /**
95
113
  * Returns `true` if the LatLng object can be properly initialized with the given
96
114
  * arguments (the same as of the constructor).
97
115
  * @param {any} lat
@@ -153,7 +171,7 @@ var LatLng = class LatLng {
153
171
  */
154
172
  equals(obj, maxMargin) {
155
173
  if (!obj) return false;
156
- obj = new LatLng(obj);
174
+ obj = LatLng.from(obj);
157
175
  return Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)) <= (maxMargin ?? 1e-9);
158
176
  }
159
177
  /**
@@ -171,7 +189,7 @@ var LatLng = class LatLng {
171
189
  * @returns {number}
172
190
  */
173
191
  distanceTo(other) {
174
- return EarthCRS.distance(this, new LatLng(other));
192
+ return EarthCRS.distance(this, LatLng.from(other));
175
193
  }
176
194
  /**
177
195
  * Returns a new `LatLng` object with the longitude wrapped so it's always between
@@ -1 +1 @@
1
- {"version":3,"file":"LatLng.js","names":["Util.formatNum"],"sources":["../../../src/geo/LatLng.js"],"sourcesContent":["import * as Util from '../core/Util.js';\nimport {EarthCRS} from './crs/EarthCRS.js';\nimport {LatLngBounds} from './LatLngBounds.js';\n\n// a coordinate in decimal degrees, with an optional degree sign\nconst coordinate = String.raw`([+-]?\\d+(?:\\.\\d+)?)\\s*°?`,\nseparator = String.raw`(?:\\s*[,;]\\s*|\\s+)`,\n// `47.27 11.4`, `47.27, 11.4`, `+47.27;+11.4`\nplainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`),\n// `N47.27 E11.4`, `N 47.27°, E 11.4°`\nprefixRe = new RegExp(`^([NSEW])\\\\s*${coordinate}${separator}([NSEW])\\\\s*${coordinate}$`, 'i'),\n// `47.27N 11.4E`, `47.27° N, 11.4° E`\nsuffixRe = new RegExp(`^${coordinate}\\\\s*([NSEW])${separator}${coordinate}\\\\s*([NSEW])$`, 'i'),\nhemisphereRe = /^[NSEW]$/i,\n// `geo:47.27,11.4`, `geo:47.27,11.4,500;u=35`, `geo:47.27,11.4?z=13` (RFC 5870)\ngeoUriRe = /^geo:([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:,([+-]?\\d+(?:\\.\\d+)?))?(?:[;?].*)?$/i;\n\n/**\n * A geographical point: a `LatLng`, an array of the form `[lat, lng]` or\n * `[lat, lng, alt]`, or a plain object of the form `{lat, lng}` or `{lat, lng, alt}`\n * (`lon` can be used in place of `lng`). Accepted by all Maplair methods which accept\n * `LatLng` objects (unless noted otherwise). Plain arrays (`number[]`) are accepted\n * for JavaScript, where array literals in variables are no tuples.\n * @typedef {LatLng|[number, number]|[number, number, number]|number[]|{lat: number, lng: number, alt?: number}|{lat: number, lon: number, alt?: number}} LatLngExpression\n */\n\n/**\n * Represents a geographical point with a certain latitude and longitude.\n *\n * @example\n * ```js\n * const latlng = new LatLng(50.5, 30.5);\n * ```\n *\n * All Maplair methods that accept LatLng objects also accept them in a simple Array\n * form and simple object form (unless noted otherwise), so these lines are equivalent:\n *\n * ```js\n * map.panTo([50, 30]);\n * map.panTo({lat: 50, lng: 30});\n * map.panTo({lat: 50, lon: 30});\n * map.panTo(new LatLng(50, 30));\n * ```\n *\n * Note that `LatLng` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\nexport class LatLng {\n\t/**\n\t * Creates an object representing a geographical point with the given latitude and\n\t * longitude (and optionally altitude). Alternatively, expects a `LatLng` object, an\n\t * array of the form `[lat, lng]` or `[lat, lng, alt]`, or a plain object of the form\n\t * `{lat, lng}` or `{lat, lng, alt}` (`lon` can be used in place of `lng`) instead.\n\t * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.\n\t * @param {number} [lng] Longitude in degrees.\n\t * @param {number} [alt] Altitude in meters.\n\t */\n\tconstructor(lat, lng, alt) {\n\t\tconst valid = LatLng.validate(lat, lng, alt);\n\t\tif (!valid) {\n\t\t\tthrow new Error(`Invalid LatLng object: (${lat}, ${lng})`);\n\t\t}\n\n\t\tlet _lat, _lng, _alt;\n\t\tif (lat instanceof LatLng) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = lat.lng;\n\t\t\t_alt = lat.alt;\n\t\t} else if (Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t\t_alt = lat[2];\n\t\t\t} else if (lat.length === 2) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t}\n\t\t} else if (typeof lat === 'object' && 'lat' in lat) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = 'lng' in lat ? lat.lng : lat.lon;\n\t\t\t_alt = lat.alt;\n\t\t} else {\n\t\t\t_lat = lat;\n\t\t\t_lng = lng;\n\t\t\t_alt = alt;\n\t\t}\n\n\t\t/**\n\t\t * Latitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lat = +_lat;\n\n\t\t/**\n\t\t * Longitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lng = +_lng;\n\n\t\tif (_alt !== undefined) {\n\t\t\t/**\n\t\t\t * Altitude in meters (optional).\n\t\t\t * @type {number|undefined}\n\t\t\t */\n\t\t\tthis.alt = +_alt;\n\t\t}\n\t}\n\n\t/**\n\t * Returns `true` if the LatLng object can be properly initialized with the given\n\t * arguments (the same as of the constructor).\n\t * @param {any} lat\n\t * @param {any} [lng]\n\t * @param {any} [alt]\n\t * @returns {boolean}\n\t */\n\t// eslint-disable-next-line no-unused-vars\n\tstatic validate(lat, lng, alt) {\n\t\tif (lat instanceof LatLng || (typeof lat === 'object' && lat !== null && 'lat' in lat)) {\n\t\t\treturn true;\n\t\t} else if (lat && Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3 || lat.length === 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if ((lat || lat === 0) && (lng || lng === 0)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Parses coordinates in decimal degrees: a pair of numbers (latitude first), e.g.\n\t * `'47.27, 11.4'` or `'47.27 11.4'`, with the hemispheres before or after the numbers,\n\t * e.g. `'N 47.27, E 11.4'`, `'47.27° S 11.4° W'` (also longitude first), or a\n\t * [geo URI](https://www.rfc-editor.org/rfc/rfc5870) like `'geo:47.27,11.4'` (with an\n\t * optional altitude). Returns `null` for other text and out-of-range coordinates.\n\t *\n\t * @example\n\t * ```js\n\t * LatLng.parse('47.2692 N, 11.4041 E'); // LatLng(47.2692, 11.4041)\n\t * LatLng.parse('geo:47.2692,11.4041?z=13'); // LatLng(47.2692, 11.4041)\n\t * ```\n\t * @param {string} text\n\t * @returns {LatLng|null}\n\t */\n\tstatic parse(text) {\n\t\ttext = text.trim();\n\t\tlet lat, lng, alt, match;\n\t\tif ((match = geoUriRe.exec(text))) {\n\t\t\t[lat, lng, alt] = match.slice(1).map(n => (n === undefined ? undefined : Number(n)));\n\t\t} else if ((match = plainRe.exec(text))) {\n\t\t\t[lat, lng] = match.slice(1).map(Number);\n\t\t} else if ((match = prefixRe.exec(text) ?? suffixRe.exec(text))) {\n\t\t\t// the hemisphere and the number of both coordinates\n\t\t\tconst prefixed = hemisphereRe.test(match[1]),\n\t\t\tcoords = prefixed ?\n\t\t\t\t[[match[1], match[2]], [match[3], match[4]]] :\n\t\t\t\t[[match[2], match[1]], [match[4], match[3]]];\n\t\t\tfor (const [hemisphere, number] of coords) {\n\t\t\t\tconst h = hemisphere.toUpperCase(),\n\t\t\t\tvalue = Math.abs(Number(number)) * (h === 'S' || h === 'W' ? -1 : 1);\n\t\t\t\tif (h === 'N' || h === 'S') {\n\t\t\t\t\tif (lat !== undefined) { return null; }\n\t\t\t\t\tlat = value;\n\t\t\t\t} else {\n\t\t\t\t\tif (lng !== undefined) { return null; }\n\t\t\t\t\tlng = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lat === undefined || Math.abs(lat) > 90 || Math.abs(lng) > 180) { return null; }\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns `true` if the given `LatLng` point is at the same position (within a small\n\t * margin of error). The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngExpression} obj\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(obj, maxMargin) {\n\t\tif (!obj) { return false; }\n\n\t\tobj = new LatLng(obj);\n\n\t\tconst margin = Math.max(\n\t\t\tMath.abs(this.lat - obj.lat),\n\t\t\tMath.abs(this.lng - obj.lng));\n\n\t\treturn margin <= (maxMargin ?? 1.0E-9);\n\t}\n\n\t/**\n\t * Returns a string representation of the point (for debugging purposes).\n\t * @param {number|false} [precision]\n\t * @returns {string}\n\t */\n\ttoString(precision) {\n\t\treturn `LatLng(${Util.formatNum(this.lat, precision)}, ${Util.formatNum(this.lng, precision)})`;\n\t}\n\n\t/**\n\t * Returns the distance (in meters) to the given `LatLng` calculated using the\n\t * [Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula).\n\t * @param {LatLngExpression} other\n\t * @returns {number}\n\t */\n\tdistanceTo(other) {\n\t\treturn EarthCRS.distance(this, new LatLng(other));\n\t}\n\n\t/**\n\t * Returns a new `LatLng` object with the longitude wrapped so it's always between\n\t * -180 and +180 degrees.\n\t * @returns {LatLng}\n\t */\n\twrap() {\n\t\treturn EarthCRS.wrapLatLng(this);\n\t}\n\n\t/**\n\t * Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2`\n\t * meters apart from the `LatLng`.\n\t * @param {number} sizeInMeters\n\t * @returns {LatLngBounds}\n\t */\n\ttoBounds(sizeInMeters) {\n\t\tconst latAccuracy = 180 * sizeInMeters / 40075017,\n\t\tlngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\n\n\t\treturn new LatLngB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AO;KAChC,MAAM;IACP,OAAO;KACN,IAAI,QAAQ,KAAA,GAAa,OAAO;KAChC,MAAM;IACP;GACD;EACD;EACA,IAAI,QAAQ,KAAA,KAAa,KAAK,IAAI,GAAG,IAAI,MAAM,KAAK,IAAI,GAAG,IAAI,KAAO,OAAO;EAC7E,OAAO,IAAI,OAAO,KAAK,KAAK,GAAG;CAChC;;;;;;;;;CAUA,OAAO,KAAK,WAAW;EACtB,IAAI,CAAC,KAAO,OAAO;EAEnB,MAAM,IAAI,OAAO,GAAG;EAMpB,OAJe,KAAK,IACnB,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,GAC3B,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAEhB,MAAM,aAAa;CAChC;;;;;;CAOA,SAAS,WAAW;EACnB,OAAO,UAAUA,UAAe,KAAK,KAAK,SAAS,EAAE,IAAIA,UAAe,KAAK,KAAK,SAAS,EAAE;CAC9F;;;;;;;CAQA,WAAW,OAAO;EACjB,OAAO,SAAS,SAAS,MAAM,IAAI,OAAO,KAAK,CAAC;CACjD;;;;;;CAOA,OAAO;EACN,OAAO,SAAS,WAAW,IAAI;CAChC;;;;;;;CAQA,SAAS,cAAc;EACtB,MAAM,cAAc,MAAM,eAAe,UACzC,cAAc,cAAc,KAAK,IAAK,KAAK,KAAK,MAAO,KAAK,GAAG;EAE/D,OAAO,IAAI,aACV,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,GAC/C,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,CAAC;CAClD;AAED"}
1
+ {"version":3,"file":"LatLng.js","names":["Util.formatNum"],"sources":["../../../src/geo/LatLng.js"],"sourcesContent":["import * as Util from '../core/Util.js';\nimport {EarthCRS} from './crs/EarthCRS.js';\nimport {LatLngBounds} from './LatLngBounds.js';\n\n// a coordinate in decimal degrees, with an optional degree sign\nconst coordinate = String.raw`([+-]?\\d+(?:\\.\\d+)?)\\s*°?`,\nseparator = String.raw`(?:\\s*[,;]\\s*|\\s+)`,\n// `47.27 11.4`, `47.27, 11.4`, `+47.27;+11.4`\nplainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`),\n// `N47.27 E11.4`, `N 47.27°, E 11.4°`\nprefixRe = new RegExp(`^([NSEW])\\\\s*${coordinate}${separator}([NSEW])\\\\s*${coordinate}$`, 'i'),\n// `47.27N 11.4E`, `47.27° N, 11.4° E`\nsuffixRe = new RegExp(`^${coordinate}\\\\s*([NSEW])${separator}${coordinate}\\\\s*([NSEW])$`, 'i'),\nhemisphereRe = /^[NSEW]$/i,\n// `geo:47.27,11.4`, `geo:47.27,11.4,500;u=35`, `geo:47.27,11.4?z=13` (RFC 5870)\ngeoUriRe = /^geo:([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:,([+-]?\\d+(?:\\.\\d+)?))?(?:[;?].*)?$/i;\n\n/**\n * A geographical point: a `LatLng`, an array of the form `[lat, lng]` or\n * `[lat, lng, alt]`, or a plain object of the form `{lat, lng}` or `{lat, lng, alt}`\n * (`lon` can be used in place of `lng`). Accepted by all Maplair methods which accept\n * `LatLng` objects (unless noted otherwise). Plain arrays (`number[]`) are accepted\n * for JavaScript, where array literals in variables are no tuples.\n * @typedef {LatLng|[number, number]|[number, number, number]|number[]|{lat: number, lng: number, alt?: number}|{lat: number, lon: number, alt?: number}} LatLngExpression\n */\n\n/**\n * Represents a geographical point with a certain latitude and longitude.\n *\n * @example\n * ```js\n * const latlng = new LatLng(50.5, 30.5);\n * ```\n *\n * All Maplair methods that accept LatLng objects also accept them in a simple Array\n * form and simple object form (unless noted otherwise), so these lines are equivalent:\n *\n * ```js\n * map.panTo([50, 30]);\n * map.panTo({lat: 50, lng: 30});\n * map.panTo({lat: 50, lon: 30});\n * map.panTo(new LatLng(50, 30));\n * ```\n *\n * Note that `LatLng` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\nexport class LatLng {\n\t/**\n\t * Creates an object representing a geographical point with the given latitude and\n\t * longitude (and optionally altitude). Alternatively, expects a `LatLng` object, an\n\t * array of the form `[lat, lng]` or `[lat, lng, alt]`, or a plain object of the form\n\t * `{lat, lng}` or `{lat, lng, alt}` (`lon` can be used in place of `lng`) instead.\n\t * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.\n\t * @param {number} [lng] Longitude in degrees.\n\t * @param {number} [alt] Altitude in meters.\n\t */\n\tconstructor(lat, lng, alt) {\n\t\tconst valid = LatLng.validate(lat, lng, alt);\n\t\tif (!valid) {\n\t\t\tthrow new Error(`Invalid LatLng object: (${lat}, ${lng})`);\n\t\t}\n\n\t\tlet _lat, _lng, _alt;\n\t\tif (lat instanceof LatLng) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = lat.lng;\n\t\t\t_alt = lat.alt;\n\t\t} else if (Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t\t_alt = lat[2];\n\t\t\t} else if (lat.length === 2) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t}\n\t\t} else if (typeof lat === 'object' && 'lat' in lat) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = 'lng' in lat ? lat.lng : lat.lon;\n\t\t\t_alt = lat.alt;\n\t\t} else {\n\t\t\t_lat = lat;\n\t\t\t_lng = lng;\n\t\t\t_alt = alt;\n\t\t}\n\n\t\t/**\n\t\t * Latitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lat = +_lat;\n\n\t\t/**\n\t\t * Longitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lng = +_lng;\n\n\t\tif (_alt !== undefined) {\n\t\t\t/**\n\t\t\t * Altitude in meters (optional).\n\t\t\t * @type {number|undefined}\n\t\t\t */\n\t\t\tthis.alt = +_alt;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `LatLng` object as it is, or else a new `LatLng` object created\n\t * from the given arguments (the same as of the constructor) — unlike the\n\t * constructor, which always creates a new object.\n\t *\n\t * @example\n\t * ```js\n\t * LatLng.from(latlng) === latlng; // true\n\t * LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)\n\t * ```\n\t * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.\n\t * @param {number} [lng] Longitude in degrees.\n\t * @param {number} [alt] Altitude in meters.\n\t * @returns {LatLng}\n\t */\n\tstatic from(lat, lng, alt) {\n\t\treturn lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns `true` if the LatLng object can be properly initialized with the given\n\t * arguments (the same as of the constructor).\n\t * @param {any} lat\n\t * @param {any} [lng]\n\t * @param {any} [alt]\n\t * @returns {boolean}\n\t */\n\t// eslint-disable-next-line no-unused-vars\n\tstatic validate(lat, lng, alt) {\n\t\tif (lat instanceof LatLng || (typeof lat === 'object' && lat !== null && 'lat' in lat)) {\n\t\t\treturn true;\n\t\t} else if (lat && Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3 || lat.length === 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if ((lat || lat === 0) && (lng || lng === 0)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Parses coordinates in decimal degrees: a pair of numbers (latitude first), e.g.\n\t * `'47.27, 11.4'` or `'47.27 11.4'`, with the hemispheres before or after the numbers,\n\t * e.g. `'N 47.27, E 11.4'`, `'47.27° S 11.4° W'` (also longitude first), or a\n\t * [geo URI](https://www.rfc-editor.org/rfc/rfc5870) like `'geo:47.27,11.4'` (with an\n\t * optional altitude). Returns `null` for other text and out-of-range coordinates.\n\t *\n\t * @example\n\t * ```js\n\t * LatLng.parse('47.2692 N, 11.4041 E'); // LatLng(47.2692, 11.4041)\n\t * LatLng.parse('geo:47.2692,11.4041?z=13'); // LatLng(47.2692, 11.4041)\n\t * ```\n\t * @param {string} text\n\t * @returns {LatLng|null}\n\t */\n\tstatic parse(text) {\n\t\ttext = text.trim();\n\t\tlet lat, lng, alt, match;\n\t\tif ((match = geoUriRe.exec(text))) {\n\t\t\t[lat, lng, alt] = match.slice(1).map(n => (n === undefined ? undefined : Number(n)));\n\t\t} else if ((match = plainRe.exec(text))) {\n\t\t\t[lat, lng] = match.slice(1).map(Number);\n\t\t} else if ((match = prefixRe.exec(text) ?? suffixRe.exec(text))) {\n\t\t\t// the hemisphere and the number of both coordinates\n\t\t\tconst prefixed = hemisphereRe.test(match[1]),\n\t\t\tcoords = prefixed ?\n\t\t\t\t[[match[1], match[2]], [match[3], match[4]]] :\n\t\t\t\t[[match[2], match[1]], [match[4], match[3]]];\n\t\t\tfor (const [hemisphere, number] of coords) {\n\t\t\t\tconst h = hemisphere.toUpperCase(),\n\t\t\t\tvalue = Math.abs(Number(number)) * (h === 'S' || h === 'W' ? -1 : 1);\n\t\t\t\tif (h === 'N' || h === 'S') {\n\t\t\t\t\tif (lat !== undefined) { return null; }\n\t\t\t\t\tlat = value;\n\t\t\t\t} else {\n\t\t\t\t\tif (lng !== undefined) { return null; }\n\t\t\t\t\tlng = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lat === undefined || Math.abs(lat) > 90 || Math.abs(lng) > 180) { return null; }\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns `true` if the given `LatLng` point is at the same position (within a small\n\t * margin of error). The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngExpression} obj\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(obj, maxMargin) {\n\t\tif (!obj) { return false; }\n\n\t\tobj = LatLng.from(obj);\n\n\t\tconst margin = Math.max(\n\t\t\tMath.abs(this.lat - obj.lat),\n\t\t\tMath.abs(this.lng - obj.lng));\n\n\t\treturn margin <= (maxMargin ?? 1.0E-9);\n\t}\n\n\t/**\n\t * Returns a string representation of the point (for debugging purposes).\n\t * @param {number|false} [precision]\n\t * @returns {string}\n\t */\n\ttoString(precision) {\n\t\treturn `LatLng(${Util.formatNum(this.lat, precision)}, ${Util.formatNum(this.lng, precision)})`;\n\t}\n\n\t/**\n\t * Returns the distance (in meters) to the given `LatLng` calculated using the\n\t * [Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula).\n\t * @param {LatLngExpression} other\n\t * @returns {number}\n\t */\n\tdistanceTo(other) {\n\t\treturn EarthCRS.distance(this, LatLng.from(other));\n\t}\n\n\t/**\n\t * Returns a new `LatLng` object with the longitude wrapped so it's always between\n\t * -180 and +180 degrees.\n\t * @returns {LatLng}\n\t */\n\twrap() {\n\t\treturn EarthCRS.wrapLatLng(this);\n\t}\n\n\t/**\n\t * Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2`\n\t * meters apart from the `LatLng`.\n\t * @param {number} sizeInMeters\n\t * @returns {LatLngBounds}\n\t */\n\ttoBounds(sizeInMeters) {\n\t\tconst latAccuracy = 180 * sizeInMeters / 40075017,\n\t\tlngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\n\n\t\treturn new LatLngBounds(\n\t\t\t[this.lat - latAccuracy, this.lng - lngAccuracy],\n\t\t\t[this.lat + latAccuracy, this.lng + lngAccuracy]);\n\t}\n\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,OAAO,GAAG;AAC7B,MAAA,YAAY,OAAO,GAAG;AAEtB,MAAA,UAAU,IAAI,OAAO,IAAI,aAAa,YAAY,WAAW,EAAE;AAE/D,MAAA,WAAW,IAAI,OAAO,gBAAgB,aAAa,UAAU,cAAc,WAAW,IAAI,GAAG;AAE7F,MAAA,WAAW,IAAI,OAAO,IAAI,WAAW,cAAc,YAAY,WAAW,gBAAgB,GAAG;AAC7F,MAAA,eAAe;AAEf,MAAA,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCX,IAAa,SAAb,MAAa,OAAO;;;;;;;;;;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AAI,GAAG,GAC3B,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAEhB,MAAM,aAAa;CAChC;;;;;;CAOA,SAAS,WAAW;EACnB,OAAO,UAAUA,UAAe,KAAK,KAAK,SAAS,EAAE,IAAIA,UAAe,KAAK,KAAK,SAAS,EAAE;CAC9F;;;;;;;CAQA,WAAW,OAAO;EACjB,OAAO,SAAS,SAAS,MAAM,OAAO,KAAK,KAAK,CAAC;CAClD;;;;;;CAOA,OAAO;EACN,OAAO,SAAS,WAAW,IAAI;CAChC;;;;;;;CAQA,SAAS,cAAc;EACtB,MAAM,cAAc,MAAM,eAAe,UACzC,cAAc,cAAc,KAAK,IAAK,KAAK,KAAK,MAAO,KAAK,GAAG;EAE/D,OAAO,IAAI,aACV,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,GAC/C,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,CAAC;CAClD;AAED"}
@@ -60,6 +60,18 @@ var LatLngBounds = class LatLngBounds {
60
60
  for (const latlng of latlngs) this.extend(latlng);
61
61
  }
62
62
  /**
63
+ * Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`
64
+ * object created from the given arguments (the same as of the constructor) — unlike
65
+ * the constructor, which always creates a new object.
66
+ * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the
67
+ * points or the bounds.
68
+ * @param {LatLngExpression} [corner2] The opposite corner.
69
+ * @returns {LatLngBounds}
70
+ */
71
+ static from(corner1, corner2) {
72
+ return corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);
73
+ }
74
+ /**
63
75
  * Extend the bounds to contain the given point or bounds.
64
76
  * @param {LatLngExpression|LatLngBoundsExpression} obj
65
77
  * @returns {this}
@@ -76,8 +88,8 @@ var LatLngBounds = class LatLngBounds {
76
88
  if (!sw2 || !ne2) return this;
77
89
  } else {
78
90
  if (!obj) return this;
79
- if (LatLng.validate(obj)) return this.extend(new LatLng(obj));
80
- return this.extend(new LatLngBounds(obj));
91
+ if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
92
+ return this.extend(LatLngBounds.from(obj));
81
93
  }
82
94
  if (!sw && !ne) {
83
95
  this._southWest = new LatLng(sw2.lat, sw2.lng);
@@ -170,8 +182,8 @@ var LatLngBounds = class LatLngBounds {
170
182
  * @returns {boolean}
171
183
  */
172
184
  contains(obj) {
173
- if (LatLng.validate(obj)) obj = new LatLng(obj);
174
- else obj = new LatLngBounds(obj);
185
+ if (LatLng.validate(obj)) obj = LatLng.from(obj);
186
+ else obj = LatLngBounds.from(obj);
175
187
  const sw = this._southWest, ne = this._northEast;
176
188
  let sw2, ne2;
177
189
  if (obj instanceof LatLngBounds) {
@@ -187,7 +199,7 @@ var LatLngBounds = class LatLngBounds {
187
199
  * @returns {boolean}
188
200
  */
189
201
  intersects(bounds) {
190
- bounds = new LatLngBounds(bounds);
202
+ bounds = LatLngBounds.from(bounds);
191
203
  const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latIntersects = ne2.lat >= sw.lat && sw2.lat <= ne.lat, lngIntersects = ne2.lng >= sw.lng && sw2.lng <= ne.lng;
192
204
  return latIntersects && lngIntersects;
193
205
  }
@@ -198,7 +210,7 @@ var LatLngBounds = class LatLngBounds {
198
210
  * @returns {boolean}
199
211
  */
200
212
  overlaps(bounds) {
201
- bounds = new LatLngBounds(bounds);
213
+ bounds = LatLngBounds.from(bounds);
202
214
  const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = ne2.lat > sw.lat && sw2.lat < ne.lat, lngOverlaps = ne2.lng > sw.lng && sw2.lng < ne.lng;
203
215
  return latOverlaps && lngOverlaps;
204
216
  }
@@ -226,7 +238,7 @@ var LatLngBounds = class LatLngBounds {
226
238
  */
227
239
  equals(bounds, maxMargin) {
228
240
  if (!bounds) return false;
229
- bounds = new LatLngBounds(bounds);
241
+ bounds = LatLngBounds.from(bounds);
230
242
  return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin);
231
243
  }
232
244
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n/** @import {LatLngExpression} from './LatLng.js' */\n\n/**\n * A geographical area: a `LatLngBounds`, or an array of geographical points (usually\n * two diagonally opposite corners), e.g. `[[40.712, -74.227], [40.774, -74.125]]`.\n * Accepted by all Maplair methods which accept `LatLngBounds` objects (unless noted\n * otherwise).\n * @typedef {LatLngBounds|LatLngExpression[]} LatLngBoundsExpression\n */\n\n// TODO International date line?\n\n/**\n * Represents a rectangular geographical area on a map.\n *\n * @example\n * ```js\n * const corner1 = new LatLng(40.712, -74.227),\n * corner2 = new LatLng(40.774, -74.125),\n * bounds = new LatLngBounds(corner1, corner2);\n * ```\n *\n * All Maplair methods that accept LatLngBounds objects also accept them in a simple\n * Array form (unless noted otherwise), so the bounds example above can be passed like\n * this:\n *\n * ```js\n * map.fitBounds([\n * \t[40.712, -74.227],\n * \t[40.774, -74.125]\n * ]);\n * ```\n *\n * Caution: if the area crosses the antimeridian (often confused with the International\n * Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\n *\n * Note that `LatLngBounds` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\nexport class LatLngBounds {\n\t/**\n\t * Creates a `LatLngBounds` object by defining two diagonally opposite corners of the\n\t * rectangle. Alternatively, creates a `LatLngBounds` object defined by the\n\t * geographical points it contains (very useful for zooming the map to fit a\n\t * particular set of locations with [`fitBounds`](#map-fitbounds)), or a copy of the\n\t * given `LatLngBounds` object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds to copy.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t */\n\tconstructor(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\n\t\tif (!corner1) { return; }\n\n\t\tif (corner1 instanceof LatLngBounds) {\n\t\t\tif (corner1.isValid()) {\n\t\t\t\tthis._southWest = new LatLng(corner1._southWest);\n\t\t\t\tthis._northEast = new LatLng(corner1._northEast);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst latlngs = corner2 ? [corner1, corner2] : corner1;\n\n\t\tfor (const latlng of latlngs) {\n\t\t\tthis.extend(latlng);\n\t\t}\n\t}\n\n\t/**\n\t * Extend the bounds to contain the given point or bounds.\n\t * @param {LatLngExpression|LatLngBoundsExpression} obj\n\t * @returns {this}\n\t */\n\textend(obj) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLng) {\n\t\t\tsw2 = obj;\n\t\t\tne2 = obj;\n\n\t\t} else if (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj._southWest;\n\t\t\tne2 = obj._northEast;\n\n\t\t\tif (!sw2 || !ne2) { return this; }\n\n\t\t} else {\n\t\t\tif (!obj) {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tif (LatLng.validate(obj)) {\n\t\t\t\treturn this.extend(new LatLng(obj));\n\t\t\t}\n\t\t\treturn this.extend(new LatLngBounds(obj));\n\t\t}\n\n\t\tif (!sw && !ne) {\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\n\t\t} else {\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {LatLngBounds}\n\t */\n\tpad(bufferRatio) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\theightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\n\t\twidthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\n\n\t\treturn new LatLngBounds(\n\t\t\tnew LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\n\t\t\tnew LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\n\t}\n\n\t/**\n\t * Returns the center point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetCenter() {\n\t\treturn new LatLng(\n\t\t\t(this._southWest.lat + this._northEast.lat) / 2,\n\t\t\t(this._southWest.lng + this._northEast.lng) / 2);\n\t}\n\n\t/**\n\t * Returns the south-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t/**\n\t * Returns the north-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t/**\n\t * Returns the north-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t/**\n\t * Returns the south-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t/**\n\t * Returns the west longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t/**\n\t * Returns the south latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t/**\n\t * Returns the east longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t/**\n\t * Returns the north latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {LatLngBoundsExpression|LatLngExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = new LatLng(obj);\n\t\t} else {\n\t\t\tobj = new LatLngBounds(obj);\n\t\t}\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj.getSouthWest();\n\t\t\tne2 = obj.getNorthEast();\n\t\t} else {\n\t\t\tsw2 = ne2 = obj;\n\t\t}\n\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds intersect\n\t * if they have at least one point in common.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\n\t\tlngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\n\n\t\treturn latIntersects && lngIntersects;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if\n\t * their intersection is an area.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\n\t\tlngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\n\n\t\treturn latOverlaps && lngOverlaps;\n\t}\n\n\t/**\n\t * Returns a string with bounding box coordinates in a\n\t * 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for\n\t * sending requests to web services that return geo data.\n\t * @returns {string}\n\t */\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent (within a small margin of error) to\n\t * the given bounds. The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = new LatLngBounds(bounds);\n\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\n\t}\n\n\t/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,eAAb,MAAa,aAAa;;;;;;;;;;;CAWzB,YAAY,SAAS,SAAS;EAC7B,IAAI,CAAC,SAAW;EAEhB,IAAI,mBAAmB,cAAc;GACpC,IAAI,QAAQ,QAAQ,GAAG;IACtB,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;IAC/C,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;GAChD;GACA;EACD;EAEA,MAAM,UAAU,UAAU,CAAC,SAAS,OAAO,IAAI;EAE/C,KAAK,MAAM,UAAU,SACpB,KAAK,OAAO,MAAM;CAEpB;;;;;;CAOA,OAAO,KAAK;EACX,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK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AS,IAAI,MAAM,GAAG,KAClD,cAAe,IAAI,MAAM,GAAG,OAAS,IAAI,MAAM,GAAG;EAElD,OAAO,eAAe;CACvB;;;;;;;CAQA,eAAe;EACd,OAAO;GAAC,KAAK,QAAQ;GAAG,KAAK,SAAS;GAAG,KAAK,QAAQ;GAAG,KAAK,SAAS;EAAC,CAAC,CAAC,KAAK,GAAG;CACnF;;;;;;;;;CAUA,OAAO,QAAQ,WAAW;EACzB,IAAI,CAAC,QAAU,OAAO;EAEtB,SAAS,IAAI,aAAa,MAAM;EAEhC,OAAO,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS,KACvD,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS;CAC/D;;;;;CAMA,UAAU;EACT,OAAO,CAAC,EAAE,KAAK,cAAc,KAAK;CACnC;AACD"}
1
+ {"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n/** @import {LatLngExpression} from './LatLng.js' */\n\n/**\n * A geographical area: a `LatLngBounds`, or an array of geographical points (usually\n * two diagonally opposite corners), e.g. `[[40.712, -74.227], [40.774, -74.125]]`.\n * Accepted by all Maplair methods which accept `LatLngBounds` objects (unless noted\n * otherwise).\n * @typedef {LatLngBounds|LatLngExpression[]} LatLngBoundsExpression\n */\n\n// TODO International date line?\n\n/**\n * Represents a rectangular geographical area on a map.\n *\n * @example\n * ```js\n * const corner1 = new LatLng(40.712, -74.227),\n * corner2 = new LatLng(40.774, -74.125),\n * bounds = new LatLngBounds(corner1, corner2);\n * ```\n *\n * All Maplair methods that accept LatLngBounds objects also accept them in a simple\n * Array form (unless noted otherwise), so the bounds example above can be passed like\n * this:\n *\n * ```js\n * map.fitBounds([\n * \t[40.712, -74.227],\n * \t[40.774, -74.125]\n * ]);\n * ```\n *\n * Caution: if the area crosses the antimeridian (often confused with the International\n * Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\n *\n * Note that `LatLngBounds` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\nexport class LatLngBounds {\n\t/**\n\t * Creates a `LatLngBounds` object by defining two diagonally opposite corners of the\n\t * rectangle. Alternatively, creates a `LatLngBounds` object defined by the\n\t * geographical points it contains (very useful for zooming the map to fit a\n\t * particular set of locations with [`fitBounds`](#map-fitbounds)), or a copy of the\n\t * given `LatLngBounds` object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds to copy.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t */\n\tconstructor(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\n\t\tif (!corner1) { return; }\n\n\t\tif (corner1 instanceof LatLngBounds) {\n\t\t\tif (corner1.isValid()) {\n\t\t\t\tthis._southWest = new LatLng(corner1._southWest);\n\t\t\t\tthis._northEast = new LatLng(corner1._northEast);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst latlngs = corner2 ? [corner1, corner2] : corner1;\n\n\t\tfor (const latlng of latlngs) {\n\t\t\tthis.extend(latlng);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`\n\t * object created from the given arguments (the same as of the constructor) — unlike\n\t * the constructor, which always creates a new object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t * @returns {LatLngBounds}\n\t */\n\tstatic from(corner1, corner2) {\n\t\treturn corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);\n\t}\n\n\t/**\n\t * Extend the bounds to contain the given point or bounds.\n\t * @param {LatLngExpression|LatLngBoundsExpression} obj\n\t * @returns {this}\n\t */\n\textend(obj) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLng) {\n\t\t\tsw2 = obj;\n\t\t\tne2 = obj;\n\n\t\t} else if (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj._southWest;\n\t\t\tne2 = obj._northEast;\n\n\t\t\tif (!sw2 || !ne2) { return this; }\n\n\t\t} else {\n\t\t\tif (!obj) {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tif (LatLng.validate(obj)) {\n\t\t\t\treturn this.extend(LatLng.from(obj));\n\t\t\t}\n\t\t\treturn this.extend(LatLngBounds.from(obj));\n\t\t}\n\n\t\tif (!sw && !ne) {\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\n\t\t} else {\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {LatLngBounds}\n\t */\n\tpad(bufferRatio) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\theightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\n\t\twidthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\n\n\t\treturn new LatLngBounds(\n\t\t\tnew LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\n\t\t\tnew LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\n\t}\n\n\t/**\n\t * Returns the center point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetCenter() {\n\t\treturn new LatLng(\n\t\t\t(this._southWest.lat + this._northEast.lat) / 2,\n\t\t\t(this._southWest.lng + this._northEast.lng) / 2);\n\t}\n\n\t/**\n\t * Returns the south-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t/**\n\t * Returns the north-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t/**\n\t * Returns the north-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t/**\n\t * Returns the south-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t/**\n\t * Returns the west longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t/**\n\t * Returns the south latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t/**\n\t * Returns the east longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t/**\n\t * Returns the north latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {LatLngBoundsExpression|LatLngExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = LatLng.from(obj);\n\t\t} else {\n\t\t\tobj = LatLngBounds.from(obj);\n\t\t}\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj.getSouthWest();\n\t\t\tne2 = obj.getNorthEast();\n\t\t} else {\n\t\t\tsw2 = ne2 = obj;\n\t\t}\n\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds intersect\n\t * if they have at least one point in common.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) {\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\n\t\tlngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\n\n\t\treturn latIntersects && lngIntersects;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if\n\t * their intersection is an area.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) {\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\n\t\tlngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\n\n\t\treturn latOverlaps && lngOverlaps;\n\t}\n\n\t/**\n\t * Returns a string with bounding box coordinates in a\n\t * 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for\n\t * sending requests to web services that return geo data.\n\t * @returns {string}\n\t */\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent (within a small margin of error) to\n\t * the given bounds. The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\n\t}\n\n\t/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,eAAb,MAAa,aAAa;;;;;;;;;;;CAWzB,YAAY,SAAS,SAAS;EAC7B,IAAI,CAAC,SAAW;EAEhB,IAAI,mBAAmB,cAAc;GACpC,IAAI,QAAQ,QAAQ,GAAG;IACtB,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;IAC/C,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;GAChD;GACA;EACD;EAEA,MAAM,UAAU,UAAU,CAAC,SAAS,OAAO,IAAI;EAE/C,KAAK,MAAM,UAAU,SACpB,KAAK,OAAO,MAAM;CAEpB;;;;;;;;;;CAWA,OAAO,KAAK,SAAS,SAAS;EAC7B,OAAO,mBAAmB,eAAe,UAAU,IAAI,aAAa,SAAS,OAAO;CACrF;;;;;;CAOA,OAAO,KAAK;EACX,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK;EACV,IAAI,KAAK;EAET,IAAI,eAAe,QAAQ;GAC1B,MAAM;GACN,MAAM;EAEP,OAAO,IAAI,eAAe,cAAc;GACvC,MAAM,IAAI;GACV,MAAM,IAAI;GAEV,IAAI,CAAC,OAAO,CAAC,KAAO,OAAO;EAE5B,OAAO;GACN,IAAI,CAAC,KACJ,OAAO;GAER,IAAI,OAAO,SAAS,GAAG,GACtB,OAAO,KAAK,OAAO,OAAO,KAAK,GAAG,CAAC;GAEpC,OAAO,KAAK,OAAO,aAAa,KAAK,GAAG,CAAC;EAC1C;EAEA,IAAI,CAAC,MAAM,CAAC,IAAI;GACf,KAAK,aA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KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS;CAC/D;;;;;CAMA,UAAU;EACT,OAAO,CAAC,EAAE,KAAK,cAAc,KAAK;CACnC;AACD"}
@@ -16,8 +16,9 @@ import { LatLng } from "../LatLng.js";
16
16
  * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).
17
17
  *
18
18
  * Maplair defines the most usual CRSs by default. If you want to use a
19
- * CRS not defined by default, take a look at the
20
- * [Proj4Maplair](https://github.com/kartena/Proj4Leaflet) plugin.
19
+ * CRS not defined by default, extend `CRS` with a projection of your own, e.g.
20
+ * based on [Proj4js](https://github.com/proj4js/proj4js) (the Leaflet plugin
21
+ * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) doesn't work with Maplair).
21
22
  *
22
23
  * The CRSs are classes with static properties and methods only; they are not
23
24
  * instantiated, the class itself is passed as the CRS, e.g. to the `crs` option of the
@@ -127,7 +128,7 @@ var CRS = class {
127
128
  * @returns {LatLng}
128
129
  */
129
130
  static wrapLatLng(latlng) {
130
- latlng = new LatLng(latlng);
131
+ latlng = LatLng.from(latlng);
131
132
  const lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, alt = latlng.alt;
132
133
  return new LatLng(lat, lng, alt);
133
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CRS.js","names":["Util.wrapNum"],"sources":["../../../../src/geo/crs/CRS.js"],"sourcesContent":["\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {LatLng} from '../LatLng.js';\nimport {LatLngBounds} from '../LatLngBounds.js';\nimport * as Util from '../../core/Util.js';\n/** @import {LatLngExpression} from '../LatLng.js' */\n/** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {Transformation} from '../../geometry/Transformation.js' */\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * Object that defines coordinate reference systems for projecting\n * geographical points into pixel (screen) coordinates and back (and to\n * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service)\n * services). See\n * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).\n *\n * Maplair defines the most usual CRSs by default. If you want to use a\n * CRS not defined by default, take a look at the\n * [Proj4Maplair](https://github.com/kartena/Proj4Leaflet) plugin.\n *\n * The CRSs are classes with static properties and methods only; they are not\n * instantiated, the class itself is passed as the CRS, e.g. to the `crs` option of the\n * map. Maplair's CRSs extend `CRS` (`EarthCRS` for the global ones).\n *\n * Besides the properties and methods below, a CRS may define:\n *\n * * `code: string`: Standard code name of the CRS passed into WMS services (e.g.\n * `'EPSG:3857'`).\n * * `wrapLng: [number, number]`: An array of two numbers defining whether the longitude\n * (horizontal) coordinate axis wraps around a given range and how. Defaults to\n * `[-180, 180]` in most geographical CRSs. If `undefined`, the longitude axis does\n * not wrap around.\n * * `wrapLat: [number, number]`: Like `wrapLng`, but for the latitude (vertical) axis.\n * * `distance(latlng1: LatLng, latlng2: LatLng): number`: Returns the distance between\n * two geographical coordinates.\n */\nexport class CRS {\n\t/**\n\t * The projection of the CRS.\n\t * @type {Projection|undefined}\n\t */\n\tstatic projection = undefined;\n\t/**\n\t * The transformation of projected coordinates into pixel coordinates at zoom 0.\n\t * @type {Transformation|undefined}\n\t */\n\tstatic transformation = undefined;\n\n\t/**\n\t * Projects geographical coordinates into pixel coordinates for a given zoom.\n\t * @param {LatLngExpression} latlng\n\t * @param {number} zoom\n\t * @returns {Point}\n\t */\n\tstatic latLngToPoint(latlng, zoom) {\n\t\tconst projectedPoint = this.projection.project(latlng),\n\t\tscale = this.scale(zoom);\n\n\t\treturn this.transformation._transform(projectedPoint, scale);\n\t}\n\n\t/**\n\t * The inverse of `latLngToPoint`. Projects pixel coordinates on a given\n\t * zoom into geographical coordinates.\n\t * @param {Point} point\n\t * @param {number} zoom\n\t * @returns {LatLng}\n\t */\n\tstatic pointToLatLng(point, zoom) {\n\t\tconst scale = this.scale(zoom),\n\t\tuntransformedPoint = this.transformation.untransform(point, scale);\n\n\t\treturn this.projection.unproject(untransformedPoint);\n\t}\n\n\t/**\n\t * Projects geographical coordinates into coordinates in units accepted for\n\t * this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\n\t * @param {LatLngExpression} latlng\n\t * @returns {Point}\n\t */\n\tstatic project(latlng) {\n\t\treturn this.projection.project(latlng);\n\t}\n\n\t/**\n\t * Given a projected coordinate returns the corresponding LatLng.\n\t * The inverse of `project`.\n\t * @param {Point} point\n\t * @returns {LatLng}\n\t */\n\tstatic unproject(point) {\n\t\treturn this.projection.unproject(point);\n\t}\n\n\t/**\n\t * Returns the scale used when transforming projected coordinates into\n\t * pixel coordinates for a particular zoom. For example, it returns\n\t * `256 * 2^zoom` for Mercator-based CRS.\n\t * @param {number} zoom\n\t * @returns {number}\n\t */\n\tstatic scale(zoom) {\n\t\treturn 256 * 2 ** zoom;\n\t}\n\n\t/**\n\t * Inverse of `scale()`, returns the zoom level corresponding to a scale\n\t * factor of `scale`.\n\t * @param {number} scale\n\t * @returns {number}\n\t */\n\tstatic zoom(scale) {\n\t\treturn Math.log(scale / 256) / Math.LN2;\n\t}\n\n\t/**\n\t * Returns the projection's bounds scaled and transformed for the provided `zoom`\n\t * (`null` if the CRS is `infinite`).\n\t * @param {number} zoom\n\t * @returns {Bounds|null}\n\t */\n\tstatic getProjectedBounds(zoom) {\n\t\tif (this.infinite) { return null; }\n\n\t\tconst b = this.projection.bounds,\n\t\ts = this.scale(zoom),\n\t\tmin = this.transformation.transform(b.min, s),\n\t\tmax = this.transformation.transform(b.max, s);\n\n\t\treturn new Bounds(min, max);\n\t}\n\n\t/**\n\t * If true, the coordinate space will be unbounded (infinite in both axes).\n\t * @type {boolean}\n\t */\n\tstatic infinite = false;\n\n\t/**\n\t * Returns a `LatLng` where lat and lng has been wrapped according to the\n\t * CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\n\t * @param {LatLngExpression} latlng\n\t * @returns {LatLng}\n\t */\n\tstatic wrapLatLng(latlng) {\n\t\tlatlng = new LatLng(latlng);\n\t\tconst lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\n\t\tlat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\n\t\talt = latlng.alt;\n\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns a `LatLngBounds` with the same size as the given one, ensuring\n\t * that its center is within the CRS's bounds.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {LatLngBounds}\n\t */\n\tstatic wrapLatLngBounds(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\t\tconst center = bounds.getCenter(),\n\t\tnewCenter = this.wrapLatLng(center),\n\t\tlatShift = center.lat - newCenter.lat,\n\t\tlngShift = center.lng - newCenter.lng;\n\n\t\tif (latShift === 0 && lngShift === 0) {\n\t\t\treturn bounds;\n\t\t}\n\n\t\tconst sw = bounds.getSouthWest(),\n\t\tne = bounds.getNorthEast(),\n\t\tnewSw = new LatLng(sw.lat - latShift, sw.lng - lngShift),\n\t\tnewNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);\n\n\t\treturn new LatLngBounds(newSw, newNe);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAa,MAAb,MAAiB;;;;;CAKhB,OAAO,aAAa,KAAA;;;;;CAKpB,OAAO,iBAAiB,KAAA;;;;;;;CAQxB,OAAO,cAAc,QAAQ,MAAM;EAClC,MAAM,iBAAiB,KAAK,WAAW,QAAQ,MAAM,GACrD,QAAQ,KAAK,MAAM,IAAI;EAEvB,OAAO,KAAK,eAAe,WAAW,gBAAgB,KAAK;CAC5D;;;;;;;;CASA,OAAO,cAAc,OAAO,MAAM;EACjC,MAAM,QAAQ,KAAK,MAAM,IAAI,GAC7B,qBAAqB,KAAK,eAAe,YAAY,OAAO,KAAK;EAE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,MAAM,UAAU,GAAG,MAAM,QAAQ,GACvD,QAAQ,IAAI,OAAO,GAAG,MAAM,UAAU,GAAG,MAAM,QAAQ;EAEvD,OAAO,IAAI,aAAa,OAAO,KAAK;CACrC;AACD"}
1
+ {"version":3,"file":"CRS.js","names":["Util.wrapNum"],"sources":["../../../../src/geo/crs/CRS.js"],"sourcesContent":["\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {LatLng} from '../LatLng.js';\nimport {LatLngBounds} from '../LatLngBounds.js';\nimport * as Util from '../../core/Util.js';\n/** @import {LatLngExpression} from '../LatLng.js' */\n/** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {Transformation} from '../../geometry/Transformation.js' */\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * Object that defines coordinate reference systems for projecting\n * geographical points into pixel (screen) coordinates and back (and to\n * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service)\n * services). See\n * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).\n *\n * Maplair defines the most usual CRSs by default. If you want to use a\n * CRS not defined by default, extend `CRS` with a projection of your own, e.g.\n * based on [Proj4js](https://github.com/proj4js/proj4js) (the Leaflet plugin\n * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) doesn't work with Maplair).\n *\n * The CRSs are classes with static properties and methods only; they are not\n * instantiated, the class itself is passed as the CRS, e.g. to the `crs` option of the\n * map. Maplair's CRSs extend `CRS` (`EarthCRS` for the global ones).\n *\n * Besides the properties and methods below, a CRS may define:\n *\n * * `code: string`: Standard code name of the CRS passed into WMS services (e.g.\n * `'EPSG:3857'`).\n * * `wrapLng: [number, number]`: An array of two numbers defining whether the longitude\n * (horizontal) coordinate axis wraps around a given range and how. Defaults to\n * `[-180, 180]` in most geographical CRSs. If `undefined`, the longitude axis does\n * not wrap around.\n * * `wrapLat: [number, number]`: Like `wrapLng`, but for the latitude (vertical) axis.\n * * `distance(latlng1: LatLng, latlng2: LatLng): number`: Returns the distance between\n * two geographical coordinates.\n */\nexport class CRS {\n\t/**\n\t * The projection of the CRS.\n\t * @type {Projection|undefined}\n\t */\n\tstatic projection = undefined;\n\t/**\n\t * The transformation of projected coordinates into pixel coordinates at zoom 0.\n\t * @type {Transformation|undefined}\n\t */\n\tstatic transformation = undefined;\n\n\t/**\n\t * Projects geographical coordinates into pixel coordinates for a given zoom.\n\t * @param {LatLngExpression} latlng\n\t * @param {number} zoom\n\t * @returns {Point}\n\t */\n\tstatic latLngToPoint(latlng, zoom) {\n\t\tconst projectedPoint = this.projection.project(latlng),\n\t\tscale = this.scale(zoom);\n\n\t\treturn this.transformation._transform(projectedPoint, scale);\n\t}\n\n\t/**\n\t * The inverse of `latLngToPoint`. Projects pixel coordinates on a given\n\t * zoom into geographical coordinates.\n\t * @param {Point} point\n\t * @param {number} zoom\n\t * @returns {LatLng}\n\t */\n\tstatic pointToLatLng(point, zoom) {\n\t\tconst scale = this.scale(zoom),\n\t\tuntransformedPoint = this.transformation.untransform(point, scale);\n\n\t\treturn this.projection.unproject(untransformedPoint);\n\t}\n\n\t/**\n\t * Projects geographical coordinates into coordinates in units accepted for\n\t * this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).\n\t * @param {LatLngExpression} latlng\n\t * @returns {Point}\n\t */\n\tstatic project(latlng) {\n\t\treturn this.projection.project(latlng);\n\t}\n\n\t/**\n\t * Given a projected coordinate returns the corresponding LatLng.\n\t * The inverse of `project`.\n\t * @param {Point} point\n\t * @returns {LatLng}\n\t */\n\tstatic unproject(point) {\n\t\treturn this.projection.unproject(point);\n\t}\n\n\t/**\n\t * Returns the scale used when transforming projected coordinates into\n\t * pixel coordinates for a particular zoom. For example, it returns\n\t * `256 * 2^zoom` for Mercator-based CRS.\n\t * @param {number} zoom\n\t * @returns {number}\n\t */\n\tstatic scale(zoom) {\n\t\treturn 256 * 2 ** zoom;\n\t}\n\n\t/**\n\t * Inverse of `scale()`, returns the zoom level corresponding to a scale\n\t * factor of `scale`.\n\t * @param {number} scale\n\t * @returns {number}\n\t */\n\tstatic zoom(scale) {\n\t\treturn Math.log(scale / 256) / Math.LN2;\n\t}\n\n\t/**\n\t * Returns the projection's bounds scaled and transformed for the provided `zoom`\n\t * (`null` if the CRS is `infinite`).\n\t * @param {number} zoom\n\t * @returns {Bounds|null}\n\t */\n\tstatic getProjectedBounds(zoom) {\n\t\tif (this.infinite) { return null; }\n\n\t\tconst b = this.projection.bounds,\n\t\ts = this.scale(zoom),\n\t\tmin = this.transformation.transform(b.min, s),\n\t\tmax = this.transformation.transform(b.max, s);\n\n\t\treturn new Bounds(min, max);\n\t}\n\n\t/**\n\t * If true, the coordinate space will be unbounded (infinite in both axes).\n\t * @type {boolean}\n\t */\n\tstatic infinite = false;\n\n\t/**\n\t * Returns a `LatLng` where lat and lng has been wrapped according to the\n\t * CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.\n\t * @param {LatLngExpression} latlng\n\t * @returns {LatLng}\n\t */\n\tstatic wrapLatLng(latlng) {\n\t\tlatlng = LatLng.from(latlng);\n\t\tconst lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,\n\t\tlat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,\n\t\talt = latlng.alt;\n\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns a `LatLngBounds` with the same size as the given one, ensuring\n\t * that its center is within the CRS's bounds.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {LatLngBounds}\n\t */\n\tstatic wrapLatLngBounds(bounds) {\n\t\tbounds = new LatLngBounds(bounds);\n\t\tconst center = bounds.getCenter(),\n\t\tnewCenter = this.wrapLatLng(center),\n\t\tlatShift = center.lat - newCenter.lat,\n\t\tlngShift = center.lng - newCenter.lng;\n\n\t\tif (latShift === 0 && lngShift === 0) {\n\t\t\treturn bounds;\n\t\t}\n\n\t\tconst sw = bounds.getSouthWest(),\n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