maplair 4.1.0 → 4.3.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 (213) hide show
  1. package/CHANGELOG.md +77 -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 +2 -2
  25. package/dist/esm/core/Events.js.map +1 -1
  26. package/dist/esm/core/Handler.js +10 -3
  27. package/dist/esm/core/Handler.js.map +1 -1
  28. package/dist/esm/core/I18n.js +1 -2
  29. package/dist/esm/core/Util.js +2 -3
  30. package/dist/esm/core/Util.js.map +1 -1
  31. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  32. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  33. package/dist/esm/dom/DomEvent.js +10 -18
  34. package/dist/esm/dom/DomEvent.js.map +1 -1
  35. package/dist/esm/dom/DomUtil.js +1 -2
  36. package/dist/esm/dom/Draggable.js +4 -3
  37. package/dist/esm/dom/Draggable.js.map +1 -1
  38. package/dist/esm/dom/PosAnimation.js +1 -2
  39. package/dist/esm/geo/LatLng.js +1 -2
  40. package/dist/esm/geo/LatLngBounds.js +9 -15
  41. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  42. package/dist/esm/geo/crs/CRS.js +1 -2
  43. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  44. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  45. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  46. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  47. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  48. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  49. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  50. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  51. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  52. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  53. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  54. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  55. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  56. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  57. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  58. package/dist/esm/geometry/Bounds.js +10 -14
  59. package/dist/esm/geometry/Bounds.js.map +1 -1
  60. package/dist/esm/geometry/LineUtil.js +2 -3
  61. package/dist/esm/geometry/LineUtil.js.map +1 -1
  62. package/dist/esm/geometry/Point.js +1 -2
  63. package/dist/esm/geometry/PolyUtil.js +17 -25
  64. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  65. package/dist/esm/geometry/Transformation.js +1 -2
  66. package/dist/esm/layer/BlanketOverlay.js +1 -2
  67. package/dist/esm/layer/Classification.js +1 -2
  68. package/dist/esm/layer/DivOverlay.js +2 -3
  69. package/dist/esm/layer/DivOverlay.js.map +1 -1
  70. package/dist/esm/layer/FeatureGroup.js +5 -4
  71. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  72. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  73. package/dist/esm/layer/GeoJSON.js +8 -10
  74. package/dist/esm/layer/GeoJSON.js.map +1 -1
  75. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  76. package/dist/esm/layer/HeatLayer.js +2 -3
  77. package/dist/esm/layer/HeatLayer.js.map +1 -1
  78. package/dist/esm/layer/ImageOverlay.js +2 -3
  79. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  80. package/dist/esm/layer/Layer.js +1 -2
  81. package/dist/esm/layer/LayerGroup.js +2 -3
  82. package/dist/esm/layer/LayerGroup.js.map +1 -1
  83. package/dist/esm/layer/Popup.js +9 -16
  84. package/dist/esm/layer/Popup.js.map +1 -1
  85. package/dist/esm/layer/SVGOverlay.js +1 -2
  86. package/dist/esm/layer/Tooltip.js +16 -17
  87. package/dist/esm/layer/Tooltip.js.map +1 -1
  88. package/dist/esm/layer/VideoOverlay.js +1 -2
  89. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  90. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  91. package/dist/esm/layer/marker/DivIcon.js +1 -2
  92. package/dist/esm/layer/marker/Icon.js +2 -2
  93. package/dist/esm/layer/marker/Icon.js.map +1 -1
  94. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  95. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  96. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  97. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  98. package/dist/esm/layer/marker/Marker.js +54 -14
  99. package/dist/esm/layer/marker/Marker.js.map +1 -1
  100. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  101. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  102. package/dist/esm/layer/tile/GridLayer.js +4 -4
  103. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  104. package/dist/esm/layer/tile/TileLayer.js +8 -8
  105. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  106. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  107. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  108. package/dist/esm/layer/vector/Canvas.js +7 -14
  109. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  110. package/dist/esm/layer/vector/Circle.js +5 -3
  111. package/dist/esm/layer/vector/Circle.js.map +1 -1
  112. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  113. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  114. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  115. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  116. package/dist/esm/layer/vector/Path.js +1 -2
  117. package/dist/esm/layer/vector/Polygon.js +2 -3
  118. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  119. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  120. package/dist/esm/layer/vector/Polyline.js +2 -3
  121. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  122. package/dist/esm/layer/vector/Rectangle.js +1 -2
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  124. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  125. package/dist/esm/layer/vector/Renderer.js +1 -2
  126. package/dist/esm/layer/vector/SVG.js +7 -4
  127. package/dist/esm/layer/vector/SVG.js.map +1 -1
  128. package/dist/esm/map/Hash.js +1 -2
  129. package/dist/esm/map/Map.Rotation.js +31 -16
  130. package/dist/esm/map/Map.Rotation.js.map +1 -1
  131. package/dist/esm/map/Map.js +10 -17
  132. package/dist/esm/map/Map.js.map +1 -1
  133. package/dist/esm/map/MapSync.js +1 -2
  134. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  135. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  136. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  137. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  138. package/dist/esm/map/handler/DragHandler.js +1 -2
  139. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  140. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  141. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  144. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  145. package/dist/esm/package.js +2 -3
  146. package/dist/maplair-global-src.js +489 -613
  147. package/dist/maplair-global-src.js.map +1 -1
  148. package/dist/maplair-global.js +2 -2
  149. package/dist/maplair-global.js.map +1 -1
  150. package/dist/maplair-src.js +485 -609
  151. package/dist/maplair-src.js.map +1 -1
  152. package/dist/maplair.css +1 -1263
  153. package/dist/maplair.js +2 -2
  154. package/dist/maplair.js.map +1 -1
  155. package/package.json +4 -8
  156. package/src/Maplair.all.js +0 -1
  157. package/src/control/LayersControl.js +39 -52
  158. package/src/control/ZoomControl.js +17 -31
  159. package/src/core/Class.js +5 -14
  160. package/src/core/Events.js +2 -0
  161. package/src/core/Handler.js +11 -1
  162. package/src/core/Util.js +1 -1
  163. package/src/dom/DomEvent.js +9 -19
  164. package/src/dom/Draggable.js +5 -1
  165. package/src/geo/LatLngBounds.js +8 -15
  166. package/src/geo/crs/EPSG3395.js +3 -3
  167. package/src/geo/crs/EPSG3857.js +3 -3
  168. package/src/geo/crs/EPSG4326.js +2 -2
  169. package/src/geo/crs/SimpleCRS.js +2 -2
  170. package/src/geo/index.js +1 -2
  171. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  172. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  173. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  174. package/src/geo/projection/index.js +5 -5
  175. package/src/geometry/Bounds.js +12 -17
  176. package/src/geometry/LineUtil.js +1 -1
  177. package/src/geometry/PolyUtil.js +23 -31
  178. package/src/layer/DivOverlay.js +1 -1
  179. package/src/layer/FeatureGroup.js +8 -2
  180. package/src/layer/GeoJSON.js +10 -13
  181. package/src/layer/HeatLayer.js +1 -1
  182. package/src/layer/ImageOverlay.js +2 -2
  183. package/src/layer/LayerGroup.js +1 -1
  184. package/src/layer/Popup.js +9 -19
  185. package/src/layer/Tooltip.js +19 -17
  186. package/src/layer/marker/DefaultIcon.js +33 -5
  187. package/src/layer/marker/Icon.js +2 -0
  188. package/src/layer/marker/Marker.Drag.js +53 -5
  189. package/src/layer/marker/Marker.Move.js +3 -4
  190. package/src/layer/marker/Marker.js +64 -13
  191. package/src/layer/tile/GridLayer.js +5 -2
  192. package/src/layer/tile/TileLayer.js +9 -6
  193. package/src/layer/tile/WMSTileLayer.js +5 -2
  194. package/src/layer/vector/Canvas.js +10 -14
  195. package/src/layer/vector/Circle.js +7 -1
  196. package/src/layer/vector/CircleMarker.js +2 -1
  197. package/src/layer/vector/Polygon.js +1 -1
  198. package/src/layer/vector/Polyline.js +1 -1
  199. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  200. package/src/layer/vector/SVG.js +12 -2
  201. package/src/map/Map.Rotation.js +28 -4
  202. package/src/map/Map.js +17 -21
  203. package/src/map/handler/BoxZoomHandler.js +21 -42
  204. package/src/map/handler/KeyboardHandler.js +34 -53
  205. package/src/maplair.css +5 -0
  206. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  207. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  208. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  209. package/dist/esm/geo/projection/index.js +0 -14
  210. package/dist/esm/geo/projection/index.js.map +0 -1
  211. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  212. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  213. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -1,12 +1,12 @@
1
1
  /* @preserve
2
- * Maplair 4.1.0, a JS library for interactive maps. https://maplair.org
2
+ * Maplair 4.3.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
  (function (previousL) {
6
6
  (function(global, factory) {
7
7
  typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define([], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.L = factory());
8
8
  })(this, function() {
9
- //#region \0rolldown/runtime.js
9
+ // \0rolldown/runtime.js
10
10
  var __defProp = Object.defineProperty;
11
11
  var __exportAll = (all, no_symbols) => {
12
12
  let target = {};
@@ -17,11 +17,9 @@
17
17
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
18
  return target;
19
19
  };
20
- //#endregion
21
- //#region package.json
22
- var version$1 = "4.1.0";
23
- //#endregion
24
- //#region src/core/Util.js
20
+ // package.json
21
+ var version$1 = "4.3.0";
22
+ // src/core/Util.js
25
23
  var Util_exports = /* @__PURE__ */ __exportAll({
26
24
  falseFn: () => falseFn,
27
25
  formatNum: () => formatNum,
@@ -79,7 +77,7 @@
79
77
  }
80
78
  /**
81
79
  * Returns the number `x` modulo `range` in such a way so it lies within
82
- * `range[0]` and `range[1]`. The returned value will be always smaller than
80
+ * `range[0]` and `range[1]`. The returned value will always be smaller than
83
81
  * `range[1]` unless `includeMax` is set to `true`.
84
82
  * @param {number} x
85
83
  * @param {[number, number]} range
@@ -161,8 +159,7 @@
161
159
  return value;
162
160
  });
163
161
  }
164
- //#endregion
165
- //#region src/core/Class.js
162
+ // src/core/Class.js
166
163
  /**
167
164
  * Class powers the OOP facilities of Maplair and is used to create almost all of the
168
165
  * Maplair classes documented here.
@@ -320,15 +317,9 @@
320
317
  * @returns {T}
321
318
  */
322
319
  static include(props) {
323
- for (const k of getAllMethodNames(props)) if (k !== "constructor" && k !== "options") this.prototype[k] = props[k];
320
+ 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];
324
321
  if (props.options) this.mergeOptions(props.options);
325
322
  return this;
326
- function* getAllMethodNames(obj) {
327
- do {
328
- if (obj === Object || obj === Object.prototype) break;
329
- for (const k of Object.getOwnPropertyNames(obj)) yield k;
330
- } while ((obj = Object.getPrototypeOf(obj)) !== null);
331
- }
332
323
  }
333
324
  /**
334
325
  * [Merges `options`](#class-options) into the `defaultOptions` of the class.
@@ -393,8 +384,7 @@
393
384
  return this;
394
385
  }
395
386
  };
396
- //#endregion
397
- //#region src/geometry/Point.js
387
+ // src/geometry/Point.js
398
388
  /**
399
389
  * A point in pixels: a `Point`, an array of the form `[x, y]`, or a plain object of
400
390
  * the form `{x, y}`. Accepted by all Maplair methods and options which accept `Point`
@@ -647,8 +637,7 @@
647
637
  return `Point(${formatNum(this.x)}, ${formatNum(this.y)})`;
648
638
  }
649
639
  };
650
- //#endregion
651
- //#region src/dom/DomEvent.DoubleTap.js
640
+ // src/dom/DomEvent.DoubleTap.js
652
641
  function makeDblclick(ev) {
653
642
  const init = {
654
643
  bubbles: ev.bubbles,
@@ -735,8 +724,7 @@
735
724
  obj.removeEventListener("pointerdown", handlers.onPointerDown, true);
736
725
  obj.removeEventListener("click", handlers.simDblclick);
737
726
  }
738
- //#endregion
739
- //#region src/dom/DomEvent.PointerEvents.js
727
+ // src/dom/DomEvent.PointerEvents.js
740
728
  var DomEvent_PointerEvents_exports = /* @__PURE__ */ __exportAll({
741
729
  disablePointerDetection: () => disablePointerDetection,
742
730
  enablePointerDetection: () => enablePointerDetection,
@@ -787,8 +775,7 @@
787
775
  function getPointers() {
788
776
  return [...activePointers.values()];
789
777
  }
790
- //#endregion
791
- //#region src/dom/DomEvent.js
778
+ // src/dom/DomEvent.js
792
779
  var DomEvent_exports = /* @__PURE__ */ __exportAll({
793
780
  PointerEvents: () => DomEvent_PointerEvents_exports,
794
781
  disableClickPropagation: () => disableClickPropagation,
@@ -814,12 +801,11 @@
814
801
  * @param {string|Record<string, (ev: any) => void>} types
815
802
  * @param {((ev: any) => void)|object} [fn]
816
803
  * @param {object} [context]
817
- * @returns {typeof import('./DomEvent.js')}
804
+ * @returns {void}
818
805
  */
819
806
  function on(obj, types, fn, context) {
820
807
  if (types && typeof types === "object") for (const [type, listener] of Object.entries(types)) addOne(obj, type, listener, fn);
821
808
  else for (const type of splitWords(types)) addOne(obj, type, fn, context);
822
- return this;
823
809
  }
824
810
  const eventsKey = "_maplair_events";
825
811
  /**
@@ -833,7 +819,7 @@
833
819
  * @param {string|Record<string, (ev: any) => void>} [types]
834
820
  * @param {((ev: any) => void)|object} [fn]
835
821
  * @param {object} [context]
836
- * @returns {typeof import('./DomEvent.js')}
822
+ * @returns {void}
837
823
  */
838
824
  function off(obj, types, fn, context) {
839
825
  if (arguments.length === 1) {
@@ -845,7 +831,6 @@
845
831
  if (arguments.length === 2) batchRemove(obj, (type) => types.includes(type));
846
832
  else for (const type of types) removeOne(obj, type, fn, context);
847
833
  }
848
- return this;
849
834
  }
850
835
  const DIGIT_RE = /\d/;
851
836
  function batchRemove(obj, filterFn) {
@@ -856,7 +841,7 @@
856
841
  }
857
842
  function addOne(obj, type, fn, context) {
858
843
  const id = type + stamp(fn) + (context ? `_${stamp(context)}` : "");
859
- if (obj[eventsKey] && obj[eventsKey][id]) return this;
844
+ if (obj[eventsKey] && obj[eventsKey][id]) return;
860
845
  let handler = function(e) {
861
846
  return fn.call(context || obj, e);
862
847
  };
@@ -868,7 +853,7 @@
868
853
  function removeOne(obj, type, fn, context, id) {
869
854
  id ??= type + stamp(fn) + (context ? `_${stamp(context)}` : "");
870
855
  const handler = obj[eventsKey] && obj[eventsKey][id];
871
- if (!handler) return this;
856
+ if (!handler) return;
872
857
  if (type === "dblclick") removeDoubleTapListener(obj, handler);
873
858
  else obj.removeEventListener(type, handler, false);
874
859
  obj[eventsKey][id] = null;
@@ -881,22 +866,20 @@
881
866
  * ```
882
867
  * Also accepts a Maplair event with an `originalEvent`.
883
868
  * @param {Event|{originalEvent: Event}} e
884
- * @returns {typeof import('./DomEvent.js')}
869
+ * @returns {void}
885
870
  */
886
871
  function stopPropagation(e) {
887
872
  if (e.stopPropagation) e.stopPropagation();
888
873
  else if (e.originalEvent) e.originalEvent._stopped = true;
889
874
  else console.debug("Unsupported event", e);
890
- return this;
891
875
  }
892
876
  /**
893
877
  * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).
894
878
  * @param {HTMLElement} el
895
- * @returns {typeof import('./DomEvent.js')}
879
+ * @returns {void}
896
880
  */
897
881
  function disableScrollPropagation(el) {
898
882
  addOne(el, "wheel", stopPropagation);
899
- return this;
900
883
  }
901
884
  /**
902
885
  * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`
@@ -904,12 +887,11 @@
904
887
  * For `'click'` events, prevents the map from handling the click
905
888
  * while still allowing the native DOM click event to propagate normally.
906
889
  * @param {HTMLElement} el
907
- * @returns {typeof import('./DomEvent.js')}
890
+ * @returns {void}
908
891
  */
909
892
  function disableClickPropagation(el) {
910
893
  on(el, "pointerdown dblclick contextmenu", stopPropagation);
911
894
  el["_maplair_disable_click"] = true;
912
- return this;
913
895
  }
914
896
  /**
915
897
  * Prevents the default action of the DOM Event `e` from happening (such as
@@ -917,21 +899,19 @@
917
899
  * with page reload when a `<form>` is submitted).
918
900
  * Use it inside listener functions.
919
901
  * @param {Event} e
920
- * @returns {typeof import('./DomEvent.js')}
902
+ * @returns {void}
921
903
  */
922
904
  function preventDefault(e) {
923
905
  e.preventDefault?.();
924
- return this;
925
906
  }
926
907
  /**
927
908
  * Does `stopPropagation` and `preventDefault` at the same time.
928
909
  * @param {Event} e
929
- * @returns {typeof import('./DomEvent.js')}
910
+ * @returns {void}
930
911
  */
931
912
  function stop(e) {
932
913
  preventDefault(e);
933
914
  stopPropagation(e);
934
- return this;
935
915
  }
936
916
  /**
937
917
  * Gets normalized pointer position from a DOM event relative to the
@@ -974,8 +954,7 @@
974
954
  function isExternalTarget(el, e) {
975
955
  return !el.contains(e.relatedTarget);
976
956
  }
977
- //#endregion
978
- //#region src/dom/DomUtil.js
957
+ // src/dom/DomUtil.js
979
958
  var DomUtil_exports = /* @__PURE__ */ __exportAll({
980
959
  create: () => create,
981
960
  disableImageDrag: () => disableImageDrag,
@@ -1115,8 +1094,7 @@
1115
1094
  boundingClientRect: rect
1116
1095
  };
1117
1096
  }
1118
- //#endregion
1119
- //#region src/control/Control.js
1097
+ // src/control/Control.js
1120
1098
  /** @import {MaplairMap} from '../map/Map.js' */
1121
1099
  /**
1122
1100
  * Options of `Control`, inherited by all controls.
@@ -1271,8 +1249,7 @@
1271
1249
  MaplairMap.include(mapControlMethods);
1272
1250
  }
1273
1251
  };
1274
- //#endregion
1275
- //#region src/core/I18n.js
1252
+ // src/core/I18n.js
1276
1253
  /**
1277
1254
  * Utility functions to deal with translations.
1278
1255
  *
@@ -1341,8 +1318,7 @@
1341
1318
  }
1342
1319
  }
1343
1320
  };
1344
- //#endregion
1345
- //#region src/control/AttributionControl.js
1321
+ // src/control/AttributionControl.js
1346
1322
  /** @import {ControlOptions} from './Control.js' */
1347
1323
  /** @import {MaplairMap} from '../map/Map.js' */
1348
1324
  const mapleLeaf = "<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">&#x1F341;</span>";
@@ -1495,8 +1471,7 @@
1495
1471
  });
1496
1472
  }
1497
1473
  };
1498
- //#endregion
1499
- //#region src/control/ButtonControl.js
1474
+ // src/control/ButtonControl.js
1500
1475
  /** @import {ControlOptions} from './Control.js' */
1501
1476
  /** @import {MaplairMap} from '../map/Map.js' */
1502
1477
  /**
@@ -1708,8 +1683,7 @@
1708
1683
  return this._buttons;
1709
1684
  }
1710
1685
  };
1711
- //#endregion
1712
- //#region src/core/Events.js
1686
+ // src/core/Events.js
1713
1687
  const warnedEvents = /* @__PURE__ */ new Set();
1714
1688
  /** @import {LatLng} from '../geo/LatLng.js' */
1715
1689
  /** @import {LatLngBounds} from '../geo/LatLngBounds.js' */
@@ -2091,13 +2065,13 @@
2091
2065
  }
2092
2066
  _propagateEvent(e) {
2093
2067
  for (const p of Object.values(this._eventParents ?? {})) p.fire(e.type, {
2068
+ layer: e.target,
2094
2069
  propagatedFrom: e.target,
2095
2070
  ...e
2096
2071
  }, true);
2097
2072
  }
2098
2073
  };
2099
- //#endregion
2100
- //#region src/layer/Layer.js
2074
+ // src/layer/Layer.js
2101
2075
  /** @import {MaplairMap} from '../map/Map.js' */
2102
2076
  /** @import {LayerGroup} from './LayerGroup.js' */
2103
2077
  /** @import {EventListener, MaplairEvent, MaplairPointerEvent, LayerEvent} from '../core/Events.js' */
@@ -2418,8 +2392,7 @@
2418
2392
  MaplairMap.include(mapLayerMethods);
2419
2393
  }
2420
2394
  };
2421
- //#endregion
2422
- //#region src/control/ContextMenu.js
2395
+ // src/control/ContextMenu.js
2423
2396
  /** @import {MaplairMap} from '../map/Map.js' */
2424
2397
  /** @import {LatLng} from '../geo/LatLng.js' */
2425
2398
  /** @import {Point} from '../geometry/Point.js' */
@@ -2581,8 +2554,7 @@
2581
2554
  buttons.at(next % buttons.length)?.focus();
2582
2555
  }
2583
2556
  };
2584
- //#endregion
2585
- //#region src/control/FullscreenControl.js
2557
+ // src/control/FullscreenControl.js
2586
2558
  /** @import {ControlOptions} from './Control.js' */
2587
2559
  /** @import {MaplairMap} from '../map/Map.js' */
2588
2560
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -2758,8 +2730,7 @@
2758
2730
  });
2759
2731
  }
2760
2732
  };
2761
- //#endregion
2762
- //#region src/control/LayersControl.js
2733
+ // src/control/LayersControl.js
2763
2734
  /** @import {ControlOptions} from './Control.js' */
2764
2735
  /** @import {MaplairMap} from '../map/Map.js' */
2765
2736
  /** @import {Layer} from '../layer/Layer.js' */
@@ -2938,6 +2909,7 @@
2938
2909
  this._map.off("zoomend", this._checkDisabledLayers, this);
2939
2910
  for (const layer of this._layers) layer.layer.off("add remove", this._onLayerChange, this);
2940
2911
  this._map.off("resize", this._expandIfNotCollapsed, this);
2912
+ this._map.off("click", this.collapse, this);
2941
2913
  }
2942
2914
  /**
2943
2915
  * Adds a base layer (radio button entry) with the given name to the control.
@@ -2966,8 +2938,7 @@
2966
2938
  */
2967
2939
  removeLayer(layer) {
2968
2940
  layer.off("add remove", this._onLayerChange, this);
2969
- const obj = this._getLayer(stamp(layer));
2970
- if (obj) this._layers.splice(this._layers.indexOf(obj), 1);
2941
+ this._layers = this._layers.filter((o) => o.layer !== layer);
2971
2942
  return this._map ? this._update() : this;
2972
2943
  }
2973
2944
  /**
@@ -2991,7 +2962,7 @@
2991
2962
  * @returns {this}
2992
2963
  */
2993
2964
  selectLayer(layer) {
2994
- const input = this._layerControlInputs.find((input) => input.layerId === stamp(layer));
2965
+ const input = this._layerControlInputs.find((input) => input._layer === layer);
2995
2966
  if (input && !input.checked) {
2996
2967
  input.checked = true;
2997
2968
  this._onInputClick();
@@ -3016,21 +2987,14 @@
3016
2987
  }
3017
2988
  /**
3018
2989
  * Collapse the control container if expanded.
3019
- * @param {Event} [ev] The event causing the collapse, if any (collapsing is skipped
3020
- * for `pointerleave` and `pointerout` of touch).
3021
2990
  * @returns {this}
3022
2991
  */
3023
- collapse(ev) {
2992
+ collapse() {
3024
2993
  if (this.options.inline) return this;
3025
- if (!ev || !((ev.type === "pointerleave" || ev.type === "pointerout") && ev.pointerType === "touch")) {
3026
- if (this.options.collapseDelay > 0) {
3027
- this._collapseDelayTimeout = setTimeout(() => {
3028
- this._container.classList.remove("maplair-control-layers-expanded");
3029
- }, this.options.collapseDelay);
3030
- return this;
3031
- }
2994
+ if (this.options.collapseDelay > 0) this._collapseDelayTimeout = setTimeout(() => {
3032
2995
  this._container.classList.remove("maplair-control-layers-expanded");
3033
- }
2996
+ }, this.options.collapseDelay);
2997
+ else this._container.classList.remove("maplair-control-layers-expanded");
3034
2998
  return this;
3035
2999
  }
3036
3000
  _initLayout() {
@@ -3044,7 +3008,9 @@
3044
3008
  this._map.on("click", this.collapse, this);
3045
3009
  on(container, {
3046
3010
  pointerenter: this._expandSafely,
3047
- pointerleave: this.collapse
3011
+ pointerleave(e) {
3012
+ if (e.pointerType !== "touch") this.collapse();
3013
+ }
3048
3014
  }, this);
3049
3015
  }
3050
3016
  if (!this.options.inline) {
@@ -3071,9 +3037,6 @@
3071
3037
  this._overlaysList = create("div", `${className}-overlays`, section);
3072
3038
  container.appendChild(section);
3073
3039
  }
3074
- _getLayer(id) {
3075
- for (const layer of this._layers) if (layer && stamp(layer.layer) === id) return layer;
3076
- }
3077
3040
  _addLayer(layer, name, overlay) {
3078
3041
  if (this._map) layer.on("add remove", this._onLayerChange, this);
3079
3042
  this._layers.push({
@@ -3110,7 +3073,7 @@
3110
3073
  }
3111
3074
  _onLayerChange(e) {
3112
3075
  if (!this._handlingClick) this._update();
3113
- const obj = this._getLayer(stamp(e.target));
3076
+ const obj = this._layers.find((o) => o.layer === e.target);
3114
3077
  const type = obj.overlay ? e.type === "add" ? "overlayadd" : "overlayremove" : e.type === "add" ? "baselayerchange" : null;
3115
3078
  if (type) this._map.fire(type, this._clickEvent ? {
3116
3079
  ...obj,
@@ -3125,7 +3088,7 @@
3125
3088
  input.defaultChecked = checked;
3126
3089
  if (!obj.overlay) input.name = `maplair-base-layers_${stamp(this)}`;
3127
3090
  this._layerControlInputs.push(input);
3128
- input.layerId = stamp(obj.layer);
3091
+ input._layer = obj.layer;
3129
3092
  on(input, "click", this._onInputClick, this);
3130
3093
  const group = this.options.groupBy?.(obj.name, obj.layer, obj.overlay);
3131
3094
  const name = document.createElement("span");
@@ -3159,24 +3122,29 @@
3159
3122
  }
3160
3123
  _onInputClick(e) {
3161
3124
  if (this._preventClick) return;
3162
- const inputs = this._layerControlInputs, addedLayers = [], removedLayers = [];
3125
+ const checked = /* @__PURE__ */ new Map();
3126
+ for (const input of this._layerControlInputs) {
3127
+ const layer = input._layer;
3128
+ checked.set(layer, checked.get(layer) || input.checked);
3129
+ }
3130
+ const addedLayers = [], removedLayers = [];
3131
+ for (const [layer, on] of checked) if (on !== this._map.hasLayer(layer)) (on ? addedLayers : removedLayers).push(layer);
3163
3132
  this._handlingClick = true;
3164
3133
  this._clickEvent = e;
3165
- for (const input of inputs) {
3166
- const layer = this._getLayer(input.layerId).layer;
3167
- if (input.checked) addedLayers.push(layer);
3168
- else if (!input.checked) removedLayers.push(layer);
3169
- }
3170
- for (const layer of removedLayers) if (this._map.hasLayer(layer)) this._map.removeLayer(layer);
3171
- for (const layer of addedLayers) if (!this._map.hasLayer(layer)) this._map.addLayer(layer);
3134
+ for (const layer of removedLayers) this._map.removeLayer(layer);
3135
+ for (const layer of addedLayers) this._map.addLayer(layer);
3172
3136
  this._handlingClick = false;
3173
3137
  this._clickEvent = void 0;
3138
+ for (const [layer, on] of checked) if (on !== this._map.hasLayer(layer)) {
3139
+ this._update();
3140
+ break;
3141
+ }
3174
3142
  this._refocusOnMap(e);
3175
3143
  }
3176
3144
  _checkDisabledLayers() {
3177
3145
  const inputs = this._layerControlInputs, zoom = this._map.getZoom();
3178
3146
  for (const input of inputs) {
3179
- const layer = this._getLayer(input.layerId).layer;
3147
+ const layer = input._layer;
3180
3148
  input.disabled = layer.options.minZoom !== void 0 && zoom < layer.options.minZoom || layer.options.maxZoom !== void 0 && zoom > layer.options.maxZoom;
3181
3149
  }
3182
3150
  }
@@ -3198,8 +3166,7 @@
3198
3166
  });
3199
3167
  }
3200
3168
  };
3201
- //#endregion
3202
- //#region src/geometry/Bounds.js
3169
+ // src/geometry/Bounds.js
3203
3170
  /** @import {PointExpression} from './Point.js' */
3204
3171
  /**
3205
3172
  * A rectangular area in pixel coordinates: a `Bounds`, or an array of points (usually
@@ -3276,14 +3243,12 @@
3276
3243
  extend(obj) {
3277
3244
  let min2, max2;
3278
3245
  if (!obj) return this;
3279
- if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 = Point.from(obj);
3246
+ if (isPointExpression(obj)) min2 = max2 = Point.from(obj);
3280
3247
  else {
3281
- obj = Bounds.from(obj);
3282
- min2 = obj.min;
3283
- max2 = obj.max;
3284
- if (!min2 || !max2) return this;
3248
+ ({min: min2, max: max2} = Bounds.from(obj));
3249
+ if (!min2) return this;
3285
3250
  }
3286
- if (!this.min && !this.max) {
3251
+ if (!this.min) {
3287
3252
  this.min = new Point(min2);
3288
3253
  this.max = new Point(max2);
3289
3254
  } else {
@@ -3344,12 +3309,8 @@
3344
3309
  */
3345
3310
  contains(obj) {
3346
3311
  let min, max;
3347
- if (typeof obj[0] === "number" || obj instanceof Point) obj = Point.from(obj);
3348
- else obj = Bounds.from(obj);
3349
- if (obj instanceof Bounds) {
3350
- min = obj.min;
3351
- max = obj.max;
3352
- } else min = max = obj;
3312
+ if (isPointExpression(obj)) min = max = Point.from(obj);
3313
+ else ({min, max} = Bounds.from(obj));
3353
3314
  return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
3354
3315
  }
3355
3316
  /**
@@ -3403,8 +3364,10 @@
3403
3364
  return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
3404
3365
  }
3405
3366
  };
3406
- //#endregion
3407
- //#region src/layer/BlanketOverlay.js
3367
+ function isPointExpression(obj) {
3368
+ return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] === "number" : "x" in obj);
3369
+ }
3370
+ // src/layer/BlanketOverlay.js
3408
3371
  /** @import {LayerOptions} from './Layer.js' */
3409
3372
  /** @import {MaplairMap} from '../map/Map.js' */
3410
3373
  /** @import {EventListener} from '../core/Events.js' */
@@ -3533,8 +3496,7 @@
3533
3496
  _onViewReset() {}
3534
3497
  _onSettled() {}
3535
3498
  };
3536
- //#endregion
3537
- //#region src/layer/vector/Renderer.js
3499
+ // src/layer/vector/Renderer.js
3538
3500
  /** @import {BlanketOverlayOptions} from '../BlanketOverlay.js' */
3539
3501
  /** @import {MaplairEvent} from '../../core/Events.js' */
3540
3502
  /** @import {MaplairMap} from '../../map/Map.js' */
@@ -3603,8 +3565,7 @@
3603
3565
  }
3604
3566
  _update() {}
3605
3567
  };
3606
- //#endregion
3607
- //#region src/layer/vector/SVG.js
3568
+ // src/layer/vector/SVG.js
3608
3569
  /** @import {Point} from '../../geometry/Point.js' */
3609
3570
  /** @import {RendererOptions} from './Renderer.js' */
3610
3571
  /**
@@ -3728,7 +3689,7 @@
3728
3689
  }
3729
3690
  _updateCircle(layer) {
3730
3691
  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 `;
3731
- const d = layer._empty() ? "M0 0" : `M${p.x - r},${p.y}${arc}${r * 2},0 ${arc}${-r * 2},0 `;
3692
+ const d = layer._empty() ? "M0 0" : `M${num(p.x - r)},${num(p.y)}${arc}${r * 2},0 ${arc}${-r * 2},0 `;
3732
3693
  this._setPath(layer, d);
3733
3694
  }
3734
3695
  _setPath(layer, path) {
@@ -3758,11 +3719,14 @@
3758
3719
  * @returns {string}
3759
3720
  */
3760
3721
  static pointsToPath(rings, closed) {
3761
- return rings.flatMap((points) => [...points.map((p, j) => `${(j ? "L" : "M") + p.x} ${p.y}`), closed ? "z" : ""]).join("") || "M0 0";
3722
+ return rings.flatMap((points) => [...points.map((p, j) => `${(j ? "L" : "M") + num(p.x)} ${num(p.y)}`), closed ? "z" : ""]).join("") || "M0 0";
3762
3723
  }
3763
3724
  };
3764
- //#endregion
3765
- //#region src/layer/vector/Path.js
3725
+ function num(v) {
3726
+ const n = Math.round(v * 10), a = n < 0 ? -n : n, i = Math.floor(a / 10), d = a - i * 10;
3727
+ return (n < 0 ? "-" : "") + (d ? `${i}.${d}` : i);
3728
+ }
3729
+ // src/layer/vector/Path.js
3766
3730
  /** @import {InteractiveLayerOptions} from '../Layer.js' */
3767
3731
  /** @import {MaplairMap} from '../../map/Map.js' */
3768
3732
  /** @import {Renderer} from './Renderer.js' */
@@ -3904,8 +3868,7 @@
3904
3868
  return (this.options.stroke ? this.options.weight / 2 : 0) + (this._renderer.options.tolerance || 0);
3905
3869
  }
3906
3870
  };
3907
- //#endregion
3908
- //#region src/geo/LatLngBounds.js
3871
+ // src/geo/LatLngBounds.js
3909
3872
  /** @import {LatLngExpression} from './LatLng.js' */
3910
3873
  /**
3911
3874
  * A geographical area: a `LatLngBounds`, or an array of geographical points (usually
@@ -3985,19 +3948,14 @@
3985
3948
  extend(obj) {
3986
3949
  const sw = this._southWest, ne = this._northEast;
3987
3950
  let sw2, ne2;
3988
- if (obj instanceof LatLng) {
3989
- sw2 = obj;
3990
- ne2 = obj;
3991
- } else if (obj instanceof LatLngBounds) {
3992
- sw2 = obj._southWest;
3993
- ne2 = obj._northEast;
3994
- if (!sw2 || !ne2) return this;
3995
- } else {
3996
- if (!obj) return this;
3997
- if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
3998
- return this.extend(LatLngBounds.from(obj));
3999
- }
4000
- if (!sw && !ne) {
3951
+ if (obj instanceof LatLng) sw2 = ne2 = obj;
3952
+ else if (obj instanceof LatLngBounds) {
3953
+ ({_southWest: sw2, _northEast: ne2} = obj);
3954
+ if (!sw2) return this;
3955
+ } else if (!obj) return this;
3956
+ else if (LatLng.validate(obj)) sw2 = ne2 = LatLng.from(obj);
3957
+ else return this.extend(LatLngBounds.from(obj));
3958
+ if (!sw) {
4001
3959
  this._southWest = new LatLng(sw2.lat, sw2.lng);
4002
3960
  this._northEast = new LatLng(ne2.lat, ne2.lng);
4003
3961
  } else {
@@ -4155,8 +4113,7 @@
4155
4113
  return !!(this._southWest && this._northEast);
4156
4114
  }
4157
4115
  };
4158
- //#endregion
4159
- //#region src/geo/LatLng.js
4116
+ // src/geo/LatLng.js
4160
4117
  const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
4161
4118
  const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
4162
4119
  const plainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`);
@@ -4376,8 +4333,7 @@
4376
4333
  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;
4377
4334
  return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
4378
4335
  }
4379
- //#endregion
4380
- //#region src/geometry/LineUtil.js
4336
+ // src/geometry/LineUtil.js
4381
4337
  var LineUtil_exports = /* @__PURE__ */ __exportAll({
4382
4338
  _getBitCode: () => _getBitCode,
4383
4339
  _getEdgeIntersection: () => _getEdgeIntersection,
@@ -4596,12 +4552,11 @@
4596
4552
  if (!latlngs || latlngs.length === 0) throw new Error("latlngs not passed");
4597
4553
  if (!isFlat(latlngs)) {
4598
4554
  console.warn("latlngs are not flat! Only the first ring will be used");
4599
- latlngs = latlngs[0];
4555
+ return _projectRing(latlngs[0], crs);
4600
4556
  }
4601
4557
  return latlngs.map((latlng) => crs.project(LatLng.from(latlng)));
4602
4558
  }
4603
- //#endregion
4604
- //#region src/layer/GeoJSONUtil.js
4559
+ // src/layer/GeoJSONUtil.js
4605
4560
  /** @import {Feature, FeatureCollection, GeoJsonObject, Geometry} from 'geojson' */
4606
4561
  /** @import {Layer} from './Layer.js' */
4607
4562
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
@@ -4669,8 +4624,7 @@
4669
4624
  coordinates: latLngToCoords(layer.getLatLng(), precision)
4670
4625
  });
4671
4626
  }
4672
- //#endregion
4673
- //#region src/layer/vector/CircleMarker.js
4627
+ // src/layer/vector/CircleMarker.js
4674
4628
  /** @import {Feature} from 'geojson' */
4675
4629
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
4676
4630
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -4762,7 +4716,7 @@
4762
4716
  return this;
4763
4717
  }
4764
4718
  _project() {
4765
- this._point = this._map.latLngToLayerPoint(this._latlng);
4719
+ this._point = this._map.latLngToLayerPoint(this._latlng)._round();
4766
4720
  this._pxRadius = this._radius;
4767
4721
  this._updateBounds();
4768
4722
  }
@@ -4793,8 +4747,7 @@
4793
4747
  return pointToGeoJSON(this, precision);
4794
4748
  }
4795
4749
  };
4796
- //#endregion
4797
- //#region src/control/LegendControl.js
4750
+ // src/control/LegendControl.js
4798
4751
  /** @import {ControlOptions} from './Control.js' */
4799
4752
  /** @import {MaplairMap} from '../map/Map.js' */
4800
4753
  /** @import {FeatureGroup} from '../layer/FeatureGroup.js' */
@@ -5013,8 +4966,7 @@
5013
4966
  for (const [key, value] of Object.entries(attributes)) el.setAttribute(key, value);
5014
4967
  return el;
5015
4968
  }
5016
- //#endregion
5017
- //#region src/geo/crs/CRS.js
4969
+ // src/geo/crs/CRS.js
5018
4970
  /** @import {LatLngExpression} from '../LatLng.js' */
5019
4971
  /** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */
5020
4972
  /** @import {Point} from '../../geometry/Point.js' */
@@ -5158,8 +5110,7 @@
5158
5110
  return new LatLngBounds(new LatLng(sw.lat - latShift, sw.lng - lngShift), new LatLng(ne.lat - latShift, ne.lng - lngShift));
5159
5111
  }
5160
5112
  };
5161
- //#endregion
5162
- //#region src/geo/crs/EarthCRS.js
5113
+ // src/geo/crs/EarthCRS.js
5163
5114
  /** @import {LatLng} from '../LatLng.js' */
5164
5115
  /**
5165
5116
  * Serves as the base for CRS that are global such that they cover the earth.
@@ -5191,8 +5142,7 @@
5191
5142
  return haversineDistance(latlng1, latlng2, this.R);
5192
5143
  }
5193
5144
  };
5194
- //#endregion
5195
- //#region src/geo/projection/Projection.SphericalMercator.js
5145
+ // src/geo/projection/SphericalMercatorProjection.js
5196
5146
  /** @import {Projection} from './index.js' */
5197
5147
  const earthRadius$1 = 6378137;
5198
5148
  /**
@@ -5201,7 +5151,7 @@
5201
5151
  * a sphere. Used by the `EPSG:3857` CRS.
5202
5152
  * @type {Projection & {R: number, MAX_LATITUDE: number}}
5203
5153
  */
5204
- const SphericalMercator = {
5154
+ const SphericalMercatorProjection = {
5205
5155
  R: earthRadius$1,
5206
5156
  MAX_LATITUDE: 85.0511287798,
5207
5157
  project(latlng) {
@@ -5219,8 +5169,7 @@
5219
5169
  return new Bounds([-d, -d], [d, d]);
5220
5170
  })()
5221
5171
  };
5222
- //#endregion
5223
- //#region src/geometry/Transformation.js
5172
+ // src/geometry/Transformation.js
5224
5173
  /**
5225
5174
  * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`
5226
5175
  * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing
@@ -5284,8 +5233,7 @@
5284
5233
  return new Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c);
5285
5234
  }
5286
5235
  };
5287
- //#endregion
5288
- //#region src/geo/crs/EPSG3857.js
5236
+ // src/geo/crs/EPSG3857.js
5289
5237
  /** @import {Projection} from '../projection/index.js' */
5290
5238
  /**
5291
5239
  * The most common CRS for online maps, used by almost all free and commercial
@@ -5296,10 +5244,10 @@
5296
5244
  /** @type {string} */
5297
5245
  static code = "EPSG:3857";
5298
5246
  /** @type {Projection} */
5299
- static projection = SphericalMercator;
5247
+ static projection = SphericalMercatorProjection;
5300
5248
  /** @type {Transformation} */
5301
5249
  static transformation = /* @__PURE__ */ (() => {
5302
- const scale = .5 / (Math.PI * SphericalMercator.R);
5250
+ const scale = .5 / (Math.PI * SphericalMercatorProjection.R);
5303
5251
  return new Transformation(scale, .5, -scale, .5);
5304
5252
  })();
5305
5253
  };
@@ -5310,8 +5258,7 @@
5310
5258
  /** @type {string} */
5311
5259
  static code = "EPSG:900913";
5312
5260
  };
5313
- //#endregion
5314
- //#region src/dom/PosAnimation.js
5261
+ // src/dom/PosAnimation.js
5315
5262
  /** @import {Point} from '../geometry/Point.js' */
5316
5263
  /** @import {MaplairEvent} from '../core/Events.js' */
5317
5264
  /**
@@ -5387,8 +5334,7 @@
5387
5334
  return 1 - (1 - t) ** this._easeOutPower;
5388
5335
  }
5389
5336
  };
5390
- //#endregion
5391
- //#region src/control/ZoomControl.js
5337
+ // src/control/ZoomControl.js
5392
5338
  /** @import {ControlOptions} from './Control.js' */
5393
5339
  /** @import {MaplairMap} from '../map/Map.js' */
5394
5340
  /**
@@ -5442,8 +5388,8 @@
5442
5388
  */
5443
5389
  onAdd(map) {
5444
5390
  const zoomName = "maplair-control-zoom", container = create("div", `${zoomName} maplair-bar`), options = this.options;
5445
- this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, this._zoomIn);
5446
- this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, this._zoomOut);
5391
+ this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, (e) => this._zoom(e, 1));
5392
+ this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, (e) => this._zoom(e, -1));
5447
5393
  this._updateDisabled();
5448
5394
  map.on("zoomend zoomlevelschange", this._updateDisabled, this);
5449
5395
  return container;
@@ -5473,16 +5419,11 @@
5473
5419
  this._updateDisabled();
5474
5420
  return this;
5475
5421
  }
5476
- _zoomIn(e) {
5477
- if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {
5478
- this._map._setUserEvent(e);
5479
- this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
5480
- }
5481
- }
5482
- _zoomOut(e) {
5483
- if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {
5484
- this._map._setUserEvent(e);
5485
- this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
5422
+ _zoom(e, dir) {
5423
+ const map = this._map;
5424
+ if (!this._disabled && (dir > 0 ? map._zoom < map.getMaxZoom() : map._zoom > map.getMinZoom())) {
5425
+ map._setUserEvent(e);
5426
+ map.zoomIn(dir * map.options.zoomDelta * (e.shiftKey ? 3 : 1));
5486
5427
  }
5487
5428
  }
5488
5429
  _createButton(html, title, className, container, fn) {
@@ -5492,24 +5433,19 @@
5492
5433
  link.title = title;
5493
5434
  link.setAttribute("aria-label", title);
5494
5435
  disableClickPropagation(link);
5495
- on(link, "click", stop);
5496
- on(link, "click", fn, this);
5497
- on(link, "click", this._refocusOnMap, this);
5436
+ on(link, "click", (e) => {
5437
+ stop(e);
5438
+ fn.call(this, e);
5439
+ this._refocusOnMap(e);
5440
+ });
5498
5441
  return link;
5499
5442
  }
5500
5443
  _updateDisabled() {
5501
- const map = this._map, className = "maplair-disabled";
5502
- this._zoomInButton.classList.remove(className);
5503
- this._zoomOutButton.classList.remove(className);
5504
- this._zoomInButton.setAttribute("aria-disabled", "false");
5505
- this._zoomOutButton.setAttribute("aria-disabled", "false");
5506
- if (this._disabled || map._zoom === map.getMinZoom()) {
5507
- this._zoomOutButton.classList.add(className);
5508
- this._zoomOutButton.setAttribute("aria-disabled", "true");
5509
- }
5510
- if (this._disabled || map._zoom === map.getMaxZoom()) {
5511
- this._zoomInButton.classList.add(className);
5512
- this._zoomInButton.setAttribute("aria-disabled", "true");
5444
+ const map = this._map;
5445
+ for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
5446
+ const disabled = this._disabled || map._zoom === limit;
5447
+ button.classList.toggle("maplair-disabled", disabled);
5448
+ button.setAttribute("aria-disabled", `${disabled}`);
5513
5449
  }
5514
5450
  }
5515
5451
  /**
@@ -5527,8 +5463,7 @@
5527
5463
  });
5528
5464
  }
5529
5465
  };
5530
- //#endregion
5531
- //#region src/layer/LayerGroup.js
5466
+ // src/layer/LayerGroup.js
5532
5467
  /** @import {Feature, FeatureCollection} from 'geojson' */
5533
5468
  /** @import {InteractiveLayerOptions} from './Layer.js' */
5534
5469
  /** @import {MaplairMap} from '../map/Map.js' */
@@ -5575,7 +5510,7 @@
5575
5510
  * @returns {this}
5576
5511
  */
5577
5512
  removeLayer(layer) {
5578
- const id = layer in this._layers ? layer : this.getLayerId(layer);
5513
+ const id = typeof layer === "number" ? layer : this.getLayerId(layer);
5579
5514
  if (this._map && this._layers[id]) this._map.removeLayer(this._layers[id]);
5580
5515
  delete this._layers[id];
5581
5516
  return this;
@@ -5707,8 +5642,7 @@
5707
5642
  };
5708
5643
  }
5709
5644
  };
5710
- //#endregion
5711
- //#region src/layer/FeatureGroup.js
5645
+ // src/layer/FeatureGroup.js
5712
5646
  /** @import {Layer, InteractiveLayerOptions} from './Layer.js' */
5713
5647
  /** @import {LayerEvent} from '../core/Events.js' */
5714
5648
  /** @import {PathOptions} from './vector/Path.js' */
@@ -5803,17 +5737,18 @@
5803
5737
  }
5804
5738
  /**
5805
5739
  * Returns the `LatLngBounds` of the feature group (created from bounds and
5806
- * coordinates of its children).
5740
+ * coordinates of its children, including the layers of nested layer groups).
5807
5741
  * @returns {LatLngBounds}
5808
5742
  */
5809
5743
  getBounds() {
5810
5744
  const bounds = new LatLngBounds();
5811
- for (const layer of Object.values(this._layers)) bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng());
5745
+ for (const layer of Object.values(this._layers)) if (layer.getBounds) bounds.extend(layer.getBounds());
5746
+ else if (layer.getLatLng) bounds.extend(layer.getLatLng());
5747
+ else if (layer instanceof LayerGroup) bounds.extend(FeatureGroup.prototype.getBounds.call(layer));
5812
5748
  return bounds;
5813
5749
  }
5814
5750
  };
5815
- //#endregion
5816
- //#region src/layer/DivOverlay.js
5751
+ // src/layer/DivOverlay.js
5817
5752
  /** @import {InteractiveLayerOptions} from './Layer.js' */
5818
5753
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
5819
5754
  /** @import {PointExpression} from '../geometry/Point.js' */
@@ -6152,7 +6087,7 @@
6152
6087
  }
6153
6088
  _updatePosition() {
6154
6089
  if (!this._map) return;
6155
- const pos = this._map.latLngToLayerPoint(this._latlng), offset = Point.from(this.options.offset);
6090
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round(), offset = Point.from(this.options.offset);
6156
6091
  this._setContainerPosition(pos.add(this._getAnchor()));
6157
6092
  const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
6158
6093
  if (this.options.overflow) {
@@ -6185,8 +6120,7 @@
6185
6120
  Layer.include(layerDivOverlayMethods);
6186
6121
  }
6187
6122
  };
6188
- //#endregion
6189
- //#region src/layer/Popup.js
6123
+ // src/layer/Popup.js
6190
6124
  /** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */
6191
6125
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
6192
6126
  /** @import {PointExpression} from '../geometry/Point.js' */
@@ -6392,7 +6326,7 @@
6392
6326
  },
6393
6327
  _openPopup(e) {
6394
6328
  if (!this._popup || !this._map) return;
6395
- stop(e);
6329
+ stopPropagation(e);
6396
6330
  const target = e.propagatedFrom ?? e.target;
6397
6331
  if (this._popup._source === target && !(target instanceof Path)) {
6398
6332
  if (this._map.hasLayer(this._popup)) this.closePopup();
@@ -6544,9 +6478,6 @@
6544
6478
  const wrapper = this._wrapper = create("div", `${prefix}-content-wrapper`, container);
6545
6479
  this._contentNode = create("div", `${prefix}-content`, wrapper);
6546
6480
  disableClickPropagation(container);
6547
- on(container, "keydown", (e) => {
6548
- if (e.key === "Escape" && this.options.closeOnEscapeKey) this.close();
6549
- });
6550
6481
  disableScrollPropagation(this._contentNode);
6551
6482
  on(container, "contextmenu", stopPropagation);
6552
6483
  this._tipContainer = create("div", `${prefix}-tip-container`, container);
@@ -6562,14 +6493,12 @@
6562
6493
  });
6563
6494
  }
6564
6495
  if (this.options.trackResize) {
6565
- this._resizeObserver = new ResizeObserver(((entries) => {
6496
+ this._resizeObserver = new ResizeObserver(() => {
6566
6497
  if (!this._map) return;
6567
- this._containerWidth = entries[0]?.contentRect?.width;
6568
- this._containerHeight = entries[0]?.contentRect?.height;
6569
6498
  this._updateLayout();
6570
6499
  this._updatePosition();
6571
6500
  this._adjustPan();
6572
- }));
6501
+ });
6573
6502
  this._resizeObserver.observe(this._contentNode);
6574
6503
  }
6575
6504
  }
@@ -6577,11 +6506,10 @@
6577
6506
  const container = this._contentNode, style = container.style;
6578
6507
  style.maxWidth = `${this.options.maxWidth}px`;
6579
6508
  style.minWidth = `${this.options.minWidth}px`;
6580
- const maxHeight = this.options.maxHeight, scrolledClass = "maplair-popup-scrolled";
6581
- if (maxHeight && (this._containerHeight ?? container.offsetHeight) > maxHeight) {
6582
- style.height = `${maxHeight}px`;
6583
- container.classList.add(scrolledClass);
6584
- } else container.classList.remove(scrolledClass);
6509
+ style.height = "";
6510
+ const maxHeight = this.options.maxHeight, scrolled = !!maxHeight && container.offsetHeight > maxHeight;
6511
+ if (scrolled) style.height = `${maxHeight}px`;
6512
+ container.classList.toggle("maplair-popup-scrolled", scrolled);
6585
6513
  this._containerWidth = this._container.offsetWidth;
6586
6514
  this._containerHeight = this._container.offsetHeight;
6587
6515
  this._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;
@@ -6625,8 +6553,7 @@
6625
6553
  Layer.include(layerPopupMethods);
6626
6554
  }
6627
6555
  };
6628
- //#endregion
6629
- //#region src/layer/Tooltip.js
6556
+ // src/layer/Tooltip.js
6630
6557
  const directions = [
6631
6558
  "top",
6632
6559
  "bottom",
@@ -6733,8 +6660,9 @@
6733
6660
  * @returns {this}
6734
6661
  */
6735
6662
  bindTooltip(content, options) {
6736
- if (this._tooltip && this.isTooltipOpen()) this.unbindTooltip();
6737
- this._tooltip = this._initOverlay(Tooltip, this._tooltip, content, options);
6663
+ const old = this.isTooltipOpen() ? null : this._tooltip;
6664
+ if (this._tooltip) this.unbindTooltip();
6665
+ this._tooltip = this._initOverlay(Tooltip, old, content, options);
6738
6666
  this._initTooltipInteractions();
6739
6667
  if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) this.openTooltip();
6740
6668
  return this;
@@ -6753,21 +6681,20 @@
6753
6681
  return this;
6754
6682
  },
6755
6683
  _initTooltipInteractions(remove) {
6756
- if (!remove && this._tooltipHandlersAdded) return;
6757
- const onOff = remove ? "off" : "on", events = {
6684
+ const { permanent, sticky } = this._tooltip.options, events = {
6758
6685
  remove: this.closeTooltip,
6759
6686
  move: this._moveTooltip
6760
6687
  };
6761
- if (!this._tooltip.options.permanent) {
6688
+ if (permanent) events.add = this._openTooltip;
6689
+ else {
6762
6690
  events.pointerover = this._openTooltip;
6763
6691
  events.pointerout = this.closeTooltip;
6764
6692
  events.click = this._openTooltip;
6765
- if (this._map) this._addFocusListeners(remove);
6766
- else events.add = () => this._addFocusListeners(remove);
6767
- } else events.add = this._openTooltip;
6768
- if (this._tooltip.options.sticky) events.pointermove = this._moveTooltip;
6769
- this[onOff](events);
6770
- this._tooltipHandlersAdded = !remove;
6693
+ events.add = this._toggleFocusListeners;
6694
+ if (this._map) this._toggleFocusListeners(!remove);
6695
+ }
6696
+ if (sticky) events.pointermove = this._moveTooltip;
6697
+ this[remove ? "off" : "on"](events);
6771
6698
  },
6772
6699
  /**
6773
6700
  * Opens the bound tooltip at the specified `latlng` or at the default tooltip
@@ -6833,9 +6760,9 @@
6833
6760
  getTooltip() {
6834
6761
  return this._tooltip;
6835
6762
  },
6836
- _addFocusListeners(remove) {
6837
- if (this.getElement) this._addFocusListenersOnLayer(this, remove);
6838
- else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer, remove), this);
6763
+ _toggleFocusListeners(add) {
6764
+ if (this.getElement) this._addFocusListenersOnLayer(this, !add);
6765
+ else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer, !add), this);
6839
6766
  },
6840
6767
  _addFocusListenersOnLayer(layer, remove) {
6841
6768
  const el = typeof layer.getElement === "function" && layer.getElement();
@@ -7068,7 +6995,7 @@
7068
6995
  };
7069
6996
  }
7070
6997
  _updatePosition() {
7071
- const pos = this._map.latLngToLayerPoint(this._latlng);
6998
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round();
7072
6999
  this._setPosition(pos);
7073
7000
  }
7074
7001
  /**
@@ -7097,8 +7024,7 @@
7097
7024
  Layer.include(layerTooltipMethods);
7098
7025
  }
7099
7026
  };
7100
- //#endregion
7101
- //#region src/layer/vector/Renderer.getRenderer.js
7027
+ // src/layer/vector/Renderer.getRenderer.js
7102
7028
  var Renderer_getRenderer_exports = /* @__PURE__ */ __exportAll({ register: () => register });
7103
7029
  /** @import {MaplairMap} from '../../map/Map.js' */
7104
7030
  /** @import {Path} from './Path.js' */
@@ -7114,11 +7040,11 @@
7114
7040
  * are respected, and that the renderers do exist on the map.
7115
7041
  * @internal
7116
7042
  * @param {Path} layer
7117
- * @returns {Renderer}
7043
+ * @returns {Renderer|undefined}
7118
7044
  */
7119
7045
  getRenderer(layer) {
7120
- const renderer = layer.options.renderer ?? this._getPaneRenderer(layer) ?? this.options.renderer ?? (this._renderer ??= layer._createRenderer());
7121
- if (!this.hasLayer(renderer)) this.addLayer(renderer);
7046
+ const renderer = layer.options.renderer ?? this._getPaneRenderer(layer) ?? this.options.renderer ?? (this._renderer ??= layer._createRenderer?.());
7047
+ if (renderer && !this.hasLayer(renderer)) this.addLayer(renderer);
7122
7048
  return renderer;
7123
7049
  },
7124
7050
  _getPaneRenderer(layer) {
@@ -7157,15 +7083,14 @@
7157
7083
  if (this.options.preferCanvas !== void 0) console.error("MaplairMap: preferCanvas option has been removed. Use renderer: new Canvas() instead.");
7158
7084
  });
7159
7085
  }
7160
- //#endregion
7161
- //#region src/core/Handler.js
7086
+ // src/core/Handler.js
7162
7087
  /** @import {MaplairMap} from '../map/Map.js' */
7163
7088
  /**
7164
7089
  * Abstract class for map interaction handlers, the base class of the handlers that
7165
7090
  * are used internally to inject interaction features like dragging to classes like
7166
7091
  * `MaplairMap` and `Marker`.
7167
7092
  *
7168
- * Classes inheriting from `Handler` must implement the two following extension methods:
7093
+ * Classes inheriting from `Handler` implement the two following extension methods:
7169
7094
  *
7170
7095
  * * `addHooks()` is called when the handler is enabled, should add event hooks.
7171
7096
  * * `removeHooks()` is called when the handler is disabled, should remove the event
@@ -7208,6 +7133,14 @@
7208
7133
  return !!this._enabled;
7209
7134
  }
7210
7135
  /**
7136
+ * Called when the handler is enabled, should add event hooks.
7137
+ */
7138
+ addHooks() {}
7139
+ /**
7140
+ * Called when the handler is disabled, should remove the event hooks added previously.
7141
+ */
7142
+ removeHooks() {}
7143
+ /**
7211
7144
  * Adds a new handler of this class to the given map with the given name, which is
7212
7145
  * then available as the property of the map with this name.
7213
7146
  * @template {typeof Handler} T
@@ -7221,8 +7154,7 @@
7221
7154
  return this;
7222
7155
  }
7223
7156
  };
7224
- //#endregion
7225
- //#region src/map/handler/BoxZoomHandler.js
7157
+ // src/map/handler/BoxZoomHandler.js
7226
7158
  /** @import {MaplairMap} from '../Map.js' */
7227
7159
  /** @import {MaplairEvent} from '../../core/Events.js' */
7228
7160
  /**
@@ -7259,23 +7191,19 @@
7259
7191
  */
7260
7192
  constructor(map) {
7261
7193
  super(map);
7262
- this._container = map._container;
7263
- this._pane = map._panes.overlayPane;
7264
- this._resetStateTimeout = 0;
7265
- map.on("unload", this._destroy, this);
7266
7194
  this.callInitHooks(BoxZoomHandler);
7267
7195
  }
7268
7196
  /**
7269
7197
  * Called when the handler is enabled, adds the event hooks.
7270
7198
  */
7271
7199
  addHooks() {
7272
- on(this._container, "pointerdown", this._onPointerDown, this);
7200
+ on(this._map._container, "pointerdown", this._onPointerDown, this);
7273
7201
  }
7274
7202
  /**
7275
7203
  * Called when the handler is disabled, removes the event hooks.
7276
7204
  */
7277
7205
  removeHooks() {
7278
- off(this._container, "pointerdown", this._onPointerDown, this);
7206
+ off(this._map._container, "pointerdown", this._onPointerDown, this);
7279
7207
  }
7280
7208
  /**
7281
7209
  * Returns `true` if a box has been drawn by the current or last interaction.
@@ -7284,42 +7212,34 @@
7284
7212
  moved() {
7285
7213
  return this._moved;
7286
7214
  }
7287
- _destroy() {
7288
- this._pane.remove();
7289
- delete this._pane;
7290
- }
7291
7215
  _resetState() {
7292
- this._resetStateTimeout = 0;
7216
+ clearTimeout(this._resetStateTimeout);
7293
7217
  this._moved = false;
7294
7218
  }
7295
- _clearDeferredResetState() {
7296
- if (this._resetStateTimeout !== 0) {
7297
- clearTimeout(this._resetStateTimeout);
7298
- this._resetStateTimeout = 0;
7299
- }
7219
+ _toggleListeners(onOff) {
7220
+ onOff(this._map._container, {
7221
+ contextmenu: stop,
7222
+ pointermove: this._onPointerMove,
7223
+ pointerup: this._onPointerUp
7224
+ }, this);
7225
+ onOff(document, "keydown", this._onKeyDown, this);
7300
7226
  }
7301
7227
  _onPointerDown(e) {
7302
7228
  if (!e.shiftKey || e.button !== 0) return false;
7303
- this._clearDeferredResetState();
7304
7229
  this._resetState();
7305
7230
  preventDefault(e);
7306
7231
  this._startPoint = this._map.pointerEventToContainerPoint(e);
7307
- on(this._container, {
7308
- contextmenu: stop,
7309
- pointermove: this._onPointerMove,
7310
- pointerup: this._onPointerUp,
7311
- keydown: this._onKeyDown
7312
- }, this);
7313
- on(document, "keydown", this._onKeyDown, this);
7232
+ this._toggleListeners(on);
7314
7233
  }
7315
7234
  _onPointerMove(e) {
7235
+ const map = this._map;
7316
7236
  if (!this._moved) {
7317
7237
  this._moved = true;
7318
- this._box = create("div", "maplair-zoom-box", this._container);
7319
- this._container.classList.add("maplair-crosshair");
7320
- this._map.fire("boxzoomstart");
7238
+ this._box = create("div", "maplair-zoom-box", map._container);
7239
+ map._container.classList.add("maplair-crosshair");
7240
+ map.fire("boxzoomstart");
7321
7241
  }
7322
- this._point = this._map.pointerEventToContainerPoint(e);
7242
+ this._point = map.pointerEventToContainerPoint(e);
7323
7243
  const bounds = new Bounds(this._point, this._startPoint), size = bounds.getSize();
7324
7244
  setPosition(this._box, bounds.min);
7325
7245
  this._box.style.width = `${size.x}px`;
@@ -7328,21 +7248,15 @@
7328
7248
  _finish() {
7329
7249
  if (this._moved) {
7330
7250
  this._box.remove();
7331
- this._container.classList.remove("maplair-crosshair");
7251
+ this._map._container.classList.remove("maplair-crosshair");
7332
7252
  }
7333
- off(this._container, {
7334
- contextmenu: stop,
7335
- pointermove: this._onPointerMove,
7336
- pointerup: this._onPointerUp
7337
- }, this);
7338
- off(document, "keydown", this._onKeyDown, this);
7253
+ this._toggleListeners(off);
7339
7254
  }
7340
7255
  _onPointerUp(e) {
7341
7256
  if (e.button !== 0) return;
7342
7257
  this._finish();
7343
7258
  if (!this._moved) return;
7344
- this._clearDeferredResetState();
7345
- this._resetStateTimeout = setTimeout(this._resetState.bind(this), 0);
7259
+ this._resetStateTimeout = setTimeout(() => this._resetState(), 0);
7346
7260
  const bounds = new LatLngBounds(this._map.containerPointToLatLng(this._startPoint), this._map.containerPointToLatLng(this._point));
7347
7261
  this._map._setUserEvent(e);
7348
7262
  if (this._map.getBoundsZoom(bounds) !== Infinity) this._map.fitBounds(bounds);
@@ -7351,7 +7265,6 @@
7351
7265
  _onKeyDown(e) {
7352
7266
  if (e.code === "Escape") {
7353
7267
  this._finish();
7354
- this._clearDeferredResetState();
7355
7268
  this._resetState();
7356
7269
  }
7357
7270
  }
@@ -7365,8 +7278,7 @@
7365
7278
  MaplairMap.addInitHook("addHandler", "boxZoom", BoxZoomHandler);
7366
7279
  }
7367
7280
  };
7368
- //#endregion
7369
- //#region src/map/handler/DoubleClickZoomHandler.js
7281
+ // src/map/handler/DoubleClickZoomHandler.js
7370
7282
  /** @import {MaplairMap} from '../Map.js' */
7371
7283
  /**
7372
7284
  * Map options of `DoubleClickZoomHandler`.
@@ -7432,8 +7344,7 @@
7432
7344
  MaplairMap.addInitHook("addHandler", "doubleClickZoom", DoubleClickZoomHandler);
7433
7345
  }
7434
7346
  };
7435
- //#endregion
7436
- //#region src/dom/Draggable.js
7347
+ // src/dom/Draggable.js
7437
7348
  /** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */
7438
7349
  /**
7439
7350
  * Options of `Draggable`.
@@ -7506,7 +7417,8 @@
7506
7417
  _onDown(e) {
7507
7418
  this._moved = false;
7508
7419
  if (this._element.classList.contains("maplair-zoom-anim")) return;
7509
- if (getPointers().length !== 1) {
7420
+ const pointers = getPointers().length;
7421
+ if (pointers > 1) {
7510
7422
  if (Draggable._dragging === this) this.finishDrag();
7511
7423
  return;
7512
7424
  }
@@ -7514,6 +7426,7 @@
7514
7426
  Draggable._dragging = this;
7515
7427
  disableImageDrag();
7516
7428
  if (this._moving) return;
7429
+ if (!pointers && e.isTrusted) e.target.setPointerCapture(e.pointerId);
7517
7430
  this.fire("down");
7518
7431
  const sizedParent = getSizedParentNode(this._element);
7519
7432
  this._startPoint = new Point(e.clientX, e.clientY);
@@ -7583,8 +7496,7 @@
7583
7496
  });
7584
7497
  }
7585
7498
  };
7586
- //#endregion
7587
- //#region src/map/handler/DragHandler.js
7499
+ // src/map/handler/DragHandler.js
7588
7500
  /** @import {MaplairMap} from '../Map.js' */
7589
7501
  /** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
7590
7502
  /**
@@ -7771,8 +7683,7 @@
7771
7683
  MaplairMap.addInitHook("addHandler", "dragging", DragHandler);
7772
7684
  }
7773
7685
  };
7774
- //#endregion
7775
- //#region src/map/handler/KeyboardHandler.js
7686
+ // src/map/handler/KeyboardHandler.js
7776
7687
  /** @import {MaplairMap} from '../Map.js' */
7777
7688
  /** @import {MaplairEvent} from '../../core/Events.js' */
7778
7689
  /**
@@ -7822,8 +7733,6 @@
7822
7733
  */
7823
7734
  constructor(map) {
7824
7735
  super(map);
7825
- this._setPanDelta(map.options.keyboardPanDelta);
7826
- this._setZoomDelta(map.options.zoomDelta);
7827
7736
  this.callInitHooks(KeyboardHandler);
7828
7737
  }
7829
7738
  /**
@@ -7837,27 +7746,21 @@
7837
7746
  on(container, {
7838
7747
  focus: this._onFocus,
7839
7748
  blur: this._onBlur,
7840
- pointerdown: this._onPointerDown
7841
- }, this);
7842
- this._map.on({
7843
- focus: this._addHooks,
7844
- blur: this._removeHooks
7749
+ pointerdown: this._onPointerDown,
7750
+ keydown: this._onContainerKeyDown
7845
7751
  }, this);
7846
7752
  }
7847
7753
  /**
7848
7754
  * Called when the handler is disabled, removes the event hooks.
7849
7755
  */
7850
7756
  removeHooks() {
7851
- this._removeHooks();
7757
+ off(document, "keydown", this._onKeyDown, this);
7852
7758
  if (this._map.options.ariaKeyShortcuts) this._map._container.removeAttribute("aria-keyshortcuts");
7853
7759
  off(this._map._container, {
7854
7760
  focus: this._onFocus,
7855
7761
  blur: this._onBlur,
7856
- pointerdown: this._onPointerDown
7857
- }, this);
7858
- this._map.off({
7859
- focus: this._addHooks,
7860
- blur: this._removeHooks
7762
+ pointerdown: this._onPointerDown,
7763
+ keydown: this._onContainerKeyDown
7861
7764
  }, this);
7862
7765
  this._help?.remove();
7863
7766
  this._help = null;
@@ -7903,29 +7806,21 @@
7903
7806
  }
7904
7807
  _onFocus() {
7905
7808
  this._focused = true;
7809
+ on(document, "keydown", this._onKeyDown, this);
7906
7810
  this._map.fire("focus");
7907
7811
  }
7908
7812
  _onBlur() {
7909
7813
  this._focused = false;
7814
+ off(document, "keydown", this._onKeyDown, this);
7910
7815
  this._map.fire("blur");
7911
7816
  }
7912
- _setPanDelta(panDelta) {
7913
- const panKeys = this._panKeys = {}, { left, right, down, up } = KeyboardHandler.keys;
7914
- for (const key of left) panKeys[key] = [-panDelta, 0];
7915
- for (const key of right) panKeys[key] = [panDelta, 0];
7916
- for (const key of down) panKeys[key] = [0, panDelta];
7917
- for (const key of up) panKeys[key] = [0, -panDelta];
7918
- }
7919
- _setZoomDelta(zoomDelta) {
7920
- const zoomKeys = this._zoomKeys = {}, { zoomIn, zoomOut } = KeyboardHandler.keys;
7921
- for (const key of zoomIn) zoomKeys[key] = zoomDelta;
7922
- for (const key of zoomOut) zoomKeys[key] = -zoomDelta;
7923
- }
7924
- _addHooks() {
7925
- on(document, "keydown", this._onKeyDown, this);
7926
- }
7927
- _removeHooks() {
7928
- off(document, "keydown", this._onKeyDown, this);
7817
+ _onContainerKeyDown(e) {
7818
+ const map = this._map, popup = map._popup;
7819
+ if (e.key !== "Escape" || e.defaultPrevented || !popup?.options.closeOnEscapeKey || map._controlContainer?.contains(e.target)) return;
7820
+ const inPopup = popup._container.contains(e.target), icon = popup._source?._icon;
7821
+ map.closePopup();
7822
+ e.preventDefault();
7823
+ if (inPopup) (icon?.tabIndex >= 0 ? icon : map._container).focus();
7929
7824
  }
7930
7825
  _onKeyDown(e) {
7931
7826
  if (e.altKey || e.ctrlKey || e.metaKey) return;
@@ -7934,23 +7829,20 @@
7934
7829
  stop(e);
7935
7830
  return;
7936
7831
  }
7937
- const key = e.key, map = this._map;
7938
- let offset;
7939
- if (key in this._panKeys) {
7940
- if (!map._panAnim || !map._panAnim._inProgress) {
7941
- offset = this._panKeys[key];
7942
- if (e.shiftKey) offset = Point.from(offset).multiplyBy(3);
7943
- if (map.options.maxBounds) offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
7832
+ 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;
7833
+ if (x || y) {
7834
+ if (!map._panAnim?._inProgress) {
7835
+ let offset = new Point(x, y).multiplyBy(k * map.options.keyboardPanDelta);
7836
+ if (map.options.maxBounds) offset = map._limitOffset(offset, map.options.maxBounds);
7944
7837
  map._setUserEvent(e);
7945
7838
  map.panBy(offset);
7946
7839
  }
7947
- } else if (key in this._zoomKeys) {
7840
+ } else if (dz) {
7948
7841
  if (!map._zoomInputBlocked()) {
7949
7842
  map._setUserEvent(e);
7950
- map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);
7843
+ map.setZoom(map.getZoom() + k * dz * map.options.zoomDelta);
7951
7844
  }
7952
- } else if (key === "Escape" && map._popup && map._popup.options.closeOnEscapeKey) map.closePopup();
7953
- else return;
7845
+ } else return;
7954
7846
  stop(e);
7955
7847
  }
7956
7848
  /**
@@ -7967,8 +7859,7 @@
7967
7859
  MaplairMap.addInitHook("addHandler", "keyboard", KeyboardHandler);
7968
7860
  }
7969
7861
  };
7970
- //#endregion
7971
- //#region src/map/handler/PinchZoomHandler.js
7862
+ // src/map/handler/PinchZoomHandler.js
7972
7863
  /** @import {MaplairMap} from '../Map.js' */
7973
7864
  /**
7974
7865
  * Map options of `PinchZoomHandler`, touch interaction options.
@@ -8103,8 +7994,7 @@
8103
7994
  });
8104
7995
  }
8105
7996
  };
8106
- //#endregion
8107
- //#region src/map/handler/ScrollWheelZoomHandler.js
7997
+ // src/map/handler/ScrollWheelZoomHandler.js
8108
7998
  /** @import {MaplairMap} from '../Map.js' */
8109
7999
  const pinchPxPerZoomLevel = 100;
8110
8000
  const gestureEndDelay$1 = 150;
@@ -8306,8 +8196,7 @@
8306
8196
  MaplairMap.addInitHook("addHandler", "scrollWheelZoom", ScrollWheelZoomHandler);
8307
8197
  }
8308
8198
  };
8309
- //#endregion
8310
- //#region src/map/handler/TapHoldHandler.js
8199
+ // src/map/handler/TapHoldHandler.js
8311
8200
  /** @import {MaplairMap} from '../Map.js' */
8312
8201
  const tapHoldDelay = 600;
8313
8202
  /**
@@ -8418,8 +8307,7 @@
8418
8307
  MaplairMap.addInitHook("addHandler", "tapHold", TapHoldHandler);
8419
8308
  }
8420
8309
  };
8421
- //#endregion
8422
- //#region src/map/handler/TapDragZoomHandler.js
8310
+ // src/map/handler/TapDragZoomHandler.js
8423
8311
  /** @import {MaplairMap} from '../Map.js' */
8424
8312
  const maxTapInterval = 500;
8425
8313
  const maxTapDistance = 30;
@@ -8560,8 +8448,7 @@
8560
8448
  MaplairMap.addInitHook("addHandler", "tapDragZoom", TapDragZoomHandler);
8561
8449
  }
8562
8450
  };
8563
- //#endregion
8564
- //#region src/map/Map.js
8451
+ // src/map/Map.js
8565
8452
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
8566
8453
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
8567
8454
  /** @import {PointExpression} from '../geometry/Point.js' */
@@ -8934,7 +8821,7 @@
8934
8821
  * @returns {this}
8935
8822
  */
8936
8823
  setZoomAround(latlng, zoom, options) {
8937
- 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));
8824
+ 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))));
8938
8825
  return this.setView(newCenter, zoom, { zoom: options });
8939
8826
  }
8940
8827
  _getBoundsCenterZoom(bounds, options) {
@@ -9056,9 +8943,6 @@
9056
8943
  return -Math.asinh(t1 / b1);
9057
8944
  }
9058
8945
  const r0 = r(0);
9059
- function w(s) {
9060
- return w0 * (Math.cosh(r0) / Math.cosh(r0 + rho * s));
9061
- }
9062
8946
  function u(s) {
9063
8947
  return w0 * (Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2;
9064
8948
  }
@@ -9070,7 +8954,7 @@
9070
8954
  const t = (Date.now() - start) / duration, s = easeOut(t) * S;
9071
8955
  if (t <= 1) {
9072
8956
  this._flyToFrame = requestAnimationFrame(frame);
9073
- this._move(this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), this.getScaleZoom(w0 / w(s), startZoom), { flyTo: true });
8957
+ 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 });
9074
8958
  } else {
9075
8959
  const zoomChanged = this._zoom !== targetZoom;
9076
8960
  this._move(targetCenter, targetZoom);
@@ -9398,7 +9282,7 @@
9398
9282
  */
9399
9283
  getCenter() {
9400
9284
  this._checkIfLoaded();
9401
- if (this._lastCenter && !this._moved()) return new LatLng(this._lastCenter);
9285
+ if (this._lastCenter && this._getMapPanePos().equals(this._lastCenterPanePos)) return new LatLng(this._lastCenter);
9402
9286
  return this.layerPointToLatLng(this._getCenterLayerPoint());
9403
9287
  }
9404
9288
  /**
@@ -9602,7 +9486,7 @@
9602
9486
  * @returns {Point}
9603
9487
  */
9604
9488
  latLngToLayerPoint(latlng) {
9605
- return this.project(LatLng.from(latlng))._round()._subtract(this.getPixelOrigin());
9489
+ return this.project(LatLng.from(latlng))._subtract(this.getPixelOrigin());
9606
9490
  }
9607
9491
  /**
9608
9492
  * Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
@@ -9852,6 +9736,7 @@
9852
9736
  const zoomChanged = this._zoom !== zoom;
9853
9737
  this._zoom = zoom;
9854
9738
  this._lastCenter = center;
9739
+ this._lastCenterPanePos = this._getMapPanePos();
9855
9740
  this._pixelOrigin = this._getNewPixelOrigin(center);
9856
9741
  if (!suppressEvent) {
9857
9742
  if (zoomChanged || data?.pinch) this.fire("zoom", data);
@@ -9964,10 +9849,10 @@
9964
9849
  const target = targets[0];
9965
9850
  const data = { originalEvent: e };
9966
9851
  if (e.type !== "keydown" && e.type !== "keyup") {
9967
- const isMarker = target.getLatLng && (!target._pxRadius || target._pxRadius <= 10);
9968
- data.containerPoint = isMarker ? this.latLngToContainerPoint(target.getLatLng()) : this.pointerEventToContainerPoint(e);
9852
+ const latlng = (!target._pxRadius || target._pxRadius <= 10) && target.getLatLng?.();
9853
+ data.containerPoint = latlng ? this.latLngToContainerPoint(latlng) : this.pointerEventToContainerPoint(e);
9969
9854
  data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
9970
- data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint);
9855
+ data.latlng = latlng || this.layerPointToLatLng(data.layerPoint);
9971
9856
  }
9972
9857
  for (const t of targets) {
9973
9858
  t.fire(type, data, true);
@@ -9996,10 +9881,6 @@
9996
9881
  _getMapPanePos() {
9997
9882
  return getPosition(this._mapPane);
9998
9883
  }
9999
- _moved() {
10000
- const pos = this._getMapPanePos();
10001
- return pos && !pos.equals([0, 0]);
10002
- }
10003
9884
  _getTopLeftPoint(center, zoom) {
10004
9885
  return (center && zoom !== void 0 ? this._getNewPixelOrigin(center, zoom) : this.getPixelOrigin()).subtract(this._getMapPanePos());
10005
9886
  }
@@ -10015,7 +9896,7 @@
10015
9896
  return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
10016
9897
  }
10017
9898
  _getCenterOffset(latlng) {
10018
- return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint());
9899
+ return this.latLngToLayerPoint(latlng)._round()._subtract(this._getCenterLayerPoint());
10019
9900
  }
10020
9901
  _limitCenter(center, zoom, bounds) {
10021
9902
  if (!bounds) return center;
@@ -10162,8 +10043,7 @@
10162
10043
  ZoomControl,
10163
10044
  FullscreenControl
10164
10045
  ]) feature.register(MaplairMap);
10165
- //#endregion
10166
- //#region src/layer/vector/Polyline.js
10046
+ // src/layer/vector/Polyline.js
10167
10047
  /** @import {Feature} from 'geojson' */
10168
10048
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
10169
10049
  /** @import {PointExpression} from '../../geometry/Point.js' */
@@ -10354,7 +10234,7 @@
10354
10234
  for (i = 0, k = 0, len = this._rings.length; i < len; i++) {
10355
10235
  points = this._rings[i];
10356
10236
  for (j = 0, len2 = points.length; j < len2 - 1; j++) {
10357
- segment = clipSegment(points[j], points[j + 1], bounds, j, true);
10237
+ segment = clipSegment(points[j], points[j + 1], bounds, j);
10358
10238
  if (!segment) continue;
10359
10239
  parts[k] ??= [];
10360
10240
  parts[k].push(segment[0]);
@@ -10408,8 +10288,7 @@
10408
10288
  });
10409
10289
  }
10410
10290
  };
10411
- //#endregion
10412
- //#region src/geometry/PolyUtil.js
10291
+ // src/geometry/PolyUtil.js
10413
10292
  var PolyUtil_exports = /* @__PURE__ */ __exportAll({
10414
10293
  centroid: () => centroid,
10415
10294
  clipPolygon: () => clipPolygon,
@@ -10430,37 +10309,30 @@
10430
10309
  * @returns {Point[]}
10431
10310
  */
10432
10311
  function clipPolygon(points, bounds, round) {
10433
- let clippedPoints, i, j, k, a, b, len, edge, p;
10434
- const edges = [
10312
+ for (const edge of [
10435
10313
  1,
10436
10314
  4,
10437
10315
  2,
10438
10316
  8
10439
- ];
10440
- for (i = 0, len = points.length; i < len; i++) points[i]._code = _getBitCode(points[i], bounds);
10441
- for (k = 0; k < 4; k++) {
10442
- edge = edges[k];
10443
- clippedPoints = [];
10444
- for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
10445
- a = points[i];
10446
- b = points[j];
10447
- if (!(a._code & edge)) {
10448
- if (b._code & edge) {
10449
- p = _getEdgeIntersection(b, a, edge, bounds, round);
10450
- p._code = _getBitCode(p, bounds);
10451
- clippedPoints.push(p);
10452
- }
10453
- clippedPoints.push(a);
10454
- } else if (!(b._code & edge)) {
10455
- p = _getEdgeIntersection(b, a, edge, bounds, round);
10456
- p._code = _getBitCode(p, bounds);
10457
- clippedPoints.push(p);
10458
- }
10317
+ ]) {
10318
+ if (!points.length) break;
10319
+ /** @type {Point[]} */
10320
+ const clippedPoints = [];
10321
+ let b = points[points.length - 1], bOut = isOutside(b, edge, bounds);
10322
+ for (const a of points) {
10323
+ const aOut = isOutside(a, edge, bounds);
10324
+ if (aOut !== bOut) clippedPoints.push(_getEdgeIntersection(b, a, edge, bounds, round));
10325
+ if (!aOut) clippedPoints.push(a);
10326
+ b = a;
10327
+ bOut = aOut;
10459
10328
  }
10460
10329
  points = clippedPoints;
10461
10330
  }
10462
10331
  return points;
10463
10332
  }
10333
+ function isOutside(p, edge, bounds) {
10334
+ 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;
10335
+ }
10464
10336
  /**
10465
10337
  * Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the passed
10466
10338
  * LatLngs (first ring) from a polygon.
@@ -10497,8 +10369,7 @@
10497
10369
  }
10498
10370
  return new LatLng([latSum / len, lngSum / len]);
10499
10371
  }
10500
- //#endregion
10501
- //#region src/layer/vector/Polygon.js
10372
+ // src/layer/vector/Polygon.js
10502
10373
  /** @import {Feature} from 'geojson' */
10503
10374
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
10504
10375
  /** @import {PolylineOptions} from './Polyline.js' */
@@ -10603,7 +10474,7 @@
10603
10474
  return;
10604
10475
  }
10605
10476
  for (const ring of this._rings) {
10606
- const clipped = clipPolygon(ring, bounds, true);
10477
+ const clipped = clipPolygon(ring, bounds);
10607
10478
  if (clipped.length) this._parts.push(clipped);
10608
10479
  }
10609
10480
  }
@@ -10640,8 +10511,7 @@
10640
10511
  });
10641
10512
  }
10642
10513
  };
10643
- //#endregion
10644
- //#region src/control/MiniMapControl.js
10514
+ // src/control/MiniMapControl.js
10645
10515
  /** @import {ControlOptions} from './Control.js' */
10646
10516
  /** @import {MaplairMapOptions} from '../map/Map.js' */
10647
10517
  /** @import {Layer} from '../layer/Layer.js' */
@@ -10811,8 +10681,7 @@
10811
10681
  if (!this._miniMap.dragging?.moved()) this._map.panTo(e.latlng);
10812
10682
  }
10813
10683
  };
10814
- //#endregion
10815
- //#region src/control/ScaleControl.js
10684
+ // src/control/ScaleControl.js
10816
10685
  /** @import {ControlOptions} from './Control.js' */
10817
10686
  /** @import {MaplairMap} from '../map/Map.js' */
10818
10687
  /**
@@ -10915,8 +10784,7 @@
10915
10784
  return pow10 * d;
10916
10785
  }
10917
10786
  };
10918
- //#endregion
10919
- //#region src/layer/marker/Icon.js
10787
+ // src/layer/marker/Icon.js
10920
10788
  /** @import {PointExpression} from '../../geometry/Point.js' */
10921
10789
  /**
10922
10790
  * Options of `Icon`.
@@ -11028,6 +10896,7 @@
11028
10896
  img.style.marginLeft = `${-anchor.x}px`;
11029
10897
  img.style.marginTop = `${-anchor.y}px`;
11030
10898
  }
10899
+ img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
11031
10900
  if (size) {
11032
10901
  img.style.width = `${size.x}px`;
11033
10902
  img.style.height = `${size.y}px`;
@@ -11042,14 +10911,25 @@
11042
10911
  return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
11043
10912
  }
11044
10913
  };
11045
- //#endregion
11046
- //#region src/layer/marker/DefaultIcon.js
10914
+ // src/layer/marker/DefaultIcon.js
11047
10915
  /** @import {IconOptions} from './Icon.js' */
11048
10916
  /** @import {PointExpression} from '../../geometry/Point.js' */
11049
10917
  /**
10918
+ * @param {string} fill
10919
+ * @param {string} fillTop
10920
+ * @param {number} fillTopOpacity
10921
+ * @param {string} stroke
10922
+ * @param {string} strokeTop
10923
+ * @param {string} [outline]
10924
+ * @returns {string}
10925
+ */
10926
+ 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>`;
10927
+ /**
11050
10928
  * Options of `DefaultIcon`.
11051
10929
  * @typedef {object} DefaultIconOptions
11052
10930
  * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
10931
+ * @property {string|null} [color=null] Paints the pin in the given CSS color instead of
10932
+ * the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.
11053
10933
  * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
11054
10934
  * @property {PointExpression|number} [iconSize=[25, 41]]
11055
10935
  * @property {PointExpression} [iconAnchor=[12, 41]]
@@ -11059,9 +10939,9 @@
11059
10939
  * @extends IconOptions
11060
10940
  */
11061
10941
  /**
11062
- * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when
11063
- * no icon is specified. The maple leaf marker and its shadow are inlined as SVG data
11064
- * URIs, so they work with any bundler and need no image files.
10942
+ * A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is
10943
+ * specified, optionally in another `color`. The maple leaf marker and its shadow are
10944
+ * inlined as SVG data URIs, so they work with any bundler and need no image files.
11065
10945
  *
11066
10946
  * In order to customize the default icon, just change the properties of
11067
10947
  * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
@@ -11071,13 +10951,14 @@
11071
10951
  */
11072
10952
  var DefaultIcon = class DefaultIcon extends Icon {
11073
10953
  static defaultOptions = {
11074
- 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>",
10954
+ iconUrl: /* @__PURE__ */ marker("%23C2331B", "%23E2603F", 1, "%238F2D20", "%23B23A27"),
11075
10955
  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>",
11076
10956
  iconSize: [25, 41],
11077
10957
  iconAnchor: [12, 41],
11078
10958
  popupAnchor: [1, -34],
11079
10959
  tooltipAnchor: [16, -28],
11080
- shadowSize: [41, 41]
10960
+ shadowSize: [41, 41],
10961
+ color: null
11081
10962
  };
11082
10963
  /**
11083
10964
  * Creates the default icon, optionally with changed options.
@@ -11087,11 +10968,27 @@
11087
10968
  super(...args);
11088
10969
  this.callInitHooks(DefaultIcon);
11089
10970
  }
10971
+ /**
10972
+ * @param {'icon'|'shadow'} name
10973
+ * @returns {string|undefined}
10974
+ */
10975
+ _getIconUrl(name) {
10976
+ const { color } = this.options;
10977
+ if (!color || name !== "icon") return super._getIconUrl(name);
10978
+ const c = encodeURIComponent(color);
10979
+ return marker(c, c, .75, c, c, "<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>");
10980
+ }
11090
10981
  };
11091
- //#endregion
11092
- //#region src/layer/marker/Marker.Drag.js
10982
+ // src/layer/marker/Marker.Drag.js
11093
10983
  /** @import {Marker, MarkerMoveEvent} from './Marker.js' */
11094
10984
  /** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
10985
+ /** @type {Record<string, [number, number]>} */
10986
+ const arrows = {
10987
+ ArrowLeft: [-1, 0],
10988
+ ArrowRight: [1, 0],
10989
+ ArrowUp: [0, -1],
10990
+ ArrowDown: [0, 1]
10991
+ };
11095
10992
  /**
11096
10993
  * The handler of `Marker` which makes the markers draggable, see the
11097
10994
  * [`dragging`](#marker-dragging) property of markers and its `draggable` option.
@@ -11126,18 +11023,21 @@
11126
11023
  drag: this._onDrag,
11127
11024
  dragend: this._onDragEnd
11128
11025
  }, this).enable();
11026
+ on(icon, "keydown keyup blur", this._onKey, this);
11129
11027
  icon.classList.add("maplair-marker-draggable");
11130
11028
  }
11131
11029
  /**
11132
11030
  * Makes the icon of the marker undraggable, called by `disable()`.
11133
11031
  */
11134
11032
  removeHooks() {
11033
+ this._keyOffset = null;
11135
11034
  this._draggable.off({
11136
11035
  dragstart: this._onDragStart,
11137
11036
  predrag: this._onPreDrag,
11138
11037
  drag: this._onDrag,
11139
11038
  dragend: this._onDragEnd
11140
11039
  }, this).disable();
11040
+ off(this._draggable._element, "keydown keyup blur", this._onKey, this);
11141
11041
  this._marker._icon?.classList.remove("maplair-marker-draggable");
11142
11042
  }
11143
11043
  /**
@@ -11172,8 +11072,8 @@
11172
11072
  }
11173
11073
  }
11174
11074
  _onDrag(e) {
11175
- const marker = this._marker, shadow = marker._shadow, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
11176
- if (shadow) setPosition(shadow, iconPos);
11075
+ const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
11076
+ marker._positionElements(iconPos);
11177
11077
  marker._latlng = latlng;
11178
11078
  e.latlng = latlng;
11179
11079
  e.oldLatLng = this._oldLatLng;
@@ -11184,9 +11084,37 @@
11184
11084
  delete this._oldLatLng;
11185
11085
  this._marker.fire("moveend").fire("dragend", e);
11186
11086
  }
11087
+ /** @param {KeyboardEvent|FocusEvent} e */
11088
+ _onKey(e) {
11089
+ const k = e, dir = arrows[k.key], draggable = this._draggable, { options, _map: map } = this._marker;
11090
+ if (e.type !== "keydown") {
11091
+ if (this._keyOffset) {
11092
+ this._keyOffset = null;
11093
+ draggable.finishDrag();
11094
+ }
11095
+ } else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {
11096
+ e.preventDefault();
11097
+ if (!this._keyOffset) {
11098
+ if (Draggable._dragging) return;
11099
+ Draggable._dragging = draggable;
11100
+ draggable._startPos = getPosition(draggable._element);
11101
+ draggable._moved = draggable._moving = true;
11102
+ this._keyOffset = new Point(0, 0);
11103
+ draggable.fire("dragstart");
11104
+ }
11105
+ const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
11106
+ this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
11107
+ draggable._newPos = draggable._startPos.add(this._keyOffset);
11108
+ setPosition(draggable._element, draggable._newPos);
11109
+ draggable.fire("drag", { originalEvent: k });
11110
+ if (options.autoPan) map.panInside(this._marker._latlng, {
11111
+ padding: options.autoPanPadding,
11112
+ animate: false
11113
+ });
11114
+ }
11115
+ }
11187
11116
  };
11188
- //#endregion
11189
- //#region src/layer/marker/Marker.js
11117
+ // src/layer/marker/Marker.js
11190
11118
  /** @import {Feature} from 'geojson' */
11191
11119
  /** @import {Icon} from './Icon.js' */
11192
11120
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
@@ -11212,6 +11140,10 @@
11212
11140
  * top of all others (or below), specifying a high value like `1000` (or high negative
11213
11141
  * value, respectively).
11214
11142
  * @property {number} [opacity=1] The opacity of the marker.
11143
+ * @property {number|null} [rotation=null] Rotation of the marker icon in degrees,
11144
+ * clockwise, around the icon anchor, e.g. for the heading of a vehicle. A rotated
11145
+ * marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong
11146
+ * under a tilted one. `null` means no rotation.
11215
11147
  * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of
11216
11148
  * others when you hover the pointer over it.
11217
11149
  * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`
@@ -11231,7 +11163,8 @@
11231
11163
  * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is
11232
11164
  * visible within the map's bounds.
11233
11165
  * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or
11234
- * not.
11166
+ * not. A focused draggable marker can also be moved with the arrow keys, by 10 pixels
11167
+ * or 30 with Shift.
11235
11168
  * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker
11236
11169
  * near its edge or not.
11237
11170
  * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the
@@ -11270,6 +11203,7 @@
11270
11203
  alt: "Marker",
11271
11204
  zIndexOffset: 0,
11272
11205
  opacity: 1,
11206
+ rotation: null,
11273
11207
  riseOnHover: false,
11274
11208
  riseOffset: 250,
11275
11209
  pane: "markerPane",
@@ -11397,7 +11331,7 @@
11397
11331
  */
11398
11332
  update() {
11399
11333
  if (this._icon && this._map && !this._culled) {
11400
- const pos = this._map.latLngToLayerPoint(this._latlng).round();
11334
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round();
11401
11335
  this._setPos(pos);
11402
11336
  }
11403
11337
  return this;
@@ -11424,7 +11358,7 @@
11424
11358
  pointerout: this._resetZIndex
11425
11359
  });
11426
11360
  if (this.options.autoPanOnFocus) on(icon, "focus", this._panOnFocus, this);
11427
- const newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;
11361
+ const newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;
11428
11362
  let addShadow = false;
11429
11363
  if (newShadow !== this._shadow) {
11430
11364
  this._removeShadow();
@@ -11470,18 +11404,28 @@
11470
11404
  this._shadow = null;
11471
11405
  }
11472
11406
  _setPos(pos) {
11473
- if (this._icon) setPosition(this._icon, pos);
11474
- if (this._shadow) setPosition(this._shadow, pos);
11407
+ this._positionElements(pos);
11475
11408
  this._zIndex = pos.y + this.options.zIndexOffset;
11476
11409
  this._resetZIndex();
11477
11410
  }
11411
+ _positionElements(pos) {
11412
+ const rotation = this.options.rotation;
11413
+ if (this._icon) {
11414
+ setPosition(this._icon, pos);
11415
+ if (rotation != null) this._icon.style.transform += ` rotate(${rotation}deg)`;
11416
+ }
11417
+ if (this._shadow) {
11418
+ setPosition(this._shadow, pos);
11419
+ this._shadow.style.display = rotation == null ? "" : "none";
11420
+ }
11421
+ }
11478
11422
  _updateZIndex(offset) {
11479
11423
  const zIndex = String(this._zIndex + offset);
11480
11424
  if (this._icon && this._icon.style.zIndex !== zIndex) this._icon.style.zIndex = zIndex;
11481
11425
  }
11482
11426
  _animateZoom(opt) {
11483
11427
  if (this._culled) return;
11484
- const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
11428
+ const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)._round();
11485
11429
  this._setPos(pos);
11486
11430
  }
11487
11431
  _updateInteractive() {
@@ -11533,6 +11477,27 @@
11533
11477
  }
11534
11478
  }
11535
11479
  /**
11480
+ * Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.
11481
+ * @returns {number|null}
11482
+ */
11483
+ getRotation() {
11484
+ return this.options.rotation;
11485
+ }
11486
+ /**
11487
+ * Changes the [rotation](#markeroptions-rotation) of the marker; `null` removes it.
11488
+ * @param {number|null} rotation
11489
+ * @returns {this}
11490
+ */
11491
+ setRotation(rotation) {
11492
+ this.options.rotation = rotation;
11493
+ if (this._icon && !this._map._animatingZoom) {
11494
+ this._positionElements(getPosition(this._icon));
11495
+ this._popup?._updatePosition();
11496
+ this._tooltip?._updatePosition();
11497
+ }
11498
+ return this;
11499
+ }
11500
+ /**
11536
11501
  * Changes the opacity of the marker.
11537
11502
  * @param {number} opacity
11538
11503
  * @returns {this}
@@ -11564,19 +11529,23 @@
11564
11529
  _panOnFocus() {
11565
11530
  const map = this._map;
11566
11531
  if (!map) return;
11567
- const iconOpts = this.options.icon.options;
11568
- const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
11569
- const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
11532
+ 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);
11570
11533
  map.panInside(this._latlng, {
11571
11534
  paddingTopLeft: anchor,
11572
11535
  paddingBottomRight: size.subtract(anchor)
11573
11536
  });
11574
11537
  }
11575
11538
  _getPopupAnchor() {
11576
- return this.options.icon.options.popupAnchor;
11539
+ return this._rotateAnchor(this.options.icon.options.popupAnchor);
11577
11540
  }
11578
11541
  _getTooltipAnchor() {
11579
- return this.options.icon.options.tooltipAnchor;
11542
+ return this._rotateAnchor(this.options.icon.options.tooltipAnchor);
11543
+ }
11544
+ _rotateAnchor(anchor) {
11545
+ const angle = this.options.rotation * Math.PI / 180;
11546
+ if (!angle || !anchor) return anchor;
11547
+ const { x, y } = Point.from(anchor), cos = Math.cos(angle), sin = Math.sin(angle);
11548
+ return new Point(x * cos - y * sin, x * sin + y * cos);
11580
11549
  }
11581
11550
  /**
11582
11551
  * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the
@@ -11590,8 +11559,7 @@
11590
11559
  return pointToGeoJSON(this, precision);
11591
11560
  }
11592
11561
  };
11593
- //#endregion
11594
- //#region src/control/SearchControl.js
11562
+ // src/control/SearchControl.js
11595
11563
  /** @import {ControlOptions} from './Control.js' */
11596
11564
  /** @import {MaplairMap} from '../map/Map.js' */
11597
11565
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -12103,8 +12071,7 @@
12103
12071
  else this.collapse();
12104
12072
  }
12105
12073
  };
12106
- //#endregion
12107
- //#region src/control/SideBySideControl.js
12074
+ // src/control/SideBySideControl.js
12108
12075
  /** @import {ControlOptions} from './Control.js' */
12109
12076
  /** @import {MaplairMap} from '../map/Map.js' */
12110
12077
  /** @import {Layer} from '../layer/Layer.js' */
@@ -12302,8 +12269,7 @@
12302
12269
  function getElement(layer) {
12303
12270
  return layer.getContainer?.() ?? layer.getElement?.();
12304
12271
  }
12305
- //#endregion
12306
- //#region src/control/TextControl.js
12272
+ // src/control/TextControl.js
12307
12273
  /** @import {ControlOptions} from './Control.js' */
12308
12274
  /**
12309
12275
  * Options of `TextControl`.
@@ -12377,8 +12343,7 @@
12377
12343
  container.hidden = !content;
12378
12344
  }
12379
12345
  };
12380
- //#endregion
12381
- //#region src/control/TimeControl.js
12346
+ // src/control/TimeControl.js
12382
12347
  /** @import {ControlOptions} from './Control.js' */
12383
12348
  /** @import {MaplairMap} from '../map/Map.js' */
12384
12349
  /** @import {Layer} from '../layer/Layer.js' */
@@ -12777,8 +12742,7 @@
12777
12742
  return this;
12778
12743
  }
12779
12744
  };
12780
- //#endregion
12781
- //#region src/geo/projection/Projection.LonLat.js
12745
+ // src/geo/projection/LonLatProjection.js
12782
12746
  /** @import {Projection} from './index.js' */
12783
12747
  /**
12784
12748
  * Equirectangular, or Plate Carree projection — the most simple projection,
@@ -12787,7 +12751,7 @@
12787
12751
  * `EPSG4326` and `SimpleCRS` CRS.
12788
12752
  * @type {Projection}
12789
12753
  */
12790
- const LonLat = {
12754
+ const LonLatProjection = {
12791
12755
  project(latlng) {
12792
12756
  latlng = LatLng.from(latlng);
12793
12757
  return new Point(latlng.lng, latlng.lat);
@@ -12803,7 +12767,7 @@
12803
12767
  * Earth is an ellipsoid. Used by the EPSG:3395 CRS.
12804
12768
  * @type {Projection & {R: number, R_MINOR: number}}
12805
12769
  */
12806
- const Mercator = {
12770
+ const MercatorProjection = {
12807
12771
  R: 6378137,
12808
12772
  R_MINOR: 6356752.314245179,
12809
12773
  bounds: /* @__PURE__ */ new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
@@ -12829,15 +12793,7 @@
12829
12793
  return new LatLng(phi * d, point.x * d / r);
12830
12794
  }
12831
12795
  };
12832
- //#endregion
12833
- //#region src/geo/projection/index.js
12834
- var projection_exports = /* @__PURE__ */ __exportAll({
12835
- LonLat: () => LonLat,
12836
- Mercator: () => Mercator,
12837
- SphericalMercator: () => SphericalMercator
12838
- });
12839
- //#endregion
12840
- //#region src/geo/crs/EPSG3395.js
12796
+ // src/geo/crs/EPSG3395.js
12841
12797
  /** @import {Projection} from '../projection/index.js' */
12842
12798
  /**
12843
12799
  * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
@@ -12846,15 +12802,14 @@
12846
12802
  /** @type {string} */
12847
12803
  static code = "EPSG:3395";
12848
12804
  /** @type {Projection} */
12849
- static projection = Mercator;
12805
+ static projection = MercatorProjection;
12850
12806
  /** @type {Transformation} */
12851
12807
  static transformation = /* @__PURE__ */ (() => {
12852
- const scale = .5 / (Math.PI * Mercator.R);
12808
+ const scale = .5 / (Math.PI * MercatorProjection.R);
12853
12809
  return new Transformation(scale, .5, -scale, .5);
12854
12810
  })();
12855
12811
  };
12856
- //#endregion
12857
- //#region src/geo/crs/EPSG4326.js
12812
+ // src/geo/crs/EPSG4326.js
12858
12813
  /** @import {Projection} from '../projection/index.js' */
12859
12814
  /**
12860
12815
  * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
@@ -12870,12 +12825,11 @@
12870
12825
  /** @type {string} */
12871
12826
  static code = "EPSG:4326";
12872
12827
  /** @type {Projection} */
12873
- static projection = LonLat;
12828
+ static projection = LonLatProjection;
12874
12829
  /** @type {Transformation} */
12875
12830
  static transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, .5);
12876
12831
  };
12877
- //#endregion
12878
- //#region src/geo/crs/SimpleCRS.js
12832
+ // src/geo/crs/SimpleCRS.js
12879
12833
  /** @import {LatLng} from '../LatLng.js' */
12880
12834
  /** @import {Projection} from '../projection/index.js' */
12881
12835
  /**
@@ -12886,7 +12840,7 @@
12886
12840
  */
12887
12841
  var SimpleCRS = class extends CRS {
12888
12842
  /** @type {Projection} */
12889
- static projection = LonLat;
12843
+ static projection = LonLatProjection;
12890
12844
  /** @type {Transformation} */
12891
12845
  static transformation = /* @__PURE__ */ new Transformation(1, 0, -1, 0);
12892
12846
  /**
@@ -12918,8 +12872,7 @@
12918
12872
  /** @type {boolean} */
12919
12873
  static infinite = true;
12920
12874
  };
12921
- //#endregion
12922
- //#region src/layer/GeoJSON.js
12875
+ // src/layer/GeoJSON.js
12923
12876
  /** @import {Feature, FeatureCollection, GeoJSON as GeoJSONData, GeoJsonObject, Geometry} from 'geojson' */
12924
12877
  /** @import {Layer, InteractiveLayerOptions} from './Layer.js' */
12925
12878
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
@@ -13015,19 +12968,18 @@
13015
12968
  * @returns {this}
13016
12969
  */
13017
12970
  addData(geojson) {
13018
- const features = Array.isArray(geojson) ? geojson : geojson.features;
13019
- if (features) {
13020
- for (const feature of features) if (feature.geometries || feature.geometry || feature.features || feature.coordinates) this.addData(feature);
12971
+ if (Array.isArray(geojson) || "features" in geojson) {
12972
+ for (const data of Array.isArray(geojson) ? geojson : geojson.features) this.addData(data);
13021
12973
  return this;
13022
12974
  }
13023
- const options = this.options;
13024
- if (options.filter && !options.filter(geojson)) return this;
13025
- const layer = GeoJSON.geometryToLayer(geojson, options);
12975
+ const options = this.options, feature = GeoJSON.asFeature(geojson);
12976
+ if (!feature.geometry || options.filter && !options.filter(feature)) return this;
12977
+ const layer = GeoJSON.geometryToLayer(feature, options);
13026
12978
  if (!layer) return this;
13027
- layer.feature = GeoJSON.asFeature(geojson);
12979
+ layer.feature = feature;
13028
12980
  layer.defaultOptions = layer.options;
13029
12981
  this.resetStyle(layer);
13030
- if (options.onEachFeature) options.onEachFeature(geojson, layer);
12982
+ if (options.onEachFeature) options.onEachFeature(feature, layer);
13031
12983
  return this.addLayer(layer);
13032
12984
  }
13033
12985
  /**
@@ -13176,8 +13128,7 @@
13176
13128
  return asFeature(geojson);
13177
13129
  }
13178
13130
  };
13179
- //#endregion
13180
- //#region src/layer/Classification.js
13131
+ // src/layer/Classification.js
13181
13132
  /** @import {PathOptions} from './vector/Path.js' */
13182
13133
  /**
13183
13134
  * A class of a `Classification`, given by value or by range.
@@ -13445,8 +13396,7 @@
13445
13396
  return range;
13446
13397
  });
13447
13398
  }
13448
- //#endregion
13449
- //#region src/layer/HeatLayer.js
13399
+ // src/layer/HeatLayer.js
13450
13400
  /** @import {BlanketOverlayOptions} from './BlanketOverlay.js' */
13451
13401
  /** @import {LatLngExpression} from '../geo/LatLng.js' */
13452
13402
  /**
@@ -13602,7 +13552,7 @@
13602
13552
  if (!map || !this._bounds) return;
13603
13553
  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();
13604
13554
  for (const latlng of this._latlngs) {
13605
- const point = map.latLngToLayerPoint(latlng).subtract(offset);
13555
+ const point = map.latLngToLayerPoint(latlng)._round()._subtract(offset);
13606
13556
  if (point.x < -r || point.y < -r || point.x > width + r || point.y > height + r) continue;
13607
13557
  const intensity = (latlng.alt ?? latlng[2] ?? 1) * zoomFactor, key = `${Math.floor(point.x / cellSize)}:${Math.floor(point.y / cellSize)}`, cell = grid.get(key);
13608
13558
  if (cell) {
@@ -13636,8 +13586,7 @@
13636
13586
  ctx.putImageData(image, 0, 0);
13637
13587
  }
13638
13588
  };
13639
- //#endregion
13640
- //#region src/layer/ImageOverlay.js
13589
+ // src/layer/ImageOverlay.js
13641
13590
  /** @import {InteractiveLayerOptions} from './Layer.js' */
13642
13591
  /** @import {LatLng} from '../geo/LatLng.js' */
13643
13592
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
@@ -13860,7 +13809,7 @@
13860
13809
  setTransform(this._image, offset, scale);
13861
13810
  }
13862
13811
  _reset() {
13863
- const image = this._image, bounds = new Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest()), this._map.latLngToLayerPoint(this._bounds.getSouthEast())), size = bounds.getSize();
13812
+ const image = this._image, bounds = new Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest())._round(), this._map.latLngToLayerPoint(this._bounds.getSouthEast())._round()), size = bounds.getSize();
13864
13813
  setPosition(image, bounds.min);
13865
13814
  image.style.width = `${size.x}px`;
13866
13815
  image.style.height = `${size.y}px`;
@@ -13887,8 +13836,7 @@
13887
13836
  return this._bounds.getCenter();
13888
13837
  }
13889
13838
  };
13890
- //#endregion
13891
- //#region src/layer/VideoOverlay.js
13839
+ // src/layer/VideoOverlay.js
13892
13840
  /** @import {ImageOverlayOptions} from './ImageOverlay.js' */
13893
13841
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
13894
13842
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -13980,8 +13928,7 @@
13980
13928
  }
13981
13929
  }
13982
13930
  };
13983
- //#endregion
13984
- //#region src/layer/SVGOverlay.js
13931
+ // src/layer/SVGOverlay.js
13985
13932
  /** @import {ImageOverlayOptions} from './ImageOverlay.js' */
13986
13933
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
13987
13934
  /**
@@ -14026,8 +13973,7 @@
14026
13973
  if (this.options.className) el.classList.add(...splitWords(this.options.className));
14027
13974
  }
14028
13975
  };
14029
- //#endregion
14030
- //#region src/layer/marker/DivIcon.js
13976
+ // src/layer/marker/DivIcon.js
14031
13977
  /** @import {IconOptions} from './Icon.js' */
14032
13978
  /** @import {PointExpression} from '../../geometry/Point.js' */
14033
13979
  /**
@@ -14100,8 +14046,7 @@
14100
14046
  return null;
14101
14047
  }
14102
14048
  };
14103
- //#endregion
14104
- //#region src/layer/marker/SvgIcon.js
14049
+ // src/layer/marker/SvgIcon.js
14105
14050
  /** @import {DefaultIconOptions} from './DefaultIcon.js' */
14106
14051
  const svgNS = "http://www.w3.org/2000/svg";
14107
14052
  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";
@@ -14210,8 +14155,7 @@
14210
14155
  return div;
14211
14156
  }
14212
14157
  };
14213
- //#endregion
14214
- //#region src/layer/marker/MarkerClusterGroup.js
14158
+ // src/layer/marker/MarkerClusterGroup.js
14215
14159
  /** @import {Layer, LayerOptions} from '../Layer.js' */
14216
14160
  /** @import {MaplairEvent} from '../../core/Events.js' */
14217
14161
  /**
@@ -14501,8 +14445,7 @@
14501
14445
  if (map && this._shown.has(spider.clusterMarker)) map.addLayer(spider.clusterMarker);
14502
14446
  }
14503
14447
  };
14504
- //#endregion
14505
- //#region src/layer/tile/GridLayer.js
14448
+ // src/layer/tile/GridLayer.js
14506
14449
  /** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
14507
14450
  /** @import {MaplairMap} from '../../map/Map.js' */
14508
14451
  /** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */
@@ -14751,7 +14694,7 @@
14751
14694
  * @returns {boolean}
14752
14695
  */
14753
14696
  isLoading() {
14754
- return this._loading;
14697
+ return !!this._loading;
14755
14698
  }
14756
14699
  /**
14757
14700
  * Causes the layer to clear all the tiles and request them again.
@@ -15141,9 +15084,10 @@
15141
15084
  coords
15142
15085
  });
15143
15086
  }
15144
- if (this._noTilesToLoad()) {
15087
+ if (this._map && this._noTilesToLoad()) {
15145
15088
  this._loading = false;
15146
15089
  this.fire("load");
15090
+ if (!this._map) return;
15147
15091
  this._map._scheduleIdleCheck();
15148
15092
  if (!this._map._fadeAnimated) requestAnimationFrame(this._pruneTiles.bind(this));
15149
15093
  else this._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);
@@ -15176,9 +15120,7 @@
15176
15120
  return Object.values(this._tiles).every((t) => t.loaded);
15177
15121
  }
15178
15122
  };
15179
- //#endregion
15180
- //#region src/layer/tile/TileLayer.js
15181
- /** @import {Point} from '../../geometry/Point.js' */
15123
+ // src/layer/tile/TileLayer.js
15182
15124
  /** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */
15183
15125
  /** @import {TileEvent} from '../../core/Events.js' */
15184
15126
  const osmHosts = ["tile.openstreetmap.org", "tile.osm.org"];
@@ -15311,7 +15253,8 @@
15311
15253
  Object.assign(this.options, this._nonRetinaOptions);
15312
15254
  this._retina = window.devicePixelRatio > 1;
15313
15255
  if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
15314
- this.options.tileSize = Math.floor(this.options.tileSize / 2);
15256
+ const tileSize = this.options.tileSize;
15257
+ this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
15315
15258
  if (!this.options.zoomReverse) {
15316
15259
  this.options.zoomOffset++;
15317
15260
  this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
@@ -15437,8 +15380,8 @@
15437
15380
  done(null, tile);
15438
15381
  }
15439
15382
  _tileOnError(done, tile, e) {
15440
- const errorUrl = this.options.errorTileUrl;
15441
- if (errorUrl && tile.getAttribute("src") !== errorUrl) tile.src = errorUrl;
15383
+ const errorUrl = this.options.errorTileUrl, src = tile.getAttribute("src");
15384
+ if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
15442
15385
  done(e, tile);
15443
15386
  }
15444
15387
  _getZoomForUrl() {
@@ -15448,8 +15391,8 @@
15448
15391
  return zoom + zoomOffset;
15449
15392
  }
15450
15393
  _getSubdomain(tilePoint) {
15451
- const index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
15452
- return this.options.subdomains[index];
15394
+ const { subdomains } = this.options;
15395
+ return subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];
15453
15396
  }
15454
15397
  _abortLoading() {
15455
15398
  let i, tile;
@@ -15482,8 +15425,7 @@
15482
15425
  return Math.round(super._clampZoom(zoom));
15483
15426
  }
15484
15427
  };
15485
- //#endregion
15486
- //#region src/layer/tile/WMSTileLayer.js
15428
+ // src/layer/tile/WMSTileLayer.js
15487
15429
  /** @import {CRS} from '../../geo/crs/CRS.js' */
15488
15430
  /** @import {Point} from '../../geometry/Point.js' */
15489
15431
  /** @import {MaplairMap} from '../../map/Map.js' */
@@ -15580,8 +15522,9 @@
15580
15522
  _updateCrs() {
15581
15523
  this._crs = this.options.crs ?? this._map.options.crs;
15582
15524
  this._wmsVersion = parseFloat(this.wmsParams.version);
15583
- const projectionKey = this._wmsVersion >= 1.3 ? "crs" : "srs";
15584
- this.wmsParams[projectionKey] = this._crs.code;
15525
+ delete this.wmsParams.srs;
15526
+ delete this.wmsParams.crs;
15527
+ this.wmsParams[this._wmsVersion >= 1.3 ? "crs" : "srs"] = this._crs.code;
15585
15528
  }
15586
15529
  /**
15587
15530
  * Returns the map events the layer listens to, see `Layer`.
@@ -15650,6 +15593,7 @@
15650
15593
  */
15651
15594
  setParams(params, noRedraw) {
15652
15595
  Object.assign(this.wmsParams, params);
15596
+ if (this._map) this._updateCrs();
15653
15597
  if (!noRedraw) {
15654
15598
  this._keepCurrentTiles();
15655
15599
  this.redraw();
@@ -15657,8 +15601,7 @@
15657
15601
  return this;
15658
15602
  }
15659
15603
  };
15660
- //#endregion
15661
- //#region src/layer/vector/Canvas.js
15604
+ // src/layer/vector/Canvas.js
15662
15605
  /** @import {MaplairMap} from '../../map/Map.js' */
15663
15606
  /** @import {EventListener} from '../../core/Events.js' */
15664
15607
  /** @import {RendererOptions} from './Renderer.js' */
@@ -15815,10 +15758,8 @@
15815
15758
  this._requestRedraw(layer);
15816
15759
  }
15817
15760
  _updateDashArray(layer) {
15818
- if (typeof layer.options.dashArray === "string") {
15819
- const parts = layer.options.dashArray.split(DASH_SEPARATOR_RE$1);
15820
- layer.options._dashArray = parts.map((n) => Number(n)).filter((n) => !isNaN(n));
15821
- } else layer.options._dashArray = layer.options.dashArray;
15761
+ if (typeof layer.options.dashArray === "string") layer._dashArray = layer.options.dashArray.split(DASH_SEPARATOR_RE$1).map((n) => Number(n)).filter((n) => !isNaN(n));
15762
+ else layer._dashArray = layer.options.dashArray;
15822
15763
  }
15823
15764
  _requestRedraw(layer) {
15824
15765
  if (!this._map) return;
@@ -15889,14 +15830,10 @@
15889
15830
  }
15890
15831
  _updateCircle(layer) {
15891
15832
  if (!this._drawing || layer._empty()) return;
15892
- 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;
15893
- if (s !== 1) {
15894
- ctx.save();
15895
- ctx.scale(1, s);
15896
- }
15833
+ 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;
15897
15834
  ctx.beginPath();
15898
- ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);
15899
- if (s !== 1) ctx.restore();
15835
+ if (ry === r) ctx.arc(x, y, r, 0, Math.PI * 2);
15836
+ else ctx.ellipse(x, y, r, ry, 0, 0, Math.PI * 2);
15900
15837
  this._fillStroke(ctx, layer);
15901
15838
  }
15902
15839
  _fillStroke(ctx, layer) {
@@ -15908,7 +15845,7 @@
15908
15845
  }
15909
15846
  if (options.stroke && options.weight !== 0) {
15910
15847
  ctx.lineDashOffset = Number(options.dashOffset ?? 0);
15911
- ctx.setLineDash(options._dashArray ?? []);
15848
+ ctx.setLineDash(layer._dashArray ?? []);
15912
15849
  ctx.globalAlpha = options.opacity;
15913
15850
  ctx.lineWidth = options.weight;
15914
15851
  ctx.strokeStyle = options.color;
@@ -15998,8 +15935,7 @@
15998
15935
  this._requestRedraw(layer);
15999
15936
  }
16000
15937
  };
16001
- //#endregion
16002
- //#region src/layer/vector/Circle.js
15938
+ // src/layer/vector/Circle.js
16003
15939
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
16004
15940
  /** @import {CircleMarkerOptions} from './CircleMarker.js' */
16005
15941
  /**
@@ -16028,15 +15964,18 @@
16028
15964
  * @param {CircleOptions} [options]
16029
15965
  */
16030
15966
  constructor(latlng, options) {
15967
+ if (typeof options === "number") throw new Error("Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).");
16031
15968
  super(latlng, options);
16032
15969
  if (isNaN(this.options.radius)) throw new Error("Circle radius cannot be NaN");
16033
15970
  this.callInitHooks(Circle);
16034
15971
  }
16035
15972
  /**
16036
- * Returns the `LatLngBounds` of the path.
15973
+ * Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're
15974
+ * approximated on a sphere.
16037
15975
  * @returns {LatLngBounds}
16038
15976
  */
16039
15977
  getBounds() {
15978
+ if (!this._map) return this._latlng.toBounds(this._radius * 2);
16040
15979
  const half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];
16041
15980
  return new LatLngBounds(this._map.layerPointToLatLng(this._point.subtract(half)), this._map.layerPointToLatLng(this._point.add(half)));
16042
15981
  }
@@ -16057,8 +15996,7 @@
16057
15996
  this._updateBounds();
16058
15997
  }
16059
15998
  };
16060
- //#endregion
16061
- //#region src/layer/vector/Rectangle.js
15999
+ // src/layer/vector/Rectangle.js
16062
16000
  /** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
16063
16001
  /** @import {PolygonOptions} from './Polygon.js' */
16064
16002
  /**
@@ -16105,8 +16043,7 @@
16105
16043
  ];
16106
16044
  }
16107
16045
  };
16108
- //#endregion
16109
- //#region src/map/Hash.js
16046
+ // src/map/Hash.js
16110
16047
  /** @import {MaplairMap} from './Map.js' */
16111
16048
  /** @import {Layer} from '../layer/Layer.js' */
16112
16049
  const leadingHashRe = /^#/;
@@ -16338,8 +16275,7 @@
16338
16275
  ].filter(Boolean).join("&")}`;
16339
16276
  }
16340
16277
  };
16341
- //#endregion
16342
- //#region src/map/MapSync.js
16278
+ // src/map/MapSync.js
16343
16279
  /** @import {MaplairMap} from './Map.js' */
16344
16280
  /**
16345
16281
  * Options of `MapSync`.
@@ -16503,8 +16439,7 @@
16503
16439
  }
16504
16440
  }
16505
16441
  };
16506
- //#endregion
16507
- //#region src/map/handler/DisplaceHandler.js
16442
+ // src/map/handler/DisplaceHandler.js
16508
16443
  /** @import {MaplairMap} from '../Map.js' */
16509
16444
  /** @import {Layer} from '../../layer/Layer.js' */
16510
16445
  /** @import {LayerEvent} from '../../core/Events.js' */
@@ -16843,81 +16778,13 @@
16843
16778
  }
16844
16779
  return points;
16845
16780
  }
16846
- //#endregion
16847
- //#region src/Maplair.js
16781
+ // src/Maplair.js
16848
16782
  /**
16849
16783
  * A constant that represents the Maplair version in use.
16850
16784
  * @type {string}
16851
16785
  */
16852
16786
  const version = version$1;
16853
- //#endregion
16854
- //#region src/layer/marker/Marker.Rotation.js
16855
- const { _setPos: setPos } = Marker.prototype, { _onDrag: onDrag } = MarkerDrag.prototype;
16856
- /**
16857
- * Options of `Marker` for the rotation of marker icons, see the
16858
- * [marker rotation](#marker-setrotationangle).
16859
- * @typedef {object} MarkerRotationOptions
16860
- * @lends MarkerOptions
16861
- * @property {number} [rotationAngle=0] Rotation of the icon in degrees, clockwise, e.g.
16862
- * for the heading of a vehicle. On a rotated map, the angle is relative to the screen,
16863
- * or to north with `rotateWithView`. The shadow is not rotated.
16864
- * @property {string} [rotationOrigin] The CSS
16865
- * [`transform-origin`](https://developer.mozilla.org/docs/Web/CSS/transform-origin) to
16866
- * rotate the icon around, e.g. `'center'`. By default the anchor of the icon.
16867
- * @property {boolean} [rotateWithView=false] On a rotated map (see
16868
- * `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
16869
- * pointing in a geographic direction) instead of staying upright.
16870
- */
16871
- Marker.include({ options: {
16872
- rotationAngle: 0,
16873
- rotationOrigin: void 0,
16874
- rotateWithView: false
16875
- } });
16876
- /** @typedef {typeof markerRotationMethods} MarkerRotationMethods */
16877
- Marker.include({
16878
- /**
16879
- * Changes the [`rotationAngle`](#markeroptions-rotationangle) of the icon.
16880
- * @group Marker rotation
16881
- * @param {number} angle
16882
- * @returns {this}
16883
- */
16884
- setRotationAngle(angle) {
16885
- this.options.rotationAngle = angle;
16886
- return this.update();
16887
- },
16888
- /**
16889
- * Changes the [`rotationOrigin`](#markeroptions-rotationorigin) of the icon.
16890
- * @group Marker rotation
16891
- * @param {string} origin
16892
- * @returns {this}
16893
- */
16894
- setRotationOrigin(origin) {
16895
- this.options.rotationOrigin = origin;
16896
- return this.update();
16897
- },
16898
- _setPos(pos) {
16899
- setPos.call(this, pos);
16900
- this._rotateIcon();
16901
- },
16902
- _rotateIcon() {
16903
- const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing?.() ?? 0;
16904
- this._rotateElement(this._icon, bearing + (this.options.rotationAngle || 0), this.options.rotationOrigin);
16905
- this._rotateElement(this._shadow, bearing);
16906
- },
16907
- _rotateElement(el, angle, origin) {
16908
- if (!el) return;
16909
- if (angle % 360) {
16910
- el.style.transform += ` rotate(${angle}deg)`;
16911
- el.style.transformOrigin = origin ?? `${-parseFloat(el.style.marginLeft) || 0}px ${-parseFloat(el.style.marginTop) || 0}px`;
16912
- } else if (el.style.transformOrigin) el.style.transformOrigin = "";
16913
- }
16914
- });
16915
- MarkerDrag.include({ _onDrag(e) {
16916
- onDrag.call(this, e);
16917
- this._marker._rotateIcon();
16918
- } });
16919
- //#endregion
16920
- //#region src/control/RotateControl.js
16787
+ // src/control/RotateControl.js
16921
16788
  /** @import {ControlOptions} from './Control.js' */
16922
16789
  /** @import {MaplairMap} from '../map/Map.js' */
16923
16790
  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>";
@@ -17011,8 +16878,7 @@
17011
16878
  });
17012
16879
  }
17013
16880
  };
17014
- //#endregion
17015
- //#region src/map/Map.Rotation.js
16881
+ // src/map/Map.Rotation.js
17016
16882
  function normalizeBearing(bearing) {
17017
16883
  return (Number(bearing) % 360 + 360) % 360;
17018
16884
  }
@@ -17021,7 +16887,7 @@
17021
16887
  return new Point(point.x * cos - point.y * sin, point.x * sin + point.y * cos);
17022
16888
  }
17023
16889
  const rotatedMaps = /* @__PURE__ */ new WeakMap();
17024
- 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;
16890
+ 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;
17025
16891
  /**
17026
16892
  * Map options of the map rotation (`maplair/map-rotation`).
17027
16893
  * @typedef {object} RotationMapOptions
@@ -17267,7 +17133,7 @@
17267
17133
  },
17268
17134
  _updatePosition() {
17269
17135
  if (!this._map) return;
17270
- const map = this._map, pos = map.latLngToLayerPoint(this._latlng), anchor = map._rotateToPane(new Point(this._getAnchor()));
17136
+ const map = this._map, pos = map.latLngToLayerPoint(this._latlng)._round(), anchor = map._rotateToPane(new Point(this._getAnchor()));
17271
17137
  let offset = Point.from(this.options.offset);
17272
17138
  const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
17273
17139
  if (!transformed) offset = offset.add(pos).add(anchor);
@@ -17335,19 +17201,36 @@
17335
17201
  container.style.top = `${delta.y}px`;
17336
17202
  this._setContainerPosition(pos, `${-delta.x - margin[0]}px ${-delta.y - margin[1]}px`);
17337
17203
  } });
17338
- /** @typedef {typeof markerRotationMethods} MarkerMapRotationMethods */
17339
- Marker.include({
17340
17204
  /**
17341
- * Overrides `getEvents()` of `Marker` to update the marker on rotation.
17342
- * @internal
17343
- * @returns {Record<string, Function>}
17205
+ * Options of `Marker` for the map rotation.
17206
+ * @typedef {object} MarkerMapRotationOptions
17207
+ * @lends MarkerOptions
17208
+ * @property {boolean} [rotateWithView=false] On a rotated map (see
17209
+ * `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
17210
+ * pointing in a geographic direction) instead of staying upright. The `rotation` of
17211
+ * the marker is relative to the screen, or to north with `rotateWithView`.
17344
17212
  */
17345
- getEvents() {
17346
- return {
17347
- ...getMarkerEvents.call(this),
17348
- rotate: this.update
17349
- };
17350
- } });
17213
+ Marker.include({ options: { rotateWithView: false } });
17214
+ /** @typedef {typeof markerRotationMethods} MarkerMapRotationMethods */
17215
+ Marker.include({
17216
+ /**
17217
+ * Overrides `getEvents()` of `Marker` to update the marker on rotation.
17218
+ * @internal
17219
+ * @returns {Record<string, Function>}
17220
+ */
17221
+ getEvents() {
17222
+ return {
17223
+ ...getMarkerEvents.call(this),
17224
+ rotate: this.update
17225
+ };
17226
+ },
17227
+ _positionElements(pos) {
17228
+ positionMarkerElements.call(this, pos);
17229
+ const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing() ?? 0;
17230
+ if (!bearing) return;
17231
+ for (const el of [this._icon, this._shadow]) if (el) el.style.transform += ` rotate(${bearing}deg)`;
17232
+ }
17233
+ });
17351
17234
  /** @typedef {typeof markerDragRotationMethods} MarkerDragMapRotationMethods */
17352
17235
  MarkerDrag.include({ _adjustPan(e) {
17353
17236
  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();
@@ -17492,8 +17375,7 @@ getEvents() {
17492
17375
  this._panTimer = setTimeout(this._endPan.bind(this), gestureEndDelay);
17493
17376
  }
17494
17377
  });
17495
- //#endregion
17496
- //#region src/layer/marker/Marker.Move.js
17378
+ // src/layer/marker/Marker.Move.js
17497
17379
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
17498
17380
  /** @import {MaplairMap} from '../../map/Map.js' */
17499
17381
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -17503,9 +17385,8 @@ getEvents() {
17503
17385
  * @property {number} [duration=1000] The duration of the movement in milliseconds.
17504
17386
  * @property {number} [speed] The speed in meters (or units of the CRS) per second
17505
17387
  * instead of the `duration`.
17506
- * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to
17507
- * the heading of the movement (for icons pointing up; needs the marker rotation, see
17508
- * `rotationAngle`).
17388
+ * @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to
17389
+ * the heading of the movement (for icons pointing up).
17509
17390
  */
17510
17391
  const { onRemove } = Marker.prototype;
17511
17392
  /** @typedef {typeof markerMoveMethods} MarkerMoveMethods */
@@ -17544,7 +17425,7 @@ getEvents() {
17544
17425
  i++;
17545
17426
  }
17546
17427
  const from = points[i], to = points[i + 1];
17547
- if (options.rotate && !from.equals(to)) this.options.rotationAngle = this._heading(from, to);
17428
+ if (options.rotate && !from.equals(to)) this.options.rotation = this._heading(from, to);
17548
17429
  this.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));
17549
17430
  if (moved < total) this._moveFrame = requestAnimationFrame(frame);
17550
17431
  else {
@@ -17593,8 +17474,7 @@ getEvents() {
17593
17474
  return onRemove.call(this, map);
17594
17475
  }
17595
17476
  });
17596
- //#endregion
17597
- //#region src/layer/vector/Path.DashAnimation.js
17477
+ // src/layer/vector/Path.DashAnimation.js
17598
17478
  const DASH_SEPARATOR_RE = /[ ,]+/;
17599
17479
  const { _updateStyle: updateSvgStyle$1 } = SVG.prototype, { _fillStroke: fillStroke, _destroyContainer: destroyCanvasContainer } = Canvas.prototype;
17600
17480
  /**
@@ -17664,8 +17544,7 @@ getEvents() {
17664
17544
  return performance.now() / 1e3 * speed % length;
17665
17545
  }
17666
17546
  });
17667
- //#endregion
17668
- //#region src/layer/vector/Polyline.Decorations.js
17547
+ // src/layer/vector/Polyline.Decorations.js
17669
17548
  /**
17670
17549
  * Options of `Path` for arrowheads and text along lines (for `Polyline`s and
17671
17550
  * `Polygon`s). They are an optional feature: import this module to add the
@@ -17900,8 +17779,7 @@ getEvents() {
17900
17779
  }
17901
17780
  }
17902
17781
  });
17903
- //#endregion
17904
- //#region src/layer/GeoJSON.Load.js
17782
+ // src/layer/GeoJSON.Load.js
17905
17783
  /** @import {GeoJsonObject} from 'geojson' */
17906
17784
  /** @import {MaplairEvent} from '../core/Events.js' */
17907
17785
  /**
@@ -17958,8 +17836,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
17958
17836
  GeoJSON.addInitHook(function() {
17959
17837
  if (this.options.url) this.load(this.options.url).catch(() => {});
17960
17838
  });
17961
- //#endregion
17962
- //#region src/layer/vector/Path.ZoomStyles.js
17839
+ // src/layer/vector/Path.ZoomStyles.js
17963
17840
  /**
17964
17841
  * A zoom-dependent style value, of the `weight` option of paths and the `radius` of
17965
17842
  * circle markers: either a function of the zoom or an object of zoom stops
@@ -18031,8 +17908,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
18031
17908
  Path.addInitHook(function() {
18032
17909
  this._takeZoomStyles(this.options);
18033
17910
  });
18034
- //#endregion
18035
- //#region src/Maplair.all.js
17911
+ // src/Maplair.all.js
18036
17912
  var Maplair_all_exports = /* @__PURE__ */ __exportAll({
18037
17913
  AttributionControl: () => AttributionControl,
18038
17914
  BlanketOverlay: () => BlanketOverlay,
@@ -18082,11 +17958,13 @@ load(source, fetchOptions = this.options.fetchOptions) {
18082
17958
  LeafletMap: () => MaplairMap,
18083
17959
  LegendControl: () => LegendControl,
18084
17960
  LineUtil: () => LineUtil_exports,
17961
+ LonLatProjection: () => LonLatProjection,
18085
17962
  Map: () => MaplairMap,
18086
17963
  MapSync: () => MapSync,
18087
17964
  MaplairMap: () => MaplairMap,
18088
17965
  Marker: () => Marker,
18089
17966
  MarkerClusterGroup: () => MarkerClusterGroup,
17967
+ MercatorProjection: () => MercatorProjection,
18090
17968
  MiniMapControl: () => MiniMapControl,
18091
17969
  Path: () => Path,
18092
17970
  PinchZoomHandler: () => PinchZoomHandler,
@@ -18095,7 +17973,6 @@ load(source, fetchOptions = this.options.fetchOptions) {
18095
17973
  Polygon: () => Polygon,
18096
17974
  Polyline: () => Polyline,
18097
17975
  Popup: () => Popup,
18098
- Projection: () => projection_exports,
18099
17976
  Rectangle: () => Rectangle,
18100
17977
  Renderer: () => Renderer,
18101
17978
  RotateControl: () => RotateControl,
@@ -18106,6 +17983,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
18106
17983
  SearchControl: () => SearchControl,
18107
17984
  SideBySideControl: () => SideBySideControl,
18108
17985
  SimpleCRS: () => SimpleCRS,
17986
+ SphericalMercatorProjection: () => SphericalMercatorProjection,
18109
17987
  SvgIcon: () => SvgIcon,
18110
17988
  TapDragZoomHandler: () => TapDragZoomHandler,
18111
17989
  TapHoldHandler: () => TapHoldHandler,
@@ -18121,13 +17999,11 @@ load(source, fetchOptions = this.options.fetchOptions) {
18121
17999
  displace: () => displace,
18122
18000
  version: () => version
18123
18001
  });
18124
- //#endregion
18125
- //#region build/global.js
18002
+ // build/global.js
18126
18003
  const isNamespace = (value) => value?.[Symbol.toStringTag] === "Module";
18127
18004
  function toPlain(ns) {
18128
18005
  return Object.fromEntries(Object.entries(ns).map(([key, value]) => [key, isNamespace(value) ? toPlain(value) : value]));
18129
18006
  }
18130
- //#endregion
18131
18007
  return toPlain(Maplair_all_exports);
18132
18008
  });
18133
18009