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,11 +1,19 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
+ import { off, on } from "../../dom/DomEvent.js";
2
3
  import { getPosition, setPosition } from "../../dom/DomUtil.js";
3
4
  import { Bounds } from "../../geometry/Bounds.js";
4
5
  import { Handler } from "../../core/Handler.js";
5
6
  import { Draggable } from "../../dom/Draggable.js";
6
- //#region src/layer/marker/Marker.Drag.js
7
+ // src/layer/marker/Marker.Drag.js
7
8
  /** @import {Marker, MarkerMoveEvent} from './Marker.js' */
8
9
  /** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
10
+ /** @type {Record<string, [number, number]>} */
11
+ const arrows = {
12
+ ArrowLeft: [-1, 0],
13
+ ArrowRight: [1, 0],
14
+ ArrowUp: [0, -1],
15
+ ArrowDown: [0, 1]
16
+ };
9
17
  /**
10
18
  * The handler of `Marker` which makes the markers draggable, see the
11
19
  * [`dragging`](#marker-dragging) property of markers and its `draggable` option.
@@ -40,18 +48,21 @@ var MarkerDrag = class MarkerDrag extends Handler {
40
48
  drag: this._onDrag,
41
49
  dragend: this._onDragEnd
42
50
  }, this).enable();
51
+ on(icon, "keydown keyup blur", this._onKey, this);
43
52
  icon.classList.add("maplair-marker-draggable");
44
53
  }
45
54
  /**
46
55
  * Makes the icon of the marker undraggable, called by `disable()`.
47
56
  */
48
57
  removeHooks() {
58
+ this._keyOffset = null;
49
59
  this._draggable.off({
50
60
  dragstart: this._onDragStart,
51
61
  predrag: this._onPreDrag,
52
62
  drag: this._onDrag,
53
63
  dragend: this._onDragEnd
54
64
  }, this).disable();
65
+ off(this._draggable._element, "keydown keyup blur", this._onKey, this);
55
66
  this._marker._icon?.classList.remove("maplair-marker-draggable");
56
67
  }
57
68
  /**
@@ -86,8 +97,8 @@ var MarkerDrag = class MarkerDrag extends Handler {
86
97
  }
87
98
  }
88
99
  _onDrag(e) {
89
- const marker = this._marker, shadow = marker._shadow, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
90
- if (shadow) setPosition(shadow, iconPos);
100
+ const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
101
+ marker._positionElements(iconPos);
91
102
  marker._latlng = latlng;
92
103
  e.latlng = latlng;
93
104
  e.oldLatLng = this._oldLatLng;
@@ -98,8 +109,36 @@ var MarkerDrag = class MarkerDrag extends Handler {
98
109
  delete this._oldLatLng;
99
110
  this._marker.fire("moveend").fire("dragend", e);
100
111
  }
112
+ /** @param {KeyboardEvent|FocusEvent} e */
113
+ _onKey(e) {
114
+ const k = e, dir = arrows[k.key], draggable = this._draggable, { options, _map: map } = this._marker;
115
+ if (e.type !== "keydown") {
116
+ if (this._keyOffset) {
117
+ this._keyOffset = null;
118
+ draggable.finishDrag();
119
+ }
120
+ } else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {
121
+ e.preventDefault();
122
+ if (!this._keyOffset) {
123
+ if (Draggable._dragging) return;
124
+ Draggable._dragging = draggable;
125
+ draggable._startPos = getPosition(draggable._element);
126
+ draggable._moved = draggable._moving = true;
127
+ this._keyOffset = new Point(0, 0);
128
+ draggable.fire("dragstart");
129
+ }
130
+ const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
131
+ this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
132
+ draggable._newPos = draggable._startPos.add(this._keyOffset);
133
+ setPosition(draggable._element, draggable._newPos);
134
+ draggable.fire("drag", { originalEvent: k });
135
+ if (options.autoPan) map.panInside(this._marker._latlng, {
136
+ padding: options.autoPanPadding,
137
+ animate: false
138
+ });
139
+ }
140
+ }
101
141
  };
102
- //#endregion
103
142
  export { MarkerDrag };
104
143
 
105
144
  //# sourceMappingURL=Marker.Drag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.Drag.js","names":["DomUtil.getPosition"],"sources":["../../../../src/layer/marker/Marker.Drag.js"],"sourcesContent":["import {Handler} from '../../core/Handler.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Draggable} from '../../dom/Draggable.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Marker, MarkerMoveEvent} from './Marker.js' */\n/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */\n\n/**\n * The handler of `Marker` which makes the markers draggable, see the\n * [`dragging`](#marker-dragging) property of markers and its `draggable` option.\n *\n * @fires Marker#dragstart {MaplairEvent} Fired when the user starts dragging the marker.\n * @fires Marker#movestart {MaplairEvent} Fired when the marker starts moving (because of\n * dragging).\n * @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.\n * @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (because of\n * dragging).\n */\nexport class MarkerDrag extends Handler {\n\t/**\n\t * Creates the dragging handler of the given marker.\n\t * @param {Marker} marker\n\t */\n\tconstructor(marker) {\n\t\tsuper(marker._map);\n\t\tthis._marker = marker;\n\n\t\tthis.callInitHooks(MarkerDrag);\n\t}\n\n\t/**\n\t * Makes the icon of the marker draggable, called by `enable()`.\n\t */\n\taddHooks() {\n\t\tconst icon = this._marker._icon;\n\n\t\tif (!this._draggable) {\n\t\t\tthis._draggable = new Draggable(icon);\n\t\t}\n\n\t\tthis._draggable.on({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).enable();\n\n\t\ticon.classList.add('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Makes the icon of the marker undraggable, called by `disable()`.\n\t */\n\tremoveHooks() {\n\t\tthis._draggable.off({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).disable();\n\n\t\tthis._marker._icon?.classList.remove('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Returns `true` if the marker has been moved by the current or last drag.\n\t * @returns {boolean}\n\t */\n\tmoved() {\n\t\treturn this._draggable?._moved;\n\t}\n\n\t_adjustPan(e) {\n\t\tconst marker = this._marker,\n\t\tmap = marker._map,\n\t\tspeed = this._marker.options.autoPanSpeed,\n\t\tpadding = this._marker.options.autoPanPadding,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tbounds = map.getPixelBounds(),\n\t\torigin = map.getPixelOrigin();\n\n\t\tconst panBounds = new Bounds(\n\t\t\tbounds.min._subtract(origin).add(padding),\n\t\t\tbounds.max._subtract(origin).subtract(padding)\n\t\t);\n\n\t\tif (!panBounds.contains(iconPos)) {\n\t\t\t// Compute incremental movement\n\t\t\tconst movement = new Point(\n\t\t\t\t(Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) -\n\t\t\t\t(Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x),\n\n\t\t\t\t(Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) -\n\t\t\t\t(Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)\n\t\t\t).multiplyBy(speed);\n\n\t\t\tmap.panBy(movement, {animate: false});\n\n\t\t\tthis._draggable._newPos._add(movement);\n\t\t\tthis._draggable._startPos._add(movement);\n\n\t\t\tDomUtil.setPosition(marker._icon, this._draggable._newPos);\n\t\t\tthis._onDrag(e);\n\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDragStart() {\n\t\tthis._oldLatLng = this._marker.getLatLng();\n\n\t\t// When using ES6 imports it could not be set when `Popup` was not imported as well\n\t\tthis._marker.closePopup?.();\n\n\t\tthis._marker\n\t\t\t.fire('movestart')\n\t\t\t.fire('dragstart');\n\t}\n\n\t_onPreDrag(e) {\n\t\tif (this._marker.options.autoPan) {\n\t\t\tcancelAnimationFrame(this._panRequest);\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDrag(e) {\n\t\tconst marker = this._marker,\n\t\tshadow = marker._shadow,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// update shadow position\n\t\tif (shadow) {\n\t\t\tDomUtil.setPosition(shadow, iconPos);\n\t\t}\n\n\t\tmarker._latlng = latlng;\n\t\te.latlng = latlng;\n\t\te.oldLatLng = this._oldLatLng;\n\n\t\tmarker\n\t\t\t.fire('move', e)\n\t\t\t.fire('drag', e);\n\t}\n\n\t_onDragEnd(e) {\n\t\tcancelAnimationFrame(this._panRequest);\n\n\t\tdelete this._oldLatLng;\n\t\tthis._marker\n\t\t\t.fire('moveend')\n\t\t\t.fire('dragend', e);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,aAAb,MAAa,mBAAmB,QAAQ;;;;;CAKvC,YAAY,QAAQ;EACnB,MAAM,OAAO,IAAI;EACjB,KAAK,UAAU;EAEf,KAAK,cAAc,UAAU;CAC9B;;;;CAKA,WAAW;EACV,MAAM,OAAO,KAAK,QAAQ;EAE1B,IAAI,CAAC,KAAK,YACT,KAAK,aAAa,IAAI,UAAU,IAAI;EAGrC,KAAK,WAAW,GAAG;GAClB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,OAAO;EAEhB,KAAK,UAAU,IAAI,0BAA0B;CAC9C;;;;CAKA,cAAc;EACb,KAAK,WAAW,IAAI;GACnB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,QAAQ;EAEjB,KAAK,QAAQ,OAAO,UAAU,OAAO,0BAA0B;CAChE;;;;;CAMA,QAAQ;EACP,OAAO,K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AAK,QACH,KAAK,WAAW,CAAC,CACjB,KAAK,WAAW;CACnB;CAEA,WAAW,GAAG;EACb,IAAI,KAAK,QAAQ,QAAQ,SAAS;GACjC,qBAAqB,KAAK,WAAW;GACrC,KAAK,cAAc,sBAAsB,KAAK,WAAW,KAAK,MAAM,CAAC,CAAC;EACvE;CACD;CAEA,QAAQ,GAAG;EACV,MAAM,SAAS,KAAK,SACpB,SAAS,OAAO,SAChB,UAAUA,YAAoB,OAAO,KAAK,GAC1C,SAAS,OAAO,KAAK,mBAAmB,OAAO;EAG/C,IAAI,QACH,YAAoB,QAAQ,OAAO;EAGpC,OAAO,UAAU;EACjB,EAAE,SAAS;EACX,EAAE,YAAY,KAAK;EAEnB,OACE,KAAK,QAAQ,CAAC,CAAC,CACf,KAAK,QAAQ,CAAC;CACjB;CAEA,WAAW,GAAG;EACb,qBAAqB,KAAK,WAAW;EAErC,OAAO,KAAK;EACZ,KAAK,QACH,KAAK,SAAS,CAAC,CACf,KAAK,WAAW,CAAC;CACpB;AACD"}
1
+ {"version":3,"file":"Marker.Drag.js","names":["DomUtil.getPosition"],"sources":["../../../../src/layer/marker/Marker.Drag.js"],"sourcesContent":["import {Handler} from '../../core/Handler.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Draggable} from '../../dom/Draggable.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Marker, MarkerMoveEvent} from './Marker.js' */\n/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */\n\n/** @type {Record<string, [number, number]>} */\nconst arrows = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]};\n\n/**\n * The handler of `Marker` which makes the markers draggable, see the\n * [`dragging`](#marker-dragging) property of markers and its `draggable` option.\n *\n * @fires Marker#dragstart {MaplairEvent} Fired when the user starts dragging the marker.\n * @fires Marker#movestart {MaplairEvent} Fired when the marker starts moving (because of\n * dragging).\n * @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.\n * @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (because of\n * dragging).\n */\nexport class MarkerDrag extends Handler {\n\t/**\n\t * Creates the dragging handler of the given marker.\n\t * @param {Marker} marker\n\t */\n\tconstructor(marker) {\n\t\tsuper(marker._map);\n\t\tthis._marker = marker;\n\n\t\tthis.callInitHooks(MarkerDrag);\n\t}\n\n\t/**\n\t * Makes the icon of the marker draggable, called by `enable()`.\n\t */\n\taddHooks() {\n\t\tconst icon = this._marker._icon;\n\n\t\tif (!this._draggable) {\n\t\t\tthis._draggable = new Draggable(icon);\n\t\t}\n\n\t\tthis._draggable.on({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).enable();\n\n\t\tDomEvent.on(icon, 'keydown keyup blur', this._onKey, this);\n\n\t\ticon.classList.add('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Makes the icon of the marker undraggable, called by `disable()`.\n\t */\n\tremoveHooks() {\n\t\tthis._keyOffset = null; // disabling the Draggable below ends a keyboard drag in progress, as it does a pointer drag\n\n\t\tthis._draggable.off({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).disable();\n\n\t\tDomEvent.off(this._draggable._element, 'keydown keyup blur', this._onKey, this);\n\n\t\tthis._marker._icon?.classList.remove('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Returns `true` if the marker has been moved by the current or last drag.\n\t * @returns {boolean}\n\t */\n\tmoved() {\n\t\treturn this._draggable?._moved;\n\t}\n\n\t_adjustPan(e) {\n\t\tconst marker = this._marker,\n\t\tmap = marker._map,\n\t\tspeed = this._marker.options.autoPanSpeed,\n\t\tpadding = this._marker.options.autoPanPadding,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tbounds = map.getPixelBounds(),\n\t\torigin = map.getPixelOrigin();\n\n\t\tconst panBounds = new Bounds(\n\t\t\tbounds.min._subtract(origin).add(padding),\n\t\t\tbounds.max._subtract(origin).subtract(padding)\n\t\t);\n\n\t\tif (!panBounds.contains(iconPos)) {\n\t\t\t// Compute incremental movement\n\t\t\tconst movement = new Point(\n\t\t\t\t(Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) -\n\t\t\t\t(Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x),\n\n\t\t\t\t(Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) -\n\t\t\t\t(Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)\n\t\t\t).multiplyBy(speed);\n\n\t\t\tmap.panBy(movement, {animate: false});\n\n\t\t\tthis._draggable._newPos._add(movement);\n\t\t\tthis._draggable._startPos._add(movement);\n\n\t\t\tDomUtil.setPosition(marker._icon, this._draggable._newPos);\n\t\t\tthis._onDrag(e);\n\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDragStart() {\n\t\tthis._oldLatLng = this._marker.getLatLng();\n\n\t\t// When using ES6 imports it could not be set when `Popup` was not imported as well\n\t\tthis._marker.closePopup?.();\n\n\t\tthis._marker\n\t\t\t.fire('movestart')\n\t\t\t.fire('dragstart');\n\t}\n\n\t_onPreDrag(e) {\n\t\tif (this._marker.options.autoPan) {\n\t\t\tcancelAnimationFrame(this._panRequest);\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDrag(e) {\n\t\tconst marker = this._marker,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// Draggable only moved the icon and dropped its rotation\n\t\tmarker._positionElements(iconPos);\n\n\t\tmarker._latlng = latlng;\n\t\te.latlng = latlng;\n\t\te.oldLatLng = this._oldLatLng;\n\n\t\tmarker\n\t\t\t.fire('move', e)\n\t\t\t.fire('drag', e);\n\t}\n\n\t_onDragEnd(e) {\n\t\tcancelAnimationFrame(this._panRequest);\n\n\t\tdelete this._oldLatLng;\n\t\tthis._marker\n\t\t\t.fire('moveend')\n\t\t\t.fire('dragend', e);\n\t}\n\n\t// Arrow keys move a focused marker. Holding a key down is one drag, driven through the Draggable like a pointer\n\t// drag (so the two can't overlap), and ends on keyup or blur.\n\t/** @param {KeyboardEvent|FocusEvent} e */\n\t_onKey(e) {\n\t\tconst k = /** @type {KeyboardEvent} */ (e), // all but blur\n\t\tdir = arrows[k.key],\n\t\tdraggable = this._draggable,\n\t\t{options, _map: map} = this._marker;\n\n\t\tif (e.type !== 'keydown') {\n\t\t\tif (this._keyOffset) {\n\t\t\t\tthis._keyOffset = null;\n\t\t\t\tdraggable.finishDrag();\n\t\t\t}\n\n\t\t} else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {\n\t\t\te.preventDefault(); // don't scroll the page\n\n\t\t\tif (!this._keyOffset) {\n\t\t\t\tif (Draggable._dragging) { return; }\n\t\t\t\tDraggable._dragging = draggable;\n\t\t\t\tdraggable._startPos = DomUtil.getPosition(draggable._element);\n\t\t\t\tdraggable._moved = draggable._moving = true;\n\t\t\t\tthis._keyOffset = new Point(0, 0);\n\t\t\t\tdraggable.fire('dragstart');\n\t\t\t}\n\n\t\t\t// in container pixels, which the map rotation (if any) turns to the frame of the rotated pane\n\t\t\tconst offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);\n\t\t\tthis._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);\n\t\t\t// not through _updatePosition, whose predrag would start the pointer autoPan loop\n\t\t\tdraggable._newPos = draggable._startPos.add(this._keyOffset);\n\t\t\tDomUtil.setPosition(draggable._element, draggable._newPos);\n\t\t\tdraggable.fire('drag', {originalEvent: k});\n\n\t\t\tif (options.autoPan) {\n\t\t\t\tmap.panInside(this._marker._latlng, {padding: options.autoPanPadding, animate: false});\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,SAAS;CAAC,WAAW,CAAC,IAAI,CAAC;CAAG,YAAY,CAAC,GAAG,CAAC;CAAG,SAAS,CAAC,GAAG,EAAE;CAAG,WAAW,CAAC,GAAG,CAAC;AAAC;;;;;;;;;;;;;AAc3F,IAAa,aAAb,MAAa,mBAAmB,QAAQ;;;;;CAKvC,YAAY,QAAQ;EACnB,MAAM,OAAO,IAAI;EACjB,KAAK,UAAU;EAEf,KAAK,cAAc,UAAU;CAC9B;;;;CAKA,WAAW;EACV,MAAM,OAAO,KAAK,QAAQ;EAE1B,IAAI,CAAC,KAAK,YACT,KAAK,aAAa,IAAI,UAAU,IAAI;EAGrC,KAAK,WAAW,GAAG;GAClB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,OAAO;EAEhB,GAAY,MAAM,sBAAsB,KAAK,QAAQ,IAAI;EAEzD,KAAK,UAAU,IAAI,0BAA0B;CAC9C;;;;CAKA,cAAc;EACb,KAAK,aAAa;EAElB,KAAK,WAAW,IAAI;GACnB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,QAAQ;EAEjB,IAAa,KAAK,WAAW,UAAU,sBAAsB,KAAK,QAAQ,IAAI;EAE9E,KAAK,QAAQ,OAAO,UAAU,OAAO,0BAA0B;CAChE;;;;;CAMA,QAAQ;EACP,OAAO,KAAK,YAAY;CACzB;CAEA,WAAW,GAAG;EACb,MAAM,SAAS,KAAK,SACpB,MA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U,UAAU,UAAU,IAAI,KAAK,UAAU;GAC3D,YAAoB,UAAU,UAAU,UAAU,OAAO;GACzD,UAAU,KAAK,QAAQ,EAAC,eAAe,EAAC,CAAC;GAEzC,IAAI,QAAQ,SACX,IAAI,UAAU,KAAK,QAAQ,SAAS;IAAC,SAAS,QAAQ;IAAgB,SAAS;GAAK,CAAC;EAEvF;CACD;AACD"}
@@ -1,7 +1,7 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
2
  import { LatLng } from "../../geo/LatLng.js";
3
3
  import { Marker } from "./Marker.js";
4
- //#region src/layer/marker/Marker.Move.js
4
+ // src/layer/marker/Marker.Move.js
5
5
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
6
6
  /** @import {MaplairMap} from '../../map/Map.js' */
7
7
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -11,9 +11,8 @@ import { Marker } from "./Marker.js";
11
11
  * @property {number} [duration=1000] The duration of the movement in milliseconds.
12
12
  * @property {number} [speed] The speed in meters (or units of the CRS) per second
13
13
  * instead of the `duration`.
14
- * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to
15
- * the heading of the movement (for icons pointing up; needs the marker rotation, see
16
- * `rotationAngle`).
14
+ * @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to
15
+ * the heading of the movement (for icons pointing up).
17
16
  */
18
17
  const { onRemove } = Marker.prototype;
19
18
  /** @typedef {typeof markerMoveMethods} MarkerMoveMethods */
@@ -52,7 +51,7 @@ Marker.include({
52
51
  i++;
53
52
  }
54
53
  const from = points[i], to = points[i + 1];
55
- if (options.rotate && !from.equals(to)) this.options.rotationAngle = this._heading(from, to);
54
+ if (options.rotate && !from.equals(to)) this.options.rotation = this._heading(from, to);
56
55
  this.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));
57
56
  if (moved < total) this._moveFrame = requestAnimationFrame(frame);
58
57
  else {
@@ -101,6 +100,5 @@ Marker.include({
101
100
  return onRemove.call(this, map);
102
101
  }
103
102
  });
104
- //#endregion
105
103
 
106
104
  //# sourceMappingURL=Marker.Move.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.Move.js","names":[],"sources":["../../../../src/layer/marker/Marker.Move.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n\n/**\n * Options of the movement of markers, see `moveAlong()`.\n * @typedef {object} MarkerMovementOptions\n * @property {number} [duration=1000] The duration of the movement in milliseconds.\n * @property {number} [speed] The speed in meters (or units of the CRS) per second\n * instead of the `duration`.\n * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to\n * the heading of the movement (for icons pointing up; needs the marker rotation, see\n * `rotationAngle`).\n */\n\n// The methods extended below\nconst {onRemove} = Marker.prototype;\n\n/**\n * Methods of `Marker` for the animated movement of markers, an optional feature: import\n * this module to add `moveTo()`, `moveAlong()`, `stopMoving()` and `isMoving()` to\n * `Marker`.\n *\n * ```js\n * import 'maplair/marker-movement';\n *\n * marker.moveAlong([[47.27, 11.40], [47.28, 11.42]], {duration: 5000});\n * ```\n *\n * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n * @lends Marker.prototype\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (after dragging\n * or `moveAlong()`).\n */\nconst markerMoveMethods = {\n\t/**\n\t * Moves the marker smoothly to `latlng`, see `moveAlong()`.\n\t * @group Marker movement\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveTo(latlng, options) {\n\t\treturn this.moveAlong([latlng], options);\n\t},\n\n\t/**\n\t * Moves the marker smoothly along the given points, frame by frame at a constant\n\t * speed, e.g. to follow a vehicle or to replay a track. Fires `move` with each\n\t * frame and `moveend` at the end. A new movement or `stopMoving()` stops it; with\n\t * [reduced motion](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),\n\t * the marker jumps to the end.\n\t * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n\t * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n\t * @group Marker movement\n\t * @param {LatLngExpression[]} latlngs\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveAlong(latlngs, options = {}) {\n\t\tthis.stopMoving();\n\n\t\tconst points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],\n\t\tlengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),\n\t\ttotal = lengths.reduce((sum, length) => sum + length, 0),\n\t\tduration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),\n\t\tstart = performance.now();\n\n\t\tconst frame = () => {\n\t\t\t// the distance moved, at a constant speed\n\t\t\tlet distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total,\n\t\t\ti = 0;\n\t\t\tconst moved = distance;\n\t\t\twhile (i < lengths.length - 1 && distance > lengths[i]) {\n\t\t\t\tdistance -= lengths[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tconst from = points[i], to = points[i + 1];\n\t\t\tif (options.rotate && !from.equals(to)) {\n\t\t\t\tthis.options.rotationAngle = this._heading(from, to);\n\t\t\t}\n\t\t\tthis.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));\n\n\t\t\tif (moved < total) {\n\t\t\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\t\t} else {\n\t\t\t\tthis._moveFrame = null;\n\t\t\t\tthis.fire('moveend');\n\t\t\t}\n\t\t};\n\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Stops the movement of `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {this}\n\t */\n\tstopMoving() {\n\t\tcancelAnimationFrame(this._moveFrame);\n\t\tthis._moveFrame = null;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` while the marker moves with `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {boolean}\n\t */\n\tisMoving() {\n\t\treturn !!this._moveFrame;\n\t},\n\n\t// A straight line in the projection of the map (if any)\n\t_interpolate(from, to, t) {\n\t\tconst crs = this._map?.options.crs;\n\t\tif (!crs) {\n\t\t\treturn new LatLng(from.lat + (to.lat - from.lat) * t, from.lng + (to.lng - from.lng) * t);\n\t\t}\n\t\tconst a = crs.projection.project(from),\n\t\tb = crs.projection.project(to);\n\t\treturn crs.projection.unproject(a.add(b.subtract(a).multiplyBy(t)));\n\t},\n\n\t// The heading from `from` to `to` in degrees clockwise from north, relative to\n\t// the screen unless the icon rotates with the view\n\t_heading(from, to) {\n\t\tconst crs = this._map?.options.crs,\n\t\ta = crs ? crs.latLngToPoint(from, 0) : new Point(from.lng, -from.lat),\n\t\tb = crs ? crs.latLngToPoint(to, 0) : new Point(to.lng, -to.lat),\n\t\theading = Math.atan2(b.x - a.x, a.y - b.y) * 180 / Math.PI;\n\t\treturn heading - (this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0));\n\t},\n\n\t/**\n\t * Stops the movement when the marker is removed from the map.\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis.stopMoving();\n\t\treturn onRemove.call(this, map);\n\t}\n};\n/** @typedef {typeof markerMoveMethods} MarkerMoveMethods */\n\nMarker.include(markerMoveMethods);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,EAAC,aAAY,OAAO;;AAoI1B,OAAO,QAAQ;;;;;;;;CAzGd,OAAO,QAAQ,SAAS;EACvB,OAAO,KAAK,UAAU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AAO;CACR;;;;;;CAOA,WAAW;EACV,OAAO,CAAC,CAAC,KAAK;CACf;CAGA,aAAa,MAAM,IAAI,GAAG;EACzB,MAAM,MAAM,KAAK,MAAM,QAAQ;EAC/B,IAAI,CAAC,KACJ,OAAO,IAAI,OAAO,KAAK,OAAO,GAAG,MAAM,KAAK,OAAO,GAAG,KAAK,OAAO,GAAG,MAAM,KAAK,OAAO,CAAC;EAEzF,MAAM,IAAI,IAAI,WAAW,QAAQ,IAAI,GACrC,IAAI,IAAI,WAAW,QAAQ,EAAE;EAC7B,OAAO,IAAI,WAAW,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;CACnE;CAIA,SAAS,MAAM,IAAI;EAClB,MAAM,MAAM,KAAK,MAAM,QAAQ,KAC/B,IAAI,MAAM,IAAI,cAAc,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,KAAK,GAAG,GACpE,IAAI,MAAM,IAAI,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG;EAE9D,OADU,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,KAAK,MACtC,KAAK,QAAQ,iBAAiB,IAAK,KAAK,MAAM,aAAa,KAAK;CACnF;;;;;;CAOA,SAAS,KAAK;EACb,KAAK,WAAW;EAChB,OAAO,SAAS,KAAK,MAAM,GAAG;CAC/B;AAI8B,CAAC"}
1
+ {"version":3,"file":"Marker.Move.js","names":[],"sources":["../../../../src/layer/marker/Marker.Move.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n\n/**\n * Options of the movement of markers, see `moveAlong()`.\n * @typedef {object} MarkerMovementOptions\n * @property {number} [duration=1000] The duration of the movement in milliseconds.\n * @property {number} [speed] The speed in meters (or units of the CRS) per second\n * instead of the `duration`.\n * @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to\n * the heading of the movement (for icons pointing up).\n */\n\n// The methods extended below\nconst {onRemove} = Marker.prototype;\n\n/**\n * Methods of `Marker` for the animated movement of markers, an optional feature: import\n * this module to add `moveTo()`, `moveAlong()`, `stopMoving()` and `isMoving()` to\n * `Marker`.\n *\n * ```js\n * import 'maplair/marker-movement';\n *\n * marker.moveAlong([[47.27, 11.40], [47.28, 11.42]], {duration: 5000});\n * ```\n *\n * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n * @lends Marker.prototype\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (after dragging\n * or `moveAlong()`).\n */\nconst markerMoveMethods = {\n\t/**\n\t * Moves the marker smoothly to `latlng`, see `moveAlong()`.\n\t * @group Marker movement\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveTo(latlng, options) {\n\t\treturn this.moveAlong([latlng], options);\n\t},\n\n\t/**\n\t * Moves the marker smoothly along the given points, frame by frame at a constant\n\t * speed, e.g. to follow a vehicle or to replay a track. Fires `move` with each\n\t * frame and `moveend` at the end. A new movement or `stopMoving()` stops it; with\n\t * [reduced motion](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),\n\t * the marker jumps to the end.\n\t * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n\t * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n\t * @group Marker movement\n\t * @param {LatLngExpression[]} latlngs\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveAlong(latlngs, options = {}) {\n\t\tthis.stopMoving();\n\n\t\tconst points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],\n\t\tlengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),\n\t\ttotal = lengths.reduce((sum, length) => sum + length, 0),\n\t\tduration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),\n\t\tstart = performance.now();\n\n\t\tconst frame = () => {\n\t\t\t// the distance moved, at a constant speed\n\t\t\tlet distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total,\n\t\t\ti = 0;\n\t\t\tconst moved = distance;\n\t\t\twhile (i < lengths.length - 1 && distance > lengths[i]) {\n\t\t\t\tdistance -= lengths[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tconst from = points[i], to = points[i + 1];\n\t\t\tif (options.rotate && !from.equals(to)) {\n\t\t\t\tthis.options.rotation = this._heading(from, to);\n\t\t\t}\n\t\t\tthis.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));\n\n\t\t\tif (moved < total) {\n\t\t\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\t\t} else {\n\t\t\t\tthis._moveFrame = null;\n\t\t\t\tthis.fire('moveend');\n\t\t\t}\n\t\t};\n\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Stops the movement of `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {this}\n\t */\n\tstopMoving() {\n\t\tcancelAnimationFrame(this._moveFrame);\n\t\tthis._moveFrame = null;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` while the marker moves with `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {boolean}\n\t */\n\tisMoving() {\n\t\treturn !!this._moveFrame;\n\t},\n\n\t// A straight line in the projection of the map (if any)\n\t_interpolate(from, to, t) {\n\t\tconst crs = this._map?.options.crs;\n\t\tif (!crs) {\n\t\t\treturn new LatLng(from.lat + (to.lat - from.lat) * t, from.lng + (to.lng - from.lng) * t);\n\t\t}\n\t\tconst a = crs.projection.project(from),\n\t\tb = crs.projection.project(to);\n\t\treturn crs.projection.unproject(a.add(b.subtract(a).multiplyBy(t)));\n\t},\n\n\t// The heading from `from` to `to` in degrees clockwise from north, relative to\n\t// the screen unless the icon rotates with the view\n\t_heading(from, to) {\n\t\tconst crs = this._map?.options.crs,\n\t\ta = crs ? crs.latLngToPoint(from, 0) : new Point(from.lng, -from.lat),\n\t\tb = crs ? crs.latLngToPoint(to, 0) : new Point(to.lng, -to.lat),\n\t\theading = Math.atan2(b.x - a.x, a.y - b.y) * 180 / Math.PI;\n\t\treturn heading - (this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0));\n\t},\n\n\t/**\n\t * Stops the movement when the marker is removed from the map.\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis.stopMoving();\n\t\treturn onRemove.call(this, map);\n\t}\n};\n/** @typedef {typeof markerMoveMethods} MarkerMoveMethods */\n\nMarker.include(markerMoveMethods);\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,EAAC,aAAY,OAAO;;AAoI1B,OAAO,QAAQ;;;;;;;;CAzGd,OAAO,QAAQ,SAAS;EACvB,OAAO,KAAK,UAAU,CAAC,MAAM,GAAG,OAAO;CACxC;;;;;;;;;;;;;;CAeA,UAAU,SAAS,UAAU,CAAC,GAAG;EAChC,KAAK,WAAW;EAEhB,MAAM,SAAS,CAAC,KAAK,SAAS,GAAG,QAAQ,KAAI,WAAU,OAAO,KAAK,MAAM,CAAC,CAAC,GAC3E,UAAU,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,KAAK,MAAM,SAAS,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC,WAAW,KAAK,CAAC,GAChH,QAAQ,QAAQ,QAAQ,KAAK,WAAW,MAAM,QAAQ,CAAC,GACvD,WAAW,QAAQ,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AW,CAAC,CAAC,CAAC;CACnE;CAIA,SAAS,MAAM,IAAI;EAClB,MAAM,MAAM,KAAK,MAAM,QAAQ,KAC/B,IAAI,MAAM,IAAI,cAAc,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,KAAK,GAAG,GACpE,IAAI,MAAM,IAAI,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG;EAE9D,OADU,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,KAAK,MACtC,KAAK,QAAQ,iBAAiB,IAAK,KAAK,MAAM,aAAa,KAAK;CACnF;;;;;;CAOA,SAAS,KAAK;EACb,KAAK,WAAW;EAChB,OAAO,SAAS,KAAK,MAAM,GAAG;CAC/B;AAI8B,CAAC"}
@@ -1,13 +1,13 @@
1
1
  import { setOptions } from "../../core/Util.js";
2
2
  import { Point } from "../../geometry/Point.js";
3
3
  import { off, on } from "../../dom/DomEvent.js";
4
- import { setPosition } from "../../dom/DomUtil.js";
4
+ import { getPosition, setPosition } from "../../dom/DomUtil.js";
5
5
  import { Layer } from "../Layer.js";
6
6
  import { LatLng } from "../../geo/LatLng.js";
7
7
  import { pointToGeoJSON } from "../GeoJSONUtil.js";
8
8
  import { DefaultIcon } from "./DefaultIcon.js";
9
9
  import { MarkerDrag } from "./Marker.Drag.js";
10
- //#region src/layer/marker/Marker.js
10
+ // src/layer/marker/Marker.js
11
11
  /** @import {Feature} from 'geojson' */
12
12
  /** @import {Icon} from './Icon.js' */
13
13
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
@@ -33,6 +33,10 @@ import { MarkerDrag } from "./Marker.Drag.js";
33
33
  * top of all others (or below), specifying a high value like `1000` (or high negative
34
34
  * value, respectively).
35
35
  * @property {number} [opacity=1] The opacity of the marker.
36
+ * @property {number|null} [rotation=null] Rotation of the marker icon in degrees,
37
+ * clockwise, around the icon anchor, e.g. for the heading of a vehicle. A rotated
38
+ * marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong
39
+ * under a tilted one. `null` means no rotation.
36
40
  * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of
37
41
  * others when you hover the pointer over it.
38
42
  * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`
@@ -52,7 +56,8 @@ import { MarkerDrag } from "./Marker.Drag.js";
52
56
  * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is
53
57
  * visible within the map's bounds.
54
58
  * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or
55
- * not.
59
+ * not. A focused draggable marker can also be moved with the arrow keys, by 10 pixels
60
+ * or 30 with Shift.
56
61
  * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker
57
62
  * near its edge or not.
58
63
  * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the
@@ -91,6 +96,7 @@ var Marker = class Marker extends Layer {
91
96
  alt: "Marker",
92
97
  zIndexOffset: 0,
93
98
  opacity: 1,
99
+ rotation: null,
94
100
  riseOnHover: false,
95
101
  riseOffset: 250,
96
102
  pane: "markerPane",
@@ -218,7 +224,7 @@ var Marker = class Marker extends Layer {
218
224
  */
219
225
  update() {
220
226
  if (this._icon && this._map && !this._culled) {
221
- const pos = this._map.latLngToLayerPoint(this._latlng).round();
227
+ const pos = this._map.latLngToLayerPoint(this._latlng)._round();
222
228
  this._setPos(pos);
223
229
  }
224
230
  return this;
@@ -245,7 +251,7 @@ var Marker = class Marker extends Layer {
245
251
  pointerout: this._resetZIndex
246
252
  });
247
253
  if (this.options.autoPanOnFocus) on(icon, "focus", this._panOnFocus, this);
248
- const newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;
254
+ const newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;
249
255
  let addShadow = false;
250
256
  if (newShadow !== this._shadow) {
251
257
  this._removeShadow();
@@ -291,18 +297,28 @@ var Marker = class Marker extends Layer {
291
297
  this._shadow = null;
292
298
  }
293
299
  _setPos(pos) {
294
- if (this._icon) setPosition(this._icon, pos);
295
- if (this._shadow) setPosition(this._shadow, pos);
300
+ this._positionElements(pos);
296
301
  this._zIndex = pos.y + this.options.zIndexOffset;
297
302
  this._resetZIndex();
298
303
  }
304
+ _positionElements(pos) {
305
+ const rotation = this.options.rotation;
306
+ if (this._icon) {
307
+ setPosition(this._icon, pos);
308
+ if (rotation != null) this._icon.style.transform += ` rotate(${rotation}deg)`;
309
+ }
310
+ if (this._shadow) {
311
+ setPosition(this._shadow, pos);
312
+ this._shadow.style.display = rotation == null ? "" : "none";
313
+ }
314
+ }
299
315
  _updateZIndex(offset) {
300
316
  const zIndex = String(this._zIndex + offset);
301
317
  if (this._icon && this._icon.style.zIndex !== zIndex) this._icon.style.zIndex = zIndex;
302
318
  }
303
319
  _animateZoom(opt) {
304
320
  if (this._culled) return;
305
- const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
321
+ const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)._round();
306
322
  this._setPos(pos);
307
323
  }
308
324
  _updateInteractive() {
@@ -354,6 +370,27 @@ var Marker = class Marker extends Layer {
354
370
  }
355
371
  }
356
372
  /**
373
+ * Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.
374
+ * @returns {number|null}
375
+ */
376
+ getRotation() {
377
+ return this.options.rotation;
378
+ }
379
+ /**
380
+ * Changes the [rotation](#markeroptions-rotation) of the marker; `null` removes it.
381
+ * @param {number|null} rotation
382
+ * @returns {this}
383
+ */
384
+ setRotation(rotation) {
385
+ this.options.rotation = rotation;
386
+ if (this._icon && !this._map._animatingZoom) {
387
+ this._positionElements(getPosition(this._icon));
388
+ this._popup?._updatePosition();
389
+ this._tooltip?._updatePosition();
390
+ }
391
+ return this;
392
+ }
393
+ /**
357
394
  * Changes the opacity of the marker.
358
395
  * @param {number} opacity
359
396
  * @returns {this}
@@ -385,19 +422,23 @@ var Marker = class Marker extends Layer {
385
422
  _panOnFocus() {
386
423
  const map = this._map;
387
424
  if (!map) return;
388
- const iconOpts = this.options.icon.options;
389
- const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
390
- const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
425
+ 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);
391
426
  map.panInside(this._latlng, {
392
427
  paddingTopLeft: anchor,
393
428
  paddingBottomRight: size.subtract(anchor)
394
429
  });
395
430
  }
396
431
  _getPopupAnchor() {
397
- return this.options.icon.options.popupAnchor;
432
+ return this._rotateAnchor(this.options.icon.options.popupAnchor);
398
433
  }
399
434
  _getTooltipAnchor() {
400
- return this.options.icon.options.tooltipAnchor;
435
+ return this._rotateAnchor(this.options.icon.options.tooltipAnchor);
436
+ }
437
+ _rotateAnchor(anchor) {
438
+ const angle = this.options.rotation * Math.PI / 180;
439
+ if (!angle || !anchor) return anchor;
440
+ const { x, y } = Point.from(anchor), cos = Math.cos(angle), sin = Math.sin(angle);
441
+ return new Point(x * cos - y * sin, x * sin + y * cos);
401
442
  }
402
443
  /**
403
444
  * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the
@@ -411,7 +452,6 @@ var Marker = class Marker extends Layer {
411
452
  return pointToGeoJSON(this, precision);
412
453
  }
413
454
  };
414
- //#endregion
415
455
  export { Marker };
416
456
 
417
457
  //# sourceMappingURL=Marker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.js","names":[],"sources":["../../../../src/layer/marker/Marker.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport {DefaultIcon} from './DefaultIcon.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {MarkerDrag} from './Marker.Drag.js';\nimport {pointToGeoJSON} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {Icon} from './Icon.js' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {InteractiveLayerOptions} from '../Layer.js' */\n\n/**\n * Options of `Marker`.\n * @typedef {object} MarkerOptions\n * @property {Icon} [icon=new DefaultIcon()] Icon instance to use for rendering the\n * marker. See [Icon documentation](#Icon) for details on how to customize the marker\n * icon. If not specified, a common instance of `DefaultIcon` is used.\n * @property {boolean} [keyboard=true] Whether the marker can be tabbed to with a keyboard\n * and, if interactive, clicked by pressing Enter or Space.\n * @property {string} [title=''] Text for the browser tooltip that appear on marker hover\n * (no tooltip by default).\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {string} [alt='Marker'] Text for the `alt` attribute of the icon image.\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {number} [zIndexOffset=0] By default, marker images zIndex is set\n * automatically based on its latitude. Use this option if you want to put the marker on\n * top of all others (or below), specifying a high value like `1000` (or high negative\n * value, respectively).\n * @property {number} [opacity=1] The opacity of the marker.\n * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of\n * others when you hover the pointer over it.\n * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`\n * feature.\n * @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.\n * @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will\n * be added.\n * @property {boolean} [shadow=true] Whether to show the shadow of the marker's icon. Each\n * shadow is an additional element on the page, so disabling shadows noticeably reduces\n * the browser's rendering work when showing many markers (e.g. several thousands),\n * especially while panning and zooming. To disable shadows for all markers, use\n * `Marker.mergeOptions({shadow: false})`.\n * @property {boolean} [bubblingPointerEvents=false] When `true`, a pointer event on this\n * marker will trigger the same event on the map (unless\n * [`DomEvent.stopPropagation`](#domevent-stoppropagation) is used).\n * @property {boolean} [autoPanOnFocus=true] When `true`, the map will pan whenever the\n * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is\n * visible within the map's bounds.\n * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or\n * not.\n * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker\n * near its edge or not.\n * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the\n * left/right and to the top/bottom) of the map edge to start panning the map.\n * @property {number} [autoPanSpeed=10] Number of pixels the map should pan by.\n * @extends InteractiveLayerOptions\n */\n\n/**\n * The event object of `move` and `drag` of markers.\n * @typedef {object} MarkerMoveEvent\n * @property {LatLng} latlng The new position of the marker.\n * @property {LatLng} [oldLatLng] The previous position of the marker.\n * @extends MaplairEvent\n */\n\n/**\n * Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\n *\n * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and\n * [popup methods](#Popup) like `bindPopup()` you can also use the methods below.\n *\n * @example\n * ```js\n * new Marker([50.5, 30.5]).addTo(map);\n * ```\n *\n * @fires move {MarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new\n * coordinates are included in event arguments as `oldLatLng`, `latlng`.\n */\nexport class Marker extends Layer {\n\n\tstatic defaultOptions = {\n\t\ticon: /* @__PURE__ */ new DefaultIcon(),\n\n\t\t// Option inherited from \"Interactive layer\" abstract class\n\t\tinteractive: true,\n\n\t\tkeyboard: true,\n\t\ttitle: '',\n\t\talt: 'Marker',\n\t\tzIndexOffset: 0,\n\t\topacity: 1,\n\t\triseOnHover: false,\n\t\triseOffset: 250,\n\t\tpane: 'markerPane',\n\t\tshadowPane: 'shadowPane',\n\t\tshadow: true,\n\t\tbubblingPointerEvents: false,\n\t\tautoPanOnFocus: true,\n\t\tdraggable: false,\n\t\tautoPan: false,\n\t\tautoPanPadding: [50, 50],\n\t\tautoPanSpeed: 10\n\t};\n\n\t/**\n\t * Instantiates a Marker object given a geographical point and optionally an options\n\t * object.\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\n\t\tthis.callInitHooks(Marker);\n\t}\n\n\t/**\n\t * Adds the icon (and shadow) of the marker to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.on('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._initIcon();\n\t\tthis.update();\n\n\t\tif (map.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the icon (and shadow) of the marker from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this.dragging) {\n\t\t\t// remember whether dragging is on or off (`dragging.disable()`) for when the marker is added again\n\t\t\tthis.options.draggable = this.dragging.enabled();\n\t\t\tif (this.options.draggable) { this.dragging.removeHooks(); }\n\t\t}\n\t\tdelete this.dragging;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.off('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._removeIcon();\n\t\tthis._removeShadow();\n\t\tthis._culled = false;\n\t}\n\n\t/**\n\t * Returns the map events the marker listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tzoom: this.update,\n\t\t\tviewreset: this.update\n\t\t};\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tevents.moveend = this._updateCulling;\n\t\t}\n\t\treturn events;\n\t}\n\n\t/**\n\t * Returns the current geographical position of the marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Changes the marker position to the given point.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t\tthis.update();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Changes the [zIndex offset](#markeroptions-zindexoffset) of the marker.\n\t * @param {number} offset\n\t * @returns {this}\n\t */\n\tsetZIndexOffset(offset) {\n\t\tthis.options.zIndexOffset = offset;\n\t\treturn this.update();\n\t}\n\n\t/**\n\t * Returns the current icon used by the marker.\n\t * @returns {Icon}\n\t */\n\tgetIcon() {\n\t\treturn this.options.icon;\n\t}\n\n\t/**\n\t * Changes the marker icon.\n\t * @param {Icon} icon\n\t * @returns {this}\n\t */\n\tsetIcon(icon) {\n\n\t\tthis.options.icon = icon;\n\n\t\tif (this._map) {\n\t\t\tthis._initIcon();\n\t\t\tthis.update();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the instance of [`HTMLElement`](https://developer.mozilla.org/docs/Web/API/HTMLElement)\n\t * used by Marker layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetElement() {\n\t\treturn this._icon;\n\t}\n\n\t/**\n\t * Updates the position of the marker on the map, e.g. after a change of its options.\n\t * @returns {this}\n\t */\n\tupdate() {\n\n\t\tif (this._icon && this._map && !this._culled) {\n\t\t\tconst pos = this._map.latLngToLayerPoint(this._latlng).round();\n\t\t\tthis._setPos(pos);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_initIcon() {\n\t\tconst options = this.options,\n\t\tclassToAdd = `maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;\n\n\t\tconst icon = options.icon.createIcon(this._icon);\n\t\tlet addIcon = false;\n\n\t\t// if we're not reusing the icon, remove the old one and init new one\n\t\tif (icon !== this._icon) {\n\t\t\tif (this._icon) {\n\t\t\t\tthis._removeIcon();\n\t\t\t}\n\t\t\taddIcon = true;\n\n\t\t\tif (options.title) {\n\t\t\t\ticon.title = options.title;\n\t\t\t}\n\n\t\t\tif (icon instanceof HTMLImageElement) {\n\t\t\t\ticon.alt = options.alt ?? '';\n\t\t\t}\n\t\t}\n\n\t\ticon.classList.add(classToAdd);\n\n\t\tif (options.keyboard) {\n\t\t\ticon.tabIndex = 0;\n\t\t\tif (options.interactive) {\n\t\t\t\ticon.setAttribute('role', 'button');\n\t\t\t}\n\t\t\tDomEvent.on(icon, 'keydown', this._onKeyDown, this);\n\t\t}\n\n\t\tthis._icon = icon;\n\n\t\tif (options.riseOnHover) {\n\t\t\tthis.on({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.on(icon, 'focus', this._panOnFocus, this);\n\t\t}\n\n\t\tconst newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;\n\t\tlet addShadow = false;\n\n\t\tif (newShadow !== this._shadow) {\n\t\t\tthis._removeShadow();\n\t\t\taddShadow = true;\n\t\t}\n\n\t\tif (newShadow) {\n\t\t\tnewShadow.classList.add(classToAdd);\n\t\t\tnewShadow.alt = '';\n\t\t}\n\t\tthis._shadow = newShadow;\n\n\n\t\tif (options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\n\t\tif (addIcon) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t}\n\t\tthis._initInteraction();\n\t\tif (newShadow && addShadow) {\n\t\t\tthis.getPane(options.shadowPane).appendChild(this._shadow);\n\t\t}\n\t}\n\n\t_removeIcon() {\n\t\tif (this.options.riseOnHover) {\n\t\t\tthis.off({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.off(this._icon, 'focus', this._panOnFocus, this);\n\t\t}\n\t\tDomEvent.off(this._icon, 'keydown', this._onKeyDown, this);\n\n\t\tthis._icon.remove();\n\t\tthis.removeInteractiveTarget(this._icon);\n\n\t\tthis._icon = null;\n\t}\n\n\t// With the map's `markerCulling` option, takes the icon and shadow of a marker\n\t// far outside of the map view off the page (and puts them back when needed),\n\t// so that the browser doesn't need to render, and the marker doesn't need\n\t// to reposition, them while panning and zooming.\n\t_updateCulling() {\n\t\tif (!this._icon || !this._map) { return; }\n\n\t\tconst map = this._map,\n\t\t// computed once per view for all markers, reset by the map on `move`\n\t\tbounds = map._cullingBounds ??= map.getBounds().pad(0.5),\n\t\tvisible = bounds.contains(this._latlng) ||\n\t\t\t!!this.dragging?._draggable?._moving ||\n\t\t\tthis._icon.contains(document.activeElement);\n\n\t\tif (visible === !this._culled) { return; }\n\t\tthis._culled = !visible;\n\n\t\tif (visible) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t\tif (this._shadow) {\n\t\t\t\tthis.getPane(this.options.shadowPane).appendChild(this._shadow);\n\t\t\t}\n\t\t\tthis.update();\n\t\t} else {\n\t\t\tthis._icon.remove();\n\t\t\tthis._shadow?.remove();\n\t\t}\n\t}\n\n\t_removeShadow() {\n\t\tthis._shadow?.remove();\n\t\tthis._shadow = null;\n\t}\n\n\t_setPos(pos) {\n\n\t\tif (this._icon) {\n\t\t\tDomUtil.setPosition(this._icon, pos);\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tDomUtil.setPosition(this._shadow, pos);\n\t\t}\n\n\t\tthis._zIndex = pos.y + this.options.zIndexOffset;\n\n\t\tthis._resetZIndex();\n\t}\n\n\t_updateZIndex(offset) {\n\t\tconst zIndex = String(this._zIndex + offset);\n\t\tif (this._icon && this._icon.style.zIndex !== zIndex) {\n\t\t\tthis._icon.style.zIndex = zIndex;\n\t\t}\n\t}\n\n\t_animateZoom(opt) {\n\t\tif (this._culled) { return; }\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();\n\n\t\tthis._setPos(pos);\n\t}\n\n\t_updateInteractive() {\n\t\tif (!this._icon) { return; }\n\t\tif (this.options.keyboard) {\n\t\t\tif (this.options.interactive) {\n\t\t\t\tthis._icon.setAttribute('role', 'button');\n\t\t\t} else {\n\t\t\t\tthis._icon.removeAttribute('role');\n\t\t\t}\n\t\t}\n\t\tif (this.options.interactive) {\n\t\t\tthis._initInteraction();\n\t\t\tif (this._draggableBeforeNonInteractive) {\n\t\t\t\tthis.dragging?.enable();\n\t\t\t}\n\t\t} else {\n\t\t\tthis._icon.classList.remove('maplair-interactive');\n\t\t\tthis.removeInteractiveTarget(this._icon);\n\t\t\tthis._draggableBeforeNonInteractive = this.dragging?.enabled();\n\t\t\tthis.dragging?.disable();\n\t\t}\n\t}\n\n\t_initInteraction() {\n\n\t\tif (!this.options.interactive) { return; }\n\n\t\tthis._icon.classList.add('maplair-interactive');\n\n\t\tthis.addInteractiveTarget(this._icon);\n\n\t\tif (MarkerDrag) {\n\t\t\t// When the icon element is reused, the drag handler still refers to it. Keep that handler, because\n\t\t\t// replacing it ends a drag in progress and forgets that the marker has just been dragged.\n\t\t\tif (this.dragging?._draggable?._element === this._icon) {\n\t\t\t\t// the icon has reset the class names of the element\n\t\t\t\tthis._icon.classList.toggle('maplair-marker-draggable', this.dragging.enabled());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet draggable = this.options.draggable;\n\t\t\tif (this.dragging) {\n\t\t\t\tdraggable = this.dragging.enabled();\n\t\t\t\tthis.dragging.disable();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Marker dragging handler, see `Handler`. Only valid when the marker is on the\n\t\t\t * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).\n\t\t\t *\n\t\t\t * Interaction handlers are properties of a marker instance that allow you to\n\t\t\t * control interaction behavior in runtime, enabling or disabling certain\n\t\t\t * features such as dragging (see `Handler` methods). Example:\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * marker.dragging.disable();\n\t\t\t * ```\n\t\t\t * @group Interaction handlers\n\t\t\t * @type {MarkerDrag}\n\t\t\t */\n\t\t\tthis.dragging = new MarkerDrag(this);\n\n\t\t\tif (draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Changes the opacity of the marker.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tif (this._map) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_updateOpacity() {\n\t\tconst opacity = this.options.opacity;\n\n\t\tif (this._icon) {\n\t\t\tthis._icon.style.opacity = `${opacity}`;\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tthis._shadow.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_bringToFront() {\n\t\tthis._updateZIndex(this.options.riseOffset);\n\t}\n\n\t_resetZIndex() {\n\t\tthis._updateZIndex(0);\n\t}\n\n\t_onKeyDown(e) {\n\t\t// a key pressed on a focusable element inside a DivIcon (e.g. a <button>) already clicks it natively\n\t\tif (this.options.interactive && e.target === this._icon && !e.repeat && (e.key === 'Enter' || e.key === ' ')) {\n\t\t\te.preventDefault(); // stop Space from scrolling the page\n\t\t\t// lets a popup opened by the click take the focus, see Popup.onAdd()\n\t\t\tthis._clickedByKeyboard = true;\n\t\t\tthis._icon.click();\n\t\t\tthis._clickedByKeyboard = false;\n\t\t}\n\t}\n\n\t_panOnFocus() {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\n\t\tconst iconOpts = this.options.icon.options;\n\t\tconst size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);\n\t\tconst anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);\n\n\t\tmap.panInside(this._latlng, {\n\t\t\tpaddingTopLeft: anchor,\n\t\t\tpaddingBottomRight: size.subtract(anchor)\n\t\t});\n\t}\n\n\t_getPopupAnchor() {\n\t\treturn this.options.icon.options.popupAnchor;\n\t}\n\n\t_getTooltipAnchor() {\n\t\treturn this.options.icon.options.tooltipAnchor;\n\t}\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the marker (as a GeoJSON `Point` Feature).\n\t * @group Other methods\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\treturn pointToGeoJSON(this, precision);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,IAAa,SAAb,MAAa,eAAe,MAAM;CAEjC,OAAO,iBAAiB;EACvB,sBAAsB,IAAI,YAAY;EAGtC,aAAa;EAEb,UAAU;EACV,OAAO;EACP,KAAK;EACL,cAAc;EACd,SAAS;EACT,aAAa;EACb,YAAY;EACZ,MAAM;EACN,YAAY;EACZ,QAAQ;EACR,uBAAuB;EACvB,gBAAgB;EAChB,WAAW;EACX,SAAS;EACT,gBAAgB,CAAC,IAAI,EAAE;EACvB,cAAc;CACf;;;;;;;CAQA,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,UAAU,IAAI,OAAO,MAAM;EAEhC,KAAK,cAAc,MAAM;CAC1B;;;;;CAMA,MAAM,KAAK;EACV,KAAK,gBAAgB,KAAK,iBAAiB,IAAI,QAAQ;EAEvD,IAAI,KAAK,eACR,IAAI,GAAG,YAAY,KAAK,cAAc,IAAI;EAG3C,KAAK,UAAU;EACf,KAAK,OAAO;EAEZ,IAAI,IAAI,QAAQ,eACf,KAAK,eAAe;CAEtB;;;;;CAMA,SAAS,KAAK;EACb,IAAI,KAAK,UAAU;GAElB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K,QAAQ,UAAU;CAC3C;CAEA,eAAe;EACd,KAAK,cAAc,CAAC;CACrB;CAEA,WAAW,GAAG;EAEb,IAAI,KAAK,QAAQ,eAAe,EAAE,WAAW,KAAK,SAAS,CAAC,EAAE,WAAW,EAAE,QAAQ,WAAW,EAAE,QAAQ,MAAM;GAC7G,EAAE,eAAe;GAEjB,KAAK,qBAAqB;GAC1B,KAAK,MAAM,MAAM;GACjB,KAAK,qBAAqB;EAC3B;CACD;CAEA,cAAc;EACb,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,KAAO;EAEZ,MAAM,WAAW,KAAK,QAAQ,KAAK;EACnC,MAAM,OAAO,SAAS,WAAW,MAAM,KAAK,SAAS,QAAQ,IAAI,IAAI,MAAM,GAAG,CAAC;EAC/E,MAAM,SAAS,SAAS,aAAa,MAAM,KAAK,SAAS,UAAU,IAAI,IAAI,MAAM,GAAG,CAAC;EAErF,IAAI,UAAU,KAAK,SAAS;GAC3B,gBAAgB;GAChB,oBAAoB,KAAK,SAAS,MAAM;EACzC,CAAC;CACF;CAEA,kBAAkB;EACjB,OAAO,KAAK,QAAQ,KAAK,QAAQ;CAClC;CAEA,oBAAoB;EACnB,OAAO,KAAK,QAAQ,KAAK,QAAQ;CAClC;;;;;;;;;CAUA,UAAU,WAAW;EACpB,OAAO,eAAe,MAAM,SAAS;CACtC;AACD"}
1
+ {"version":3,"file":"Marker.js","names":["DomUtil.getPosition"],"sources":["../../../../src/layer/marker/Marker.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport {DefaultIcon} from './DefaultIcon.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {MarkerDrag} from './Marker.Drag.js';\nimport {pointToGeoJSON} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {Icon} from './Icon.js' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {InteractiveLayerOptions} from '../Layer.js' */\n\n/**\n * Options of `Marker`.\n * @typedef {object} MarkerOptions\n * @property {Icon} [icon=new DefaultIcon()] Icon instance to use for rendering the\n * marker. See [Icon documentation](#Icon) for details on how to customize the marker\n * icon. If not specified, a common instance of `DefaultIcon` is used.\n * @property {boolean} [keyboard=true] Whether the marker can be tabbed to with a keyboard\n * and, if interactive, clicked by pressing Enter or Space.\n * @property {string} [title=''] Text for the browser tooltip that appear on marker hover\n * (no tooltip by default).\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {string} [alt='Marker'] Text for the `alt` attribute of the icon image.\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {number} [zIndexOffset=0] By default, marker images zIndex is set\n * automatically based on its latitude. Use this option if you want to put the marker on\n * top of all others (or below), specifying a high value like `1000` (or high negative\n * value, respectively).\n * @property {number} [opacity=1] The opacity of the marker.\n * @property {number|null} [rotation=null] Rotation of the marker icon in degrees,\n * clockwise, around the icon anchor, e.g. for the heading of a vehicle. A rotated\n * marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong\n * under a tilted one. `null` means no rotation.\n * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of\n * others when you hover the pointer over it.\n * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`\n * feature.\n * @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.\n * @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will\n * be added.\n * @property {boolean} [shadow=true] Whether to show the shadow of the marker's icon. Each\n * shadow is an additional element on the page, so disabling shadows noticeably reduces\n * the browser's rendering work when showing many markers (e.g. several thousands),\n * especially while panning and zooming. To disable shadows for all markers, use\n * `Marker.mergeOptions({shadow: false})`.\n * @property {boolean} [bubblingPointerEvents=false] When `true`, a pointer event on this\n * marker will trigger the same event on the map (unless\n * [`DomEvent.stopPropagation`](#domevent-stoppropagation) is used).\n * @property {boolean} [autoPanOnFocus=true] When `true`, the map will pan whenever the\n * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is\n * visible within the map's bounds.\n * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or\n * not. A focused draggable marker can also be moved with the arrow keys, by 10 pixels\n * or 30 with Shift.\n * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker\n * near its edge or not.\n * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the\n * left/right and to the top/bottom) of the map edge to start panning the map.\n * @property {number} [autoPanSpeed=10] Number of pixels the map should pan by.\n * @extends InteractiveLayerOptions\n */\n\n/**\n * The event object of `move` and `drag` of markers.\n * @typedef {object} MarkerMoveEvent\n * @property {LatLng} latlng The new position of the marker.\n * @property {LatLng} [oldLatLng] The previous position of the marker.\n * @extends MaplairEvent\n */\n\n/**\n * Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\n *\n * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and\n * [popup methods](#Popup) like `bindPopup()` you can also use the methods below.\n *\n * @example\n * ```js\n * new Marker([50.5, 30.5]).addTo(map);\n * ```\n *\n * @fires move {MarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new\n * coordinates are included in event arguments as `oldLatLng`, `latlng`.\n */\nexport class Marker extends Layer {\n\n\tstatic defaultOptions = {\n\t\ticon: /* @__PURE__ */ new DefaultIcon(),\n\n\t\t// Option inherited from \"Interactive layer\" abstract class\n\t\tinteractive: true,\n\n\t\tkeyboard: true,\n\t\ttitle: '',\n\t\talt: 'Marker',\n\t\tzIndexOffset: 0,\n\t\topacity: 1,\n\t\trotation: null,\n\t\triseOnHover: false,\n\t\triseOffset: 250,\n\t\tpane: 'markerPane',\n\t\tshadowPane: 'shadowPane',\n\t\tshadow: true,\n\t\tbubblingPointerEvents: false,\n\t\tautoPanOnFocus: true,\n\t\tdraggable: false,\n\t\tautoPan: false,\n\t\tautoPanPadding: [50, 50],\n\t\tautoPanSpeed: 10\n\t};\n\n\t/**\n\t * Instantiates a Marker object given a geographical point and optionally an options\n\t * object.\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\n\t\tthis.callInitHooks(Marker);\n\t}\n\n\t/**\n\t * Adds the icon (and shadow) of the marker to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.on('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._initIcon();\n\t\tthis.update();\n\n\t\tif (map.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the icon (and shadow) of the marker from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this.dragging) {\n\t\t\t// remember whether dragging is on or off (`dragging.disable()`) for when the marker is added again\n\t\t\tthis.options.draggable = this.dragging.enabled();\n\t\t\tif (this.options.draggable) { this.dragging.removeHooks(); }\n\t\t}\n\t\tdelete this.dragging;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.off('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._removeIcon();\n\t\tthis._removeShadow();\n\t\tthis._culled = false;\n\t}\n\n\t/**\n\t * Returns the map events the marker listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tzoom: this.update,\n\t\t\tviewreset: this.update\n\t\t};\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tevents.moveend = this._updateCulling;\n\t\t}\n\t\treturn events;\n\t}\n\n\t/**\n\t * Returns the current geographical position of the marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Changes the marker position to the given point.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t\tthis.update();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Changes the [zIndex offset](#markeroptions-zindexoffset) of the marker.\n\t * @param {number} offset\n\t * @returns {this}\n\t */\n\tsetZIndexOffset(offset) {\n\t\tthis.options.zIndexOffset = offset;\n\t\treturn this.update();\n\t}\n\n\t/**\n\t * Returns the current icon used by the marker.\n\t * @returns {Icon}\n\t */\n\tgetIcon() {\n\t\treturn this.options.icon;\n\t}\n\n\t/**\n\t * Changes the marker icon.\n\t * @param {Icon} icon\n\t * @returns {this}\n\t */\n\tsetIcon(icon) {\n\n\t\tthis.options.icon = icon;\n\n\t\tif (this._map) {\n\t\t\tthis._initIcon();\n\t\t\tthis.update();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the instance of [`HTMLElement`](https://developer.mozilla.org/docs/Web/API/HTMLElement)\n\t * used by Marker layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetElement() {\n\t\treturn this._icon;\n\t}\n\n\t/**\n\t * Updates the position of the marker on the map, e.g. after a change of its options.\n\t * @returns {this}\n\t */\n\tupdate() {\n\n\t\tif (this._icon && this._map && !this._culled) {\n\t\t\tconst pos = this._map.latLngToLayerPoint(this._latlng)._round();\n\t\t\tthis._setPos(pos);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_initIcon() {\n\t\tconst options = this.options,\n\t\tclassToAdd = `maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;\n\n\t\tconst icon = options.icon.createIcon(this._icon);\n\t\tlet addIcon = false;\n\n\t\t// if we're not reusing the icon, remove the old one and init new one\n\t\tif (icon !== this._icon) {\n\t\t\tif (this._icon) {\n\t\t\t\tthis._removeIcon();\n\t\t\t}\n\t\t\taddIcon = true;\n\n\t\t\tif (options.title) {\n\t\t\t\ticon.title = options.title;\n\t\t\t}\n\n\t\t\tif (icon instanceof HTMLImageElement) {\n\t\t\t\ticon.alt = options.alt ?? '';\n\t\t\t}\n\t\t}\n\n\t\ticon.classList.add(classToAdd);\n\n\t\tif (options.keyboard) {\n\t\t\ticon.tabIndex = 0;\n\t\t\tif (options.interactive) {\n\t\t\t\ticon.setAttribute('role', 'button');\n\t\t\t}\n\t\t\tDomEvent.on(icon, 'keydown', this._onKeyDown, this);\n\t\t}\n\n\t\tthis._icon = icon;\n\n\t\tif (options.riseOnHover) {\n\t\t\tthis.on({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.on(icon, 'focus', this._panOnFocus, this);\n\t\t}\n\n\t\tconst newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;\n\t\tlet addShadow = false;\n\n\t\tif (newShadow !== this._shadow) {\n\t\t\tthis._removeShadow();\n\t\t\taddShadow = true;\n\t\t}\n\n\t\tif (newShadow) {\n\t\t\tnewShadow.classList.add(classToAdd);\n\t\t\tnewShadow.alt = '';\n\t\t}\n\t\tthis._shadow = newShadow;\n\n\n\t\tif (options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\n\t\tif (addIcon) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t}\n\t\tthis._initInteraction();\n\t\tif (newShadow && addShadow) {\n\t\t\tthis.getPane(options.shadowPane).appendChild(this._shadow);\n\t\t}\n\t}\n\n\t_removeIcon() {\n\t\tif (this.options.riseOnHover) {\n\t\t\tthis.off({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.off(this._icon, 'focus', this._panOnFocus, this);\n\t\t}\n\t\tDomEvent.off(this._icon, 'keydown', this._onKeyDown, this);\n\n\t\tthis._icon.remove();\n\t\tthis.removeInteractiveTarget(this._icon);\n\n\t\tthis._icon = null;\n\t}\n\n\t// With the map's `markerCulling` option, takes the icon and shadow of a marker\n\t// far outside of the map view off the page (and puts them back when needed),\n\t// so that the browser doesn't need to render, and the marker doesn't need\n\t// to reposition, them while panning and zooming.\n\t_updateCulling() {\n\t\tif (!this._icon || !this._map) { return; }\n\n\t\tconst map = this._map,\n\t\t// computed once per view for all markers, reset by the map on `move`\n\t\tbounds = map._cullingBounds ??= map.getBounds().pad(0.5),\n\t\tvisible = bounds.contains(this._latlng) ||\n\t\t\t!!this.dragging?._draggable?._moving ||\n\t\t\tthis._icon.contains(document.activeElement);\n\n\t\tif (visible === !this._culled) { return; }\n\t\tthis._culled = !visible;\n\n\t\tif (visible) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t\tif (this._shadow) {\n\t\t\t\tthis.getPane(this.options.shadowPane).appendChild(this._shadow);\n\t\t\t}\n\t\t\tthis.update();\n\t\t} else {\n\t\t\tthis._icon.remove();\n\t\t\tthis._shadow?.remove();\n\t\t}\n\t}\n\n\t_removeShadow() {\n\t\tthis._shadow?.remove();\n\t\tthis._shadow = null;\n\t}\n\n\t_setPos(pos) {\n\t\tthis._positionElements(pos);\n\n\t\tthis._zIndex = pos.y + this.options.zIndexOffset;\n\n\t\tthis._resetZIndex();\n\t}\n\n\t_positionElements(pos) {\n\t\tconst rotation = this.options.rotation;\n\n\t\tif (this._icon) {\n\t\t\tDomUtil.setPosition(this._icon, pos);\n\t\t\tif (rotation != null) {\n\t\t\t\tthis._icon.style.transform += ` rotate(${rotation}deg)`;\n\t\t\t}\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tDomUtil.setPosition(this._shadow, pos);\n\t\t\tthis._shadow.style.display = rotation == null ? '' : 'none';\n\t\t}\n\t}\n\n\t_updateZIndex(offset) {\n\t\tconst zIndex = String(this._zIndex + offset);\n\t\tif (this._icon && this._icon.style.zIndex !== zIndex) {\n\t\t\tthis._icon.style.zIndex = zIndex;\n\t\t}\n\t}\n\n\t_animateZoom(opt) {\n\t\tif (this._culled) { return; }\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)._round();\n\n\t\tthis._setPos(pos);\n\t}\n\n\t_updateInteractive() {\n\t\tif (!this._icon) { return; }\n\t\tif (this.options.keyboard) {\n\t\t\tif (this.options.interactive) {\n\t\t\t\tthis._icon.setAttribute('role', 'button');\n\t\t\t} else {\n\t\t\t\tthis._icon.removeAttribute('role');\n\t\t\t}\n\t\t}\n\t\tif (this.options.interactive) {\n\t\t\tthis._initInteraction();\n\t\t\tif (this._draggableBeforeNonInteractive) {\n\t\t\t\tthis.dragging?.enable();\n\t\t\t}\n\t\t} else {\n\t\t\tthis._icon.classList.remove('maplair-interactive');\n\t\t\tthis.removeInteractiveTarget(this._icon);\n\t\t\tthis._draggableBeforeNonInteractive = this.dragging?.enabled();\n\t\t\tthis.dragging?.disable();\n\t\t}\n\t}\n\n\t_initInteraction() {\n\n\t\tif (!this.options.interactive) { return; }\n\n\t\tthis._icon.classList.add('maplair-interactive');\n\n\t\tthis.addInteractiveTarget(this._icon);\n\n\t\tif (MarkerDrag) {\n\t\t\t// When the icon element is reused, the drag handler still refers to it. Keep that handler, because\n\t\t\t// replacing it ends a drag in progress and forgets that the marker has just been dragged.\n\t\t\tif (this.dragging?._draggable?._element === this._icon) {\n\t\t\t\t// the icon has reset the class names of the element\n\t\t\t\tthis._icon.classList.toggle('maplair-marker-draggable', this.dragging.enabled());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet draggable = this.options.draggable;\n\t\t\tif (this.dragging) {\n\t\t\t\tdraggable = this.dragging.enabled();\n\t\t\t\tthis.dragging.disable();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Marker dragging handler, see `Handler`. Only valid when the marker is on the\n\t\t\t * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).\n\t\t\t *\n\t\t\t * Interaction handlers are properties of a marker instance that allow you to\n\t\t\t * control interaction behavior in runtime, enabling or disabling certain\n\t\t\t * features such as dragging (see `Handler` methods). Example:\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * marker.dragging.disable();\n\t\t\t * ```\n\t\t\t * @group Interaction handlers\n\t\t\t * @type {MarkerDrag}\n\t\t\t */\n\t\t\tthis.dragging = new MarkerDrag(this);\n\n\t\t\tif (draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.\n\t * @returns {number|null}\n\t */\n\tgetRotation() {\n\t\treturn this.options.rotation;\n\t}\n\n\t/**\n\t * Changes the [rotation](#markeroptions-rotation) of the marker; `null` removes it.\n\t * @param {number|null} rotation\n\t * @returns {this}\n\t */\n\tsetRotation(rotation) {\n\t\tthis.options.rotation = rotation;\n\t\t// mid-zoom, the icon is transitioning to a position that update() can't compute yet; the zoom end applies it\n\t\tif (this._icon && !this._map._animatingZoom) {\n\t\t\tthis._positionElements(DomUtil.getPosition(this._icon));\n\t\t\tthis._popup?._updatePosition();\n\t\t\tthis._tooltip?._updatePosition();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Changes the opacity of the marker.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tif (this._map) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_updateOpacity() {\n\t\tconst opacity = this.options.opacity;\n\n\t\tif (this._icon) {\n\t\t\tthis._icon.style.opacity = `${opacity}`;\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tthis._shadow.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_bringToFront() {\n\t\tthis._updateZIndex(this.options.riseOffset);\n\t}\n\n\t_resetZIndex() {\n\t\tthis._updateZIndex(0);\n\t}\n\n\t_onKeyDown(e) {\n\t\t// a key pressed on a focusable element inside a DivIcon (e.g. a <button>) already clicks it natively\n\t\tif (this.options.interactive && e.target === this._icon && !e.repeat && (e.key === 'Enter' || e.key === ' ')) {\n\t\t\te.preventDefault(); // stop Space from scrolling the page\n\t\t\t// lets a popup opened by the click take the focus, see Popup.onAdd()\n\t\t\tthis._clickedByKeyboard = true;\n\t\t\tthis._icon.click();\n\t\t\tthis._clickedByKeyboard = false;\n\t\t}\n\t}\n\n\t_panOnFocus() {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\n\t\tconst icon = this._icon,\n\t\tstyle = getComputedStyle(icon),\n\t\tanchor = new Point(-parseFloat(style.marginLeft) || 0, -parseFloat(style.marginTop) || 0),\n\t\tsize = new Point(icon.offsetWidth, icon.offsetHeight);\n\n\t\tmap.panInside(this._latlng, {\n\t\t\tpaddingTopLeft: anchor,\n\t\t\tpaddingBottomRight: size.subtract(anchor)\n\t\t});\n\t}\n\n\t_getPopupAnchor() {\n\t\treturn this._rotateAnchor(this.options.icon.options.popupAnchor);\n\t}\n\n\t_getTooltipAnchor() {\n\t\treturn this._rotateAnchor(this.options.icon.options.tooltipAnchor);\n\t}\n\n\t// anchors are offsets from the icon anchor, which is also the rotation origin\n\t_rotateAnchor(anchor) {\n\t\tconst angle = this.options.rotation * Math.PI / 180;\n\t\tif (!angle || !anchor) { return anchor; }\n\n\t\tconst {x, y} = Point.from(anchor),\n\t\tcos = Math.cos(angle),\n\t\tsin = Math.sin(angle);\n\t\treturn new Point(x * cos - y * sin, x * sin + y * cos);\n\t}\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the marker (as a GeoJSON `Point` Feature).\n\t * @group Other methods\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\treturn pointToGeoJSON(this, precision);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAa,SAAb,MAAa,eAAe,MAAM;CAEjC,OAAO,iBAAiB;EACvB,sBAAsB,IAAI,YAAY;EAGtC,aAAa;EAEb,UAAU;EACV,OAAO;EACP,KAAK;EACL,cAAc;EACd,SAAS;EACT,UAAU;EACV,aAAa;EACb,YAAY;EACZ,MAAM;EACN,YAAY;EACZ,QAAQ;EACR,uBAAuB;EACvB,gBAAgB;EAChB,WAAW;EACX,SAAS;EACT,gBAAgB,CAAC,IAAI,EAAE;EACvB,cAAc;CACf;;;;;;;CAQA,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,UAAU,IAAI,OAAO,MAAM;EAEhC,KAAK,cAAc,MAAM;CAC1B;;;;;CAMA,MAAM,KAAK;EACV,KAAK,gBAAgB,KAAK,iBAAiB,IAAI,QAAQ;EAEvD,IAAI,KAAK,eACR,IAAI,GAAG,YAAY,KAAK,cAAc,IAAI;EAG3C,KAAK,UAAU;EACf,KAAK,OAAO;EAEZ,IAAI,IAAI,QAAQ,eACf,KAAK,eAAe;CAEtB;;;;;CAMA,SAAS,KAAK;EACb,IAAI,KAAK,UAAU;GAElB,KAAK,QAAQ,YAAY,KAAK,SAAS,QAAQ;GAC/C,IAAI,KAAK,QAAQ,WAAa,KAAK,SAAS,YAAY;EACzD;EACA,OAAO,KAAK;EAEZ,IAAI,KAAK,eACR,IAAI,IAAI,YAAY,KAAK,cAAc,IAAI;EAG5C,KAAK,YAAY;EACjB,KAAK,cAAc;EACn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,MAAM,GAChC,MAAM,KAAK,IAAI,KAAK,GACpB,MAAM,KAAK,IAAI,KAAK;EACpB,OAAO,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,IAAI,GAAG;CACtD;;;;;;;;;CAUA,UAAU,WAAW;EACpB,OAAO,eAAe,MAAM,SAAS;CACtC;AACD"}
@@ -6,7 +6,7 @@ import { FeatureGroup } from "../FeatureGroup.js";
6
6
  import { Polyline } from "../vector/Polyline.js";
7
7
  import { Marker } from "./Marker.js";
8
8
  import { DivIcon } from "./DivIcon.js";
9
- //#region src/layer/marker/MarkerClusterGroup.js
9
+ // src/layer/marker/MarkerClusterGroup.js
10
10
  /** @import {Layer, LayerOptions} from '../Layer.js' */
11
11
  /** @import {MaplairEvent} from '../../core/Events.js' */
12
12
  /**
@@ -296,7 +296,6 @@ var MarkerClusterGroup = class MarkerClusterGroup extends FeatureGroup {
296
296
  if (map && this._shown.has(spider.clusterMarker)) map.addLayer(spider.clusterMarker);
297
297
  }
298
298
  };
299
- //#endregion
300
299
  export { MarkerClusterGroup };
301
300
 
302
301
  //# sourceMappingURL=MarkerClusterGroup.js.map
@@ -1,5 +1,5 @@
1
1
  import { DefaultIcon } from "./DefaultIcon.js";
2
- //#region src/layer/marker/SvgIcon.js
2
+ // src/layer/marker/SvgIcon.js
3
3
  /** @import {DefaultIconOptions} from './DefaultIcon.js' */
4
4
  const svgNS = "http://www.w3.org/2000/svg";
5
5
  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";
@@ -108,7 +108,6 @@ var SvgIcon = class SvgIcon extends DefaultIcon {
108
108
  return div;
109
109
  }
110
110
  };
111
- //#endregion
112
111
  export { SvgIcon };
113
112
 
114
113
  //# sourceMappingURL=SvgIcon.js.map
@@ -4,7 +4,7 @@ import { create, getPosition, setPosition, setTransform, toBack, toFront } from
4
4
  import { Layer } from "../Layer.js";
5
5
  import { Bounds } from "../../geometry/Bounds.js";
6
6
  import { LatLngBounds } from "../../geo/LatLngBounds.js";
7
- //#region src/layer/tile/GridLayer.js
7
+ // src/layer/tile/GridLayer.js
8
8
  /** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
9
9
  /** @import {MaplairMap} from '../../map/Map.js' */
10
10
  /** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */
@@ -253,7 +253,7 @@ var GridLayer = class GridLayer extends Layer {
253
253
  * @returns {boolean}
254
254
  */
255
255
  isLoading() {
256
- return this._loading;
256
+ return !!this._loading;
257
257
  }
258
258
  /**
259
259
  * Causes the layer to clear all the tiles and request them again.
@@ -643,9 +643,10 @@ var GridLayer = class GridLayer extends Layer {
643
643
  coords
644
644
  });
645
645
  }
646
- if (this._noTilesToLoad()) {
646
+ if (this._map && this._noTilesToLoad()) {
647
647
  this._loading = false;
648
648
  this.fire("load");
649
+ if (!this._map) return;
649
650
  this._map._scheduleIdleCheck();
650
651
  if (!this._map._fadeAnimated) requestAnimationFrame(this._pruneTiles.bind(this));
651
652
  else this._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);
@@ -678,7 +679,6 @@ var GridLayer = class GridLayer extends Layer {
678
679
  return Object.values(this._tiles).every((t) => t.loaded);
679
680
  }
680
681
  };
681
- //#endregion
682
682
  export { GridLayer };
683
683
 
684
684
  //# sourceMappingURL=GridLayer.js.map