maplair 4.1.0 → 4.2.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 (211) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/esm/Maplair.js +5 -4
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +1 -2
  6. package/dist/esm/control/ButtonControl.js +1 -2
  7. package/dist/esm/control/ContextMenu.js +1 -2
  8. package/dist/esm/control/Control.js +1 -2
  9. package/dist/esm/control/FullscreenControl.js +1 -2
  10. package/dist/esm/control/LayersControl.js +27 -31
  11. package/dist/esm/control/LayersControl.js.map +1 -1
  12. package/dist/esm/control/LegendControl.js +1 -2
  13. package/dist/esm/control/MiniMapControl.js +1 -2
  14. package/dist/esm/control/RotateControl.js +1 -2
  15. package/dist/esm/control/ScaleControl.js +1 -2
  16. package/dist/esm/control/SearchControl.js +1 -2
  17. package/dist/esm/control/SideBySideControl.js +1 -2
  18. package/dist/esm/control/TextControl.js +1 -2
  19. package/dist/esm/control/TimeControl.js +1 -2
  20. package/dist/esm/control/ZoomControl.js +18 -29
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Class.js +2 -9
  23. package/dist/esm/core/Class.js.map +1 -1
  24. package/dist/esm/core/Events.js +1 -2
  25. package/dist/esm/core/Handler.js +10 -3
  26. package/dist/esm/core/Handler.js.map +1 -1
  27. package/dist/esm/core/I18n.js +1 -2
  28. package/dist/esm/core/Util.js +2 -3
  29. package/dist/esm/core/Util.js.map +1 -1
  30. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  32. package/dist/esm/dom/DomEvent.js +10 -18
  33. package/dist/esm/dom/DomEvent.js.map +1 -1
  34. package/dist/esm/dom/DomUtil.js +1 -2
  35. package/dist/esm/dom/Draggable.js +4 -3
  36. package/dist/esm/dom/Draggable.js.map +1 -1
  37. package/dist/esm/dom/PosAnimation.js +1 -2
  38. package/dist/esm/geo/LatLng.js +1 -2
  39. package/dist/esm/geo/LatLngBounds.js +9 -15
  40. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  41. package/dist/esm/geo/crs/CRS.js +1 -2
  42. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  43. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  44. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  45. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  46. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  47. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  48. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  49. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  50. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  51. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  52. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  53. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  54. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  55. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  56. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  57. package/dist/esm/geometry/Bounds.js +10 -14
  58. package/dist/esm/geometry/Bounds.js.map +1 -1
  59. package/dist/esm/geometry/LineUtil.js +2 -3
  60. package/dist/esm/geometry/LineUtil.js.map +1 -1
  61. package/dist/esm/geometry/Point.js +1 -2
  62. package/dist/esm/geometry/PolyUtil.js +17 -25
  63. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  64. package/dist/esm/geometry/Transformation.js +1 -2
  65. package/dist/esm/layer/BlanketOverlay.js +1 -2
  66. package/dist/esm/layer/Classification.js +1 -2
  67. package/dist/esm/layer/DivOverlay.js +2 -3
  68. package/dist/esm/layer/DivOverlay.js.map +1 -1
  69. package/dist/esm/layer/FeatureGroup.js +5 -4
  70. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  71. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  72. package/dist/esm/layer/GeoJSON.js +8 -10
  73. package/dist/esm/layer/GeoJSON.js.map +1 -1
  74. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  75. package/dist/esm/layer/HeatLayer.js +2 -3
  76. package/dist/esm/layer/HeatLayer.js.map +1 -1
  77. package/dist/esm/layer/ImageOverlay.js +2 -3
  78. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  79. package/dist/esm/layer/Layer.js +1 -2
  80. package/dist/esm/layer/LayerGroup.js +2 -3
  81. package/dist/esm/layer/LayerGroup.js.map +1 -1
  82. package/dist/esm/layer/Popup.js +9 -16
  83. package/dist/esm/layer/Popup.js.map +1 -1
  84. package/dist/esm/layer/SVGOverlay.js +1 -2
  85. package/dist/esm/layer/Tooltip.js +16 -17
  86. package/dist/esm/layer/Tooltip.js.map +1 -1
  87. package/dist/esm/layer/VideoOverlay.js +1 -2
  88. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  89. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  90. package/dist/esm/layer/marker/DivIcon.js +1 -2
  91. package/dist/esm/layer/marker/Icon.js +2 -2
  92. package/dist/esm/layer/marker/Icon.js.map +1 -1
  93. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  94. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  95. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  96. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  97. package/dist/esm/layer/marker/Marker.js +54 -14
  98. package/dist/esm/layer/marker/Marker.js.map +1 -1
  99. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  100. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  101. package/dist/esm/layer/tile/GridLayer.js +4 -4
  102. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  103. package/dist/esm/layer/tile/TileLayer.js +8 -8
  104. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  105. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  106. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  107. package/dist/esm/layer/vector/Canvas.js +7 -14
  108. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  109. package/dist/esm/layer/vector/Circle.js +4 -3
  110. package/dist/esm/layer/vector/Circle.js.map +1 -1
  111. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  112. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  113. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  114. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  115. package/dist/esm/layer/vector/Path.js +1 -2
  116. package/dist/esm/layer/vector/Polygon.js +2 -3
  117. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  118. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  119. package/dist/esm/layer/vector/Polyline.js +2 -3
  120. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  121. package/dist/esm/layer/vector/Rectangle.js +1 -2
  122. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  124. package/dist/esm/layer/vector/Renderer.js +1 -2
  125. package/dist/esm/layer/vector/SVG.js +7 -4
  126. package/dist/esm/layer/vector/SVG.js.map +1 -1
  127. package/dist/esm/map/Hash.js +1 -2
  128. package/dist/esm/map/Map.Rotation.js +31 -16
  129. package/dist/esm/map/Map.Rotation.js.map +1 -1
  130. package/dist/esm/map/Map.js +10 -17
  131. package/dist/esm/map/Map.js.map +1 -1
  132. package/dist/esm/map/MapSync.js +1 -2
  133. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  134. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  135. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  136. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  137. package/dist/esm/map/handler/DragHandler.js +1 -2
  138. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  139. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  140. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  141. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  144. package/dist/esm/package.js +2 -3
  145. package/dist/maplair-global-src.js +487 -613
  146. package/dist/maplair-global-src.js.map +1 -1
  147. package/dist/maplair-global.js +2 -2
  148. package/dist/maplair-global.js.map +1 -1
  149. package/dist/maplair-src.js +483 -609
  150. package/dist/maplair-src.js.map +1 -1
  151. package/dist/maplair.css +1 -1263
  152. package/dist/maplair.js +2 -2
  153. package/dist/maplair.js.map +1 -1
  154. package/package.json +3 -8
  155. package/src/Maplair.all.js +0 -1
  156. package/src/control/LayersControl.js +39 -52
  157. package/src/control/ZoomControl.js +17 -31
  158. package/src/core/Class.js +5 -14
  159. package/src/core/Handler.js +11 -1
  160. package/src/core/Util.js +1 -1
  161. package/src/dom/DomEvent.js +9 -19
  162. package/src/dom/Draggable.js +5 -1
  163. package/src/geo/LatLngBounds.js +8 -15
  164. package/src/geo/crs/EPSG3395.js +3 -3
  165. package/src/geo/crs/EPSG3857.js +3 -3
  166. package/src/geo/crs/EPSG4326.js +2 -2
  167. package/src/geo/crs/SimpleCRS.js +2 -2
  168. package/src/geo/index.js +1 -2
  169. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  170. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  171. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  172. package/src/geo/projection/index.js +5 -5
  173. package/src/geometry/Bounds.js +12 -17
  174. package/src/geometry/LineUtil.js +1 -1
  175. package/src/geometry/PolyUtil.js +23 -31
  176. package/src/layer/DivOverlay.js +1 -1
  177. package/src/layer/FeatureGroup.js +8 -2
  178. package/src/layer/GeoJSON.js +10 -13
  179. package/src/layer/HeatLayer.js +1 -1
  180. package/src/layer/ImageOverlay.js +2 -2
  181. package/src/layer/LayerGroup.js +1 -1
  182. package/src/layer/Popup.js +9 -19
  183. package/src/layer/Tooltip.js +19 -17
  184. package/src/layer/marker/DefaultIcon.js +33 -5
  185. package/src/layer/marker/Icon.js +2 -0
  186. package/src/layer/marker/Marker.Drag.js +53 -5
  187. package/src/layer/marker/Marker.Move.js +3 -4
  188. package/src/layer/marker/Marker.js +64 -13
  189. package/src/layer/tile/GridLayer.js +5 -2
  190. package/src/layer/tile/TileLayer.js +9 -6
  191. package/src/layer/tile/WMSTileLayer.js +5 -2
  192. package/src/layer/vector/Canvas.js +10 -14
  193. package/src/layer/vector/Circle.js +4 -1
  194. package/src/layer/vector/CircleMarker.js +2 -1
  195. package/src/layer/vector/Polygon.js +1 -1
  196. package/src/layer/vector/Polyline.js +1 -1
  197. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  198. package/src/layer/vector/SVG.js +12 -2
  199. package/src/map/Map.Rotation.js +28 -4
  200. package/src/map/Map.js +17 -21
  201. package/src/map/handler/BoxZoomHandler.js +21 -42
  202. package/src/map/handler/KeyboardHandler.js +34 -53
  203. package/src/maplair.css +5 -0
  204. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  205. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  206. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  207. package/dist/esm/geo/projection/index.js +0 -14
  208. package/dist/esm/geo/projection/index.js.map +0 -1
  209. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  210. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  211. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -1,9 +1,9 @@
1
1
  /* @preserve
2
- * Maplair 4.1.0, a JS library for interactive maps. https://maplair.org
2
+ * Maplair 4.2.0, a JS library for interactive maps. https://maplair.org
3
3
  * (c) 2026 Simon Legner and Maplair contributors, (c) 2010-2026 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
4
4
  */
5
5
 
6
- //#region \0rolldown/runtime.js
6
+ // \0rolldown/runtime.js
7
7
  var __defProp = Object.defineProperty;
8
8
  var __exportAll = (all, no_symbols) => {
9
9
  let target = {};
@@ -14,11 +14,9 @@ var __exportAll = (all, no_symbols) => {
14
14
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
15
  return target;
16
16
  };
17
- //#endregion
18
- //#region package.json
19
- var version$1 = "4.1.0";
20
- //#endregion
21
- //#region src/core/Util.js
17
+ // package.json
18
+ var version$1 = "4.2.0";
19
+ // src/core/Util.js
22
20
  var Util_exports = /* @__PURE__ */ __exportAll({
23
21
  falseFn: () => falseFn,
24
22
  formatNum: () => formatNum,
@@ -76,7 +74,7 @@ function throttle(fn, time, context) {
76
74
  }
77
75
  /**
78
76
  * Returns the number `x` modulo `range` in such a way so it lies within
79
- * `range[0]` and `range[1]`. The returned value will be always smaller than
77
+ * `range[0]` and `range[1]`. The returned value will always be smaller than
80
78
  * `range[1]` unless `includeMax` is set to `true`.
81
79
  * @param {number} x
82
80
  * @param {[number, number]} range
@@ -158,8 +156,7 @@ function template(str, data) {
158
156
  return value;
159
157
  });
160
158
  }
161
- //#endregion
162
- //#region src/core/Class.js
159
+ // src/core/Class.js
163
160
  /**
164
161
  * Class powers the OOP facilities of Maplair and is used to create almost all of the
165
162
  * Maplair classes documented here.
@@ -317,15 +314,9 @@ var Class = class {
317
314
  * @returns {T}
318
315
  */
319
316
  static include(props) {
320
- for (const k of getAllMethodNames(props)) if (k !== "constructor" && k !== "options") this.prototype[k] = props[k];
317
+ for (let obj = props; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) for (const k of Object.getOwnPropertyNames(obj)) if (k !== "constructor" && k !== "options") this.prototype[k] = props[k];
321
318
  if (props.options) this.mergeOptions(props.options);
322
319
  return this;
323
- function* getAllMethodNames(obj) {
324
- do {
325
- if (obj === Object || obj === Object.prototype) break;
326
- for (const k of Object.getOwnPropertyNames(obj)) yield k;
327
- } while ((obj = Object.getPrototypeOf(obj)) !== null);
328
- }
329
320
  }
330
321
  /**
331
322
  * [Merges `options`](#class-options) into the `defaultOptions` of the class.
@@ -390,8 +381,7 @@ var Class = class {
390
381
  return this;
391
382
  }
392
383
  };
393
- //#endregion
394
- //#region src/geometry/Point.js
384
+ // src/geometry/Point.js
395
385
  /**
396
386
  * A point in pixels: a `Point`, an array of the form `[x, y]`, or a plain object of
397
387
  * the form `{x, y}`. Accepted by all Maplair methods and options which accept `Point`
@@ -644,8 +634,7 @@ var Point = class Point {
644
634
  return `Point(${formatNum(this.x)}, ${formatNum(this.y)})`;
645
635
  }
646
636
  };
647
- //#endregion
648
- //#region src/dom/DomEvent.DoubleTap.js
637
+ // src/dom/DomEvent.DoubleTap.js
649
638
  function makeDblclick(ev) {
650
639
  const init = {
651
640
  bubbles: ev.bubbles,
@@ -732,8 +721,7 @@ function removeDoubleTapListener(obj, handlers) {
732
721
  obj.removeEventListener("pointerdown", handlers.onPointerDown, true);
733
722
  obj.removeEventListener("click", handlers.simDblclick);
734
723
  }
735
- //#endregion
736
- //#region src/dom/DomEvent.PointerEvents.js
724
+ // src/dom/DomEvent.PointerEvents.js
737
725
  var DomEvent_PointerEvents_exports = /* @__PURE__ */ __exportAll({
738
726
  disablePointerDetection: () => disablePointerDetection,
739
727
  enablePointerDetection: () => enablePointerDetection,
@@ -784,8 +772,7 @@ function _onDelete(e) {
784
772
  function getPointers() {
785
773
  return [...activePointers.values()];
786
774
  }
787
- //#endregion
788
- //#region src/dom/DomEvent.js
775
+ // src/dom/DomEvent.js
789
776
  var DomEvent_exports = /* @__PURE__ */ __exportAll({
790
777
  PointerEvents: () => DomEvent_PointerEvents_exports,
791
778
  disableClickPropagation: () => disableClickPropagation,
@@ -811,12 +798,11 @@ var DomEvent_exports = /* @__PURE__ */ __exportAll({
811
798
  * @param {string|Record<string, (ev: any) => void>} types
812
799
  * @param {((ev: any) => void)|object} [fn]
813
800
  * @param {object} [context]
814
- * @returns {typeof import('./DomEvent.js')}
801
+ * @returns {void}
815
802
  */
816
803
  function on(obj, types, fn, context) {
817
804
  if (types && typeof types === "object") for (const [type, listener] of Object.entries(types)) addOne(obj, type, listener, fn);
818
805
  else for (const type of splitWords(types)) addOne(obj, type, fn, context);
819
- return this;
820
806
  }
821
807
  const eventsKey = "_maplair_events";
822
808
  /**
@@ -830,7 +816,7 @@ const eventsKey = "_maplair_events";
830
816
  * @param {string|Record<string, (ev: any) => void>} [types]
831
817
  * @param {((ev: any) => void)|object} [fn]
832
818
  * @param {object} [context]
833
- * @returns {typeof import('./DomEvent.js')}
819
+ * @returns {void}
834
820
  */
835
821
  function off(obj, types, fn, context) {
836
822
  if (arguments.length === 1) {
@@ -842,7 +828,6 @@ function off(obj, types, fn, context) {
842
828
  if (arguments.length === 2) batchRemove(obj, (type) => types.includes(type));
843
829
  else for (const type of types) removeOne(obj, type, fn, context);
844
830
  }
845
- return this;
846
831
  }
847
832
  const DIGIT_RE = /\d/;
848
833
  function batchRemove(obj, filterFn) {
@@ -853,7 +838,7 @@ function batchRemove(obj, filterFn) {
853
838
  }
854
839
  function addOne(obj, type, fn, context) {
855
840
  const id = type + stamp(fn) + (context ? `_${stamp(context)}` : "");
856
- if (obj[eventsKey] && obj[eventsKey][id]) return this;
841
+ if (obj[eventsKey] && obj[eventsKey][id]) return;
857
842
  let handler = function(e) {
858
843
  return fn.call(context || obj, e);
859
844
  };
@@ -865,7 +850,7 @@ function addOne(obj, type, fn, context) {
865
850
  function removeOne(obj, type, fn, context, id) {
866
851
  id ??= type + stamp(fn) + (context ? `_${stamp(context)}` : "");
867
852
  const handler = obj[eventsKey] && obj[eventsKey][id];
868
- if (!handler) return this;
853
+ if (!handler) return;
869
854
  if (type === "dblclick") removeDoubleTapListener(obj, handler);
870
855
  else obj.removeEventListener(type, handler, false);
871
856
  obj[eventsKey][id] = null;
@@ -878,22 +863,20 @@ function removeOne(obj, type, fn, context, id) {
878
863
  * ```
879
864
  * Also accepts a Maplair event with an `originalEvent`.
880
865
  * @param {Event|{originalEvent: Event}} e
881
- * @returns {typeof import('./DomEvent.js')}
866
+ * @returns {void}
882
867
  */
883
868
  function stopPropagation(e) {
884
869
  if (e.stopPropagation) e.stopPropagation();
885
870
  else if (e.originalEvent) e.originalEvent._stopped = true;
886
871
  else console.debug("Unsupported event", e);
887
- return this;
888
872
  }
889
873
  /**
890
874
  * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).
891
875
  * @param {HTMLElement} el
892
- * @returns {typeof import('./DomEvent.js')}
876
+ * @returns {void}
893
877
  */
894
878
  function disableScrollPropagation(el) {
895
879
  addOne(el, "wheel", stopPropagation);
896
- return this;
897
880
  }
898
881
  /**
899
882
  * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`
@@ -901,12 +884,11 @@ function disableScrollPropagation(el) {
901
884
  * For `'click'` events, prevents the map from handling the click
902
885
  * while still allowing the native DOM click event to propagate normally.
903
886
  * @param {HTMLElement} el
904
- * @returns {typeof import('./DomEvent.js')}
887
+ * @returns {void}
905
888
  */
906
889
  function disableClickPropagation(el) {
907
890
  on(el, "pointerdown dblclick contextmenu", stopPropagation);
908
891
  el["_maplair_disable_click"] = true;
909
- return this;
910
892
  }
911
893
  /**
912
894
  * Prevents the default action of the DOM Event `e` from happening (such as
@@ -914,21 +896,19 @@ function disableClickPropagation(el) {
914
896
  * with page reload when a `<form>` is submitted).
915
897
  * Use it inside listener functions.
916
898
  * @param {Event} e
917
- * @returns {typeof import('./DomEvent.js')}
899
+ * @returns {void}
918
900
  */
919
901
  function preventDefault(e) {
920
902
  e.preventDefault?.();
921
- return this;
922
903
  }
923
904
  /**
924
905
  * Does `stopPropagation` and `preventDefault` at the same time.
925
906
  * @param {Event} e
926
- * @returns {typeof import('./DomEvent.js')}
907
+ * @returns {void}
927
908
  */
928
909
  function stop(e) {
929
910
  preventDefault(e);
930
911
  stopPropagation(e);
931
- return this;
932
912
  }
933
913
  /**
934
914
  * Gets normalized pointer position from a DOM event relative to the
@@ -971,8 +951,7 @@ function getWheelDelta(e) {
971
951
  function isExternalTarget(el, e) {
972
952
  return !el.contains(e.relatedTarget);
973
953
  }
974
- //#endregion
975
- //#region src/dom/DomUtil.js
954
+ // src/dom/DomUtil.js
976
955
  var DomUtil_exports = /* @__PURE__ */ __exportAll({
977
956
  create: () => create,
978
957
  disableImageDrag: () => disableImageDrag,
@@ -1112,8 +1091,7 @@ function getScale(element) {
1112
1091
  boundingClientRect: rect
1113
1092
  };
1114
1093
  }
1115
- //#endregion
1116
- //#region src/control/Control.js
1094
+ // src/control/Control.js
1117
1095
  /** @import {MaplairMap} from '../map/Map.js' */
1118
1096
  /**
1119
1097
  * Options of `Control`, inherited by all controls.
@@ -1268,8 +1246,7 @@ var Control = class Control extends Class {
1268
1246
  MaplairMap.include(mapControlMethods);
1269
1247
  }
1270
1248
  };
1271
- //#endregion
1272
- //#region src/core/I18n.js
1249
+ // src/core/I18n.js
1273
1250
  /**
1274
1251
  * Utility functions to deal with translations.
1275
1252
  *
@@ -1338,8 +1315,7 @@ var I18n = class {
1338
1315
  }
1339
1316
  }
1340
1317
  };
1341
- //#endregion
1342
- //#region src/control/AttributionControl.js
1318
+ // src/control/AttributionControl.js
1343
1319
  /** @import {ControlOptions} from './Control.js' */
1344
1320
  /** @import {MaplairMap} from '../map/Map.js' */
1345
1321
  const mapleLeaf = "<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">&#x1F341;</span>";
@@ -1492,8 +1468,7 @@ var AttributionControl = class AttributionControl extends Control {
1492
1468
  });
1493
1469
  }
1494
1470
  };
1495
- //#endregion
1496
- //#region src/control/ButtonControl.js
1471
+ // src/control/ButtonControl.js
1497
1472
  /** @import {ControlOptions} from './Control.js' */
1498
1473
  /** @import {MaplairMap} from '../map/Map.js' */
1499
1474
  /**
@@ -1705,8 +1680,7 @@ var ButtonBarControl = class ButtonBarControl extends Control {
1705
1680
  return this._buttons;
1706
1681
  }
1707
1682
  };
1708
- //#endregion
1709
- //#region src/core/Events.js
1683
+ // src/core/Events.js
1710
1684
  const warnedEvents = /* @__PURE__ */ new Set();
1711
1685
  /** @import {LatLng} from '../geo/LatLng.js' */
1712
1686
  /** @import {LatLngBounds} from '../geo/LatLngBounds.js' */
@@ -2093,8 +2067,7 @@ var Evented = class Evented extends Class {
2093
2067
  }, true);
2094
2068
  }
2095
2069
  };
2096
- //#endregion
2097
- //#region src/layer/Layer.js
2070
+ // src/layer/Layer.js
2098
2071
  /** @import {MaplairMap} from '../map/Map.js' */
2099
2072
  /** @import {LayerGroup} from './LayerGroup.js' */
2100
2073
  /** @import {EventListener, MaplairEvent, MaplairPointerEvent, LayerEvent} from '../core/Events.js' */
@@ -2415,8 +2388,7 @@ var Layer = class extends Evented {
2415
2388
  MaplairMap.include(mapLayerMethods);
2416
2389
  }
2417
2390
  };
2418
- //#endregion
2419
- //#region src/control/ContextMenu.js
2391
+ // src/control/ContextMenu.js
2420
2392
  /** @import {MaplairMap} from '../map/Map.js' */
2421
2393
  /** @import {LatLng} from '../geo/LatLng.js' */
2422
2394
  /** @import {Point} from '../geometry/Point.js' */
@@ -2578,8 +2550,7 @@ var ContextMenu = class ContextMenu extends Class {
2578
2550
  buttons.at(next % buttons.length)?.focus();
2579
2551
  }
2580
2552
  };
2581
- //#endregion
2582
- //#region src/control/FullscreenControl.js
2553
+ // src/control/FullscreenControl.js
2583
2554
  /** @import {ControlOptions} from './Control.js' */
2584
2555
  /** @import {MaplairMap} from '../map/Map.js' */
2585
2556
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -2755,8 +2726,7 @@ var FullscreenControl = class FullscreenControl extends Control {
2755
2726
  });
2756
2727
  }
2757
2728
  };
2758
- //#endregion
2759
- //#region src/control/LayersControl.js
2729
+ // src/control/LayersControl.js
2760
2730
  /** @import {ControlOptions} from './Control.js' */
2761
2731
  /** @import {MaplairMap} from '../map/Map.js' */
2762
2732
  /** @import {Layer} from '../layer/Layer.js' */
@@ -2935,6 +2905,7 @@ var LayersControl = class LayersControl extends Control {
2935
2905
  this._map.off("zoomend", this._checkDisabledLayers, this);
2936
2906
  for (const layer of this._layers) layer.layer.off("add remove", this._onLayerChange, this);
2937
2907
  this._map.off("resize", this._expandIfNotCollapsed, this);
2908
+ this._map.off("click", this.collapse, this);
2938
2909
  }
2939
2910
  /**
2940
2911
  * Adds a base layer (radio button entry) with the given name to the control.
@@ -2963,8 +2934,7 @@ var LayersControl = class LayersControl extends Control {
2963
2934
  */
2964
2935
  removeLayer(layer) {
2965
2936
  layer.off("add remove", this._onLayerChange, this);
2966
- const obj = this._getLayer(stamp(layer));
2967
- if (obj) this._layers.splice(this._layers.indexOf(obj), 1);
2937
+ this._layers = this._layers.filter((o) => o.layer !== layer);
2968
2938
  return this._map ? this._update() : this;
2969
2939
  }
2970
2940
  /**
@@ -2988,7 +2958,7 @@ var LayersControl = class LayersControl extends Control {
2988
2958
  * @returns {this}
2989
2959
  */
2990
2960
  selectLayer(layer) {
2991
- const input = this._layerControlInputs.find((input) => input.layerId === stamp(layer));
2961
+ const input = this._layerControlInputs.find((input) => input._layer === layer);
2992
2962
  if (input && !input.checked) {
2993
2963
  input.checked = true;
2994
2964
  this._onInputClick();
@@ -3013,21 +2983,14 @@ var LayersControl = class LayersControl extends Control {
3013
2983
  }
3014
2984
  /**
3015
2985
  * Collapse the control container if expanded.
3016
- * @param {Event} [ev] The event causing the collapse, if any (collapsing is skipped
3017
- * for `pointerleave` and `pointerout` of touch).
3018
2986
  * @returns {this}
3019
2987
  */
3020
- collapse(ev) {
2988
+ collapse() {
3021
2989
  if (this.options.inline) return this;
3022
- if (!ev || !((ev.type === "pointerleave" || ev.type === "pointerout") && ev.pointerType === "touch")) {
3023
- if (this.options.collapseDelay > 0) {
3024
- this._collapseDelayTimeout = setTimeout(() => {
3025
- this._container.classList.remove("maplair-control-layers-expanded");
3026
- }, this.options.collapseDelay);
3027
- return this;
3028
- }
2990
+ if (this.options.collapseDelay > 0) this._collapseDelayTimeout = setTimeout(() => {
3029
2991
  this._container.classList.remove("maplair-control-layers-expanded");
3030
- }
2992
+ }, this.options.collapseDelay);
2993
+ else this._container.classList.remove("maplair-control-layers-expanded");
3031
2994
  return this;
3032
2995
  }
3033
2996
  _initLayout() {
@@ -3041,7 +3004,9 @@ var LayersControl = class LayersControl extends Control {
3041
3004
  this._map.on("click", this.collapse, this);
3042
3005
  on(container, {
3043
3006
  pointerenter: this._expandSafely,
3044
- pointerleave: this.collapse
3007
+ pointerleave(e) {
3008
+ if (e.pointerType !== "touch") this.collapse();
3009
+ }
3045
3010
  }, this);
3046
3011
  }
3047
3012
  if (!this.options.inline) {
@@ -3068,9 +3033,6 @@ var LayersControl = class LayersControl extends Control {
3068
3033
  this._overlaysList = create("div", `${className}-overlays`, section);
3069
3034
  container.appendChild(section);
3070
3035
  }
3071
- _getLayer(id) {
3072
- for (const layer of this._layers) if (layer && stamp(layer.layer) === id) return layer;
3073
- }
3074
3036
  _addLayer(layer, name, overlay) {
3075
3037
  if (this._map) layer.on("add remove", this._onLayerChange, this);
3076
3038
  this._layers.push({
@@ -3107,7 +3069,7 @@ var LayersControl = class LayersControl extends Control {
3107
3069
  }
3108
3070
  _onLayerChange(e) {
3109
3071
  if (!this._handlingClick) this._update();
3110
- const obj = this._getLayer(stamp(e.target));
3072
+ const obj = this._layers.find((o) => o.layer === e.target);
3111
3073
  const type = obj.overlay ? e.type === "add" ? "overlayadd" : "overlayremove" : e.type === "add" ? "baselayerchange" : null;
3112
3074
  if (type) this._map.fire(type, this._clickEvent ? {
3113
3075
  ...obj,
@@ -3122,7 +3084,7 @@ var LayersControl = class LayersControl extends Control {
3122
3084
  input.defaultChecked = checked;
3123
3085
  if (!obj.overlay) input.name = `maplair-base-layers_${stamp(this)}`;
3124
3086
  this._layerControlInputs.push(input);
3125
- input.layerId = stamp(obj.layer);
3087
+ input._layer = obj.layer;
3126
3088
  on(input, "click", this._onInputClick, this);
3127
3089
  const group = this.options.groupBy?.(obj.name, obj.layer, obj.overlay);
3128
3090
  const name = document.createElement("span");
@@ -3156,24 +3118,29 @@ var LayersControl = class LayersControl extends Control {
3156
3118
  }
3157
3119
  _onInputClick(e) {
3158
3120
  if (this._preventClick) return;
3159
- const inputs = this._layerControlInputs, addedLayers = [], removedLayers = [];
3121
+ const checked = /* @__PURE__ */ new Map();
3122
+ for (const input of this._layerControlInputs) {
3123
+ const layer = input._layer;
3124
+ checked.set(layer, checked.get(layer) || input.checked);
3125
+ }
3126
+ const addedLayers = [], removedLayers = [];
3127
+ for (const [layer, on] of checked) if (on !== this._map.hasLayer(layer)) (on ? addedLayers : removedLayers).push(layer);
3160
3128
  this._handlingClick = true;
3161
3129
  this._clickEvent = e;
3162
- for (const input of inputs) {
3163
- const layer = this._getLayer(input.layerId).layer;
3164
- if (input.checked) addedLayers.push(layer);
3165
- else if (!input.checked) removedLayers.push(layer);
3166
- }
3167
- for (const layer of removedLayers) if (this._map.hasLayer(layer)) this._map.removeLayer(layer);
3168
- for (const layer of addedLayers) if (!this._map.hasLayer(layer)) this._map.addLayer(layer);
3130
+ for (const layer of removedLayers) this._map.removeLayer(layer);
3131
+ for (const layer of addedLayers) this._map.addLayer(layer);
3169
3132
  this._handlingClick = false;
3170
3133
  this._clickEvent = void 0;
3134
+ for (const [layer, on] of checked) if (on !== this._map.hasLayer(layer)) {
3135
+ this._update();
3136
+ break;
3137
+ }
3171
3138
  this._refocusOnMap(e);
3172
3139
  }
3173
3140
  _checkDisabledLayers() {
3174
3141
  const inputs = this._layerControlInputs, zoom = this._map.getZoom();
3175
3142
  for (const input of inputs) {
3176
- const layer = this._getLayer(input.layerId).layer;
3143
+ const layer = input._layer;
3177
3144
  input.disabled = layer.options.minZoom !== void 0 && zoom < layer.options.minZoom || layer.options.maxZoom !== void 0 && zoom > layer.options.maxZoom;
3178
3145
  }
3179
3146
  }
@@ -3195,8 +3162,7 @@ var LayersControl = class LayersControl extends Control {
3195
3162
  });
3196
3163
  }
3197
3164
  };
3198
- //#endregion
3199
- //#region src/geometry/Bounds.js
3165
+ // src/geometry/Bounds.js
3200
3166
  /** @import {PointExpression} from './Point.js' */
3201
3167
  /**
3202
3168
  * A rectangular area in pixel coordinates: a `Bounds`, or an array of points (usually
@@ -3273,14 +3239,12 @@ var Bounds = class Bounds {
3273
3239
  extend(obj) {
3274
3240
  let min2, max2;
3275
3241
  if (!obj) return this;
3276
- if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 = Point.from(obj);
3242
+ if (isPointExpression(obj)) min2 = max2 = Point.from(obj);
3277
3243
  else {
3278
- obj = Bounds.from(obj);
3279
- min2 = obj.min;
3280
- max2 = obj.max;
3281
- if (!min2 || !max2) return this;
3244
+ ({min: min2, max: max2} = Bounds.from(obj));
3245
+ if (!min2) return this;
3282
3246
  }
3283
- if (!this.min && !this.max) {
3247
+ if (!this.min) {
3284
3248
  this.min = new Point(min2);
3285
3249
  this.max = new Point(max2);
3286
3250
  } else {
@@ -3341,12 +3305,8 @@ var Bounds = class Bounds {
3341
3305
  */
3342
3306
  contains(obj) {
3343
3307
  let min, max;
3344
- if (typeof obj[0] === "number" || obj instanceof Point) obj = Point.from(obj);
3345
- else obj = Bounds.from(obj);
3346
- if (obj instanceof Bounds) {
3347
- min = obj.min;
3348
- max = obj.max;
3349
- } else min = max = obj;
3308
+ if (isPointExpression(obj)) min = max = Point.from(obj);
3309
+ else ({min, max} = Bounds.from(obj));
3350
3310
  return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
3351
3311
  }
3352
3312
  /**
@@ -3400,8 +3360,10 @@ var Bounds = class Bounds {
3400
3360
  return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
3401
3361
  }
3402
3362
  };
3403
- //#endregion
3404
- //#region src/layer/BlanketOverlay.js
3363
+ function isPointExpression(obj) {
3364
+ return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] === "number" : "x" in obj);
3365
+ }
3366
+ // src/layer/BlanketOverlay.js
3405
3367
  /** @import {LayerOptions} from './Layer.js' */
3406
3368
  /** @import {MaplairMap} from '../map/Map.js' */
3407
3369
  /** @import {EventListener} from '../core/Events.js' */
@@ -3530,8 +3492,7 @@ var BlanketOverlay = class BlanketOverlay extends Layer {
3530
3492
  _onViewReset() {}
3531
3493
  _onSettled() {}
3532
3494
  };
3533
- //#endregion
3534
- //#region src/layer/vector/Renderer.js
3495
+ // src/layer/vector/Renderer.js
3535
3496
  /** @import {BlanketOverlayOptions} from '../BlanketOverlay.js' */
3536
3497
  /** @import {MaplairEvent} from '../../core/Events.js' */
3537
3498
  /** @import {MaplairMap} from '../../map/Map.js' */
@@ -3600,8 +3561,7 @@ var Renderer = class Renderer extends BlanketOverlay {
3600
3561
  }
3601
3562
  _update() {}
3602
3563
  };
3603
- //#endregion
3604
- //#region src/layer/vector/SVG.js
3564
+ // src/layer/vector/SVG.js
3605
3565
  /** @import {Point} from '../../geometry/Point.js' */
3606
3566
  /** @import {RendererOptions} from './Renderer.js' */
3607
3567
  /**
@@ -3725,7 +3685,7 @@ var SVG = class SVG extends Renderer {
3725
3685
  }
3726
3686
  _updateCircle(layer) {
3727
3687
  const p = layer._point, r = Math.max(Math.round(layer._pxRadius), 1), arc = `a${r},${Math.max(Math.round(layer._pxRadiusY), 1) || r} 0 1,0 `;
3728
- const d = layer._empty() ? "M0 0" : `M${p.x - r},${p.y}${arc}${r * 2},0 ${arc}${-r * 2},0 `;
3688
+ const d = layer._empty() ? "M0 0" : `M${num(p.x - r)},${num(p.y)}${arc}${r * 2},0 ${arc}${-r * 2},0 `;
3729
3689
  this._setPath(layer, d);
3730
3690
  }
3731
3691
  _setPath(layer, path) {
@@ -3755,11 +3715,14 @@ var SVG = class SVG extends Renderer {
3755
3715
  * @returns {string}
3756
3716
  */
3757
3717
  static pointsToPath(rings, closed) {
3758
- return rings.flatMap((points) => [...points.map((p, j) => `${(j ? "L" : "M") + p.x} ${p.y}`), closed ? "z" : ""]).join("") || "M0 0";
3718
+ return rings.flatMap((points) => [...points.map((p, j) => `${(j ? "L" : "M") + num(p.x)} ${num(p.y)}`), closed ? "z" : ""]).join("") || "M0 0";
3759
3719
  }
3760
3720
  };
3761
- //#endregion
3762
- //#region src/layer/vector/Path.js
3721
+ function num(v) {
3722
+ const n = Math.round(v * 10), a = n < 0 ? -n : n, i = Math.floor(a / 10), d = a - i * 10;
3723
+ return (n < 0 ? "-" : "") + (d ? `${i}.${d}` : i);
3724
+ }
3725
+ // src/layer/vector/Path.js
3763
3726
  /** @import {InteractiveLayerOptions} from '../Layer.js' */
3764
3727
  /** @import {MaplairMap} from '../../map/Map.js' */
3765
3728
  /** @import {Renderer} from './Renderer.js' */
@@ -3901,8 +3864,7 @@ var Path = class extends Layer {
3901
3864
  return (this.options.stroke ? this.options.weight / 2 : 0) + (this._renderer.options.tolerance || 0);
3902
3865
  }
3903
3866
  };
3904
- //#endregion
3905
- //#region src/geo/LatLngBounds.js
3867
+ // src/geo/LatLngBounds.js
3906
3868
  /** @import {LatLngExpression} from './LatLng.js' */
3907
3869
  /**
3908
3870
  * A geographical area: a `LatLngBounds`, or an array of geographical points (usually
@@ -3982,19 +3944,14 @@ var LatLngBounds = class LatLngBounds {
3982
3944
  extend(obj) {
3983
3945
  const sw = this._southWest, ne = this._northEast;
3984
3946
  let sw2, ne2;
3985
- if (obj instanceof LatLng) {
3986
- sw2 = obj;
3987
- ne2 = obj;
3988
- } else if (obj instanceof LatLngBounds) {
3989
- sw2 = obj._southWest;
3990
- ne2 = obj._northEast;
3991
- if (!sw2 || !ne2) return this;
3992
- } else {
3993
- if (!obj) return this;
3994
- if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
3995
- return this.extend(LatLngBounds.from(obj));
3996
- }
3997
- if (!sw && !ne) {
3947
+ if (obj instanceof LatLng) sw2 = ne2 = obj;
3948
+ else if (obj instanceof LatLngBounds) {
3949
+ ({_southWest: sw2, _northEast: ne2} = obj);
3950
+ if (!sw2) return this;
3951
+ } else if (!obj) return this;
3952
+ else if (LatLng.validate(obj)) sw2 = ne2 = LatLng.from(obj);
3953
+ else return this.extend(LatLngBounds.from(obj));
3954
+ if (!sw) {
3998
3955
  this._southWest = new LatLng(sw2.lat, sw2.lng);
3999
3956
  this._northEast = new LatLng(ne2.lat, ne2.lng);
4000
3957
  } else {
@@ -4152,8 +4109,7 @@ var LatLngBounds = class LatLngBounds {
4152
4109
  return !!(this._southWest && this._northEast);
4153
4110
  }
4154
4111
  };
4155
- //#endregion
4156
- //#region src/geo/LatLng.js
4112
+ // src/geo/LatLng.js
4157
4113
  const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
4158
4114
  const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
4159
4115
  const plainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`);
@@ -4373,8 +4329,7 @@ function haversineDistance(latlng1, latlng2, R) {
4373
4329
  const rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon;
4374
4330
  return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
4375
4331
  }
4376
- //#endregion
4377
- //#region src/geometry/LineUtil.js
4332
+ // src/geometry/LineUtil.js
4378
4333
  var LineUtil_exports = /* @__PURE__ */ __exportAll({
4379
4334
  _getBitCode: () => _getBitCode,
4380
4335
  _getEdgeIntersection: () => _getEdgeIntersection,
@@ -4593,12 +4548,11 @@ function _projectRing(latlngs, crs) {
4593
4548
  if (!latlngs || latlngs.length === 0) throw new Error("latlngs not passed");
4594
4549
  if (!isFlat(latlngs)) {
4595
4550
  console.warn("latlngs are not flat! Only the first ring will be used");
4596
- latlngs = latlngs[0];
4551
+ return _projectRing(latlngs[0], crs);
4597
4552
  }
4598
4553
  return latlngs.map((latlng) => crs.project(LatLng.from(latlng)));
4599
4554
  }
4600
- //#endregion
4601
- //#region src/layer/GeoJSONUtil.js
4555
+ // src/layer/GeoJSONUtil.js
4602
4556
  /** @import {Feature, FeatureCollection, GeoJsonObject, Geometry} from 'geojson' */
4603
4557
  /** @import {Layer} from './Layer.js' */
4604
4558
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
@@ -4666,8 +4620,7 @@ function pointToGeoJSON(layer, precision) {
4666
4620
  coordinates: latLngToCoords(layer.getLatLng(), precision)
4667
4621
  });
4668
4622
  }
4669
- //#endregion
4670
- //#region src/layer/vector/CircleMarker.js
4623
+ // src/layer/vector/CircleMarker.js
4671
4624
  /** @import {Feature} from 'geojson' */
4672
4625
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
4673
4626
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -4759,7 +4712,7 @@ var CircleMarker = class CircleMarker extends Path {
4759
4712
  return this;
4760
4713
  }
4761
4714
  _project() {
4762
- this._point = this._map.latLngToLayerPoint(this._latlng);
4715
+ this._point = this._map.latLngToLayerPoint(this._latlng)._round();
4763
4716
  this._pxRadius = this._radius;
4764
4717
  this._updateBounds();
4765
4718
  }
@@ -4790,8 +4743,7 @@ var CircleMarker = class CircleMarker extends Path {
4790
4743
  return pointToGeoJSON(this, precision);
4791
4744
  }
4792
4745
  };
4793
- //#endregion
4794
- //#region src/control/LegendControl.js
4746
+ // src/control/LegendControl.js
4795
4747
  /** @import {ControlOptions} from './Control.js' */
4796
4748
  /** @import {MaplairMap} from '../map/Map.js' */
4797
4749
  /** @import {FeatureGroup} from '../layer/FeatureGroup.js' */
@@ -5010,8 +4962,7 @@ function svgElement$1(name, attributes) {
5010
4962
  for (const [key, value] of Object.entries(attributes)) el.setAttribute(key, value);
5011
4963
  return el;
5012
4964
  }
5013
- //#endregion
5014
- //#region src/geo/crs/CRS.js
4965
+ // src/geo/crs/CRS.js
5015
4966
  /** @import {LatLngExpression} from '../LatLng.js' */
5016
4967
  /** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */
5017
4968
  /** @import {Point} from '../../geometry/Point.js' */
@@ -5155,8 +5106,7 @@ var CRS = class {
5155
5106
  return new LatLngBounds(new LatLng(sw.lat - latShift, sw.lng - lngShift), new LatLng(ne.lat - latShift, ne.lng - lngShift));
5156
5107
  }
5157
5108
  };
5158
- //#endregion
5159
- //#region src/geo/crs/EarthCRS.js
5109
+ // src/geo/crs/EarthCRS.js
5160
5110
  /** @import {LatLng} from '../LatLng.js' */
5161
5111
  /**
5162
5112
  * Serves as the base for CRS that are global such that they cover the earth.
@@ -5188,8 +5138,7 @@ var EarthCRS = class extends CRS {
5188
5138
  return haversineDistance(latlng1, latlng2, this.R);
5189
5139
  }
5190
5140
  };
5191
- //#endregion
5192
- //#region src/geo/projection/Projection.SphericalMercator.js
5141
+ // src/geo/projection/SphericalMercatorProjection.js
5193
5142
  /** @import {Projection} from './index.js' */
5194
5143
  const earthRadius$1 = 6378137;
5195
5144
  /**
@@ -5198,7 +5147,7 @@ const earthRadius$1 = 6378137;
5198
5147
  * a sphere. Used by the `EPSG:3857` CRS.
5199
5148
  * @type {Projection & {R: number, MAX_LATITUDE: number}}
5200
5149
  */
5201
- const SphericalMercator = {
5150
+ const SphericalMercatorProjection = {
5202
5151
  R: earthRadius$1,
5203
5152
  MAX_LATITUDE: 85.0511287798,
5204
5153
  project(latlng) {
@@ -5216,8 +5165,7 @@ const SphericalMercator = {
5216
5165
  return new Bounds([-d, -d], [d, d]);
5217
5166
  })()
5218
5167
  };
5219
- //#endregion
5220
- //#region src/geometry/Transformation.js
5168
+ // src/geometry/Transformation.js
5221
5169
  /**
5222
5170
  * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`
5223
5171
  * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing
@@ -5281,8 +5229,7 @@ var Transformation = class {
5281
5229
  return new Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c);
5282
5230
  }
5283
5231
  };
5284
- //#endregion
5285
- //#region src/geo/crs/EPSG3857.js
5232
+ // src/geo/crs/EPSG3857.js
5286
5233
  /** @import {Projection} from '../projection/index.js' */
5287
5234
  /**
5288
5235
  * The most common CRS for online maps, used by almost all free and commercial
@@ -5293,10 +5240,10 @@ var EPSG3857 = class extends EarthCRS {
5293
5240
  /** @type {string} */
5294
5241
  static code = "EPSG:3857";
5295
5242
  /** @type {Projection} */
5296
- static projection = SphericalMercator;
5243
+ static projection = SphericalMercatorProjection;
5297
5244
  /** @type {Transformation} */
5298
5245
  static transformation = /* @__PURE__ */ (() => {
5299
- const scale = .5 / (Math.PI * SphericalMercator.R);
5246
+ const scale = .5 / (Math.PI * SphericalMercatorProjection.R);
5300
5247
  return new Transformation(scale, .5, -scale, .5);
5301
5248
  })();
5302
5249
  };
@@ -5307,8 +5254,7 @@ var EPSG900913 = class extends EPSG3857 {
5307
5254
  /** @type {string} */
5308
5255
  static code = "EPSG:900913";
5309
5256
  };
5310
- //#endregion
5311
- //#region src/dom/PosAnimation.js
5257
+ // src/dom/PosAnimation.js
5312
5258
  /** @import {Point} from '../geometry/Point.js' */
5313
5259
  /** @import {MaplairEvent} from '../core/Events.js' */
5314
5260
  /**
@@ -5384,8 +5330,7 @@ var PosAnimation = class PosAnimation extends Evented {
5384
5330
  return 1 - (1 - t) ** this._easeOutPower;
5385
5331
  }
5386
5332
  };
5387
- //#endregion
5388
- //#region src/control/ZoomControl.js
5333
+ // src/control/ZoomControl.js
5389
5334
  /** @import {ControlOptions} from './Control.js' */
5390
5335
  /** @import {MaplairMap} from '../map/Map.js' */
5391
5336
  /**
@@ -5439,8 +5384,8 @@ var ZoomControl = class ZoomControl extends Control {
5439
5384
  */
5440
5385
  onAdd(map) {
5441
5386
  const zoomName = "maplair-control-zoom", container = create("div", `${zoomName} maplair-bar`), options = this.options;
5442
- this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, this._zoomIn);
5443
- this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, this._zoomOut);
5387
+ this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, (e) => this._zoom(e, 1));
5388
+ this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, (e) => this._zoom(e, -1));
5444
5389
  this._updateDisabled();
5445
5390
  map.on("zoomend zoomlevelschange", this._updateDisabled, this);
5446
5391
  return container;
@@ -5470,16 +5415,11 @@ var ZoomControl = class ZoomControl extends Control {
5470
5415
  this._updateDisabled();
5471
5416
  return this;
5472
5417
  }
5473
- _zoomIn(e) {
5474
- if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {
5475
- this._map._setUserEvent(e);
5476
- this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
5477
- }
5478
- }
5479
- _zoomOut(e) {
5480
- if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {
5481
- this._map._setUserEvent(e);
5482
- this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
5418
+ _zoom(e, dir) {
5419
+ const map = this._map;
5420
+ if (!this._disabled && (dir > 0 ? map._zoom < map.getMaxZoom() : map._zoom > map.getMinZoom())) {
5421
+ map._setUserEvent(e);
5422
+ map.zoomIn(dir * map.options.zoomDelta * (e.shiftKey ? 3 : 1));
5483
5423
  }
5484
5424
  }
5485
5425
  _createButton(html, title, className, container, fn) {
@@ -5489,24 +5429,19 @@ var ZoomControl = class ZoomControl extends Control {
5489
5429
  link.title = title;
5490
5430
  link.setAttribute("aria-label", title);
5491
5431
  disableClickPropagation(link);
5492
- on(link, "click", stop);
5493
- on(link, "click", fn, this);
5494
- on(link, "click", this._refocusOnMap, this);
5432
+ on(link, "click", (e) => {
5433
+ stop(e);
5434
+ fn.call(this, e);
5435
+ this._refocusOnMap(e);
5436
+ });
5495
5437
  return link;
5496
5438
  }
5497
5439
  _updateDisabled() {
5498
- const map = this._map, className = "maplair-disabled";
5499
- this._zoomInButton.classList.remove(className);
5500
- this._zoomOutButton.classList.remove(className);
5501
- this._zoomInButton.setAttribute("aria-disabled", "false");
5502
- this._zoomOutButton.setAttribute("aria-disabled", "false");
5503
- if (this._disabled || map._zoom === map.getMinZoom()) {
5504
- this._zoomOutButton.classList.add(className);
5505
- this._zoomOutButton.setAttribute("aria-disabled", "true");
5506
- }
5507
- if (this._disabled || map._zoom === map.getMaxZoom()) {
5508
- this._zoomInButton.classList.add(className);
5509
- this._zoomInButton.setAttribute("aria-disabled", "true");
5440
+ const map = this._map;
5441
+ for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
5442
+ const disabled = this._disabled || map._zoom === limit;
5443
+ button.classList.toggle("maplair-disabled", disabled);
5444
+ button.setAttribute("aria-disabled", `${disabled}`);
5510
5445
  }
5511
5446
  }
5512
5447
  /**
@@ -5524,8 +5459,7 @@ var ZoomControl = class ZoomControl extends Control {
5524
5459
  });
5525
5460
  }
5526
5461
  };
5527
- //#endregion
5528
- //#region src/layer/LayerGroup.js
5462
+ // src/layer/LayerGroup.js
5529
5463
  /** @import {Feature, FeatureCollection} from 'geojson' */
5530
5464
  /** @import {InteractiveLayerOptions} from './Layer.js' */
5531
5465
  /** @import {MaplairMap} from '../map/Map.js' */
@@ -5572,7 +5506,7 @@ var LayerGroup = class LayerGroup extends Layer {
5572
5506
  * @returns {this}
5573
5507
  */
5574
5508
  removeLayer(layer) {
5575
- const id = layer in this._layers ? layer : this.getLayerId(layer);
5509
+ const id = typeof layer === "number" ? layer : this.getLayerId(layer);
5576
5510
  if (this._map && this._layers[id]) this._map.removeLayer(this._layers[id]);
5577
5511
  delete this._layers[id];
5578
5512
  return this;
@@ -5704,8 +5638,7 @@ var LayerGroup = class LayerGroup extends Layer {
5704
5638
  };
5705
5639
  }
5706
5640
  };
5707
- //#endregion
5708
- //#region src/layer/FeatureGroup.js
5641
+ // src/layer/FeatureGroup.js
5709
5642
  /** @import {Layer, InteractiveLayerOptions} from './Layer.js' */
5710
5643
  /** @import {LayerEvent} from '../core/Events.js' */
5711
5644
  /** @import {PathOptions} from './vector/Path.js' */
@@ -5800,17 +5733,18 @@ var FeatureGroup = class FeatureGroup extends LayerGroup {
5800
5733
  }
5801
5734
  /**
5802
5735
  * Returns the `LatLngBounds` of the feature group (created from bounds and
5803
- * coordinates of its children).
5736
+ * coordinates of its children, including the layers of nested layer groups).
5804
5737
  * @returns {LatLngBounds}
5805
5738
  */
5806
5739
  getBounds() {
5807
5740
  const bounds = new LatLngBounds();
5808
- for (const layer of Object.values(this._layers)) bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng());
5741
+ for (const layer of Object.values(this._layers)) if (layer.getBounds) bounds.extend(layer.getBounds());
5742
+ else if (layer.getLatLng) bounds.extend(layer.getLatLng());
5743
+ else if (layer instanceof LayerGroup) bounds.extend(FeatureGroup.prototype.getBounds.call(layer));
5809
5744
  return bounds;
5810
5745
  }
5811
5746
  };
5812
- //#endregion
5813
- //#region src/layer/DivOverlay.js
5747
+ // src/layer/DivOverlay.js
5814
5748
  /** @import {InteractiveLayerOptions} from './Layer.js' */
5815
5749
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
5816
5750
  /** @import {PointExpression} from '../geometry/Point.js' */
@@ -6149,7 +6083,7 @@ var DivOverlay = class DivOverlay extends Layer {
6149
6083
  }
6150
6084
  _updatePosition() {
6151
6085
  if (!this._map) return;
6152
- const pos = this._map.latLngToLayerPoint(this._latlng), offset = Point.from(this.options.offset);
6086
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round(), offset = Point.from(this.options.offset);
6153
6087
  this._setContainerPosition(pos.add(this._getAnchor()));
6154
6088
  const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
6155
6089
  if (this.options.overflow) {
@@ -6182,8 +6116,7 @@ var DivOverlay = class DivOverlay extends Layer {
6182
6116
  Layer.include(layerDivOverlayMethods);
6183
6117
  }
6184
6118
  };
6185
- //#endregion
6186
- //#region src/layer/Popup.js
6119
+ // src/layer/Popup.js
6187
6120
  /** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */
6188
6121
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
6189
6122
  /** @import {PointExpression} from '../geometry/Point.js' */
@@ -6389,7 +6322,7 @@ const layerPopupMethods = {
6389
6322
  },
6390
6323
  _openPopup(e) {
6391
6324
  if (!this._popup || !this._map) return;
6392
- stop(e);
6325
+ stopPropagation(e);
6393
6326
  const target = e.propagatedFrom ?? e.target;
6394
6327
  if (this._popup._source === target && !(target instanceof Path)) {
6395
6328
  if (this._map.hasLayer(this._popup)) this.closePopup();
@@ -6541,9 +6474,6 @@ var Popup = class Popup extends DivOverlay {
6541
6474
  const wrapper = this._wrapper = create("div", `${prefix}-content-wrapper`, container);
6542
6475
  this._contentNode = create("div", `${prefix}-content`, wrapper);
6543
6476
  disableClickPropagation(container);
6544
- on(container, "keydown", (e) => {
6545
- if (e.key === "Escape" && this.options.closeOnEscapeKey) this.close();
6546
- });
6547
6477
  disableScrollPropagation(this._contentNode);
6548
6478
  on(container, "contextmenu", stopPropagation);
6549
6479
  this._tipContainer = create("div", `${prefix}-tip-container`, container);
@@ -6559,14 +6489,12 @@ var Popup = class Popup extends DivOverlay {
6559
6489
  });
6560
6490
  }
6561
6491
  if (this.options.trackResize) {
6562
- this._resizeObserver = new ResizeObserver(((entries) => {
6492
+ this._resizeObserver = new ResizeObserver(() => {
6563
6493
  if (!this._map) return;
6564
- this._containerWidth = entries[0]?.contentRect?.width;
6565
- this._containerHeight = entries[0]?.contentRect?.height;
6566
6494
  this._updateLayout();
6567
6495
  this._updatePosition();
6568
6496
  this._adjustPan();
6569
- }));
6497
+ });
6570
6498
  this._resizeObserver.observe(this._contentNode);
6571
6499
  }
6572
6500
  }
@@ -6574,11 +6502,10 @@ var Popup = class Popup extends DivOverlay {
6574
6502
  const container = this._contentNode, style = container.style;
6575
6503
  style.maxWidth = `${this.options.maxWidth}px`;
6576
6504
  style.minWidth = `${this.options.minWidth}px`;
6577
- const maxHeight = this.options.maxHeight, scrolledClass = "maplair-popup-scrolled";
6578
- if (maxHeight && (this._containerHeight ?? container.offsetHeight) > maxHeight) {
6579
- style.height = `${maxHeight}px`;
6580
- container.classList.add(scrolledClass);
6581
- } else container.classList.remove(scrolledClass);
6505
+ style.height = "";
6506
+ const maxHeight = this.options.maxHeight, scrolled = !!maxHeight && container.offsetHeight > maxHeight;
6507
+ if (scrolled) style.height = `${maxHeight}px`;
6508
+ container.classList.toggle("maplair-popup-scrolled", scrolled);
6582
6509
  this._containerWidth = this._container.offsetWidth;
6583
6510
  this._containerHeight = this._container.offsetHeight;
6584
6511
  this._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;
@@ -6622,8 +6549,7 @@ var Popup = class Popup extends DivOverlay {
6622
6549
  Layer.include(layerPopupMethods);
6623
6550
  }
6624
6551
  };
6625
- //#endregion
6626
- //#region src/layer/Tooltip.js
6552
+ // src/layer/Tooltip.js
6627
6553
  const directions = [
6628
6554
  "top",
6629
6555
  "bottom",
@@ -6730,8 +6656,9 @@ const layerTooltipMethods = {
6730
6656
  * @returns {this}
6731
6657
  */
6732
6658
  bindTooltip(content, options) {
6733
- if (this._tooltip && this.isTooltipOpen()) this.unbindTooltip();
6734
- this._tooltip = this._initOverlay(Tooltip, this._tooltip, content, options);
6659
+ const old = this.isTooltipOpen() ? null : this._tooltip;
6660
+ if (this._tooltip) this.unbindTooltip();
6661
+ this._tooltip = this._initOverlay(Tooltip, old, content, options);
6735
6662
  this._initTooltipInteractions();
6736
6663
  if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) this.openTooltip();
6737
6664
  return this;
@@ -6750,21 +6677,20 @@ const layerTooltipMethods = {
6750
6677
  return this;
6751
6678
  },
6752
6679
  _initTooltipInteractions(remove) {
6753
- if (!remove && this._tooltipHandlersAdded) return;
6754
- const onOff = remove ? "off" : "on", events = {
6680
+ const { permanent, sticky } = this._tooltip.options, events = {
6755
6681
  remove: this.closeTooltip,
6756
6682
  move: this._moveTooltip
6757
6683
  };
6758
- if (!this._tooltip.options.permanent) {
6684
+ if (permanent) events.add = this._openTooltip;
6685
+ else {
6759
6686
  events.pointerover = this._openTooltip;
6760
6687
  events.pointerout = this.closeTooltip;
6761
6688
  events.click = this._openTooltip;
6762
- if (this._map) this._addFocusListeners(remove);
6763
- else events.add = () => this._addFocusListeners(remove);
6764
- } else events.add = this._openTooltip;
6765
- if (this._tooltip.options.sticky) events.pointermove = this._moveTooltip;
6766
- this[onOff](events);
6767
- this._tooltipHandlersAdded = !remove;
6689
+ events.add = this._toggleFocusListeners;
6690
+ if (this._map) this._toggleFocusListeners(!remove);
6691
+ }
6692
+ if (sticky) events.pointermove = this._moveTooltip;
6693
+ this[remove ? "off" : "on"](events);
6768
6694
  },
6769
6695
  /**
6770
6696
  * Opens the bound tooltip at the specified `latlng` or at the default tooltip
@@ -6830,9 +6756,9 @@ const layerTooltipMethods = {
6830
6756
  getTooltip() {
6831
6757
  return this._tooltip;
6832
6758
  },
6833
- _addFocusListeners(remove) {
6834
- if (this.getElement) this._addFocusListenersOnLayer(this, remove);
6835
- else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer, remove), this);
6759
+ _toggleFocusListeners(add) {
6760
+ if (this.getElement) this._addFocusListenersOnLayer(this, !add);
6761
+ else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer, !add), this);
6836
6762
  },
6837
6763
  _addFocusListenersOnLayer(layer, remove) {
6838
6764
  const el = typeof layer.getElement === "function" && layer.getElement();
@@ -7065,7 +6991,7 @@ var Tooltip = class Tooltip extends DivOverlay {
7065
6991
  };
7066
6992
  }
7067
6993
  _updatePosition() {
7068
- const pos = this._map.latLngToLayerPoint(this._latlng);
6994
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round();
7069
6995
  this._setPosition(pos);
7070
6996
  }
7071
6997
  /**
@@ -7094,8 +7020,7 @@ var Tooltip = class Tooltip extends DivOverlay {
7094
7020
  Layer.include(layerTooltipMethods);
7095
7021
  }
7096
7022
  };
7097
- //#endregion
7098
- //#region src/layer/vector/Renderer.getRenderer.js
7023
+ // src/layer/vector/Renderer.getRenderer.js
7099
7024
  var Renderer_getRenderer_exports = /* @__PURE__ */ __exportAll({ register: () => register });
7100
7025
  /** @import {MaplairMap} from '../../map/Map.js' */
7101
7026
  /** @import {Path} from './Path.js' */
@@ -7111,11 +7036,11 @@ const mapRendererMethods = {
7111
7036
  * are respected, and that the renderers do exist on the map.
7112
7037
  * @internal
7113
7038
  * @param {Path} layer
7114
- * @returns {Renderer}
7039
+ * @returns {Renderer|undefined}
7115
7040
  */
7116
7041
  getRenderer(layer) {
7117
- const renderer = layer.options.renderer ?? this._getPaneRenderer(layer) ?? this.options.renderer ?? (this._renderer ??= layer._createRenderer());
7118
- if (!this.hasLayer(renderer)) this.addLayer(renderer);
7042
+ const renderer = layer.options.renderer ?? this._getPaneRenderer(layer) ?? this.options.renderer ?? (this._renderer ??= layer._createRenderer?.());
7043
+ if (renderer && !this.hasLayer(renderer)) this.addLayer(renderer);
7119
7044
  return renderer;
7120
7045
  },
7121
7046
  _getPaneRenderer(layer) {
@@ -7154,15 +7079,14 @@ function register(MaplairMap) {
7154
7079
  if (this.options.preferCanvas !== void 0) console.error("MaplairMap: preferCanvas option has been removed. Use renderer: new Canvas() instead.");
7155
7080
  });
7156
7081
  }
7157
- //#endregion
7158
- //#region src/core/Handler.js
7082
+ // src/core/Handler.js
7159
7083
  /** @import {MaplairMap} from '../map/Map.js' */
7160
7084
  /**
7161
7085
  * Abstract class for map interaction handlers, the base class of the handlers that
7162
7086
  * are used internally to inject interaction features like dragging to classes like
7163
7087
  * `MaplairMap` and `Marker`.
7164
7088
  *
7165
- * Classes inheriting from `Handler` must implement the two following extension methods:
7089
+ * Classes inheriting from `Handler` implement the two following extension methods:
7166
7090
  *
7167
7091
  * * `addHooks()` is called when the handler is enabled, should add event hooks.
7168
7092
  * * `removeHooks()` is called when the handler is disabled, should remove the event
@@ -7205,6 +7129,14 @@ var Handler = class Handler extends Class {
7205
7129
  return !!this._enabled;
7206
7130
  }
7207
7131
  /**
7132
+ * Called when the handler is enabled, should add event hooks.
7133
+ */
7134
+ addHooks() {}
7135
+ /**
7136
+ * Called when the handler is disabled, should remove the event hooks added previously.
7137
+ */
7138
+ removeHooks() {}
7139
+ /**
7208
7140
  * Adds a new handler of this class to the given map with the given name, which is
7209
7141
  * then available as the property of the map with this name.
7210
7142
  * @template {typeof Handler} T
@@ -7218,8 +7150,7 @@ var Handler = class Handler extends Class {
7218
7150
  return this;
7219
7151
  }
7220
7152
  };
7221
- //#endregion
7222
- //#region src/map/handler/BoxZoomHandler.js
7153
+ // src/map/handler/BoxZoomHandler.js
7223
7154
  /** @import {MaplairMap} from '../Map.js' */
7224
7155
  /** @import {MaplairEvent} from '../../core/Events.js' */
7225
7156
  /**
@@ -7256,23 +7187,19 @@ var BoxZoomHandler = class BoxZoomHandler extends Handler {
7256
7187
  */
7257
7188
  constructor(map) {
7258
7189
  super(map);
7259
- this._container = map._container;
7260
- this._pane = map._panes.overlayPane;
7261
- this._resetStateTimeout = 0;
7262
- map.on("unload", this._destroy, this);
7263
7190
  this.callInitHooks(BoxZoomHandler);
7264
7191
  }
7265
7192
  /**
7266
7193
  * Called when the handler is enabled, adds the event hooks.
7267
7194
  */
7268
7195
  addHooks() {
7269
- on(this._container, "pointerdown", this._onPointerDown, this);
7196
+ on(this._map._container, "pointerdown", this._onPointerDown, this);
7270
7197
  }
7271
7198
  /**
7272
7199
  * Called when the handler is disabled, removes the event hooks.
7273
7200
  */
7274
7201
  removeHooks() {
7275
- off(this._container, "pointerdown", this._onPointerDown, this);
7202
+ off(this._map._container, "pointerdown", this._onPointerDown, this);
7276
7203
  }
7277
7204
  /**
7278
7205
  * Returns `true` if a box has been drawn by the current or last interaction.
@@ -7281,42 +7208,34 @@ var BoxZoomHandler = class BoxZoomHandler extends Handler {
7281
7208
  moved() {
7282
7209
  return this._moved;
7283
7210
  }
7284
- _destroy() {
7285
- this._pane.remove();
7286
- delete this._pane;
7287
- }
7288
7211
  _resetState() {
7289
- this._resetStateTimeout = 0;
7212
+ clearTimeout(this._resetStateTimeout);
7290
7213
  this._moved = false;
7291
7214
  }
7292
- _clearDeferredResetState() {
7293
- if (this._resetStateTimeout !== 0) {
7294
- clearTimeout(this._resetStateTimeout);
7295
- this._resetStateTimeout = 0;
7296
- }
7215
+ _toggleListeners(onOff) {
7216
+ onOff(this._map._container, {
7217
+ contextmenu: stop,
7218
+ pointermove: this._onPointerMove,
7219
+ pointerup: this._onPointerUp
7220
+ }, this);
7221
+ onOff(document, "keydown", this._onKeyDown, this);
7297
7222
  }
7298
7223
  _onPointerDown(e) {
7299
7224
  if (!e.shiftKey || e.button !== 0) return false;
7300
- this._clearDeferredResetState();
7301
7225
  this._resetState();
7302
7226
  preventDefault(e);
7303
7227
  this._startPoint = this._map.pointerEventToContainerPoint(e);
7304
- on(this._container, {
7305
- contextmenu: stop,
7306
- pointermove: this._onPointerMove,
7307
- pointerup: this._onPointerUp,
7308
- keydown: this._onKeyDown
7309
- }, this);
7310
- on(document, "keydown", this._onKeyDown, this);
7228
+ this._toggleListeners(on);
7311
7229
  }
7312
7230
  _onPointerMove(e) {
7231
+ const map = this._map;
7313
7232
  if (!this._moved) {
7314
7233
  this._moved = true;
7315
- this._box = create("div", "maplair-zoom-box", this._container);
7316
- this._container.classList.add("maplair-crosshair");
7317
- this._map.fire("boxzoomstart");
7234
+ this._box = create("div", "maplair-zoom-box", map._container);
7235
+ map._container.classList.add("maplair-crosshair");
7236
+ map.fire("boxzoomstart");
7318
7237
  }
7319
- this._point = this._map.pointerEventToContainerPoint(e);
7238
+ this._point = map.pointerEventToContainerPoint(e);
7320
7239
  const bounds = new Bounds(this._point, this._startPoint), size = bounds.getSize();
7321
7240
  setPosition(this._box, bounds.min);
7322
7241
  this._box.style.width = `${size.x}px`;
@@ -7325,21 +7244,15 @@ var BoxZoomHandler = class BoxZoomHandler extends Handler {
7325
7244
  _finish() {
7326
7245
  if (this._moved) {
7327
7246
  this._box.remove();
7328
- this._container.classList.remove("maplair-crosshair");
7247
+ this._map._container.classList.remove("maplair-crosshair");
7329
7248
  }
7330
- off(this._container, {
7331
- contextmenu: stop,
7332
- pointermove: this._onPointerMove,
7333
- pointerup: this._onPointerUp
7334
- }, this);
7335
- off(document, "keydown", this._onKeyDown, this);
7249
+ this._toggleListeners(off);
7336
7250
  }
7337
7251
  _onPointerUp(e) {
7338
7252
  if (e.button !== 0) return;
7339
7253
  this._finish();
7340
7254
  if (!this._moved) return;
7341
- this._clearDeferredResetState();
7342
- this._resetStateTimeout = setTimeout(this._resetState.bind(this), 0);
7255
+ this._resetStateTimeout = setTimeout(() => this._resetState(), 0);
7343
7256
  const bounds = new LatLngBounds(this._map.containerPointToLatLng(this._startPoint), this._map.containerPointToLatLng(this._point));
7344
7257
  this._map._setUserEvent(e);
7345
7258
  if (this._map.getBoundsZoom(bounds) !== Infinity) this._map.fitBounds(bounds);
@@ -7348,7 +7261,6 @@ var BoxZoomHandler = class BoxZoomHandler extends Handler {
7348
7261
  _onKeyDown(e) {
7349
7262
  if (e.code === "Escape") {
7350
7263
  this._finish();
7351
- this._clearDeferredResetState();
7352
7264
  this._resetState();
7353
7265
  }
7354
7266
  }
@@ -7362,8 +7274,7 @@ var BoxZoomHandler = class BoxZoomHandler extends Handler {
7362
7274
  MaplairMap.addInitHook("addHandler", "boxZoom", BoxZoomHandler);
7363
7275
  }
7364
7276
  };
7365
- //#endregion
7366
- //#region src/map/handler/DoubleClickZoomHandler.js
7277
+ // src/map/handler/DoubleClickZoomHandler.js
7367
7278
  /** @import {MaplairMap} from '../Map.js' */
7368
7279
  /**
7369
7280
  * Map options of `DoubleClickZoomHandler`.
@@ -7429,8 +7340,7 @@ var DoubleClickZoomHandler = class DoubleClickZoomHandler extends Handler {
7429
7340
  MaplairMap.addInitHook("addHandler", "doubleClickZoom", DoubleClickZoomHandler);
7430
7341
  }
7431
7342
  };
7432
- //#endregion
7433
- //#region src/dom/Draggable.js
7343
+ // src/dom/Draggable.js
7434
7344
  /** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */
7435
7345
  /**
7436
7346
  * Options of `Draggable`.
@@ -7503,7 +7413,8 @@ var Draggable = class Draggable extends Evented {
7503
7413
  _onDown(e) {
7504
7414
  this._moved = false;
7505
7415
  if (this._element.classList.contains("maplair-zoom-anim")) return;
7506
- if (getPointers().length !== 1) {
7416
+ const pointers = getPointers().length;
7417
+ if (pointers > 1) {
7507
7418
  if (Draggable._dragging === this) this.finishDrag();
7508
7419
  return;
7509
7420
  }
@@ -7511,6 +7422,7 @@ var Draggable = class Draggable extends Evented {
7511
7422
  Draggable._dragging = this;
7512
7423
  disableImageDrag();
7513
7424
  if (this._moving) return;
7425
+ if (!pointers && e.isTrusted) e.target.setPointerCapture(e.pointerId);
7514
7426
  this.fire("down");
7515
7427
  const sizedParent = getSizedParentNode(this._element);
7516
7428
  this._startPoint = new Point(e.clientX, e.clientY);
@@ -7580,8 +7492,7 @@ var Draggable = class Draggable extends Evented {
7580
7492
  });
7581
7493
  }
7582
7494
  };
7583
- //#endregion
7584
- //#region src/map/handler/DragHandler.js
7495
+ // src/map/handler/DragHandler.js
7585
7496
  /** @import {MaplairMap} from '../Map.js' */
7586
7497
  /** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
7587
7498
  /**
@@ -7768,8 +7679,7 @@ var DragHandler = class DragHandler extends Handler {
7768
7679
  MaplairMap.addInitHook("addHandler", "dragging", DragHandler);
7769
7680
  }
7770
7681
  };
7771
- //#endregion
7772
- //#region src/map/handler/KeyboardHandler.js
7682
+ // src/map/handler/KeyboardHandler.js
7773
7683
  /** @import {MaplairMap} from '../Map.js' */
7774
7684
  /** @import {MaplairEvent} from '../../core/Events.js' */
7775
7685
  /**
@@ -7819,8 +7729,6 @@ var KeyboardHandler = class KeyboardHandler extends Handler {
7819
7729
  */
7820
7730
  constructor(map) {
7821
7731
  super(map);
7822
- this._setPanDelta(map.options.keyboardPanDelta);
7823
- this._setZoomDelta(map.options.zoomDelta);
7824
7732
  this.callInitHooks(KeyboardHandler);
7825
7733
  }
7826
7734
  /**
@@ -7834,27 +7742,21 @@ var KeyboardHandler = class KeyboardHandler extends Handler {
7834
7742
  on(container, {
7835
7743
  focus: this._onFocus,
7836
7744
  blur: this._onBlur,
7837
- pointerdown: this._onPointerDown
7838
- }, this);
7839
- this._map.on({
7840
- focus: this._addHooks,
7841
- blur: this._removeHooks
7745
+ pointerdown: this._onPointerDown,
7746
+ keydown: this._onContainerKeyDown
7842
7747
  }, this);
7843
7748
  }
7844
7749
  /**
7845
7750
  * Called when the handler is disabled, removes the event hooks.
7846
7751
  */
7847
7752
  removeHooks() {
7848
- this._removeHooks();
7753
+ off(document, "keydown", this._onKeyDown, this);
7849
7754
  if (this._map.options.ariaKeyShortcuts) this._map._container.removeAttribute("aria-keyshortcuts");
7850
7755
  off(this._map._container, {
7851
7756
  focus: this._onFocus,
7852
7757
  blur: this._onBlur,
7853
- pointerdown: this._onPointerDown
7854
- }, this);
7855
- this._map.off({
7856
- focus: this._addHooks,
7857
- blur: this._removeHooks
7758
+ pointerdown: this._onPointerDown,
7759
+ keydown: this._onContainerKeyDown
7858
7760
  }, this);
7859
7761
  this._help?.remove();
7860
7762
  this._help = null;
@@ -7900,29 +7802,21 @@ var KeyboardHandler = class KeyboardHandler extends Handler {
7900
7802
  }
7901
7803
  _onFocus() {
7902
7804
  this._focused = true;
7805
+ on(document, "keydown", this._onKeyDown, this);
7903
7806
  this._map.fire("focus");
7904
7807
  }
7905
7808
  _onBlur() {
7906
7809
  this._focused = false;
7810
+ off(document, "keydown", this._onKeyDown, this);
7907
7811
  this._map.fire("blur");
7908
7812
  }
7909
- _setPanDelta(panDelta) {
7910
- const panKeys = this._panKeys = {}, { left, right, down, up } = KeyboardHandler.keys;
7911
- for (const key of left) panKeys[key] = [-panDelta, 0];
7912
- for (const key of right) panKeys[key] = [panDelta, 0];
7913
- for (const key of down) panKeys[key] = [0, panDelta];
7914
- for (const key of up) panKeys[key] = [0, -panDelta];
7915
- }
7916
- _setZoomDelta(zoomDelta) {
7917
- const zoomKeys = this._zoomKeys = {}, { zoomIn, zoomOut } = KeyboardHandler.keys;
7918
- for (const key of zoomIn) zoomKeys[key] = zoomDelta;
7919
- for (const key of zoomOut) zoomKeys[key] = -zoomDelta;
7920
- }
7921
- _addHooks() {
7922
- on(document, "keydown", this._onKeyDown, this);
7923
- }
7924
- _removeHooks() {
7925
- off(document, "keydown", this._onKeyDown, this);
7813
+ _onContainerKeyDown(e) {
7814
+ const map = this._map, popup = map._popup;
7815
+ if (e.key !== "Escape" || e.defaultPrevented || !popup?.options.closeOnEscapeKey || map._controlContainer?.contains(e.target)) return;
7816
+ const inPopup = popup._container.contains(e.target), icon = popup._source?._icon;
7817
+ map.closePopup();
7818
+ e.preventDefault();
7819
+ if (inPopup) (icon?.tabIndex >= 0 ? icon : map._container).focus();
7926
7820
  }
7927
7821
  _onKeyDown(e) {
7928
7822
  if (e.altKey || e.ctrlKey || e.metaKey) return;
@@ -7931,23 +7825,20 @@ var KeyboardHandler = class KeyboardHandler extends Handler {
7931
7825
  stop(e);
7932
7826
  return;
7933
7827
  }
7934
- const key = e.key, map = this._map;
7935
- let offset;
7936
- if (key in this._panKeys) {
7937
- if (!map._panAnim || !map._panAnim._inProgress) {
7938
- offset = this._panKeys[key];
7939
- if (e.shiftKey) offset = Point.from(offset).multiplyBy(3);
7940
- if (map.options.maxBounds) offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
7828
+ const key = e.key, map = this._map, { left, right, down, up, zoomIn, zoomOut } = KeyboardHandler.keys, x = +right.includes(key) - +left.includes(key), y = +down.includes(key) - +up.includes(key), dz = +zoomIn.includes(key) - +zoomOut.includes(key), k = e.shiftKey ? 3 : 1;
7829
+ if (x || y) {
7830
+ if (!map._panAnim?._inProgress) {
7831
+ let offset = new Point(x, y).multiplyBy(k * map.options.keyboardPanDelta);
7832
+ if (map.options.maxBounds) offset = map._limitOffset(offset, map.options.maxBounds);
7941
7833
  map._setUserEvent(e);
7942
7834
  map.panBy(offset);
7943
7835
  }
7944
- } else if (key in this._zoomKeys) {
7836
+ } else if (dz) {
7945
7837
  if (!map._zoomInputBlocked()) {
7946
7838
  map._setUserEvent(e);
7947
- map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
7839
+ map.setZoom(map.getZoom() + k * dz * map.options.zoomDelta);
7948
7840
  }
7949
- } else if (key === "Escape" && map._popup && map._popup.options.closeOnEscapeKey) map.closePopup();
7950
- else return;
7841
+ } else return;
7951
7842
  stop(e);
7952
7843
  }
7953
7844
  /**
@@ -7964,8 +7855,7 @@ var KeyboardHandler = class KeyboardHandler extends Handler {
7964
7855
  MaplairMap.addInitHook("addHandler", "keyboard", KeyboardHandler);
7965
7856
  }
7966
7857
  };
7967
- //#endregion
7968
- //#region src/map/handler/PinchZoomHandler.js
7858
+ // src/map/handler/PinchZoomHandler.js
7969
7859
  /** @import {MaplairMap} from '../Map.js' */
7970
7860
  /**
7971
7861
  * Map options of `PinchZoomHandler`, touch interaction options.
@@ -8100,8 +7990,7 @@ var PinchZoomHandler = class PinchZoomHandler extends Handler {
8100
7990
  });
8101
7991
  }
8102
7992
  };
8103
- //#endregion
8104
- //#region src/map/handler/ScrollWheelZoomHandler.js
7993
+ // src/map/handler/ScrollWheelZoomHandler.js
8105
7994
  /** @import {MaplairMap} from '../Map.js' */
8106
7995
  const pinchPxPerZoomLevel = 100;
8107
7996
  const gestureEndDelay$1 = 150;
@@ -8303,8 +8192,7 @@ var ScrollWheelZoomHandler = class ScrollWheelZoomHandler extends Handler {
8303
8192
  MaplairMap.addInitHook("addHandler", "scrollWheelZoom", ScrollWheelZoomHandler);
8304
8193
  }
8305
8194
  };
8306
- //#endregion
8307
- //#region src/map/handler/TapHoldHandler.js
8195
+ // src/map/handler/TapHoldHandler.js
8308
8196
  /** @import {MaplairMap} from '../Map.js' */
8309
8197
  const tapHoldDelay = 600;
8310
8198
  /**
@@ -8415,8 +8303,7 @@ var TapHoldHandler = class TapHoldHandler extends Handler {
8415
8303
  MaplairMap.addInitHook("addHandler", "tapHold", TapHoldHandler);
8416
8304
  }
8417
8305
  };
8418
- //#endregion
8419
- //#region src/map/handler/TapDragZoomHandler.js
8306
+ // src/map/handler/TapDragZoomHandler.js
8420
8307
  /** @import {MaplairMap} from '../Map.js' */
8421
8308
  const maxTapInterval = 500;
8422
8309
  const maxTapDistance = 30;
@@ -8557,8 +8444,7 @@ var TapDragZoomHandler = class TapDragZoomHandler extends Handler {
8557
8444
  MaplairMap.addInitHook("addHandler", "tapDragZoom", TapDragZoomHandler);
8558
8445
  }
8559
8446
  };
8560
- //#endregion
8561
- //#region src/map/Map.js
8447
+ // src/map/Map.js
8562
8448
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
8563
8449
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
8564
8450
  /** @import {PointExpression} from '../geometry/Point.js' */
@@ -8931,7 +8817,7 @@ var MaplairMap = class MaplairMap extends Evented {
8931
8817
  * @returns {this}
8932
8818
  */
8933
8819
  setZoomAround(latlng, zoom, options) {
8934
- const scale = this.getZoomScale(zoom), viewHalf = this.getSize().divideBy(2), centerOffset = (latlng instanceof Point ? latlng : this.latLngToContainerPoint(latlng)).subtract(viewHalf).multiplyBy(1 - 1 / scale), newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset));
8820
+ const center = this.project(this.getCenter()), offset = latlng instanceof Point ? this.containerPointToLayerPoint(latlng).subtract(this.containerPointToLayerPoint(this.getSize().divideBy(2))) : this.project(latlng).subtract(center), newCenter = this.unproject(center.add(offset.multiplyBy(1 - 1 / this.getZoomScale(zoom))));
8935
8821
  return this.setView(newCenter, zoom, { zoom: options });
8936
8822
  }
8937
8823
  _getBoundsCenterZoom(bounds, options) {
@@ -9053,9 +8939,6 @@ var MaplairMap = class MaplairMap extends Evented {
9053
8939
  return -Math.asinh(t1 / b1);
9054
8940
  }
9055
8941
  const r0 = r(0);
9056
- function w(s) {
9057
- return w0 * (Math.cosh(r0) / Math.cosh(r0 + rho * s));
9058
- }
9059
8942
  function u(s) {
9060
8943
  return w0 * (Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2;
9061
8944
  }
@@ -9067,7 +8950,7 @@ var MaplairMap = class MaplairMap extends Evented {
9067
8950
  const t = (Date.now() - start) / duration, s = easeOut(t) * S;
9068
8951
  if (t <= 1) {
9069
8952
  this._flyToFrame = requestAnimationFrame(frame);
9070
- this._move(this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), this.getScaleZoom(w0 / w(s), startZoom), { flyTo: true });
8953
+ this._move(this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), this.getScaleZoom(Math.cosh(r0 + rho * s) / Math.cosh(r0), startZoom), { flyTo: true });
9071
8954
  } else {
9072
8955
  const zoomChanged = this._zoom !== targetZoom;
9073
8956
  this._move(targetCenter, targetZoom);
@@ -9395,7 +9278,7 @@ var MaplairMap = class MaplairMap extends Evented {
9395
9278
  */
9396
9279
  getCenter() {
9397
9280
  this._checkIfLoaded();
9398
- if (this._lastCenter && !this._moved()) return new LatLng(this._lastCenter);
9281
+ if (this._lastCenter && this._getMapPanePos().equals(this._lastCenterPanePos)) return new LatLng(this._lastCenter);
9399
9282
  return this.layerPointToLatLng(this._getCenterLayerPoint());
9400
9283
  }
9401
9284
  /**
@@ -9599,7 +9482,7 @@ var MaplairMap = class MaplairMap extends Evented {
9599
9482
  * @returns {Point}
9600
9483
  */
9601
9484
  latLngToLayerPoint(latlng) {
9602
- return this.project(LatLng.from(latlng))._round()._subtract(this.getPixelOrigin());
9485
+ return this.project(LatLng.from(latlng))._subtract(this.getPixelOrigin());
9603
9486
  }
9604
9487
  /**
9605
9488
  * Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
@@ -9849,6 +9732,7 @@ var MaplairMap = class MaplairMap extends Evented {
9849
9732
  const zoomChanged = this._zoom !== zoom;
9850
9733
  this._zoom = zoom;
9851
9734
  this._lastCenter = center;
9735
+ this._lastCenterPanePos = this._getMapPanePos();
9852
9736
  this._pixelOrigin = this._getNewPixelOrigin(center);
9853
9737
  if (!suppressEvent) {
9854
9738
  if (zoomChanged || data?.pinch) this.fire("zoom", data);
@@ -9961,10 +9845,10 @@ var MaplairMap = class MaplairMap extends Evented {
9961
9845
  const target = targets[0];
9962
9846
  const data = { originalEvent: e };
9963
9847
  if (e.type !== "keydown" && e.type !== "keyup") {
9964
- const isMarker = target.getLatLng && (!target._pxRadius || target._pxRadius <= 10);
9965
- data.containerPoint = isMarker ? this.latLngToContainerPoint(target.getLatLng()) : this.pointerEventToContainerPoint(e);
9848
+ const latlng = (!target._pxRadius || target._pxRadius <= 10) && target.getLatLng?.();
9849
+ data.containerPoint = latlng ? this.latLngToContainerPoint(latlng) : this.pointerEventToContainerPoint(e);
9966
9850
  data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
9967
- data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint);
9851
+ data.latlng = latlng || this.layerPointToLatLng(data.layerPoint);
9968
9852
  }
9969
9853
  for (const t of targets) {
9970
9854
  t.fire(type, data, true);
@@ -9993,10 +9877,6 @@ var MaplairMap = class MaplairMap extends Evented {
9993
9877
  _getMapPanePos() {
9994
9878
  return getPosition(this._mapPane);
9995
9879
  }
9996
- _moved() {
9997
- const pos = this._getMapPanePos();
9998
- return pos && !pos.equals([0, 0]);
9999
- }
10000
9880
  _getTopLeftPoint(center, zoom) {
10001
9881
  return (center && zoom !== void 0 ? this._getNewPixelOrigin(center, zoom) : this.getPixelOrigin()).subtract(this._getMapPanePos());
10002
9882
  }
@@ -10012,7 +9892,7 @@ var MaplairMap = class MaplairMap extends Evented {
10012
9892
  return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
10013
9893
  }
10014
9894
  _getCenterOffset(latlng) {
10015
- return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint());
9895
+ return this.latLngToLayerPoint(latlng)._round()._subtract(this._getCenterLayerPoint());
10016
9896
  }
10017
9897
  _limitCenter(center, zoom, bounds) {
10018
9898
  if (!bounds) return center;
@@ -10159,8 +10039,7 @@ for (const feature of [
10159
10039
  ZoomControl,
10160
10040
  FullscreenControl
10161
10041
  ]) feature.register(MaplairMap);
10162
- //#endregion
10163
- //#region src/layer/vector/Polyline.js
10042
+ // src/layer/vector/Polyline.js
10164
10043
  /** @import {Feature} from 'geojson' */
10165
10044
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
10166
10045
  /** @import {PointExpression} from '../../geometry/Point.js' */
@@ -10351,7 +10230,7 @@ var Polyline = class Polyline extends Path {
10351
10230
  for (i = 0, k = 0, len = this._rings.length; i < len; i++) {
10352
10231
  points = this._rings[i];
10353
10232
  for (j = 0, len2 = points.length; j < len2 - 1; j++) {
10354
- segment = clipSegment(points[j], points[j + 1], bounds, j, true);
10233
+ segment = clipSegment(points[j], points[j + 1], bounds, j);
10355
10234
  if (!segment) continue;
10356
10235
  parts[k] ??= [];
10357
10236
  parts[k].push(segment[0]);
@@ -10405,8 +10284,7 @@ var Polyline = class Polyline extends Path {
10405
10284
  });
10406
10285
  }
10407
10286
  };
10408
- //#endregion
10409
- //#region src/geometry/PolyUtil.js
10287
+ // src/geometry/PolyUtil.js
10410
10288
  var PolyUtil_exports = /* @__PURE__ */ __exportAll({
10411
10289
  centroid: () => centroid,
10412
10290
  clipPolygon: () => clipPolygon,
@@ -10427,37 +10305,30 @@ var PolyUtil_exports = /* @__PURE__ */ __exportAll({
10427
10305
  * @returns {Point[]}
10428
10306
  */
10429
10307
  function clipPolygon(points, bounds, round) {
10430
- let clippedPoints, i, j, k, a, b, len, edge, p;
10431
- const edges = [
10308
+ for (const edge of [
10432
10309
  1,
10433
10310
  4,
10434
10311
  2,
10435
10312
  8
10436
- ];
10437
- for (i = 0, len = points.length; i < len; i++) points[i]._code = _getBitCode(points[i], bounds);
10438
- for (k = 0; k < 4; k++) {
10439
- edge = edges[k];
10440
- clippedPoints = [];
10441
- for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
10442
- a = points[i];
10443
- b = points[j];
10444
- if (!(a._code & edge)) {
10445
- if (b._code & edge) {
10446
- p = _getEdgeIntersection(b, a, edge, bounds, round);
10447
- p._code = _getBitCode(p, bounds);
10448
- clippedPoints.push(p);
10449
- }
10450
- clippedPoints.push(a);
10451
- } else if (!(b._code & edge)) {
10452
- p = _getEdgeIntersection(b, a, edge, bounds, round);
10453
- p._code = _getBitCode(p, bounds);
10454
- clippedPoints.push(p);
10455
- }
10313
+ ]) {
10314
+ if (!points.length) break;
10315
+ /** @type {Point[]} */
10316
+ const clippedPoints = [];
10317
+ let b = points[points.length - 1], bOut = isOutside(b, edge, bounds);
10318
+ for (const a of points) {
10319
+ const aOut = isOutside(a, edge, bounds);
10320
+ if (aOut !== bOut) clippedPoints.push(_getEdgeIntersection(b, a, edge, bounds, round));
10321
+ if (!aOut) clippedPoints.push(a);
10322
+ b = a;
10323
+ bOut = aOut;
10456
10324
  }
10457
10325
  points = clippedPoints;
10458
10326
  }
10459
10327
  return points;
10460
10328
  }
10329
+ function isOutside(p, edge, bounds) {
10330
+ return edge === 1 ? p.x < bounds.min.x : edge === 2 ? p.x > bounds.max.x : edge === 4 ? p.y < bounds.min.y : p.y > bounds.max.y;
10331
+ }
10461
10332
  /**
10462
10333
  * Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the passed
10463
10334
  * LatLngs (first ring) from a polygon.
@@ -10494,8 +10365,7 @@ function centroid(coords) {
10494
10365
  }
10495
10366
  return new LatLng([latSum / len, lngSum / len]);
10496
10367
  }
10497
- //#endregion
10498
- //#region src/layer/vector/Polygon.js
10368
+ // src/layer/vector/Polygon.js
10499
10369
  /** @import {Feature} from 'geojson' */
10500
10370
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
10501
10371
  /** @import {PolylineOptions} from './Polyline.js' */
@@ -10600,7 +10470,7 @@ var Polygon = class Polygon extends Polyline {
10600
10470
  return;
10601
10471
  }
10602
10472
  for (const ring of this._rings) {
10603
- const clipped = clipPolygon(ring, bounds, true);
10473
+ const clipped = clipPolygon(ring, bounds);
10604
10474
  if (clipped.length) this._parts.push(clipped);
10605
10475
  }
10606
10476
  }
@@ -10637,8 +10507,7 @@ var Polygon = class Polygon extends Polyline {
10637
10507
  });
10638
10508
  }
10639
10509
  };
10640
- //#endregion
10641
- //#region src/control/MiniMapControl.js
10510
+ // src/control/MiniMapControl.js
10642
10511
  /** @import {ControlOptions} from './Control.js' */
10643
10512
  /** @import {MaplairMapOptions} from '../map/Map.js' */
10644
10513
  /** @import {Layer} from '../layer/Layer.js' */
@@ -10808,8 +10677,7 @@ var MiniMapControl = class MiniMapControl extends Control {
10808
10677
  if (!this._miniMap.dragging?.moved()) this._map.panTo(e.latlng);
10809
10678
  }
10810
10679
  };
10811
- //#endregion
10812
- //#region src/control/ScaleControl.js
10680
+ // src/control/ScaleControl.js
10813
10681
  /** @import {ControlOptions} from './Control.js' */
10814
10682
  /** @import {MaplairMap} from '../map/Map.js' */
10815
10683
  /**
@@ -10912,8 +10780,7 @@ var ScaleControl = class ScaleControl extends Control {
10912
10780
  return pow10 * d;
10913
10781
  }
10914
10782
  };
10915
- //#endregion
10916
- //#region src/layer/marker/Icon.js
10783
+ // src/layer/marker/Icon.js
10917
10784
  /** @import {PointExpression} from '../../geometry/Point.js' */
10918
10785
  /**
10919
10786
  * Options of `Icon`.
@@ -11025,6 +10892,7 @@ var Icon = class Icon extends Class {
11025
10892
  img.style.marginLeft = `${-anchor.x}px`;
11026
10893
  img.style.marginTop = `${-anchor.y}px`;
11027
10894
  }
10895
+ img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
11028
10896
  if (size) {
11029
10897
  img.style.width = `${size.x}px`;
11030
10898
  img.style.height = `${size.y}px`;
@@ -11039,14 +10907,25 @@ var Icon = class Icon extends Class {
11039
10907
  return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
11040
10908
  }
11041
10909
  };
11042
- //#endregion
11043
- //#region src/layer/marker/DefaultIcon.js
10910
+ // src/layer/marker/DefaultIcon.js
11044
10911
  /** @import {IconOptions} from './Icon.js' */
11045
10912
  /** @import {PointExpression} from '../../geometry/Point.js' */
11046
10913
  /**
10914
+ * @param {string} fill
10915
+ * @param {string} fillTop
10916
+ * @param {number} fillTopOpacity
10917
+ * @param {string} stroke
10918
+ * @param {string} strokeTop
10919
+ * @param {string} [outline]
10920
+ * @returns {string}
10921
+ */
10922
+ const marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = "") => `data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${fill}"/><stop offset="1" stop-color="${fillTop}" stop-opacity="${fillTopOpacity}"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${stroke}"/><stop offset="1" stop-color="${strokeTop}"/></linearGradient></defs><g fill="%23FFF"><path id="p" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/></g><use href="%23p" fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10"/>${outline}<path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>`;
10923
+ /**
11047
10924
  * Options of `DefaultIcon`.
11048
10925
  * @typedef {object} DefaultIconOptions
11049
10926
  * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
10927
+ * @property {string|null} [color=null] Paints the pin in the given CSS color instead of
10928
+ * the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.
11050
10929
  * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
11051
10930
  * @property {PointExpression|number} [iconSize=[25, 41]]
11052
10931
  * @property {PointExpression} [iconAnchor=[12, 41]]
@@ -11056,9 +10935,9 @@ var Icon = class Icon extends Class {
11056
10935
  * @extends IconOptions
11057
10936
  */
11058
10937
  /**
11059
- * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when
11060
- * no icon is specified. The maple leaf marker and its shadow are inlined as SVG data
11061
- * URIs, so they work with any bundler and need no image files.
10938
+ * A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is
10939
+ * specified, optionally in another `color`. The maple leaf marker and its shadow are
10940
+ * inlined as SVG data URIs, so they work with any bundler and need no image files.
11062
10941
  *
11063
10942
  * In order to customize the default icon, just change the properties of
11064
10943
  * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
@@ -11068,13 +10947,14 @@ var Icon = class Icon extends Class {
11068
10947
  */
11069
10948
  var DefaultIcon = class DefaultIcon extends Icon {
11070
10949
  static defaultOptions = {
11071
- iconUrl: "data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round\" viewBox=\"0 0 500 820\"><defs><linearGradient id=\"a\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 478.727 62.272)scale(37.566)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"%23C2331B\"/><stop offset=\"1\" stop-color=\"%23E2603F\"/></linearGradient><linearGradient id=\"b\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 468.484 54.002)scale(19.053)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"%238F2D20\"/><stop offset=\"1\" stop-color=\"%23B23A27\"/></linearGradient></defs><path fill=\"url(%23a)\" stroke=\"url(%23b)\" stroke-width=\"1.1\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\" d=\"M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z\" transform=\"translate(-7889.1 -9807.44)scale(19.5417)\"/><path fill=\"%23FFF\" d=\"m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z\" transform=\"translate(250 258)scale(.068)\"/></svg>",
10950
+ iconUrl: /* @__PURE__ */ marker("%23C2331B", "%23E2603F", 1, "%238F2D20", "%23B23A27"),
11072
10951
  shadowUrl: "data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" viewBox=\"0 0 817.2 820\"><radialGradient id=\"a\" cx=\"526.6\" cy=\"486.836\" r=\"478.154\" fx=\"275.876\" fy=\"893.983\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" style=\"stop-color:%235c5c5c;stop-opacity:.9477\"/><stop offset=\".112\" style=\"stop-color:%23474747;stop-opacity:.7805\"/><stop offset=\".34\" style=\"stop-color:%23202020;stop-opacity:.4413\"/><stop offset=\".523\" style=\"stop-color:%23090909;stop-opacity:.1692\"/><stop offset=\".637\" style=\"stop-color:%23000;stop-opacity:0\"/></radialGradient><path d=\"M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z\" style=\"fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)\"/></svg>",
11073
10952
  iconSize: [25, 41],
11074
10953
  iconAnchor: [12, 41],
11075
10954
  popupAnchor: [1, -34],
11076
10955
  tooltipAnchor: [16, -28],
11077
- shadowSize: [41, 41]
10956
+ shadowSize: [41, 41],
10957
+ color: null
11078
10958
  };
11079
10959
  /**
11080
10960
  * Creates the default icon, optionally with changed options.
@@ -11084,11 +10964,27 @@ var DefaultIcon = class DefaultIcon extends Icon {
11084
10964
  super(...args);
11085
10965
  this.callInitHooks(DefaultIcon);
11086
10966
  }
10967
+ /**
10968
+ * @param {'icon'|'shadow'} name
10969
+ * @returns {string|undefined}
10970
+ */
10971
+ _getIconUrl(name) {
10972
+ const { color } = this.options;
10973
+ if (!color || name !== "icon") return super._getIconUrl(name);
10974
+ const c = encodeURIComponent(color);
10975
+ return marker(c, c, .75, c, c, "<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>");
10976
+ }
11087
10977
  };
11088
- //#endregion
11089
- //#region src/layer/marker/Marker.Drag.js
10978
+ // src/layer/marker/Marker.Drag.js
11090
10979
  /** @import {Marker, MarkerMoveEvent} from './Marker.js' */
11091
10980
  /** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
10981
+ /** @type {Record<string, [number, number]>} */
10982
+ const arrows = {
10983
+ ArrowLeft: [-1, 0],
10984
+ ArrowRight: [1, 0],
10985
+ ArrowUp: [0, -1],
10986
+ ArrowDown: [0, 1]
10987
+ };
11092
10988
  /**
11093
10989
  * The handler of `Marker` which makes the markers draggable, see the
11094
10990
  * [`dragging`](#marker-dragging) property of markers and its `draggable` option.
@@ -11123,18 +11019,21 @@ var MarkerDrag = class MarkerDrag extends Handler {
11123
11019
  drag: this._onDrag,
11124
11020
  dragend: this._onDragEnd
11125
11021
  }, this).enable();
11022
+ on(icon, "keydown keyup blur", this._onKey, this);
11126
11023
  icon.classList.add("maplair-marker-draggable");
11127
11024
  }
11128
11025
  /**
11129
11026
  * Makes the icon of the marker undraggable, called by `disable()`.
11130
11027
  */
11131
11028
  removeHooks() {
11029
+ this._keyOffset = null;
11132
11030
  this._draggable.off({
11133
11031
  dragstart: this._onDragStart,
11134
11032
  predrag: this._onPreDrag,
11135
11033
  drag: this._onDrag,
11136
11034
  dragend: this._onDragEnd
11137
11035
  }, this).disable();
11036
+ off(this._draggable._element, "keydown keyup blur", this._onKey, this);
11138
11037
  this._marker._icon?.classList.remove("maplair-marker-draggable");
11139
11038
  }
11140
11039
  /**
@@ -11169,8 +11068,8 @@ var MarkerDrag = class MarkerDrag extends Handler {
11169
11068
  }
11170
11069
  }
11171
11070
  _onDrag(e) {
11172
- const marker = this._marker, shadow = marker._shadow, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
11173
- if (shadow) setPosition(shadow, iconPos);
11071
+ const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
11072
+ marker._positionElements(iconPos);
11174
11073
  marker._latlng = latlng;
11175
11074
  e.latlng = latlng;
11176
11075
  e.oldLatLng = this._oldLatLng;
@@ -11181,9 +11080,37 @@ var MarkerDrag = class MarkerDrag extends Handler {
11181
11080
  delete this._oldLatLng;
11182
11081
  this._marker.fire("moveend").fire("dragend", e);
11183
11082
  }
11083
+ /** @param {KeyboardEvent|FocusEvent} e */
11084
+ _onKey(e) {
11085
+ const k = e, dir = arrows[k.key], draggable = this._draggable, { options, _map: map } = this._marker;
11086
+ if (e.type !== "keydown") {
11087
+ if (this._keyOffset) {
11088
+ this._keyOffset = null;
11089
+ draggable.finishDrag();
11090
+ }
11091
+ } else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {
11092
+ e.preventDefault();
11093
+ if (!this._keyOffset) {
11094
+ if (Draggable._dragging) return;
11095
+ Draggable._dragging = draggable;
11096
+ draggable._startPos = getPosition(draggable._element);
11097
+ draggable._moved = draggable._moving = true;
11098
+ this._keyOffset = new Point(0, 0);
11099
+ draggable.fire("dragstart");
11100
+ }
11101
+ const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
11102
+ this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
11103
+ draggable._newPos = draggable._startPos.add(this._keyOffset);
11104
+ setPosition(draggable._element, draggable._newPos);
11105
+ draggable.fire("drag", { originalEvent: k });
11106
+ if (options.autoPan) map.panInside(this._marker._latlng, {
11107
+ padding: options.autoPanPadding,
11108
+ animate: false
11109
+ });
11110
+ }
11111
+ }
11184
11112
  };
11185
- //#endregion
11186
- //#region src/layer/marker/Marker.js
11113
+ // src/layer/marker/Marker.js
11187
11114
  /** @import {Feature} from 'geojson' */
11188
11115
  /** @import {Icon} from './Icon.js' */
11189
11116
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
@@ -11209,6 +11136,10 @@ var MarkerDrag = class MarkerDrag extends Handler {
11209
11136
  * top of all others (or below), specifying a high value like `1000` (or high negative
11210
11137
  * value, respectively).
11211
11138
  * @property {number} [opacity=1] The opacity of the marker.
11139
+ * @property {number|null} [rotation=null] Rotation of the marker icon in degrees,
11140
+ * clockwise, around the icon anchor, e.g. for the heading of a vehicle. A rotated
11141
+ * marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong
11142
+ * under a tilted one. `null` means no rotation.
11212
11143
  * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of
11213
11144
  * others when you hover the pointer over it.
11214
11145
  * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`
@@ -11228,7 +11159,8 @@ var MarkerDrag = class MarkerDrag extends Handler {
11228
11159
  * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is
11229
11160
  * visible within the map's bounds.
11230
11161
  * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or
11231
- * not.
11162
+ * not. A focused draggable marker can also be moved with the arrow keys, by 10 pixels
11163
+ * or 30 with Shift.
11232
11164
  * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker
11233
11165
  * near its edge or not.
11234
11166
  * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the
@@ -11267,6 +11199,7 @@ var Marker = class Marker extends Layer {
11267
11199
  alt: "Marker",
11268
11200
  zIndexOffset: 0,
11269
11201
  opacity: 1,
11202
+ rotation: null,
11270
11203
  riseOnHover: false,
11271
11204
  riseOffset: 250,
11272
11205
  pane: "markerPane",
@@ -11394,7 +11327,7 @@ var Marker = class Marker extends Layer {
11394
11327
  */
11395
11328
  update() {
11396
11329
  if (this._icon && this._map && !this._culled) {
11397
- const pos = this._map.latLngToLayerPoint(this._latlng).round();
11330
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round();
11398
11331
  this._setPos(pos);
11399
11332
  }
11400
11333
  return this;
@@ -11421,7 +11354,7 @@ var Marker = class Marker extends Layer {
11421
11354
  pointerout: this._resetZIndex
11422
11355
  });
11423
11356
  if (this.options.autoPanOnFocus) on(icon, "focus", this._panOnFocus, this);
11424
- const newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;
11357
+ const newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;
11425
11358
  let addShadow = false;
11426
11359
  if (newShadow !== this._shadow) {
11427
11360
  this._removeShadow();
@@ -11467,18 +11400,28 @@ var Marker = class Marker extends Layer {
11467
11400
  this._shadow = null;
11468
11401
  }
11469
11402
  _setPos(pos) {
11470
- if (this._icon) setPosition(this._icon, pos);
11471
- if (this._shadow) setPosition(this._shadow, pos);
11403
+ this._positionElements(pos);
11472
11404
  this._zIndex = pos.y + this.options.zIndexOffset;
11473
11405
  this._resetZIndex();
11474
11406
  }
11407
+ _positionElements(pos) {
11408
+ const rotation = this.options.rotation;
11409
+ if (this._icon) {
11410
+ setPosition(this._icon, pos);
11411
+ if (rotation != null) this._icon.style.transform += ` rotate(${rotation}deg)`;
11412
+ }
11413
+ if (this._shadow) {
11414
+ setPosition(this._shadow, pos);
11415
+ this._shadow.style.display = rotation == null ? "" : "none";
11416
+ }
11417
+ }
11475
11418
  _updateZIndex(offset) {
11476
11419
  const zIndex = String(this._zIndex + offset);
11477
11420
  if (this._icon && this._icon.style.zIndex !== zIndex) this._icon.style.zIndex = zIndex;
11478
11421
  }
11479
11422
  _animateZoom(opt) {
11480
11423
  if (this._culled) return;
11481
- const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
11424
+ const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)._round();
11482
11425
  this._setPos(pos);
11483
11426
  }
11484
11427
  _updateInteractive() {
@@ -11530,6 +11473,27 @@ var Marker = class Marker extends Layer {
11530
11473
  }
11531
11474
  }
11532
11475
  /**
11476
+ * Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.
11477
+ * @returns {number|null}
11478
+ */
11479
+ getRotation() {
11480
+ return this.options.rotation;
11481
+ }
11482
+ /**
11483
+ * Changes the [rotation](#markeroptions-rotation) of the marker; `null` removes it.
11484
+ * @param {number|null} rotation
11485
+ * @returns {this}
11486
+ */
11487
+ setRotation(rotation) {
11488
+ this.options.rotation = rotation;
11489
+ if (this._icon && !this._map._animatingZoom) {
11490
+ this._positionElements(getPosition(this._icon));
11491
+ this._popup?._updatePosition();
11492
+ this._tooltip?._updatePosition();
11493
+ }
11494
+ return this;
11495
+ }
11496
+ /**
11533
11497
  * Changes the opacity of the marker.
11534
11498
  * @param {number} opacity
11535
11499
  * @returns {this}
@@ -11561,19 +11525,23 @@ var Marker = class Marker extends Layer {
11561
11525
  _panOnFocus() {
11562
11526
  const map = this._map;
11563
11527
  if (!map) return;
11564
- const iconOpts = this.options.icon.options;
11565
- const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
11566
- const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
11528
+ const icon = this._icon, style = getComputedStyle(icon), anchor = new Point(-parseFloat(style.marginLeft) || 0, -parseFloat(style.marginTop) || 0), size = new Point(icon.offsetWidth, icon.offsetHeight);
11567
11529
  map.panInside(this._latlng, {
11568
11530
  paddingTopLeft: anchor,
11569
11531
  paddingBottomRight: size.subtract(anchor)
11570
11532
  });
11571
11533
  }
11572
11534
  _getPopupAnchor() {
11573
- return this.options.icon.options.popupAnchor;
11535
+ return this._rotateAnchor(this.options.icon.options.popupAnchor);
11574
11536
  }
11575
11537
  _getTooltipAnchor() {
11576
- return this.options.icon.options.tooltipAnchor;
11538
+ return this._rotateAnchor(this.options.icon.options.tooltipAnchor);
11539
+ }
11540
+ _rotateAnchor(anchor) {
11541
+ const angle = this.options.rotation * Math.PI / 180;
11542
+ if (!angle || !anchor) return anchor;
11543
+ const { x, y } = Point.from(anchor), cos = Math.cos(angle), sin = Math.sin(angle);
11544
+ return new Point(x * cos - y * sin, x * sin + y * cos);
11577
11545
  }
11578
11546
  /**
11579
11547
  * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the
@@ -11587,8 +11555,7 @@ var Marker = class Marker extends Layer {
11587
11555
  return pointToGeoJSON(this, precision);
11588
11556
  }
11589
11557
  };
11590
- //#endregion
11591
- //#region src/control/SearchControl.js
11558
+ // src/control/SearchControl.js
11592
11559
  /** @import {ControlOptions} from './Control.js' */
11593
11560
  /** @import {MaplairMap} from '../map/Map.js' */
11594
11561
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -12100,8 +12067,7 @@ var SearchControl = class SearchControl extends Control {
12100
12067
  else this.collapse();
12101
12068
  }
12102
12069
  };
12103
- //#endregion
12104
- //#region src/control/SideBySideControl.js
12070
+ // src/control/SideBySideControl.js
12105
12071
  /** @import {ControlOptions} from './Control.js' */
12106
12072
  /** @import {MaplairMap} from '../map/Map.js' */
12107
12073
  /** @import {Layer} from '../layer/Layer.js' */
@@ -12299,8 +12265,7 @@ var SideBySideControl = class SideBySideControl extends Control {
12299
12265
  function getElement(layer) {
12300
12266
  return layer.getContainer?.() ?? layer.getElement?.();
12301
12267
  }
12302
- //#endregion
12303
- //#region src/control/TextControl.js
12268
+ // src/control/TextControl.js
12304
12269
  /** @import {ControlOptions} from './Control.js' */
12305
12270
  /**
12306
12271
  * Options of `TextControl`.
@@ -12374,8 +12339,7 @@ var TextControl = class TextControl extends Control {
12374
12339
  container.hidden = !content;
12375
12340
  }
12376
12341
  };
12377
- //#endregion
12378
- //#region src/control/TimeControl.js
12342
+ // src/control/TimeControl.js
12379
12343
  /** @import {ControlOptions} from './Control.js' */
12380
12344
  /** @import {MaplairMap} from '../map/Map.js' */
12381
12345
  /** @import {Layer} from '../layer/Layer.js' */
@@ -12774,8 +12738,7 @@ var TimeControl = class TimeControl extends Control {
12774
12738
  return this;
12775
12739
  }
12776
12740
  };
12777
- //#endregion
12778
- //#region src/geo/projection/Projection.LonLat.js
12741
+ // src/geo/projection/LonLatProjection.js
12779
12742
  /** @import {Projection} from './index.js' */
12780
12743
  /**
12781
12744
  * Equirectangular, or Plate Carree projection — the most simple projection,
@@ -12784,7 +12747,7 @@ var TimeControl = class TimeControl extends Control {
12784
12747
  * `EPSG4326` and `SimpleCRS` CRS.
12785
12748
  * @type {Projection}
12786
12749
  */
12787
- const LonLat = {
12750
+ const LonLatProjection = {
12788
12751
  project(latlng) {
12789
12752
  latlng = LatLng.from(latlng);
12790
12753
  return new Point(latlng.lng, latlng.lat);
@@ -12800,7 +12763,7 @@ const LonLat = {
12800
12763
  * Earth is an ellipsoid. Used by the EPSG:3395 CRS.
12801
12764
  * @type {Projection & {R: number, R_MINOR: number}}
12802
12765
  */
12803
- const Mercator = {
12766
+ const MercatorProjection = {
12804
12767
  R: 6378137,
12805
12768
  R_MINOR: 6356752.314245179,
12806
12769
  bounds: /* @__PURE__ */ new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
@@ -12826,15 +12789,7 @@ const Mercator = {
12826
12789
  return new LatLng(phi * d, point.x * d / r);
12827
12790
  }
12828
12791
  };
12829
- //#endregion
12830
- //#region src/geo/projection/index.js
12831
- var projection_exports = /* @__PURE__ */ __exportAll({
12832
- LonLat: () => LonLat,
12833
- Mercator: () => Mercator,
12834
- SphericalMercator: () => SphericalMercator
12835
- });
12836
- //#endregion
12837
- //#region src/geo/crs/EPSG3395.js
12792
+ // src/geo/crs/EPSG3395.js
12838
12793
  /** @import {Projection} from '../projection/index.js' */
12839
12794
  /**
12840
12795
  * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
@@ -12843,15 +12798,14 @@ var EPSG3395 = class extends EarthCRS {
12843
12798
  /** @type {string} */
12844
12799
  static code = "EPSG:3395";
12845
12800
  /** @type {Projection} */
12846
- static projection = Mercator;
12801
+ static projection = MercatorProjection;
12847
12802
  /** @type {Transformation} */
12848
12803
  static transformation = /* @__PURE__ */ (() => {
12849
- const scale = .5 / (Math.PI * Mercator.R);
12804
+ const scale = .5 / (Math.PI * MercatorProjection.R);
12850
12805
  return new Transformation(scale, .5, -scale, .5);
12851
12806
  })();
12852
12807
  };
12853
- //#endregion
12854
- //#region src/geo/crs/EPSG4326.js
12808
+ // src/geo/crs/EPSG4326.js
12855
12809
  /** @import {Projection} from '../projection/index.js' */
12856
12810
  /**
12857
12811
  * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
@@ -12867,12 +12821,11 @@ var EPSG4326 = class extends EarthCRS {
12867
12821
  /** @type {string} */
12868
12822
  static code = "EPSG:4326";
12869
12823
  /** @type {Projection} */
12870
- static projection = LonLat;
12824
+ static projection = LonLatProjection;
12871
12825
  /** @type {Transformation} */
12872
12826
  static transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, .5);
12873
12827
  };
12874
- //#endregion
12875
- //#region src/geo/crs/SimpleCRS.js
12828
+ // src/geo/crs/SimpleCRS.js
12876
12829
  /** @import {LatLng} from '../LatLng.js' */
12877
12830
  /** @import {Projection} from '../projection/index.js' */
12878
12831
  /**
@@ -12883,7 +12836,7 @@ var EPSG4326 = class extends EarthCRS {
12883
12836
  */
12884
12837
  var SimpleCRS = class extends CRS {
12885
12838
  /** @type {Projection} */
12886
- static projection = LonLat;
12839
+ static projection = LonLatProjection;
12887
12840
  /** @type {Transformation} */
12888
12841
  static transformation = /* @__PURE__ */ new Transformation(1, 0, -1, 0);
12889
12842
  /**
@@ -12915,8 +12868,7 @@ var SimpleCRS = class extends CRS {
12915
12868
  /** @type {boolean} */
12916
12869
  static infinite = true;
12917
12870
  };
12918
- //#endregion
12919
- //#region src/layer/GeoJSON.js
12871
+ // src/layer/GeoJSON.js
12920
12872
  /** @import {Feature, FeatureCollection, GeoJSON as GeoJSONData, GeoJsonObject, Geometry} from 'geojson' */
12921
12873
  /** @import {Layer, InteractiveLayerOptions} from './Layer.js' */
12922
12874
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
@@ -13012,19 +12964,18 @@ var GeoJSON = class GeoJSON extends FeatureGroup {
13012
12964
  * @returns {this}
13013
12965
  */
13014
12966
  addData(geojson) {
13015
- const features = Array.isArray(geojson) ? geojson : geojson.features;
13016
- if (features) {
13017
- for (const feature of features) if (feature.geometries || feature.geometry || feature.features || feature.coordinates) this.addData(feature);
12967
+ if (Array.isArray(geojson) || "features" in geojson) {
12968
+ for (const data of Array.isArray(geojson) ? geojson : geojson.features) this.addData(data);
13018
12969
  return this;
13019
12970
  }
13020
- const options = this.options;
13021
- if (options.filter && !options.filter(geojson)) return this;
13022
- const layer = GeoJSON.geometryToLayer(geojson, options);
12971
+ const options = this.options, feature = GeoJSON.asFeature(geojson);
12972
+ if (!feature.geometry || options.filter && !options.filter(feature)) return this;
12973
+ const layer = GeoJSON.geometryToLayer(feature, options);
13023
12974
  if (!layer) return this;
13024
- layer.feature = GeoJSON.asFeature(geojson);
12975
+ layer.feature = feature;
13025
12976
  layer.defaultOptions = layer.options;
13026
12977
  this.resetStyle(layer);
13027
- if (options.onEachFeature) options.onEachFeature(geojson, layer);
12978
+ if (options.onEachFeature) options.onEachFeature(feature, layer);
13028
12979
  return this.addLayer(layer);
13029
12980
  }
13030
12981
  /**
@@ -13173,8 +13124,7 @@ var GeoJSON = class GeoJSON extends FeatureGroup {
13173
13124
  return asFeature(geojson);
13174
13125
  }
13175
13126
  };
13176
- //#endregion
13177
- //#region src/layer/Classification.js
13127
+ // src/layer/Classification.js
13178
13128
  /** @import {PathOptions} from './vector/Path.js' */
13179
13129
  /**
13180
13130
  * A class of a `Classification`, given by value or by range.
@@ -13442,8 +13392,7 @@ function rangesOf(breaks) {
13442
13392
  return range;
13443
13393
  });
13444
13394
  }
13445
- //#endregion
13446
- //#region src/layer/HeatLayer.js
13395
+ // src/layer/HeatLayer.js
13447
13396
  /** @import {BlanketOverlayOptions} from './BlanketOverlay.js' */
13448
13397
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
13449
13398
  /**
@@ -13599,7 +13548,7 @@ var HeatLayer = class HeatLayer extends BlanketOverlay {
13599
13548
  if (!map || !this._bounds) return;
13600
13549
  const ctx = this._ctx, { width, height } = this._container, offset = this._bounds.min, { radius, blur, max, minOpacity } = this.options, r = radius + blur, maxZoom = this.options.maxZoom ?? map.getMaxZoom(), zoomFactor = 1 / 2 ** Math.max(0, Math.min(maxZoom - map.getZoom(), 12)), cellSize = radius / 2, grid = /* @__PURE__ */ new Map();
13601
13550
  for (const latlng of this._latlngs) {
13602
- const point = map.latLngToLayerPoint(latlng).subtract(offset);
13551
+ const point = map.latLngToLayerPoint(latlng)._round()._subtract(offset);
13603
13552
  if (point.x < -r || point.y < -r || point.x > width + r || point.y > height + r) continue;
13604
13553
  const intensity = (latlng.alt ?? latlng[2] ?? 1) * zoomFactor, key = `${Math.floor(point.x / cellSize)}:${Math.floor(point.y / cellSize)}`, cell = grid.get(key);
13605
13554
  if (cell) {
@@ -13633,8 +13582,7 @@ var HeatLayer = class HeatLayer extends BlanketOverlay {
13633
13582
  ctx.putImageData(image, 0, 0);
13634
13583
  }
13635
13584
  };
13636
- //#endregion
13637
- //#region src/layer/ImageOverlay.js
13585
+ // src/layer/ImageOverlay.js
13638
13586
  /** @import {InteractiveLayerOptions} from './Layer.js' */
13639
13587
  /** @import {LatLng} from '../geo/LatLng.js' */
13640
13588
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
@@ -13857,7 +13805,7 @@ var ImageOverlay = class ImageOverlay extends Layer {
13857
13805
  setTransform(this._image, offset, scale);
13858
13806
  }
13859
13807
  _reset() {
13860
- const image = this._image, bounds = new Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest()), this._map.latLngToLayerPoint(this._bounds.getSouthEast())), size = bounds.getSize();
13808
+ const image = this._image, bounds = new Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest())._round(), this._map.latLngToLayerPoint(this._bounds.getSouthEast())._round()), size = bounds.getSize();
13861
13809
  setPosition(image, bounds.min);
13862
13810
  image.style.width = `${size.x}px`;
13863
13811
  image.style.height = `${size.y}px`;
@@ -13884,8 +13832,7 @@ var ImageOverlay = class ImageOverlay extends Layer {
13884
13832
  return this._bounds.getCenter();
13885
13833
  }
13886
13834
  };
13887
- //#endregion
13888
- //#region src/layer/VideoOverlay.js
13835
+ // src/layer/VideoOverlay.js
13889
13836
  /** @import {ImageOverlayOptions} from './ImageOverlay.js' */
13890
13837
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
13891
13838
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -13977,8 +13924,7 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
13977
13924
  }
13978
13925
  }
13979
13926
  };
13980
- //#endregion
13981
- //#region src/layer/SVGOverlay.js
13927
+ // src/layer/SVGOverlay.js
13982
13928
  /** @import {ImageOverlayOptions} from './ImageOverlay.js' */
13983
13929
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
13984
13930
  /**
@@ -14023,8 +13969,7 @@ var SVGOverlay = class SVGOverlay extends ImageOverlay {
14023
13969
  if (this.options.className) el.classList.add(...splitWords(this.options.className));
14024
13970
  }
14025
13971
  };
14026
- //#endregion
14027
- //#region src/layer/marker/DivIcon.js
13972
+ // src/layer/marker/DivIcon.js
14028
13973
  /** @import {IconOptions} from './Icon.js' */
14029
13974
  /** @import {PointExpression} from '../../geometry/Point.js' */
14030
13975
  /**
@@ -14097,8 +14042,7 @@ var DivIcon = class DivIcon extends Icon {
14097
14042
  return null;
14098
14043
  }
14099
14044
  };
14100
- //#endregion
14101
- //#region src/layer/marker/SvgIcon.js
14045
+ // src/layer/marker/SvgIcon.js
14102
14046
  /** @import {DefaultIconOptions} from './DefaultIcon.js' */
14103
14047
  const svgNS = "http://www.w3.org/2000/svg";
14104
14048
  const markerPath = "M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z";
@@ -14207,8 +14151,7 @@ var SvgIcon = class SvgIcon extends DefaultIcon {
14207
14151
  return div;
14208
14152
  }
14209
14153
  };
14210
- //#endregion
14211
- //#region src/layer/marker/MarkerClusterGroup.js
14154
+ // src/layer/marker/MarkerClusterGroup.js
14212
14155
  /** @import {Layer, LayerOptions} from '../Layer.js' */
14213
14156
  /** @import {MaplairEvent} from '../../core/Events.js' */
14214
14157
  /**
@@ -14498,8 +14441,7 @@ var MarkerClusterGroup = class MarkerClusterGroup extends FeatureGroup {
14498
14441
  if (map && this._shown.has(spider.clusterMarker)) map.addLayer(spider.clusterMarker);
14499
14442
  }
14500
14443
  };
14501
- //#endregion
14502
- //#region src/layer/tile/GridLayer.js
14444
+ // src/layer/tile/GridLayer.js
14503
14445
  /** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
14504
14446
  /** @import {MaplairMap} from '../../map/Map.js' */
14505
14447
  /** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */
@@ -14748,7 +14690,7 @@ var GridLayer = class GridLayer extends Layer {
14748
14690
  * @returns {boolean}
14749
14691
  */
14750
14692
  isLoading() {
14751
- return this._loading;
14693
+ return !!this._loading;
14752
14694
  }
14753
14695
  /**
14754
14696
  * Causes the layer to clear all the tiles and request them again.
@@ -15138,9 +15080,10 @@ var GridLayer = class GridLayer extends Layer {
15138
15080
  coords
15139
15081
  });
15140
15082
  }
15141
- if (this._noTilesToLoad()) {
15083
+ if (this._map && this._noTilesToLoad()) {
15142
15084
  this._loading = false;
15143
15085
  this.fire("load");
15086
+ if (!this._map) return;
15144
15087
  this._map._scheduleIdleCheck();
15145
15088
  if (!this._map._fadeAnimated) requestAnimationFrame(this._pruneTiles.bind(this));
15146
15089
  else this._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);
@@ -15173,9 +15116,7 @@ var GridLayer = class GridLayer extends Layer {
15173
15116
  return Object.values(this._tiles).every((t) => t.loaded);
15174
15117
  }
15175
15118
  };
15176
- //#endregion
15177
- //#region src/layer/tile/TileLayer.js
15178
- /** @import {Point} from '../../geometry/Point.js' */
15119
+ // src/layer/tile/TileLayer.js
15179
15120
  /** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */
15180
15121
  /** @import {TileEvent} from '../../core/Events.js' */
15181
15122
  const osmHosts = ["tile.openstreetmap.org", "tile.osm.org"];
@@ -15308,7 +15249,8 @@ var TileLayer = class TileLayer extends GridLayer {
15308
15249
  Object.assign(this.options, this._nonRetinaOptions);
15309
15250
  this._retina = window.devicePixelRatio > 1;
15310
15251
  if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
15311
- this.options.tileSize = Math.floor(this.options.tileSize / 2);
15252
+ const tileSize = this.options.tileSize;
15253
+ this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
15312
15254
  if (!this.options.zoomReverse) {
15313
15255
  this.options.zoomOffset++;
15314
15256
  this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
@@ -15434,8 +15376,8 @@ var TileLayer = class TileLayer extends GridLayer {
15434
15376
  done(null, tile);
15435
15377
  }
15436
15378
  _tileOnError(done, tile, e) {
15437
- const errorUrl = this.options.errorTileUrl;
15438
- if (errorUrl && tile.getAttribute("src") !== errorUrl) tile.src = errorUrl;
15379
+ const errorUrl = this.options.errorTileUrl, src = tile.getAttribute("src");
15380
+ if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
15439
15381
  done(e, tile);
15440
15382
  }
15441
15383
  _getZoomForUrl() {
@@ -15445,8 +15387,8 @@ var TileLayer = class TileLayer extends GridLayer {
15445
15387
  return zoom + zoomOffset;
15446
15388
  }
15447
15389
  _getSubdomain(tilePoint) {
15448
- const index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
15449
- return this.options.subdomains[index];
15390
+ const { subdomains } = this.options;
15391
+ return subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];
15450
15392
  }
15451
15393
  _abortLoading() {
15452
15394
  let i, tile;
@@ -15479,8 +15421,7 @@ var TileLayer = class TileLayer extends GridLayer {
15479
15421
  return Math.round(super._clampZoom(zoom));
15480
15422
  }
15481
15423
  };
15482
- //#endregion
15483
- //#region src/layer/tile/WMSTileLayer.js
15424
+ // src/layer/tile/WMSTileLayer.js
15484
15425
  /** @import {CRS} from '../../geo/crs/CRS.js' */
15485
15426
  /** @import {Point} from '../../geometry/Point.js' */
15486
15427
  /** @import {MaplairMap} from '../../map/Map.js' */
@@ -15577,8 +15518,9 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
15577
15518
  _updateCrs() {
15578
15519
  this._crs = this.options.crs ?? this._map.options.crs;
15579
15520
  this._wmsVersion = parseFloat(this.wmsParams.version);
15580
- const projectionKey = this._wmsVersion >= 1.3 ? "crs" : "srs";
15581
- this.wmsParams[projectionKey] = this._crs.code;
15521
+ delete this.wmsParams.srs;
15522
+ delete this.wmsParams.crs;
15523
+ this.wmsParams[this._wmsVersion >= 1.3 ? "crs" : "srs"] = this._crs.code;
15582
15524
  }
15583
15525
  /**
15584
15526
  * Returns the map events the layer listens to, see `Layer`.
@@ -15647,6 +15589,7 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
15647
15589
  */
15648
15590
  setParams(params, noRedraw) {
15649
15591
  Object.assign(this.wmsParams, params);
15592
+ if (this._map) this._updateCrs();
15650
15593
  if (!noRedraw) {
15651
15594
  this._keepCurrentTiles();
15652
15595
  this.redraw();
@@ -15654,8 +15597,7 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
15654
15597
  return this;
15655
15598
  }
15656
15599
  };
15657
- //#endregion
15658
- //#region src/layer/vector/Canvas.js
15600
+ // src/layer/vector/Canvas.js
15659
15601
  /** @import {MaplairMap} from '../../map/Map.js' */
15660
15602
  /** @import {EventListener} from '../../core/Events.js' */
15661
15603
  /** @import {RendererOptions} from './Renderer.js' */
@@ -15812,10 +15754,8 @@ var Canvas = class Canvas extends Renderer {
15812
15754
  this._requestRedraw(layer);
15813
15755
  }
15814
15756
  _updateDashArray(layer) {
15815
- if (typeof layer.options.dashArray === "string") {
15816
- const parts = layer.options.dashArray.split(DASH_SEPARATOR_RE$1);
15817
- layer.options._dashArray = parts.map((n) => Number(n)).filter((n) => !isNaN(n));
15818
- } else layer.options._dashArray = layer.options.dashArray;
15757
+ if (typeof layer.options.dashArray === "string") layer._dashArray = layer.options.dashArray.split(DASH_SEPARATOR_RE$1).map((n) => Number(n)).filter((n) => !isNaN(n));
15758
+ else layer._dashArray = layer.options.dashArray;
15819
15759
  }
15820
15760
  _requestRedraw(layer) {
15821
15761
  if (!this._map) return;
@@ -15886,14 +15826,10 @@ var Canvas = class Canvas extends Renderer {
15886
15826
  }
15887
15827
  _updateCircle(layer) {
15888
15828
  if (!this._drawing || layer._empty()) return;
15889
- const p = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), s = (Math.max(Math.round(layer._pxRadiusY), 1) || r) / r;
15890
- if (s !== 1) {
15891
- ctx.save();
15892
- ctx.scale(1, s);
15893
- }
15829
+ const { x, y } = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), ry = Math.max(Math.round(layer._pxRadiusY), 1) || r;
15894
15830
  ctx.beginPath();
15895
- ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);
15896
- if (s !== 1) ctx.restore();
15831
+ if (ry === r) ctx.arc(x, y, r, 0, Math.PI * 2);
15832
+ else ctx.ellipse(x, y, r, ry, 0, 0, Math.PI * 2);
15897
15833
  this._fillStroke(ctx, layer);
15898
15834
  }
15899
15835
  _fillStroke(ctx, layer) {
@@ -15905,7 +15841,7 @@ var Canvas = class Canvas extends Renderer {
15905
15841
  }
15906
15842
  if (options.stroke && options.weight !== 0) {
15907
15843
  ctx.lineDashOffset = Number(options.dashOffset ?? 0);
15908
- ctx.setLineDash(options._dashArray ?? []);
15844
+ ctx.setLineDash(layer._dashArray ?? []);
15909
15845
  ctx.globalAlpha = options.opacity;
15910
15846
  ctx.lineWidth = options.weight;
15911
15847
  ctx.strokeStyle = options.color;
@@ -15995,8 +15931,7 @@ var Canvas = class Canvas extends Renderer {
15995
15931
  this._requestRedraw(layer);
15996
15932
  }
15997
15933
  };
15998
- //#endregion
15999
- //#region src/layer/vector/Circle.js
15934
+ // src/layer/vector/Circle.js
16000
15935
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
16001
15936
  /** @import {CircleMarkerOptions} from './CircleMarker.js' */
16002
15937
  /**
@@ -16030,10 +15965,12 @@ var Circle = class Circle extends CircleMarker {
16030
15965
  this.callInitHooks(Circle);
16031
15966
  }
16032
15967
  /**
16033
- * Returns the `LatLngBounds` of the path.
15968
+ * Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're
15969
+ * approximated on a sphere.
16034
15970
  * @returns {LatLngBounds}
16035
15971
  */
16036
15972
  getBounds() {
15973
+ if (!this._map) return this._latlng.toBounds(this._radius * 2);
16037
15974
  const half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];
16038
15975
  return new LatLngBounds(this._map.layerPointToLatLng(this._point.subtract(half)), this._map.layerPointToLatLng(this._point.add(half)));
16039
15976
  }
@@ -16054,8 +15991,7 @@ var Circle = class Circle extends CircleMarker {
16054
15991
  this._updateBounds();
16055
15992
  }
16056
15993
  };
16057
- //#endregion
16058
- //#region src/layer/vector/Rectangle.js
15994
+ // src/layer/vector/Rectangle.js
16059
15995
  /** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
16060
15996
  /** @import {PolygonOptions} from './Polygon.js' */
16061
15997
  /**
@@ -16102,8 +16038,7 @@ var Rectangle = class Rectangle extends Polygon {
16102
16038
  ];
16103
16039
  }
16104
16040
  };
16105
- //#endregion
16106
- //#region src/map/Hash.js
16041
+ // src/map/Hash.js
16107
16042
  /** @import {MaplairMap} from './Map.js' */
16108
16043
  /** @import {Layer} from '../layer/Layer.js' */
16109
16044
  const leadingHashRe = /^#/;
@@ -16335,8 +16270,7 @@ var Hash = class Hash {
16335
16270
  ].filter(Boolean).join("&")}`;
16336
16271
  }
16337
16272
  };
16338
- //#endregion
16339
- //#region src/map/MapSync.js
16273
+ // src/map/MapSync.js
16340
16274
  /** @import {MaplairMap} from './Map.js' */
16341
16275
  /**
16342
16276
  * Options of `MapSync`.
@@ -16500,8 +16434,7 @@ var MapSync = class {
16500
16434
  }
16501
16435
  }
16502
16436
  };
16503
- //#endregion
16504
- //#region src/map/handler/DisplaceHandler.js
16437
+ // src/map/handler/DisplaceHandler.js
16505
16438
  /** @import {MaplairMap} from '../Map.js' */
16506
16439
  /** @import {Layer} from '../../layer/Layer.js' */
16507
16440
  /** @import {LayerEvent} from '../../core/Events.js' */
@@ -16840,81 +16773,13 @@ function displace(points, minSeparation, { iterations = DisplaceHandler.defaultO
16840
16773
  }
16841
16774
  return points;
16842
16775
  }
16843
- //#endregion
16844
- //#region src/Maplair.js
16776
+ // src/Maplair.js
16845
16777
  /**
16846
16778
  * A constant that represents the Maplair version in use.
16847
16779
  * @type {string}
16848
16780
  */
16849
16781
  const version = version$1;
16850
- //#endregion
16851
- //#region src/layer/marker/Marker.Rotation.js
16852
- const { _setPos: setPos } = Marker.prototype, { _onDrag: onDrag } = MarkerDrag.prototype;
16853
- /**
16854
- * Options of `Marker` for the rotation of marker icons, see the
16855
- * [marker rotation](#marker-setrotationangle).
16856
- * @typedef {object} MarkerRotationOptions
16857
- * @lends MarkerOptions
16858
- * @property {number} [rotationAngle=0] Rotation of the icon in degrees, clockwise, e.g.
16859
- * for the heading of a vehicle. On a rotated map, the angle is relative to the screen,
16860
- * or to north with `rotateWithView`. The shadow is not rotated.
16861
- * @property {string} [rotationOrigin] The CSS
16862
- * [`transform-origin`](https://developer.mozilla.org/docs/Web/CSS/transform-origin) to
16863
- * rotate the icon around, e.g. `'center'`. By default the anchor of the icon.
16864
- * @property {boolean} [rotateWithView=false] On a rotated map (see
16865
- * `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
16866
- * pointing in a geographic direction) instead of staying upright.
16867
- */
16868
- Marker.include({ options: {
16869
- rotationAngle: 0,
16870
- rotationOrigin: void 0,
16871
- rotateWithView: false
16872
- } });
16873
- /** @typedef {typeof markerRotationMethods} MarkerRotationMethods */
16874
- Marker.include({
16875
- /**
16876
- * Changes the [`rotationAngle`](#markeroptions-rotationangle) of the icon.
16877
- * @group Marker rotation
16878
- * @param {number} angle
16879
- * @returns {this}
16880
- */
16881
- setRotationAngle(angle) {
16882
- this.options.rotationAngle = angle;
16883
- return this.update();
16884
- },
16885
- /**
16886
- * Changes the [`rotationOrigin`](#markeroptions-rotationorigin) of the icon.
16887
- * @group Marker rotation
16888
- * @param {string} origin
16889
- * @returns {this}
16890
- */
16891
- setRotationOrigin(origin) {
16892
- this.options.rotationOrigin = origin;
16893
- return this.update();
16894
- },
16895
- _setPos(pos) {
16896
- setPos.call(this, pos);
16897
- this._rotateIcon();
16898
- },
16899
- _rotateIcon() {
16900
- const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing?.() ?? 0;
16901
- this._rotateElement(this._icon, bearing + (this.options.rotationAngle || 0), this.options.rotationOrigin);
16902
- this._rotateElement(this._shadow, bearing);
16903
- },
16904
- _rotateElement(el, angle, origin) {
16905
- if (!el) return;
16906
- if (angle % 360) {
16907
- el.style.transform += ` rotate(${angle}deg)`;
16908
- el.style.transformOrigin = origin ?? `${-parseFloat(el.style.marginLeft) || 0}px ${-parseFloat(el.style.marginTop) || 0}px`;
16909
- } else if (el.style.transformOrigin) el.style.transformOrigin = "";
16910
- }
16911
- });
16912
- MarkerDrag.include({ _onDrag(e) {
16913
- onDrag.call(this, e);
16914
- this._marker._rotateIcon();
16915
- } });
16916
- //#endregion
16917
- //#region src/control/RotateControl.js
16782
+ // src/control/RotateControl.js
16918
16783
  /** @import {ControlOptions} from './Control.js' */
16919
16784
  /** @import {MaplairMap} from '../map/Map.js' */
16920
16785
  const compass = "<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M8 1 11 8H5z\" fill=\"#d22\"/><path d=\"M8 15 5 8h6z\" fill=\"#999\"/></svg>";
@@ -17008,8 +16873,7 @@ var RotateControl = class RotateControl extends Control {
17008
16873
  });
17009
16874
  }
17010
16875
  };
17011
- //#endregion
17012
- //#region src/map/Map.Rotation.js
16876
+ // src/map/Map.Rotation.js
17013
16877
  function normalizeBearing(bearing) {
17014
16878
  return (Number(bearing) % 360 + 360) % 360;
17015
16879
  }
@@ -17018,7 +16882,7 @@ function rotatePoint(point, degrees) {
17018
16882
  return new Point(point.x * cos - point.y * sin, point.x * sin + point.y * cos);
17019
16883
  }
17020
16884
  const rotatedMaps = /* @__PURE__ */ new WeakMap();
17021
- const { panBy } = MaplairMap.prototype, { getEvents: getDivOverlayEvents } = DivOverlay.prototype, { _setPosition: setTooltipPosition } = Tooltip.prototype, { getEvents: getMarkerEvents } = Marker.prototype, { _onDown: onDraggableDown, _updatePosition: updateDraggablePosition } = Draggable.prototype, { _onPointerStart: onPinchStart } = PinchZoomHandler.prototype, { _onDown: onTapDragDown } = TapDragZoomHandler.prototype, { _pinchTo: pinchTo } = ScrollWheelZoomHandler.prototype;
16885
+ const { panBy } = MaplairMap.prototype, { getEvents: getDivOverlayEvents } = DivOverlay.prototype, { _setPosition: setTooltipPosition } = Tooltip.prototype, { getEvents: getMarkerEvents, _positionElements: positionMarkerElements } = Marker.prototype, { _onDown: onDraggableDown, _updatePosition: updateDraggablePosition } = Draggable.prototype, { _onPointerStart: onPinchStart } = PinchZoomHandler.prototype, { _onDown: onTapDragDown } = TapDragZoomHandler.prototype, { _pinchTo: pinchTo } = ScrollWheelZoomHandler.prototype;
17022
16886
  /**
17023
16887
  * Map options of the map rotation (`maplair/map-rotation`).
17024
16888
  * @typedef {object} RotationMapOptions
@@ -17264,7 +17128,7 @@ DivOverlay.include({
17264
17128
  },
17265
17129
  _updatePosition() {
17266
17130
  if (!this._map) return;
17267
- const map = this._map, pos = map.latLngToLayerPoint(this._latlng), anchor = map._rotateToPane(new Point(this._getAnchor()));
17131
+ const map = this._map, pos = map.latLngToLayerPoint(this._latlng)._round(), anchor = map._rotateToPane(new Point(this._getAnchor()));
17268
17132
  let offset = Point.from(this.options.offset);
17269
17133
  const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
17270
17134
  if (!transformed) offset = offset.add(pos).add(anchor);
@@ -17332,19 +17196,36 @@ Tooltip.include({ _setPosition(pos) {
17332
17196
  container.style.top = `${delta.y}px`;
17333
17197
  this._setContainerPosition(pos, `${-delta.x - margin[0]}px ${-delta.y - margin[1]}px`);
17334
17198
  } });
17335
- /** @typedef {typeof markerRotationMethods} MarkerMapRotationMethods */
17336
- Marker.include({
17337
17199
  /**
17338
- * Overrides `getEvents()` of `Marker` to update the marker on rotation.
17339
- * @internal
17340
- * @returns {Record<string, Function>}
17200
+ * Options of `Marker` for the map rotation.
17201
+ * @typedef {object} MarkerMapRotationOptions
17202
+ * @lends MarkerOptions
17203
+ * @property {boolean} [rotateWithView=false] On a rotated map (see
17204
+ * `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
17205
+ * pointing in a geographic direction) instead of staying upright. The `rotation` of
17206
+ * the marker is relative to the screen, or to north with `rotateWithView`.
17341
17207
  */
17342
- getEvents() {
17343
- return {
17344
- ...getMarkerEvents.call(this),
17345
- rotate: this.update
17346
- };
17347
- } });
17208
+ Marker.include({ options: { rotateWithView: false } });
17209
+ /** @typedef {typeof markerRotationMethods} MarkerMapRotationMethods */
17210
+ Marker.include({
17211
+ /**
17212
+ * Overrides `getEvents()` of `Marker` to update the marker on rotation.
17213
+ * @internal
17214
+ * @returns {Record<string, Function>}
17215
+ */
17216
+ getEvents() {
17217
+ return {
17218
+ ...getMarkerEvents.call(this),
17219
+ rotate: this.update
17220
+ };
17221
+ },
17222
+ _positionElements(pos) {
17223
+ positionMarkerElements.call(this, pos);
17224
+ const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing() ?? 0;
17225
+ if (!bearing) return;
17226
+ for (const el of [this._icon, this._shadow]) if (el) el.style.transform += ` rotate(${bearing}deg)`;
17227
+ }
17228
+ });
17348
17229
  /** @typedef {typeof markerDragRotationMethods} MarkerDragMapRotationMethods */
17349
17230
  MarkerDrag.include({ _adjustPan(e) {
17350
17231
  const marker = this._marker, map = marker._map, speed = this._marker.options.autoPanSpeed, padding = this._marker.options.autoPanPadding, iconPos = getPosition(marker._icon), bounds = map.getPixelBounds(), origin = map.getPixelOrigin();
@@ -17489,8 +17370,7 @@ ScrollWheelZoomHandler.include({
17489
17370
  this._panTimer = setTimeout(this._endPan.bind(this), gestureEndDelay);
17490
17371
  }
17491
17372
  });
17492
- //#endregion
17493
- //#region src/layer/marker/Marker.Move.js
17373
+ // src/layer/marker/Marker.Move.js
17494
17374
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
17495
17375
  /** @import {MaplairMap} from '../../map/Map.js' */
17496
17376
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -17500,9 +17380,8 @@ ScrollWheelZoomHandler.include({
17500
17380
  * @property {number} [duration=1000] The duration of the movement in milliseconds.
17501
17381
  * @property {number} [speed] The speed in meters (or units of the CRS) per second
17502
17382
  * instead of the `duration`.
17503
- * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to
17504
- * the heading of the movement (for icons pointing up; needs the marker rotation, see
17505
- * `rotationAngle`).
17383
+ * @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to
17384
+ * the heading of the movement (for icons pointing up).
17506
17385
  */
17507
17386
  const { onRemove } = Marker.prototype;
17508
17387
  /** @typedef {typeof markerMoveMethods} MarkerMoveMethods */
@@ -17541,7 +17420,7 @@ Marker.include({
17541
17420
  i++;
17542
17421
  }
17543
17422
  const from = points[i], to = points[i + 1];
17544
- if (options.rotate && !from.equals(to)) this.options.rotationAngle = this._heading(from, to);
17423
+ if (options.rotate && !from.equals(to)) this.options.rotation = this._heading(from, to);
17545
17424
  this.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));
17546
17425
  if (moved < total) this._moveFrame = requestAnimationFrame(frame);
17547
17426
  else {
@@ -17590,8 +17469,7 @@ Marker.include({
17590
17469
  return onRemove.call(this, map);
17591
17470
  }
17592
17471
  });
17593
- //#endregion
17594
- //#region src/layer/vector/Path.DashAnimation.js
17472
+ // src/layer/vector/Path.DashAnimation.js
17595
17473
  const DASH_SEPARATOR_RE = /[ ,]+/;
17596
17474
  const { _updateStyle: updateSvgStyle$1 } = SVG.prototype, { _fillStroke: fillStroke, _destroyContainer: destroyCanvasContainer } = Canvas.prototype;
17597
17475
  /**
@@ -17661,8 +17539,7 @@ Canvas.include({
17661
17539
  return performance.now() / 1e3 * speed % length;
17662
17540
  }
17663
17541
  });
17664
- //#endregion
17665
- //#region src/layer/vector/Polyline.Decorations.js
17542
+ // src/layer/vector/Polyline.Decorations.js
17666
17543
  /**
17667
17544
  * Options of `Path` for arrowheads and text along lines (for `Polyline`s and
17668
17545
  * `Polygon`s). They are an optional feature: import this module to add the
@@ -17897,8 +17774,7 @@ Canvas.include({
17897
17774
  }
17898
17775
  }
17899
17776
  });
17900
- //#endregion
17901
- //#region src/layer/GeoJSON.Load.js
17777
+ // src/layer/GeoJSON.Load.js
17902
17778
  /** @import {GeoJsonObject} from 'geojson' */
17903
17779
  /** @import {MaplairEvent} from '../core/Events.js' */
17904
17780
  /**
@@ -17955,8 +17831,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
17955
17831
  GeoJSON.addInitHook(function() {
17956
17832
  if (this.options.url) this.load(this.options.url).catch(() => {});
17957
17833
  });
17958
- //#endregion
17959
- //#region src/layer/vector/Path.ZoomStyles.js
17834
+ // src/layer/vector/Path.ZoomStyles.js
17960
17835
  /**
17961
17836
  * A zoom-dependent style value, of the `weight` option of paths and the `radius` of
17962
17837
  * circle markers: either a function of the zoom or an object of zoom stops
@@ -18028,7 +17903,6 @@ CircleMarker.include({ setRadius(radius) {
18028
17903
  Path.addInitHook(function() {
18029
17904
  this._takeZoomStyles(this.options);
18030
17905
  });
18031
- //#endregion
18032
- export { AttributionControl, BlanketOverlay, Bounds, BoxZoomHandler, ButtonBarControl, ButtonControl, CRS, Canvas, Circle, CircleMarker, Class, Classification, ContextMenu, Control, DefaultIcon, DisplaceHandler, DivIcon, DivOverlay, DomEvent_exports as DomEvent, DomUtil_exports as DomUtil, DoubleClickZoomHandler, DragHandler, Draggable, EPSG3395, EPSG3857, EPSG4326, EPSG900913, EarthCRS, Evented, FeatureGroup, FullscreenControl, GeoJSON, GridLayer, Handler, Hash, HeatLayer, I18n, Icon, ImageOverlay, KeyboardHandler, LatLng, LatLngBounds, Layer, LayerGroup, LayersControl, MaplairMap as LeafletMap, MaplairMap as Map, MaplairMap, LegendControl, LineUtil_exports as LineUtil, MapSync, Marker, MarkerClusterGroup, MiniMapControl, Path, PinchZoomHandler, Point, PolyUtil_exports as PolyUtil, Polygon, Polyline, Popup, projection_exports as Projection, Rectangle, Renderer, RotateControl, SVG, SVGOverlay, ScaleControl, ScrollWheelZoomHandler, SearchControl, SideBySideControl, SimpleCRS, SvgIcon, TapDragZoomHandler, TapHoldHandler, TextControl, TileLayer, TimeControl, Tooltip, Transformation, Util_exports as Util, VideoOverlay, WMSTileLayer, ZoomControl, displace, version };
17906
+ export { AttributionControl, BlanketOverlay, Bounds, BoxZoomHandler, ButtonBarControl, ButtonControl, CRS, Canvas, Circle, CircleMarker, Class, Classification, ContextMenu, Control, DefaultIcon, DisplaceHandler, DivIcon, DivOverlay, DomEvent_exports as DomEvent, DomUtil_exports as DomUtil, DoubleClickZoomHandler, DragHandler, Draggable, EPSG3395, EPSG3857, EPSG4326, EPSG900913, EarthCRS, Evented, FeatureGroup, FullscreenControl, GeoJSON, GridLayer, Handler, Hash, HeatLayer, I18n, Icon, ImageOverlay, KeyboardHandler, LatLng, LatLngBounds, Layer, LayerGroup, LayersControl, MaplairMap as LeafletMap, MaplairMap as Map, MaplairMap, LegendControl, LineUtil_exports as LineUtil, LonLatProjection, MapSync, Marker, MarkerClusterGroup, MercatorProjection, MiniMapControl, Path, PinchZoomHandler, Point, PolyUtil_exports as PolyUtil, Polygon, Polyline, Popup, Rectangle, Renderer, RotateControl, SVG, SVGOverlay, ScaleControl, ScrollWheelZoomHandler, SearchControl, SideBySideControl, SimpleCRS, SphericalMercatorProjection, SvgIcon, TapDragZoomHandler, TapHoldHandler, TextControl, TileLayer, TimeControl, Tooltip, Transformation, Util_exports as Util, VideoOverlay, WMSTileLayer, ZoomControl, displace, version };
18033
17907
 
18034
17908
  //# sourceMappingURL=maplair-src.js.map