maplair 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/esm/Maplair.js +5 -4
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +1 -2
  6. package/dist/esm/control/ButtonControl.js +1 -2
  7. package/dist/esm/control/ContextMenu.js +1 -2
  8. package/dist/esm/control/Control.js +1 -2
  9. package/dist/esm/control/FullscreenControl.js +1 -2
  10. package/dist/esm/control/LayersControl.js +27 -31
  11. package/dist/esm/control/LayersControl.js.map +1 -1
  12. package/dist/esm/control/LegendControl.js +1 -2
  13. package/dist/esm/control/MiniMapControl.js +1 -2
  14. package/dist/esm/control/RotateControl.js +1 -2
  15. package/dist/esm/control/ScaleControl.js +1 -2
  16. package/dist/esm/control/SearchControl.js +1 -2
  17. package/dist/esm/control/SideBySideControl.js +1 -2
  18. package/dist/esm/control/TextControl.js +1 -2
  19. package/dist/esm/control/TimeControl.js +1 -2
  20. package/dist/esm/control/ZoomControl.js +18 -29
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Class.js +2 -9
  23. package/dist/esm/core/Class.js.map +1 -1
  24. package/dist/esm/core/Events.js +1 -2
  25. package/dist/esm/core/Handler.js +10 -3
  26. package/dist/esm/core/Handler.js.map +1 -1
  27. package/dist/esm/core/I18n.js +1 -2
  28. package/dist/esm/core/Util.js +2 -3
  29. package/dist/esm/core/Util.js.map +1 -1
  30. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  32. package/dist/esm/dom/DomEvent.js +10 -18
  33. package/dist/esm/dom/DomEvent.js.map +1 -1
  34. package/dist/esm/dom/DomUtil.js +1 -2
  35. package/dist/esm/dom/Draggable.js +4 -3
  36. package/dist/esm/dom/Draggable.js.map +1 -1
  37. package/dist/esm/dom/PosAnimation.js +1 -2
  38. package/dist/esm/geo/LatLng.js +1 -2
  39. package/dist/esm/geo/LatLngBounds.js +9 -15
  40. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  41. package/dist/esm/geo/crs/CRS.js +1 -2
  42. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  43. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  44. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  45. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  46. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  47. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  48. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  49. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  50. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  51. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  52. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  53. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  54. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  55. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  56. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  57. package/dist/esm/geometry/Bounds.js +10 -14
  58. package/dist/esm/geometry/Bounds.js.map +1 -1
  59. package/dist/esm/geometry/LineUtil.js +2 -3
  60. package/dist/esm/geometry/LineUtil.js.map +1 -1
  61. package/dist/esm/geometry/Point.js +1 -2
  62. package/dist/esm/geometry/PolyUtil.js +17 -25
  63. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  64. package/dist/esm/geometry/Transformation.js +1 -2
  65. package/dist/esm/layer/BlanketOverlay.js +1 -2
  66. package/dist/esm/layer/Classification.js +1 -2
  67. package/dist/esm/layer/DivOverlay.js +2 -3
  68. package/dist/esm/layer/DivOverlay.js.map +1 -1
  69. package/dist/esm/layer/FeatureGroup.js +5 -4
  70. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  71. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  72. package/dist/esm/layer/GeoJSON.js +8 -10
  73. package/dist/esm/layer/GeoJSON.js.map +1 -1
  74. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  75. package/dist/esm/layer/HeatLayer.js +2 -3
  76. package/dist/esm/layer/HeatLayer.js.map +1 -1
  77. package/dist/esm/layer/ImageOverlay.js +2 -3
  78. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  79. package/dist/esm/layer/Layer.js +1 -2
  80. package/dist/esm/layer/LayerGroup.js +2 -3
  81. package/dist/esm/layer/LayerGroup.js.map +1 -1
  82. package/dist/esm/layer/Popup.js +9 -16
  83. package/dist/esm/layer/Popup.js.map +1 -1
  84. package/dist/esm/layer/SVGOverlay.js +1 -2
  85. package/dist/esm/layer/Tooltip.js +16 -17
  86. package/dist/esm/layer/Tooltip.js.map +1 -1
  87. package/dist/esm/layer/VideoOverlay.js +1 -2
  88. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  89. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  90. package/dist/esm/layer/marker/DivIcon.js +1 -2
  91. package/dist/esm/layer/marker/Icon.js +2 -2
  92. package/dist/esm/layer/marker/Icon.js.map +1 -1
  93. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  94. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  95. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  96. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  97. package/dist/esm/layer/marker/Marker.js +54 -14
  98. package/dist/esm/layer/marker/Marker.js.map +1 -1
  99. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  100. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  101. package/dist/esm/layer/tile/GridLayer.js +4 -4
  102. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  103. package/dist/esm/layer/tile/TileLayer.js +8 -8
  104. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  105. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  106. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  107. package/dist/esm/layer/vector/Canvas.js +7 -14
  108. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  109. package/dist/esm/layer/vector/Circle.js +4 -3
  110. package/dist/esm/layer/vector/Circle.js.map +1 -1
  111. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  112. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  113. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  114. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  115. package/dist/esm/layer/vector/Path.js +1 -2
  116. package/dist/esm/layer/vector/Polygon.js +2 -3
  117. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  118. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  119. package/dist/esm/layer/vector/Polyline.js +2 -3
  120. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  121. package/dist/esm/layer/vector/Rectangle.js +1 -2
  122. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  124. package/dist/esm/layer/vector/Renderer.js +1 -2
  125. package/dist/esm/layer/vector/SVG.js +7 -4
  126. package/dist/esm/layer/vector/SVG.js.map +1 -1
  127. package/dist/esm/map/Hash.js +1 -2
  128. package/dist/esm/map/Map.Rotation.js +31 -16
  129. package/dist/esm/map/Map.Rotation.js.map +1 -1
  130. package/dist/esm/map/Map.js +10 -17
  131. package/dist/esm/map/Map.js.map +1 -1
  132. package/dist/esm/map/MapSync.js +1 -2
  133. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  134. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  135. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  136. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  137. package/dist/esm/map/handler/DragHandler.js +1 -2
  138. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  139. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  140. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  141. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  144. package/dist/esm/package.js +2 -3
  145. package/dist/maplair-global-src.js +487 -613
  146. package/dist/maplair-global-src.js.map +1 -1
  147. package/dist/maplair-global.js +2 -2
  148. package/dist/maplair-global.js.map +1 -1
  149. package/dist/maplair-src.js +483 -609
  150. package/dist/maplair-src.js.map +1 -1
  151. package/dist/maplair.css +1 -1263
  152. package/dist/maplair.js +2 -2
  153. package/dist/maplair.js.map +1 -1
  154. package/package.json +3 -8
  155. package/src/Maplair.all.js +0 -1
  156. package/src/control/LayersControl.js +39 -52
  157. package/src/control/ZoomControl.js +17 -31
  158. package/src/core/Class.js +5 -14
  159. package/src/core/Handler.js +11 -1
  160. package/src/core/Util.js +1 -1
  161. package/src/dom/DomEvent.js +9 -19
  162. package/src/dom/Draggable.js +5 -1
  163. package/src/geo/LatLngBounds.js +8 -15
  164. package/src/geo/crs/EPSG3395.js +3 -3
  165. package/src/geo/crs/EPSG3857.js +3 -3
  166. package/src/geo/crs/EPSG4326.js +2 -2
  167. package/src/geo/crs/SimpleCRS.js +2 -2
  168. package/src/geo/index.js +1 -2
  169. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  170. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  171. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  172. package/src/geo/projection/index.js +5 -5
  173. package/src/geometry/Bounds.js +12 -17
  174. package/src/geometry/LineUtil.js +1 -1
  175. package/src/geometry/PolyUtil.js +23 -31
  176. package/src/layer/DivOverlay.js +1 -1
  177. package/src/layer/FeatureGroup.js +8 -2
  178. package/src/layer/GeoJSON.js +10 -13
  179. package/src/layer/HeatLayer.js +1 -1
  180. package/src/layer/ImageOverlay.js +2 -2
  181. package/src/layer/LayerGroup.js +1 -1
  182. package/src/layer/Popup.js +9 -19
  183. package/src/layer/Tooltip.js +19 -17
  184. package/src/layer/marker/DefaultIcon.js +33 -5
  185. package/src/layer/marker/Icon.js +2 -0
  186. package/src/layer/marker/Marker.Drag.js +53 -5
  187. package/src/layer/marker/Marker.Move.js +3 -4
  188. package/src/layer/marker/Marker.js +64 -13
  189. package/src/layer/tile/GridLayer.js +5 -2
  190. package/src/layer/tile/TileLayer.js +9 -6
  191. package/src/layer/tile/WMSTileLayer.js +5 -2
  192. package/src/layer/vector/Canvas.js +10 -14
  193. package/src/layer/vector/Circle.js +4 -1
  194. package/src/layer/vector/CircleMarker.js +2 -1
  195. package/src/layer/vector/Polygon.js +1 -1
  196. package/src/layer/vector/Polyline.js +1 -1
  197. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  198. package/src/layer/vector/SVG.js +12 -2
  199. package/src/map/Map.Rotation.js +28 -4
  200. package/src/map/Map.js +17 -21
  201. package/src/map/handler/BoxZoomHandler.js +21 -42
  202. package/src/map/handler/KeyboardHandler.js +34 -53
  203. package/src/maplair.css +5 -0
  204. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  205. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  206. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  207. package/dist/esm/geo/projection/index.js +0 -14
  208. package/dist/esm/geo/projection/index.js.map +0 -1
  209. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  210. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  211. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -1,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,sBA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,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,I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ACb,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,KAAO;EAEZ,MAAM,OAAO,KAAK,OAClB,QAAQ,iBAAiB,IAAI,GAC7B,SAAS,IAAI,MAAM,CAAC,WAAW,MAAM,UAAU,KAAK,GAAG,CAAC,WAAW,MAAM,SAAS,KAAK,CAAC,GACxF,OAAO,IAAI,MAAM,KAAK,aAAa,KAAK,YAAY;EAEpD,IAAI,UAAU,KAAK,SAAS;GAC3B,gBAAgB;GAChB,oBAAoB,KAAK,SAAS,MAAM;EACzC,CAAC;CACF;CAEA,kBAAkB;EACjB,OAAO,KAAK,cAAc,KAAK,QAAQ,KAAK,QAAQ,WAAW;CAChE;CAEA,oBAAoB;EACnB,OAAO,KAAK,cAAc,KAAK,QAAQ,KAAK,QAAQ,aAAa;CAClE;CAGA,cAAc,QAAQ;EACrB,MAAM,QAAQ,KAAK,QAAQ,WAAW,KAAK,KAAK;EAChD,IAAI,CAAC,SAAS,CAAC,QAAU,OAAO;EAEhC,MAAM,EAAC,GAAG,MAAK,MAAM,KAAK,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
@@ -1 +1 @@
1
- {"version":3,"file":"GridLayer.js","names":["Util.throttle","DomUtil.create","DomUtil.getPosition","Util.wrapNum"],"sources":["../../../../src/layer/tile/GridLayer.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Point} from '../../geometry/Point.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\n/** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */\n/** @import {LayerOptions} from '../Layer.js' */\n\n/**\n * Options of `GridLayer`.\n * @typedef {object} GridLayerOptions\n * @property {number|Point} [tileSize=256] Width and height of tiles in the grid. Use a\n * number if width and height are equal, or `Point(width, height)` otherwise.\n * @property {number} [opacity=1] Opacity of the tiles. Can be used in the `createTile()`\n * function.\n * @property {string|null} [placeholder=null] A CSS\n * [`background`](https://developer.mozilla.org/docs/Web/CSS/background) shown in place\n * of tiles while they are loading, e.g. `'#ddd'` or\n * `'url(loading.svg) center no-repeat #eee'`. Tiles with a placeholder appear without\n * fading in.\n * @property {boolean} [updateWhenIdle=false] Load new tiles only when panning ends.\n * @property {boolean} [updateWhenZooming=true] By default, a smooth zoom animation\n * (during a [pinch zoom](#map-pinchzoom) or a [`flyTo()`](#map-flyto)) will update grid\n * layers every integer zoom level. Setting this option to `false` will update the grid\n * layer only when the smooth animation ends.\n * @property {number} [updateInterval=200] Tiles will not update more than once every\n * `updateInterval` milliseconds when panning.\n * @property {number} [zIndex=1] The explicit zIndex of the tile layer.\n * @property {LatLngBoundsExpression|null} [bounds=null] If set, tiles will only be\n * loaded inside the set `LatLngBounds`.\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will\n * be displayed (inclusive).\n * @property {number} [maxZoom] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxNativeZoom] Maximum zoom number the tile source has available.\n * If it is specified, the tiles on all zoom levels higher than `maxNativeZoom` will be\n * loaded from `maxNativeZoom` level and auto-scaled.\n * @property {number} [minNativeZoom] Minimum zoom number the tile source has available.\n * If it is specified, the tiles on all zoom levels lower than `minNativeZoom` will be\n * loaded from `minNativeZoom` level and auto-scaled.\n * @property {boolean} [noWrap=false] Whether the layer is wrapped around the\n * antimeridian. If `true`, the GridLayer will only be displayed once at low zoom\n * levels. Has no effect when the [map CRS](#maplairmapoptions-crs) doesn't wrap around.\n * Can be used in combination with [`bounds`](#gridlayeroptions-bounds) to prevent\n * requesting tiles outside the CRS limits.\n * @property {string} [pane='tilePane'] `Map pane` where the grid layer will be added.\n * @property {string} [className=''] A custom class name to assign to the tile layer.\n * Empty by default.\n * @property {boolean} [pixelated=false] Whether to scale the tiles with\n * nearest-neighbour interpolation (`image-rendering: pixelated`) instead of smoothing\n * them, so that their pixels stay crisp, e.g. while zooming or beyond `maxNativeZoom`.\n * Useful for raster data, pixel art or scientific imagery.\n * @property {number} [keepBuffer=2] When panning the map, keep this many rows and\n * columns of tiles before unloading them.\n * @extends LayerOptions\n */\n\n/**\n * The callback of asynchronous `createTile()`, to be called with an error (or `null`)\n * and the tile when the tile has finished loading and drawing.\n * @typedef {(error: any, tile: HTMLElement) => void} TileDoneCallback\n */\n\n/**\n * Generic class for handling a tiled grid of HTML elements. This is the base class for\n * all tile layers and replaces `TileLayer.Canvas`. GridLayer can be extended to create\n * a tiled grid of HTML elements like `<canvas>`, `<img>` or `<div>`. GridLayer will\n * handle creating and animating these DOM elements for you.\n *\n * Layers extending `GridLayer` shall reimplement the [`createTile()`](#gridlayer-createtile)\n * method.\n *\n * @example\n * ### Synchronous usage\n *\n * To create a custom layer, extend GridLayer and implement the `createTile()` method,\n * which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level)\n * coordinates to draw your tile.\n *\n * ```js\n * class CanvasLayer extends GridLayer {\n * createTile(coords) {\n * // create a <canvas> element for drawing\n * const tile = DomUtil.create('canvas', 'maplair-tile');\n *\n * // setup tile width and height according to the options\n * const size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // get a canvas context and draw something on it using coords.x, coords.y and coords.z\n * const ctx = tile.getContext('2d');\n *\n * // return the tile so it can be rendered on screen\n * return tile;\n * }\n * }\n * ```\n *\n * @example\n * ### Asynchronous usage\n *\n * Tile creation can also be asynchronous, this is useful when using a third-party\n * drawing library. Once the tile is finished drawing it can be passed to the `done()`\n * callback.\n *\n * ```js\n * class CanvasLayer extends GridLayer {\n * createTile(coords, done) {\n * const error;\n *\n * // create a <canvas> element for drawing\n * const tile = DomUtil.create('canvas', 'maplair-tile');\n *\n * // setup tile width and height according to the options\n * const size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // draw something asynchronously and pass the tile to the done() callback\n * setTimeout(function() {\n * done(error, tile);\n * }, 1000);\n *\n * return tile;\n * }\n * }\n * ```\n *\n * @fires loading {MaplairEvent} Fired when the grid layer starts loading tiles.\n * @fires tileunload {TileEvent} Fired when a tile is removed (e.g. when a tile goes off\n * the screen).\n * @fires tileloadstart {TileEvent} Fired when a tile is requested and starts loading.\n * @fires tileerror {TileErrorEvent} Fired when there is an error loading a tile.\n * @fires tileload {TileEvent} Fired when a tile loads.\n * @fires load {MaplairEvent} Fired when the grid layer loaded all visible tiles.\n */\nexport class GridLayer extends Layer {\n\n\tstatic defaultOptions = {\n\t\ttileSize: 256,\n\t\topacity: 1,\n\t\tplaceholder: null,\n\t\tupdateWhenIdle: false,\n\t\tupdateWhenZooming: true,\n\t\tupdateInterval: 200,\n\t\tzIndex: 1,\n\t\tbounds: null,\n\t\tminZoom: 0,\n\t\tmaxZoom: undefined,\n\t\tmaxNativeZoom: undefined,\n\t\tminNativeZoom: undefined,\n\t\tnoWrap: false,\n\t\tpane: 'tilePane',\n\t\tclassName: '',\n\t\tpixelated: false,\n\t\tkeepBuffer: 2\n\t};\n\n\t/**\n\t * Creates a new instance of GridLayer with the supplied options.\n\t * @param {GridLayerOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis.callInitHooks(GridLayer);\n\t}\n\n\t/**\n\t * Creates the container of the tiles and loads the tiles.\n\t * @overload\n\t * @param {MaplairMap} map\n\t * @returns {void}\n\t */\n\tonAdd() {\n\t\tthis._initContainer();\n\n\t\tthis._levels = {};\n\t\tthis._tiles = {};\n\n\t\tthis._resetView(); // implicit _update() call\n\t}\n\n\t/**\n\t * Registers the zoom limits of the layer on the map.\n\t * @param {MaplairMap} map\n\t */\n\tbeforeAdd(map) {\n\t\tmap._addZoomLimit(this);\n\t}\n\n\t/**\n\t * Removes the tiles from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis._removeKeptLevel();\n\t\tthis._removeAllTiles();\n\t\tthis._container.remove();\n\t\tmap._removeZoomLimit(this);\n\t\tthis._container = null;\n\t\tthis._tileZoom = undefined;\n\t\tclearTimeout(this._pruneTimeout);\n\t\tcancelAnimationFrame(this._fadePruneFrame);\n\t\tthis._fadePruneFrame = 0;\n\t}\n\n\t/**\n\t * Brings the tile layer to the top of all tile layers.\n\t * @returns {this}\n\t */\n\tbringToFront() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toFront(this._container);\n\t\t\tthis._setAutoZIndex(Math.max);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Brings the tile layer to the bottom of all tile layers.\n\t * @returns {this}\n\t */\n\tbringToBack() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toBack(this._container);\n\t\t\tthis._setAutoZIndex(Math.min);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the HTML element that contains the tiles for this layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetContainer() {\n\t\treturn this._container;\n\t}\n\n\t/**\n\t * Changes the [opacity](#gridlayeroptions-opacity) of the grid layer.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tthis._updateOpacity();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Changes the [zIndex](#gridlayeroptions-zindex) of the grid layer.\n\t * @param {number} zIndex\n\t * @returns {this}\n\t */\n\tsetZIndex(zIndex) {\n\t\tthis.options.zIndex = zIndex;\n\t\tthis._updateZIndex();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if any tile in the grid layer has not finished loading.\n\t * @returns {boolean}\n\t */\n\tisLoading() {\n\t\treturn this._loading;\n\t}\n\n\t/**\n\t * Causes the layer to clear all the tiles and request them again.\n\t * @returns {this}\n\t */\n\tredraw() {\n\t\tif (this._map) {\n\t\t\tthis._removeAllTiles();\n\t\t\tconst tileZoom = this._clampZoom(Math.round(this._map.getZoom()));\n\t\t\tif (tileZoom !== this._tileZoom) {\n\t\t\t\tthis._tileZoom = tileZoom;\n\t\t\t\tthis._updateLevels();\n\t\t\t}\n\t\t\tthis._update();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tviewprereset: this._invalidateAll,\n\t\t\tviewreset: this._resetView,\n\t\t\tzoom: this._resetView,\n\t\t\tmoveend: this._onMoveEnd,\n\t\t\tworldcopyjump: this._onWorldCopyJump,\n\t\t\tzoomanim: this._animateZoom\n\t\t};\n\n\t\tif (!this.options.updateWhenIdle) {\n\t\t\t// update tiles on move, but not more often than once per given interval\n\t\t\tif (!this._onMove) {\n\t\t\t\tthis._onMove = Util.throttle(this._onMoveEnd, this.options.updateInterval, this);\n\t\t\t}\n\n\t\t\tevents.move = this._onMove;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, must be overridden by classes extending `GridLayer`.\n\t * Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback\n\t * is specified, it must be called when the tile has finished loading and drawing.\n\t * @group Extension methods\n\t * @overload\n\t * @param {Point} coords The `x`, `y` and `z` (zoom level) coordinates of the tile.\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLElement}\n\t */\n\t// without parameters: `createTile.length` tells whether a subclass creates tiles\n\t// asynchronously, see `_addTile()`\n\tcreateTile() {\n\t\treturn document.createElement('div');\n\t}\n\n\t/**\n\t * Normalizes the [tileSize option](#gridlayeroptions-tilesize) into a point. Used by\n\t * the `createTile()` method.\n\t * @returns {Point}\n\t */\n\tgetTileSize() {\n\t\tconst s = this.options.tileSize;\n\t\treturn s instanceof Point ? s : new Point(s, s);\n\t}\n\n\t_updateZIndex() {\n\t\tif (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) {\n\t\t\tthis._container.style.zIndex = `${this.options.zIndex}`;\n\t\t}\n\t}\n\n\t_setAutoZIndex(compare) {\n\t\t// go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)\n\n\t\tconst layers = this.getPane().children;\n\t\tlet edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min\n\n\t\tfor (const layer of layers) {\n\t\t\tconst zIndex = layer.style.zIndex;\n\n\t\t\tif (layer !== this._container && zIndex) {\n\t\t\t\tedgeZIndex = compare(edgeZIndex, +zIndex);\n\t\t\t}\n\t\t}\n\n\t\tif (isFinite(edgeZIndex)) {\n\t\t\tthis.options.zIndex = edgeZIndex + compare(-1, 1);\n\t\t\tthis._updateZIndex();\n\t\t}\n\t}\n\n\t_updateOpacity() {\n\t\tif (!this._map) { return; }\n\n\t\tthis._container.style.opacity = `${this.options.opacity}`;\n\t}\n\n\t_onOpaqueTile() {}\n\n\t_initContainer() {\n\t\tif (this._container) { return; }\n\n\t\tthis._container = DomUtil.create('div', `maplair-layer ${this.options.className ?? ''}`);\n\t\tthis._container.classList.toggle('maplair-pixelated', !!this.options.pixelated);\n\t\tthis._updateZIndex();\n\n\t\tif (this.options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\tthis.getPane().appendChild(this._container);\n\t}\n\n\t// Keeps the loaded tiles of the current level visible below the tiles loaded\n\t// next (e.g. after changing the URL), until these have loaded, to avoid flickering.\n\t_keepCurrentTiles() {\n\t\tconst zoom = this._tileZoom,\n\t\tlevel = this._levels?.[zoom];\n\t\t// keep the first level if the next one has not loaded yet\n\t\tif (!this._map || !level || this._keptLevel) { return; }\n\n\t\tconst tiles = [];\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (tile.coords.z === zoom && tile.loaded) {\n\t\t\t\ttiles.push(tile);\n\t\t\t\tdelete this._tiles[key];\n\t\t\t}\n\t\t}\n\t\tdelete this._levels[zoom];\n\t\tlevel.el.style.zIndex = -1;\n\t\tthis._keptLevel = {level, tiles};\n\t\t// new level for the next tiles\n\t\tthis._updateLevels();\n\n\t\tthis.on('load', this._onLoadKeptLevel, this);\n\t\tthis._map.on('zoomstart viewprereset', this._removeKeptLevel, this);\n\t}\n\n\t_onLoadKeptLevel() {\n\t\tif (this._map._fadeAnimated) {\n\t\t\t// after the new tiles faded in\n\t\t\tclearTimeout(this._keptLevelTimeout);\n\t\t\tthis._keptLevelTimeout = setTimeout(this._removeKeptLevel.bind(this), 250);\n\t\t} else {\n\t\t\tthis._removeKeptLevel();\n\t\t}\n\t}\n\n\t_removeKeptLevel() {\n\t\tif (!this._keptLevel) { return; }\n\t\tconst {level, tiles} = this._keptLevel;\n\t\tthis._keptLevel = null;\n\t\tclearTimeout(this._keptLevelTimeout);\n\t\tthis.off('load', this._onLoadKeptLevel, this);\n\t\tthis._map.off('zoomstart viewprereset', this._removeKeptLevel, this);\n\n\t\tlevel.el.remove();\n\t\tfor (const tile of tiles) {\n\t\t\tthis.fire('tileunload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords: tile.coords\n\t\t\t});\n\t\t}\n\t}\n\n\t_updateLevels() {\n\n\t\tconst zoom = this._tileZoom,\n\t\tmaxZoom = this.options.maxZoom;\n\n\t\tif (zoom === undefined) { return undefined; }\n\n\t\tfor (let z of Object.keys(this._levels)) {\n\t\t\tz = Number(z);\n\t\t\tif (this._levels[z].el.children.length || z === zoom) {\n\t\t\t\tthis._levels[z].el.style.zIndex = `${maxZoom - Math.abs(zoom - z)}`;\n\t\t\t\tthis._onUpdateLevel(z);\n\t\t\t} else {\n\t\t\t\tthis._levels[z].el.remove();\n\t\t\t\tthis._removeTilesAtZoom(z);\n\t\t\t\tthis._onRemoveLevel(z);\n\t\t\t\tdelete this._levels[z];\n\t\t\t}\n\t\t}\n\n\t\tlet level = this._levels[zoom];\n\t\tconst map = this._map;\n\n\t\tif (!level) {\n\t\t\tlevel = this._levels[zoom] = {};\n\n\t\t\tlevel.el = DomUtil.create('div', 'maplair-tile-container maplair-zoom-animated', this._container);\n\t\t\tlevel.el.style.zIndex = `${maxZoom}`;\n\n\t\t\tlevel.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();\n\t\t\tlevel.zoom = zoom;\n\n\t\t\tthis._setZoomTransform(level, map.getCenter(), map.getZoom());\n\n\t\t\t// force reading offsetWidth so the browser considers the newly added element for transition\n\t\t\tUtil.falseFn(level.el.offsetWidth);\n\n\t\t\tthis._onCreateLevel(level);\n\t\t}\n\n\t\tthis._level = level;\n\n\t\treturn level;\n\t}\n\n\t_onUpdateLevel() {}\n\n\t_onRemoveLevel() {}\n\n\t_onCreateLevel() {}\n\n\t_pruneTiles() {\n\t\tif (!this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst zoom = this._map.getZoom();\n\t\tif (zoom > this.options.maxZoom ||\n\t\t\tzoom < this.options.minZoom) {\n\t\t\tthis._removeAllTiles();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\ttile.retain = tile.current;\n\t\t}\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tif (tile.current && !tile.active) {\n\t\t\t\tconst coords = tile.coords;\n\t\t\t\tif (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {\n\t\t\t\t\tthis._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (!tile.retain) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTilesAtZoom(zoom) {\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (tile.coords.z === zoom) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeAllTiles() {\n\t\tfor (const key of Object.keys(this._tiles)) {\n\t\t\tthis._removeTile(key);\n\t\t}\n\t}\n\n\t_invalidateAll(e) {\n\t\t// a zoom without animation keeps the old levels until new tiles load, like the end of an animated one,\n\t\t// unless the view jumps somewhere else\n\t\tconst map = this._map;\n\t\tif (e?.zoom !== undefined && e.zoom !== map.getZoom() && map.getBounds().contains(e.center)) { return; }\n\n\t\tfor (const z of Object.keys(this._levels)) {\n\t\t\tthis._levels[z].el.remove();\n\t\t\tthis._onRemoveLevel(Number(z));\n\t\t\tdelete this._levels[z];\n\t\t}\n\t\tthis._removeAllTiles();\n\n\t\tthis._tileZoom = undefined;\n\t}\n\n\t_retainParent(x, y, z, minZoom) {\n\t\tfor (z--; z >= minZoom; z--) {\n\t\t\tx = Math.floor(x / 2);\n\t\t\ty = Math.floor(y / 2);\n\t\t\tif (this._retain(x, y, z)) { return true; }\n\t\t}\n\t\treturn false;\n\t}\n\n\t_retainChildren(x, y, z, maxZoom) {\n\t\tfor (let i = 2 * x; i < 2 * x + 2; i++) {\n\t\t\tfor (let j = 2 * y; j < 2 * y + 2; j++) {\n\t\t\t\tif (!this._retain(i, j, z + 1) && z + 1 < maxZoom) {\n\t\t\t\t\tthis._retainChildren(i, j, z + 1, maxZoom);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// retains the tile if it's loaded; returns true if it's active, so there's no need to look further\n\t_retain(x, y, z) {\n\t\tconst tile = this._tiles[this._tileCoordsToKey({x, y, z})];\n\t\tif (tile?.loaded) { tile.retain = true; }\n\t\treturn tile?.active;\n\t}\n\n\t_resetView(e) {\n\t\tconst animating = e && (e.pinch || e.flyTo || e.continuous);\n\t\tthis._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);\n\t}\n\n\t_animateZoom(e) {\n\t\tthis._setView(e.center, e.zoom, true, e.noUpdate);\n\t}\n\n\t_clampZoom(zoom) {\n\t\tconst options = this.options;\n\n\t\tif (undefined !== options.minNativeZoom && zoom < options.minNativeZoom) {\n\t\t\treturn options.minNativeZoom;\n\t\t}\n\n\t\tif (undefined !== options.maxNativeZoom && options.maxNativeZoom < zoom) {\n\t\t\treturn options.maxNativeZoom;\n\t\t}\n\n\t\treturn zoom;\n\t}\n\n\t_setView(center, zoom, noPrune, noUpdate) {\n\t\tlet tileZoom = Math.round(zoom);\n\t\tif ((this.options.maxZoom !== undefined && tileZoom > this.options.maxZoom) ||\n\t\t (this.options.minZoom !== undefined && tileZoom < this.options.minZoom)) {\n\t\t\ttileZoom = undefined;\n\t\t} else {\n\t\t\ttileZoom = this._clampZoom(tileZoom);\n\t\t}\n\n\t\tconst tileZoomChanged = this.options.updateWhenZooming && (tileZoom !== this._tileZoom);\n\n\t\tif (!noUpdate || tileZoomChanged) {\n\n\t\t\tthis._tileZoom = tileZoom;\n\n\t\t\tif (this._abortLoading) {\n\t\t\t\tthis._abortLoading();\n\t\t\t}\n\n\t\t\tthis._updateLevels();\n\t\t\tthis._resetGrid();\n\n\t\t\tif (tileZoom !== undefined) {\n\t\t\t\tthis._update(center);\n\t\t\t}\n\n\t\t\tif (!noPrune) {\n\t\t\t\tthis._pruneTiles();\n\t\t\t}\n\n\t\t\t// Flag to prevent finished tile fades from pruning tiles during\n\t\t\t// a zoom anim or a pinch gesture\n\t\t\tthis._noPrune = !!noPrune;\n\t\t}\n\n\t\tthis._setZoomTransforms(center, zoom);\n\t}\n\n\t_setZoomTransforms(center, zoom) {\n\t\tfor (const level of Object.values(this._levels)) {\n\t\t\tthis._setZoomTransform(level, center, zoom);\n\t\t}\n\t}\n\n\t_setZoomTransform(level, center, zoom) {\n\t\tconst scale = this._map.getZoomScale(zoom, level.zoom),\n\t\ttranslate = level.origin.multiplyBy(scale)\n\t\t\t.subtract(this._map._getNewPixelOrigin(center, zoom)).round();\n\n\t\tDomUtil.setTransform(level.el, translate, scale);\n\t}\n\n\t_resetGrid() {\n\t\tconst map = this._map,\n\t\tcrs = map.options.crs,\n\t\ttileSize = this._tileSize = this.getTileSize(),\n\t\ttileZoom = this._tileZoom;\n\n\t\tconst bounds = this._map.getPixelWorldBounds(this._tileZoom);\n\t\tif (bounds) {\n\t\t\tthis._globalTileRange = this._pxBoundsToTileRange(bounds);\n\t\t}\n\n\t\tthis._wrapX = crs.wrapLng && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x),\n\t\t\tMath.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.x)\n\t\t];\n\t\tthis._wrapY = crs.wrapLat && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.y),\n\t\t\tMath.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)\n\t\t];\n\t}\n\n\t_onMoveEnd() {\n\t\tif (!this._map || this._map._animatingZoom) { return; }\n\n\t\tthis._update();\n\t}\n\n\t_onWorldCopyJump({worlds}) {\n\t\t// noWrap tiles cannot be reused in another world copy.\n\t\tif (!this._wrapX) { return; }\n\n\t\tconst tileSize = this.getTileSize(),\n\t\ttiles = {};\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tconst {coords, el} = tile,\n\t\t\tdx = worlds * this._map.getPixelWorldBounds(coords.z).getSize().x;\n\n\t\t\t// tiles can't be shifted by a fraction of a column, so leave those to be reloaded\n\t\t\tif (dx % tileSize.x === 0) {\n\t\t\t\tcoords.x -= dx / tileSize.x;\n\t\t\t\tDomUtil.setPosition(el, DomUtil.getPosition(el).subtract([dx, 0]), true);\n\t\t\t}\n\t\t\ttiles[this._tileCoordsToKey(coords)] = tile;\n\t\t}\n\n\t\tthis._tiles = tiles;\n\t}\n\n\t_getTiledPixelBounds(center) {\n\t\tconst map = this._map,\n\t\tmapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),\n\t\tscale = map.getZoomScale(mapZoom, this._tileZoom),\n\t\tpixelCenter = map.project(center, this._tileZoom).floor(),\n\t\thalfSize = map.getSize().divideBy(scale * 2);\n\n\t\treturn new Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));\n\t}\n\n\t// Private method to load tiles in the grid's active zoom level according to map bounds\n\t_update(center) {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\t\tconst zoom = this._clampZoom(map.getZoom());\n\n\t\tif (center === undefined) { center = map.getCenter(); }\n\t\tif (this._tileZoom === undefined) { return; }\t// if out of minzoom/maxzoom\n\n\t\tconst pixelBounds = this._getTiledPixelBounds(center),\n\t\ttileRange = this._pxBoundsToTileRange(pixelBounds),\n\t\ttileCenter = tileRange.getCenter(),\n\t\tqueue = [],\n\t\tmargin = this.options.keepBuffer,\n\t\tnoPruneRange = new Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),\n\t\t\ttileRange.getTopRight().add([margin, -margin]));\n\n\t\t// Sanity check: panic if the tile range contains Infinity somewhere.\n\t\tif (!(isFinite(tileRange.min.x) &&\n\t\t isFinite(tileRange.min.y) &&\n\t\t isFinite(tileRange.max.x) &&\n\t\t isFinite(tileRange.max.y))) { throw new Error('Attempted to load an infinite number of tiles'); }\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tconst c = tile.coords;\n\t\t\tif (c.z !== this._tileZoom || !noPruneRange.contains(new Point(c.x, c.y))) {\n\t\t\t\ttile.current = false;\n\t\t\t}\n\t\t}\n\n\t\t// _update just loads more tiles. If the tile zoom level differs too much\n\t\t// from the map's, let _setView reset levels and prune old tiles.\n\t\tif (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }\n\n\t\t// create a queue of coordinates to load tiles from\n\t\tfor (let j = tileRange.min.y; j <= tileRange.max.y; j++) {\n\t\t\tfor (let i = tileRange.min.x; i <= tileRange.max.x; i++) {\n\t\t\t\tconst coords = new Point(i, j);\n\t\t\t\tcoords.z = this._tileZoom;\n\n\t\t\t\tif (!this._isValidTile(coords)) { continue; }\n\n\t\t\t\tconst tile = this._tiles[this._tileCoordsToKey(coords)];\n\t\t\t\tif (tile) {\n\t\t\t\t\ttile.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push(coords);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// sort tile queue to load tiles in order of their distance to center\n\t\tqueue.sort((a, b) => a.distanceTo(tileCenter) - b.distanceTo(tileCenter));\n\n\t\tif (queue.length !== 0) {\n\t\t\t// if it's the first batch of tiles to load\n\t\t\tif (!this._loading) {\n\t\t\t\tthis._loading = true;\n\t\t\t\tthis.fire('loading');\n\t\t\t\tthis._map._onLayerLoading();\n\t\t\t}\n\n\t\t\t// create DOM fragment to append tiles in one batch\n\t\t\tconst fragment = document.createDocumentFragment();\n\n\t\t\tfor (const q of queue) {\n\t\t\t\tthis._addTile(q, fragment);\n\t\t\t}\n\n\t\t\tthis._level.el.appendChild(fragment);\n\t\t}\n\t}\n\n\t_isValidTile(coords) {\n\t\tconst crs = this._map.options.crs;\n\n\t\tif (!crs.infinite) {\n\t\t\t// don't load tile if it's out of bounds and not wrapped\n\t\t\tconst bounds = this._globalTileRange;\n\t\t\tif ((!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\n\t\t\t (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; }\n\t\t}\n\n\t\tif (!this.options.bounds) { return true; }\n\n\t\t// don't load tile if it doesn't intersect the bounds in options\n\t\tconst tileBounds = this._tileCoordsToBounds(coords);\n\t\treturn LatLngBounds.from(this.options.bounds).overlaps(tileBounds);\n\t}\n\n\t_tileCoordsToNwSe(coords) {\n\t\tconst map = this._map,\n\t\ttileSize = this.getTileSize(),\n\t\tnwPoint = coords.scaleBy(tileSize),\n\t\tsePoint = nwPoint.add(tileSize),\n\t\tnw = map.unproject(nwPoint, coords.z),\n\t\tse = map.unproject(sePoint, coords.z);\n\t\treturn [nw, se];\n\t}\n\n\t// converts tile coordinates to its geographical bounds\n\t_tileCoordsToBounds(coords) {\n\t\tconst bp = this._tileCoordsToNwSe(coords);\n\t\tlet bounds = new LatLngBounds(bp[0], bp[1]);\n\n\t\tif (!this.options.noWrap) {\n\t\t\tbounds = this._map.wrapLatLngBounds(bounds);\n\t\t}\n\t\treturn bounds;\n\t}\n\t// converts tile coordinates to key for the tile cache\n\t_tileCoordsToKey(coords) {\n\t\treturn `${coords.x}:${coords.y}:${coords.z}`;\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\ttile.el.remove();\n\n\t\tdelete this._tiles[key];\n\n\t\tthis.fire('tileunload', {\n\t\t\ttile: tile.el,\n\t\t\tcoords: tile.coords\n\t\t});\n\t}\n\n\t_initTile(tile) {\n\t\ttile.classList.add('maplair-tile');\n\n\t\tconst tileSize = this.getTileSize();\n\t\ttile.style.width = `${tileSize.x}px`;\n\t\ttile.style.height = `${tileSize.y}px`;\n\n\t\tif (this.options.placeholder) {\n\t\t\ttile.style.background = this.options.placeholder;\n\t\t}\n\t}\n\n\t_addTile(coords, container) {\n\t\tconst tilePos = this._getTilePos(coords),\n\t\tkey = this._tileCoordsToKey(coords);\n\n\t\tconst tile = this.createTile(this._wrapCoords(coords), this._tileReady.bind(this, coords));\n\n\t\tthis._initTile(tile);\n\n\t\t// if createTile is defined with a second argument (\"done\" callback),\n\t\t// we know that tile is async and will be ready later; otherwise\n\t\tif (this.createTile.length < 2) {\n\t\t\t// mark tile as ready, but delay one frame for opacity animation to happen\n\t\t\trequestAnimationFrame(this._tileReady.bind(this, coords, null, tile));\n\t\t}\n\n\t\t// 2D, so tiles raster into the level's layer: as separate layers they get compositor edge antialiasing,\n\t\t// and the overlapping edge ramps show as light seams under plus-lighter blending\n\t\tDomUtil.setPosition(tile, tilePos, true);\n\n\t\t// save tile in cache\n\t\tthis._tiles[key] = {\n\t\t\tel: tile,\n\t\t\tcoords,\n\t\t\tcurrent: true\n\t\t};\n\n\t\tcontainer.appendChild(tile);\n\t\tthis.fire('tileloadstart', {\n\t\t\ttile,\n\t\t\tcoords\n\t\t});\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (err) {\n\t\t\tthis.fire('tileerror', {\n\t\t\t\terror: err,\n\t\t\t\ttile,\n\t\t\t\tcoords\n\t\t\t});\n\t\t}\n\n\t\tconst key = this._tileCoordsToKey(coords);\n\n\t\ttile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\tif (this.options.placeholder) {\n\t\t\ttile.el.style.background = '';\n\t\t}\n\t\t// fading in with a placeholder would show the map below instead of the placeholder at first\n\t\tif (!this._map._fadeAnimated || this.options.placeholder) {\n\t\t\ttile.active = true;\n\t\t\tthis._pruneTiles();\n\t\t} else if (!tile.loaded) { // with errorTileUrl, a tile is ready twice (on error and on fallback load)\n\t\t\t// while fading, the tile is a compositor layer of its own where plus-lighter would light up its\n\t\t\t// antialiased edges, so it's blended normally until the fade ends\n\t\t\ttile.el.classList.add('maplair-tile-fading');\n\t\t\ttile.el.animate({opacity: [0, 1]}, 200).onfinish = this._onTileFaded.bind(this, tile);\n\t\t}\n\t\ttile.loaded = true;\n\n\t\tif (!err) {\n\t\t\ttile.el.classList.add('maplair-tile-loaded');\n\n\t\t\tthis.fire('tileload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords\n\t\t\t});\n\t\t}\n\n\t\tif (this._noTilesToLoad()) {\n\t\t\tthis._loading = false;\n\t\t\tthis.fire('load');\n\t\t\tthis._map._scheduleIdleCheck();\n\n\t\t\tif (!this._map._fadeAnimated) {\n\t\t\t\trequestAnimationFrame(this._pruneTiles.bind(this));\n\t\t\t} else {\n\t\t\t\t// Wait a bit more than 0.2 secs (the duration of the tile fade-in)\n\t\t\t\t// to trigger a pruning.\n\t\t\t\tthis._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);\n\t\t\t}\n\t\t}\n\t}\n\n\t_onTileFaded(tile) {\n\t\ttile.el.classList.remove('maplair-tile-fading');\n\t\t// the tile's key may have changed after a world copy jump, so look it up again\n\t\tif (this._tiles[this._tileCoordsToKey(tile.coords)] !== tile) { return; }\n\n\t\ttile.active = true;\n\t\tthis._onOpaqueTile(tile);\n\n\t\t// one prune for all the tiles that finish fading in the same frame\n\t\tif (this._noPrune || this._fadePruneFrame) { return; }\n\t\tthis._fadePruneFrame = requestAnimationFrame(() => {\n\t\t\tthis._fadePruneFrame = 0;\n\t\t\tif (!this._noPrune) { this._pruneTiles(); }\n\t\t});\n\t}\n\n\t_getTilePos(coords) {\n\t\treturn coords.scaleBy(this.getTileSize()).subtract(this._level.origin);\n\t}\n\n\t_wrapCoords(coords) {\n\t\tconst newCoords = new Point(\n\t\t\tthis._wrapX ? Util.wrapNum(coords.x, this._wrapX) : coords.x,\n\t\t\tthis._wrapY ? Util.wrapNum(coords.y, this._wrapY) : coords.y);\n\t\tnewCoords.z = coords.z;\n\t\treturn newCoords;\n\t}\n\n\t_pxBoundsToTileRange(bounds) {\n\t\tconst tileSize = this.getTileSize();\n\t\treturn new Bounds(\n\t\t\tbounds.min.unscaleBy(tileSize).floor(),\n\t\t\tbounds.max.unscaleBy(tileSize).ceil().subtract([1, 1]));\n\t}\n\n\t_noTilesToLoad() {\n\t\treturn Object.values(this._tiles).every(t => t.loaded);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,IAAa,YAAb,MAAa,kBAAkB,MAAM;CAEpC,OAAO,iBAAiB;EACvB,UAAU;EACV,SAAS;EACT,aAAa;EACb,gBAAgB;EAChB,mBAAmB;EACnB,gBAAgB;EAChB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,SAAS,KAAA;EACT,eAAe,KAAA;EACf,eAAe,KAAA;EACf,QAAQ;EACR,MAAM;EACN,WAAW;EACX,WAAW;EACX,YAAY;CACb;;;;;CAMA,YAAY,SAAS;EACpB,MAAM;EACN,WAAgB,MAAM,OAAO;EAE7B,KAAK,cAAc,SAAS;CAC7B;;;;;;;CAQA,QAAQ;EACP,KAAK,eAAe;EAEpB,KAAK,UAAU,CAAC;EAChB,KAAK,SAAS,CAAC;EAEf,KAAK,WAAW;CACjB;;;;;CAMA,UAAU,KAAK;EACd,IAAI,cAAc,IAAI;CACvB;;;;;CAMA,SAAS,KAAK;EACb,KAAK,iBAAiB;EACtB,KAAK,gBAAgB;EACrB,KAAK,WAAW,OAAO;EACvB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,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;CACxD;CAEA,iBAAiB;EAChB,OAAO,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,OAAM,MAAK,EAAE,MAAM;CACtD;AACD"}
1
+ {"version":3,"file":"GridLayer.js","names":["Util.throttle","DomUtil.create","DomUtil.getPosition","Util.wrapNum"],"sources":["../../../../src/layer/tile/GridLayer.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Point} from '../../geometry/Point.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\n/** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */\n/** @import {LayerOptions} from '../Layer.js' */\n\n/**\n * Options of `GridLayer`.\n * @typedef {object} GridLayerOptions\n * @property {number|Point} [tileSize=256] Width and height of tiles in the grid. Use a\n * number if width and height are equal, or `Point(width, height)` otherwise.\n * @property {number} [opacity=1] Opacity of the tiles. Can be used in the `createTile()`\n * function.\n * @property {string|null} [placeholder=null] A CSS\n * [`background`](https://developer.mozilla.org/docs/Web/CSS/background) shown in place\n * of tiles while they are loading, e.g. `'#ddd'` or\n * `'url(loading.svg) center no-repeat #eee'`. Tiles with a placeholder appear without\n * fading in.\n * @property {boolean} [updateWhenIdle=false] Load new tiles only when panning ends.\n * @property {boolean} [updateWhenZooming=true] By default, a smooth zoom animation\n * (during a [pinch zoom](#map-pinchzoom) or a [`flyTo()`](#map-flyto)) will update grid\n * layers every integer zoom level. Setting this option to `false` will update the grid\n * layer only when the smooth animation ends.\n * @property {number} [updateInterval=200] Tiles will not update more than once every\n * `updateInterval` milliseconds when panning.\n * @property {number} [zIndex=1] The explicit zIndex of the tile layer.\n * @property {LatLngBoundsExpression|null} [bounds=null] If set, tiles will only be\n * loaded inside the set `LatLngBounds`.\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will\n * be displayed (inclusive).\n * @property {number} [maxZoom] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxNativeZoom] Maximum zoom number the tile source has available.\n * If it is specified, the tiles on all zoom levels higher than `maxNativeZoom` will be\n * loaded from `maxNativeZoom` level and auto-scaled.\n * @property {number} [minNativeZoom] Minimum zoom number the tile source has available.\n * If it is specified, the tiles on all zoom levels lower than `minNativeZoom` will be\n * loaded from `minNativeZoom` level and auto-scaled.\n * @property {boolean} [noWrap=false] Whether the layer is wrapped around the\n * antimeridian. If `true`, the GridLayer will only be displayed once at low zoom\n * levels. Has no effect when the [map CRS](#maplairmapoptions-crs) doesn't wrap around.\n * Can be used in combination with [`bounds`](#gridlayeroptions-bounds) to prevent\n * requesting tiles outside the CRS limits.\n * @property {string} [pane='tilePane'] `Map pane` where the grid layer will be added.\n * @property {string} [className=''] A custom class name to assign to the tile layer.\n * Empty by default.\n * @property {boolean} [pixelated=false] Whether to scale the tiles with\n * nearest-neighbour interpolation (`image-rendering: pixelated`) instead of smoothing\n * them, so that their pixels stay crisp, e.g. while zooming or beyond `maxNativeZoom`.\n * Useful for raster data, pixel art or scientific imagery.\n * @property {number} [keepBuffer=2] When panning the map, keep this many rows and\n * columns of tiles before unloading them.\n * @extends LayerOptions\n */\n\n/**\n * The callback of asynchronous `createTile()`, to be called with an error (or `null`)\n * and the tile when the tile has finished loading and drawing.\n * @typedef {(error: any, tile: HTMLElement) => void} TileDoneCallback\n */\n\n/**\n * Generic class for handling a tiled grid of HTML elements. This is the base class for\n * all tile layers and replaces `TileLayer.Canvas`. GridLayer can be extended to create\n * a tiled grid of HTML elements like `<canvas>`, `<img>` or `<div>`. GridLayer will\n * handle creating and animating these DOM elements for you.\n *\n * Layers extending `GridLayer` shall reimplement the [`createTile()`](#gridlayer-createtile)\n * method.\n *\n * @example\n * ### Synchronous usage\n *\n * To create a custom layer, extend GridLayer and implement the `createTile()` method,\n * which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level)\n * coordinates to draw your tile.\n *\n * ```js\n * class CanvasLayer extends GridLayer {\n * createTile(coords) {\n * // create a <canvas> element for drawing\n * const tile = DomUtil.create('canvas', 'maplair-tile');\n *\n * // setup tile width and height according to the options\n * const size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // get a canvas context and draw something on it using coords.x, coords.y and coords.z\n * const ctx = tile.getContext('2d');\n *\n * // return the tile so it can be rendered on screen\n * return tile;\n * }\n * }\n * ```\n *\n * @example\n * ### Asynchronous usage\n *\n * Tile creation can also be asynchronous, this is useful when using a third-party\n * drawing library. Once the tile is finished drawing it can be passed to the `done()`\n * callback.\n *\n * ```js\n * class CanvasLayer extends GridLayer {\n * createTile(coords, done) {\n * const error;\n *\n * // create a <canvas> element for drawing\n * const tile = DomUtil.create('canvas', 'maplair-tile');\n *\n * // setup tile width and height according to the options\n * const size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // draw something asynchronously and pass the tile to the done() callback\n * setTimeout(function() {\n * done(error, tile);\n * }, 1000);\n *\n * return tile;\n * }\n * }\n * ```\n *\n * @fires loading {MaplairEvent} Fired when the grid layer starts loading tiles.\n * @fires tileunload {TileEvent} Fired when a tile is removed (e.g. when a tile goes off\n * the screen).\n * @fires tileloadstart {TileEvent} Fired when a tile is requested and starts loading.\n * @fires tileerror {TileErrorEvent} Fired when there is an error loading a tile.\n * @fires tileload {TileEvent} Fired when a tile loads.\n * @fires load {MaplairEvent} Fired when the grid layer loaded all visible tiles.\n */\nexport class GridLayer extends Layer {\n\n\tstatic defaultOptions = {\n\t\ttileSize: 256,\n\t\topacity: 1,\n\t\tplaceholder: null,\n\t\tupdateWhenIdle: false,\n\t\tupdateWhenZooming: true,\n\t\tupdateInterval: 200,\n\t\tzIndex: 1,\n\t\tbounds: null,\n\t\tminZoom: 0,\n\t\tmaxZoom: undefined,\n\t\tmaxNativeZoom: undefined,\n\t\tminNativeZoom: undefined,\n\t\tnoWrap: false,\n\t\tpane: 'tilePane',\n\t\tclassName: '',\n\t\tpixelated: false,\n\t\tkeepBuffer: 2\n\t};\n\n\t/**\n\t * Creates a new instance of GridLayer with the supplied options.\n\t * @param {GridLayerOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis.callInitHooks(GridLayer);\n\t}\n\n\t/**\n\t * Creates the container of the tiles and loads the tiles.\n\t * @overload\n\t * @param {MaplairMap} map\n\t * @returns {void}\n\t */\n\tonAdd() {\n\t\tthis._initContainer();\n\n\t\tthis._levels = {};\n\t\tthis._tiles = {};\n\n\t\tthis._resetView(); // implicit _update() call\n\t}\n\n\t/**\n\t * Registers the zoom limits of the layer on the map.\n\t * @param {MaplairMap} map\n\t */\n\tbeforeAdd(map) {\n\t\tmap._addZoomLimit(this);\n\t}\n\n\t/**\n\t * Removes the tiles from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis._removeKeptLevel();\n\t\tthis._removeAllTiles();\n\t\tthis._container.remove();\n\t\tmap._removeZoomLimit(this);\n\t\tthis._container = null;\n\t\tthis._tileZoom = undefined;\n\t\tclearTimeout(this._pruneTimeout);\n\t\tcancelAnimationFrame(this._fadePruneFrame);\n\t\tthis._fadePruneFrame = 0;\n\t}\n\n\t/**\n\t * Brings the tile layer to the top of all tile layers.\n\t * @returns {this}\n\t */\n\tbringToFront() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toFront(this._container);\n\t\t\tthis._setAutoZIndex(Math.max);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Brings the tile layer to the bottom of all tile layers.\n\t * @returns {this}\n\t */\n\tbringToBack() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toBack(this._container);\n\t\t\tthis._setAutoZIndex(Math.min);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the HTML element that contains the tiles for this layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetContainer() {\n\t\treturn this._container;\n\t}\n\n\t/**\n\t * Changes the [opacity](#gridlayeroptions-opacity) of the grid layer.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tthis._updateOpacity();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Changes the [zIndex](#gridlayeroptions-zindex) of the grid layer.\n\t * @param {number} zIndex\n\t * @returns {this}\n\t */\n\tsetZIndex(zIndex) {\n\t\tthis.options.zIndex = zIndex;\n\t\tthis._updateZIndex();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if any tile in the grid layer has not finished loading.\n\t * @returns {boolean}\n\t */\n\tisLoading() {\n\t\treturn !!this._loading;\n\t}\n\n\t/**\n\t * Causes the layer to clear all the tiles and request them again.\n\t * @returns {this}\n\t */\n\tredraw() {\n\t\tif (this._map) {\n\t\t\tthis._removeAllTiles();\n\t\t\tconst tileZoom = this._clampZoom(Math.round(this._map.getZoom()));\n\t\t\tif (tileZoom !== this._tileZoom) {\n\t\t\t\tthis._tileZoom = tileZoom;\n\t\t\t\tthis._updateLevels();\n\t\t\t}\n\t\t\tthis._update();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tviewprereset: this._invalidateAll,\n\t\t\tviewreset: this._resetView,\n\t\t\tzoom: this._resetView,\n\t\t\tmoveend: this._onMoveEnd,\n\t\t\tworldcopyjump: this._onWorldCopyJump,\n\t\t\tzoomanim: this._animateZoom\n\t\t};\n\n\t\tif (!this.options.updateWhenIdle) {\n\t\t\t// update tiles on move, but not more often than once per given interval\n\t\t\tif (!this._onMove) {\n\t\t\t\tthis._onMove = Util.throttle(this._onMoveEnd, this.options.updateInterval, this);\n\t\t\t}\n\n\t\t\tevents.move = this._onMove;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, must be overridden by classes extending `GridLayer`.\n\t * Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback\n\t * is specified, it must be called when the tile has finished loading and drawing.\n\t * @group Extension methods\n\t * @overload\n\t * @param {Point} coords The `x`, `y` and `z` (zoom level) coordinates of the tile.\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLElement}\n\t */\n\t// without parameters: `createTile.length` tells whether a subclass creates tiles\n\t// asynchronously, see `_addTile()`\n\tcreateTile() {\n\t\treturn document.createElement('div');\n\t}\n\n\t/**\n\t * Normalizes the [tileSize option](#gridlayeroptions-tilesize) into a point. Used by\n\t * the `createTile()` method.\n\t * @returns {Point}\n\t */\n\tgetTileSize() {\n\t\tconst s = this.options.tileSize;\n\t\treturn s instanceof Point ? s : new Point(s, s);\n\t}\n\n\t_updateZIndex() {\n\t\tif (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) {\n\t\t\tthis._container.style.zIndex = `${this.options.zIndex}`;\n\t\t}\n\t}\n\n\t_setAutoZIndex(compare) {\n\t\t// go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)\n\n\t\tconst layers = this.getPane().children;\n\t\tlet edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min\n\n\t\tfor (const layer of layers) {\n\t\t\tconst zIndex = layer.style.zIndex;\n\n\t\t\tif (layer !== this._container && zIndex) {\n\t\t\t\tedgeZIndex = compare(edgeZIndex, +zIndex);\n\t\t\t}\n\t\t}\n\n\t\tif (isFinite(edgeZIndex)) {\n\t\t\tthis.options.zIndex = edgeZIndex + compare(-1, 1);\n\t\t\tthis._updateZIndex();\n\t\t}\n\t}\n\n\t_updateOpacity() {\n\t\tif (!this._map) { return; }\n\n\t\tthis._container.style.opacity = `${this.options.opacity}`;\n\t}\n\n\t_onOpaqueTile() {}\n\n\t_initContainer() {\n\t\tif (this._container) { return; }\n\n\t\tthis._container = DomUtil.create('div', `maplair-layer ${this.options.className ?? ''}`);\n\t\tthis._container.classList.toggle('maplair-pixelated', !!this.options.pixelated);\n\t\tthis._updateZIndex();\n\n\t\tif (this.options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\tthis.getPane().appendChild(this._container);\n\t}\n\n\t// Keeps the loaded tiles of the current level visible below the tiles loaded\n\t// next (e.g. after changing the URL), until these have loaded, to avoid flickering.\n\t_keepCurrentTiles() {\n\t\tconst zoom = this._tileZoom,\n\t\tlevel = this._levels?.[zoom];\n\t\t// keep the first level if the next one has not loaded yet\n\t\tif (!this._map || !level || this._keptLevel) { return; }\n\n\t\tconst tiles = [];\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (tile.coords.z === zoom && tile.loaded) {\n\t\t\t\ttiles.push(tile);\n\t\t\t\tdelete this._tiles[key];\n\t\t\t}\n\t\t}\n\t\tdelete this._levels[zoom];\n\t\tlevel.el.style.zIndex = -1;\n\t\tthis._keptLevel = {level, tiles};\n\t\t// new level for the next tiles\n\t\tthis._updateLevels();\n\n\t\tthis.on('load', this._onLoadKeptLevel, this);\n\t\tthis._map.on('zoomstart viewprereset', this._removeKeptLevel, this);\n\t}\n\n\t_onLoadKeptLevel() {\n\t\tif (this._map._fadeAnimated) {\n\t\t\t// after the new tiles faded in\n\t\t\tclearTimeout(this._keptLevelTimeout);\n\t\t\tthis._keptLevelTimeout = setTimeout(this._removeKeptLevel.bind(this), 250);\n\t\t} else {\n\t\t\tthis._removeKeptLevel();\n\t\t}\n\t}\n\n\t_removeKeptLevel() {\n\t\tif (!this._keptLevel) { return; }\n\t\tconst {level, tiles} = this._keptLevel;\n\t\tthis._keptLevel = null;\n\t\tclearTimeout(this._keptLevelTimeout);\n\t\tthis.off('load', this._onLoadKeptLevel, this);\n\t\tthis._map.off('zoomstart viewprereset', this._removeKeptLevel, this);\n\n\t\tlevel.el.remove();\n\t\tfor (const tile of tiles) {\n\t\t\tthis.fire('tileunload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords: tile.coords\n\t\t\t});\n\t\t}\n\t}\n\n\t_updateLevels() {\n\n\t\tconst zoom = this._tileZoom,\n\t\tmaxZoom = this.options.maxZoom;\n\n\t\tif (zoom === undefined) { return undefined; }\n\n\t\tfor (let z of Object.keys(this._levels)) {\n\t\t\tz = Number(z);\n\t\t\tif (this._levels[z].el.children.length || z === zoom) {\n\t\t\t\tthis._levels[z].el.style.zIndex = `${maxZoom - Math.abs(zoom - z)}`;\n\t\t\t\tthis._onUpdateLevel(z);\n\t\t\t} else {\n\t\t\t\tthis._levels[z].el.remove();\n\t\t\t\tthis._removeTilesAtZoom(z);\n\t\t\t\tthis._onRemoveLevel(z);\n\t\t\t\tdelete this._levels[z];\n\t\t\t}\n\t\t}\n\n\t\tlet level = this._levels[zoom];\n\t\tconst map = this._map;\n\n\t\tif (!level) {\n\t\t\tlevel = this._levels[zoom] = {};\n\n\t\t\tlevel.el = DomUtil.create('div', 'maplair-tile-container maplair-zoom-animated', this._container);\n\t\t\tlevel.el.style.zIndex = `${maxZoom}`;\n\n\t\t\tlevel.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();\n\t\t\tlevel.zoom = zoom;\n\n\t\t\tthis._setZoomTransform(level, map.getCenter(), map.getZoom());\n\n\t\t\t// force reading offsetWidth so the browser considers the newly added element for transition\n\t\t\tUtil.falseFn(level.el.offsetWidth);\n\n\t\t\tthis._onCreateLevel(level);\n\t\t}\n\n\t\tthis._level = level;\n\n\t\treturn level;\n\t}\n\n\t_onUpdateLevel() {}\n\n\t_onRemoveLevel() {}\n\n\t_onCreateLevel() {}\n\n\t_pruneTiles() {\n\t\tif (!this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst zoom = this._map.getZoom();\n\t\tif (zoom > this.options.maxZoom ||\n\t\t\tzoom < this.options.minZoom) {\n\t\t\tthis._removeAllTiles();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\ttile.retain = tile.current;\n\t\t}\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tif (tile.current && !tile.active) {\n\t\t\t\tconst coords = tile.coords;\n\t\t\t\tif (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {\n\t\t\t\t\tthis._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (!tile.retain) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTilesAtZoom(zoom) {\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (tile.coords.z === zoom) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeAllTiles() {\n\t\tfor (const key of Object.keys(this._tiles)) {\n\t\t\tthis._removeTile(key);\n\t\t}\n\t}\n\n\t_invalidateAll(e) {\n\t\t// a zoom without animation keeps the old levels until new tiles load, like the end of an animated one,\n\t\t// unless the view jumps somewhere else\n\t\tconst map = this._map;\n\t\tif (e?.zoom !== undefined && e.zoom !== map.getZoom() && map.getBounds().contains(e.center)) { return; }\n\n\t\tfor (const z of Object.keys(this._levels)) {\n\t\t\tthis._levels[z].el.remove();\n\t\t\tthis._onRemoveLevel(Number(z));\n\t\t\tdelete this._levels[z];\n\t\t}\n\t\tthis._removeAllTiles();\n\n\t\tthis._tileZoom = undefined;\n\t}\n\n\t_retainParent(x, y, z, minZoom) {\n\t\tfor (z--; z >= minZoom; z--) {\n\t\t\tx = Math.floor(x / 2);\n\t\t\ty = Math.floor(y / 2);\n\t\t\tif (this._retain(x, y, z)) { return true; }\n\t\t}\n\t\treturn false;\n\t}\n\n\t_retainChildren(x, y, z, maxZoom) {\n\t\tfor (let i = 2 * x; i < 2 * x + 2; i++) {\n\t\t\tfor (let j = 2 * y; j < 2 * y + 2; j++) {\n\t\t\t\tif (!this._retain(i, j, z + 1) && z + 1 < maxZoom) {\n\t\t\t\t\tthis._retainChildren(i, j, z + 1, maxZoom);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// retains the tile if it's loaded; returns true if it's active, so there's no need to look further\n\t_retain(x, y, z) {\n\t\tconst tile = this._tiles[this._tileCoordsToKey({x, y, z})];\n\t\tif (tile?.loaded) { tile.retain = true; }\n\t\treturn tile?.active;\n\t}\n\n\t_resetView(e) {\n\t\tconst animating = e && (e.pinch || e.flyTo || e.continuous);\n\t\tthis._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);\n\t}\n\n\t_animateZoom(e) {\n\t\tthis._setView(e.center, e.zoom, true, e.noUpdate);\n\t}\n\n\t_clampZoom(zoom) {\n\t\tconst options = this.options;\n\n\t\tif (undefined !== options.minNativeZoom && zoom < options.minNativeZoom) {\n\t\t\treturn options.minNativeZoom;\n\t\t}\n\n\t\tif (undefined !== options.maxNativeZoom && options.maxNativeZoom < zoom) {\n\t\t\treturn options.maxNativeZoom;\n\t\t}\n\n\t\treturn zoom;\n\t}\n\n\t_setView(center, zoom, noPrune, noUpdate) {\n\t\tlet tileZoom = Math.round(zoom);\n\t\tif ((this.options.maxZoom !== undefined && tileZoom > this.options.maxZoom) ||\n\t\t (this.options.minZoom !== undefined && tileZoom < this.options.minZoom)) {\n\t\t\ttileZoom = undefined;\n\t\t} else {\n\t\t\ttileZoom = this._clampZoom(tileZoom);\n\t\t}\n\n\t\tconst tileZoomChanged = this.options.updateWhenZooming && (tileZoom !== this._tileZoom);\n\n\t\tif (!noUpdate || tileZoomChanged) {\n\n\t\t\tthis._tileZoom = tileZoom;\n\n\t\t\tif (this._abortLoading) {\n\t\t\t\tthis._abortLoading();\n\t\t\t}\n\n\t\t\tthis._updateLevels();\n\t\t\tthis._resetGrid();\n\n\t\t\tif (tileZoom !== undefined) {\n\t\t\t\tthis._update(center);\n\t\t\t}\n\n\t\t\tif (!noPrune) {\n\t\t\t\tthis._pruneTiles();\n\t\t\t}\n\n\t\t\t// Flag to prevent finished tile fades from pruning tiles during\n\t\t\t// a zoom anim or a pinch gesture\n\t\t\tthis._noPrune = !!noPrune;\n\t\t}\n\n\t\tthis._setZoomTransforms(center, zoom);\n\t}\n\n\t_setZoomTransforms(center, zoom) {\n\t\tfor (const level of Object.values(this._levels)) {\n\t\t\tthis._setZoomTransform(level, center, zoom);\n\t\t}\n\t}\n\n\t_setZoomTransform(level, center, zoom) {\n\t\tconst scale = this._map.getZoomScale(zoom, level.zoom),\n\t\ttranslate = level.origin.multiplyBy(scale)\n\t\t\t.subtract(this._map._getNewPixelOrigin(center, zoom)).round();\n\n\t\tDomUtil.setTransform(level.el, translate, scale);\n\t}\n\n\t_resetGrid() {\n\t\tconst map = this._map,\n\t\tcrs = map.options.crs,\n\t\ttileSize = this._tileSize = this.getTileSize(),\n\t\ttileZoom = this._tileZoom;\n\n\t\tconst bounds = this._map.getPixelWorldBounds(this._tileZoom);\n\t\tif (bounds) {\n\t\t\tthis._globalTileRange = this._pxBoundsToTileRange(bounds);\n\t\t}\n\n\t\tthis._wrapX = crs.wrapLng && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x),\n\t\t\tMath.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.x)\n\t\t];\n\t\tthis._wrapY = crs.wrapLat && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.y),\n\t\t\tMath.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)\n\t\t];\n\t}\n\n\t_onMoveEnd() {\n\t\tif (!this._map || this._map._animatingZoom) { return; }\n\n\t\tthis._update();\n\t}\n\n\t_onWorldCopyJump({worlds}) {\n\t\t// noWrap tiles cannot be reused in another world copy.\n\t\tif (!this._wrapX) { return; }\n\n\t\tconst tileSize = this.getTileSize(),\n\t\ttiles = {};\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tconst {coords, el} = tile,\n\t\t\tdx = worlds * this._map.getPixelWorldBounds(coords.z).getSize().x;\n\n\t\t\t// tiles can't be shifted by a fraction of a column, so leave those to be reloaded\n\t\t\tif (dx % tileSize.x === 0) {\n\t\t\t\tcoords.x -= dx / tileSize.x;\n\t\t\t\tDomUtil.setPosition(el, DomUtil.getPosition(el).subtract([dx, 0]), true);\n\t\t\t}\n\t\t\ttiles[this._tileCoordsToKey(coords)] = tile;\n\t\t}\n\n\t\tthis._tiles = tiles;\n\t}\n\n\t_getTiledPixelBounds(center) {\n\t\tconst map = this._map,\n\t\tmapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),\n\t\tscale = map.getZoomScale(mapZoom, this._tileZoom),\n\t\tpixelCenter = map.project(center, this._tileZoom).floor(),\n\t\thalfSize = map.getSize().divideBy(scale * 2);\n\n\t\treturn new Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));\n\t}\n\n\t// Private method to load tiles in the grid's active zoom level according to map bounds\n\t_update(center) {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\t\tconst zoom = this._clampZoom(map.getZoom());\n\n\t\tif (center === undefined) { center = map.getCenter(); }\n\t\tif (this._tileZoom === undefined) { return; }\t// if out of minzoom/maxzoom\n\n\t\tconst pixelBounds = this._getTiledPixelBounds(center),\n\t\ttileRange = this._pxBoundsToTileRange(pixelBounds),\n\t\ttileCenter = tileRange.getCenter(),\n\t\tqueue = [],\n\t\tmargin = this.options.keepBuffer,\n\t\tnoPruneRange = new Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),\n\t\t\ttileRange.getTopRight().add([margin, -margin]));\n\n\t\t// Sanity check: panic if the tile range contains Infinity somewhere.\n\t\tif (!(isFinite(tileRange.min.x) &&\n\t\t isFinite(tileRange.min.y) &&\n\t\t isFinite(tileRange.max.x) &&\n\t\t isFinite(tileRange.max.y))) { throw new Error('Attempted to load an infinite number of tiles'); }\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tconst c = tile.coords;\n\t\t\tif (c.z !== this._tileZoom || !noPruneRange.contains(new Point(c.x, c.y))) {\n\t\t\t\ttile.current = false;\n\t\t\t}\n\t\t}\n\n\t\t// _update just loads more tiles. If the tile zoom level differs too much\n\t\t// from the map's, let _setView reset levels and prune old tiles.\n\t\tif (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }\n\n\t\t// create a queue of coordinates to load tiles from\n\t\tfor (let j = tileRange.min.y; j <= tileRange.max.y; j++) {\n\t\t\tfor (let i = tileRange.min.x; i <= tileRange.max.x; i++) {\n\t\t\t\tconst coords = new Point(i, j);\n\t\t\t\tcoords.z = this._tileZoom;\n\n\t\t\t\tif (!this._isValidTile(coords)) { continue; }\n\n\t\t\t\tconst tile = this._tiles[this._tileCoordsToKey(coords)];\n\t\t\t\tif (tile) {\n\t\t\t\t\ttile.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push(coords);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// sort tile queue to load tiles in order of their distance to center\n\t\tqueue.sort((a, b) => a.distanceTo(tileCenter) - b.distanceTo(tileCenter));\n\n\t\tif (queue.length !== 0) {\n\t\t\t// if it's the first batch of tiles to load\n\t\t\tif (!this._loading) {\n\t\t\t\tthis._loading = true;\n\t\t\t\tthis.fire('loading');\n\t\t\t\tthis._map._onLayerLoading();\n\t\t\t}\n\n\t\t\t// create DOM fragment to append tiles in one batch\n\t\t\tconst fragment = document.createDocumentFragment();\n\n\t\t\tfor (const q of queue) {\n\t\t\t\tthis._addTile(q, fragment);\n\t\t\t}\n\n\t\t\tthis._level.el.appendChild(fragment);\n\t\t}\n\t}\n\n\t_isValidTile(coords) {\n\t\tconst crs = this._map.options.crs;\n\n\t\tif (!crs.infinite) {\n\t\t\t// don't load tile if it's out of bounds and not wrapped\n\t\t\tconst bounds = this._globalTileRange;\n\t\t\tif ((!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\n\t\t\t (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; }\n\t\t}\n\n\t\tif (!this.options.bounds) { return true; }\n\n\t\t// don't load tile if it doesn't intersect the bounds in options\n\t\tconst tileBounds = this._tileCoordsToBounds(coords);\n\t\treturn LatLngBounds.from(this.options.bounds).overlaps(tileBounds);\n\t}\n\n\t_tileCoordsToNwSe(coords) {\n\t\tconst map = this._map,\n\t\ttileSize = this.getTileSize(),\n\t\tnwPoint = coords.scaleBy(tileSize),\n\t\tsePoint = nwPoint.add(tileSize),\n\t\tnw = map.unproject(nwPoint, coords.z),\n\t\tse = map.unproject(sePoint, coords.z);\n\t\treturn [nw, se];\n\t}\n\n\t// converts tile coordinates to its geographical bounds\n\t_tileCoordsToBounds(coords) {\n\t\tconst bp = this._tileCoordsToNwSe(coords);\n\t\tlet bounds = new LatLngBounds(bp[0], bp[1]);\n\n\t\tif (!this.options.noWrap) {\n\t\t\tbounds = this._map.wrapLatLngBounds(bounds);\n\t\t}\n\t\treturn bounds;\n\t}\n\t// converts tile coordinates to key for the tile cache\n\t_tileCoordsToKey(coords) {\n\t\treturn `${coords.x}:${coords.y}:${coords.z}`;\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\ttile.el.remove();\n\n\t\tdelete this._tiles[key];\n\n\t\tthis.fire('tileunload', {\n\t\t\ttile: tile.el,\n\t\t\tcoords: tile.coords\n\t\t});\n\t}\n\n\t_initTile(tile) {\n\t\ttile.classList.add('maplair-tile');\n\n\t\tconst tileSize = this.getTileSize();\n\t\ttile.style.width = `${tileSize.x}px`;\n\t\ttile.style.height = `${tileSize.y}px`;\n\n\t\tif (this.options.placeholder) {\n\t\t\ttile.style.background = this.options.placeholder;\n\t\t}\n\t}\n\n\t_addTile(coords, container) {\n\t\tconst tilePos = this._getTilePos(coords),\n\t\tkey = this._tileCoordsToKey(coords);\n\n\t\tconst tile = this.createTile(this._wrapCoords(coords), this._tileReady.bind(this, coords));\n\n\t\tthis._initTile(tile);\n\n\t\t// if createTile is defined with a second argument (\"done\" callback),\n\t\t// we know that tile is async and will be ready later; otherwise\n\t\tif (this.createTile.length < 2) {\n\t\t\t// mark tile as ready, but delay one frame for opacity animation to happen\n\t\t\trequestAnimationFrame(this._tileReady.bind(this, coords, null, tile));\n\t\t}\n\n\t\t// 2D, so tiles raster into the level's layer: as separate layers they get compositor edge antialiasing,\n\t\t// and the overlapping edge ramps show as light seams under plus-lighter blending\n\t\tDomUtil.setPosition(tile, tilePos, true);\n\n\t\t// save tile in cache\n\t\tthis._tiles[key] = {\n\t\t\tel: tile,\n\t\t\tcoords,\n\t\t\tcurrent: true\n\t\t};\n\n\t\tcontainer.appendChild(tile);\n\t\tthis.fire('tileloadstart', {\n\t\t\ttile,\n\t\t\tcoords\n\t\t});\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (err) {\n\t\t\tthis.fire('tileerror', {\n\t\t\t\terror: err,\n\t\t\t\ttile,\n\t\t\t\tcoords\n\t\t\t});\n\t\t}\n\n\t\tconst key = this._tileCoordsToKey(coords);\n\n\t\ttile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\tif (this.options.placeholder) {\n\t\t\ttile.el.style.background = '';\n\t\t}\n\t\t// fading in with a placeholder would show the map below instead of the placeholder at first\n\t\tif (!this._map._fadeAnimated || this.options.placeholder) {\n\t\t\ttile.active = true;\n\t\t\tthis._pruneTiles();\n\t\t} else if (!tile.loaded) { // with errorTileUrl, a tile is ready twice (on error and on fallback load)\n\t\t\t// while fading, the tile is a compositor layer of its own where plus-lighter would light up its\n\t\t\t// antialiased edges, so it's blended normally until the fade ends\n\t\t\ttile.el.classList.add('maplair-tile-fading');\n\t\t\ttile.el.animate({opacity: [0, 1]}, 200).onfinish = this._onTileFaded.bind(this, tile);\n\t\t}\n\t\ttile.loaded = true;\n\n\t\tif (!err) {\n\t\t\ttile.el.classList.add('maplair-tile-loaded');\n\n\t\t\tthis.fire('tileload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords\n\t\t\t});\n\t\t}\n\n\t\t// a tileload listener may have removed the layer, emptying the tile list\n\t\tif (this._map && this._noTilesToLoad()) {\n\t\t\tthis._loading = false;\n\t\t\tthis.fire('load');\n\n\t\t\tif (!this._map) { return; } // removed by a load listener\n\t\t\tthis._map._scheduleIdleCheck();\n\n\t\t\tif (!this._map._fadeAnimated) {\n\t\t\t\trequestAnimationFrame(this._pruneTiles.bind(this));\n\t\t\t} else {\n\t\t\t\t// Wait a bit more than 0.2 secs (the duration of the tile fade-in)\n\t\t\t\t// to trigger a pruning.\n\t\t\t\tthis._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);\n\t\t\t}\n\t\t}\n\t}\n\n\t_onTileFaded(tile) {\n\t\ttile.el.classList.remove('maplair-tile-fading');\n\t\t// the tile's key may have changed after a world copy jump, so look it up again\n\t\tif (this._tiles[this._tileCoordsToKey(tile.coords)] !== tile) { return; }\n\n\t\ttile.active = true;\n\t\tthis._onOpaqueTile(tile);\n\n\t\t// one prune for all the tiles that finish fading in the same frame\n\t\tif (this._noPrune || this._fadePruneFrame) { return; }\n\t\tthis._fadePruneFrame = requestAnimationFrame(() => {\n\t\t\tthis._fadePruneFrame = 0;\n\t\t\tif (!this._noPrune) { this._pruneTiles(); }\n\t\t});\n\t}\n\n\t_getTilePos(coords) {\n\t\treturn coords.scaleBy(this.getTileSize()).subtract(this._level.origin);\n\t}\n\n\t_wrapCoords(coords) {\n\t\tconst newCoords = new Point(\n\t\t\tthis._wrapX ? Util.wrapNum(coords.x, this._wrapX) : coords.x,\n\t\t\tthis._wrapY ? Util.wrapNum(coords.y, this._wrapY) : coords.y);\n\t\tnewCoords.z = coords.z;\n\t\treturn newCoords;\n\t}\n\n\t_pxBoundsToTileRange(bounds) {\n\t\tconst tileSize = this.getTileSize();\n\t\treturn new Bounds(\n\t\t\tbounds.min.unscaleBy(tileSize).floor(),\n\t\t\tbounds.max.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AK,mBAAmB;GAE7B,IAAI,CAAC,KAAK,KAAK,eACd,sBAAsB,KAAK,YAAY,KAAK,IAAI,CAAC;QAIjD,KAAK,gBAAgB,WAAW,KAAK,YAAY,KAAK,IAAI,GAAG,GAAG;EAElE;CACD;CAEA,aAAa,MAAM;EAClB,KAAK,GAAG,UAAU,OAAO,qBAAqB;EAE9C,IAAI,KAAK,OAAO,KAAK,iBAAiB,KAAK,MAAM,OAAO,MAAQ;EAEhE,KAAK,SAAS;EACd,KAAK,cAAc,IAAI;EAGvB,IAAI,KAAK,YAAY,KAAK,iBAAmB;EAC7C,KAAK,kBAAkB,4BAA4B;GAClD,KAAK,kBAAkB;GACvB,IAAI,CAAC,KAAK,UAAY,KAAK,YAAY;EACxC,CAAC;CACF;CAEA,YAAY,QAAQ;EACnB,OAAO,OAAO,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,MAAM;CACtE;CAEA,YAAY,QAAQ;EACnB,MAAM,YAAY,IAAI,MACrB,KAAK,SAASC,QAAa,OAAO,GAAG,KAAK,MAAM,IAAI,OAAO,GAC3D,KAAK,SAASA,QAAa,OAAO,GAAG,KAAK,MAAM,IAAI,OAAO,CAAC;EAC7D,UAAU,IAAI,OAAO;EACrB,OAAO;CACR;CAEA,qBAAqB,QAAQ;EAC5B,MAAM,WAAW,KAAK,YAAY;EAClC,OAAO,IAAI,OACV,OAAO,IAAI,UAAU,QAAQ,CAAC,CAAC,MAAM,GACrC,OAAO,IAAI,UAAU,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;CACxD;CAEA,iBAAiB;EAChB,OAAO,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,OAAM,MAAK,EAAE,MAAM;CACtD;AACD"}
@@ -1,9 +1,9 @@
1
1
  import { setOptions, template } from "../../core/Util.js";
2
+ import { Point } from "../../geometry/Point.js";
2
3
  import { on } from "../../dom/DomEvent.js";
3
4
  import { I18n } from "../../core/I18n.js";
4
5
  import { GridLayer } from "./GridLayer.js";
5
- //#region src/layer/tile/TileLayer.js
6
- /** @import {Point} from '../../geometry/Point.js' */
6
+ // src/layer/tile/TileLayer.js
7
7
  /** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */
8
8
  /** @import {TileEvent} from '../../core/Events.js' */
9
9
  const osmHosts = ["tile.openstreetmap.org", "tile.osm.org"];
@@ -136,7 +136,8 @@ var TileLayer = class TileLayer extends GridLayer {
136
136
  Object.assign(this.options, this._nonRetinaOptions);
137
137
  this._retina = window.devicePixelRatio > 1;
138
138
  if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
139
- this.options.tileSize = Math.floor(this.options.tileSize / 2);
139
+ const tileSize = this.options.tileSize;
140
+ this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
140
141
  if (!this.options.zoomReverse) {
141
142
  this.options.zoomOffset++;
142
143
  this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
@@ -262,8 +263,8 @@ var TileLayer = class TileLayer extends GridLayer {
262
263
  done(null, tile);
263
264
  }
264
265
  _tileOnError(done, tile, e) {
265
- const errorUrl = this.options.errorTileUrl;
266
- if (errorUrl && tile.getAttribute("src") !== errorUrl) tile.src = errorUrl;
266
+ const errorUrl = this.options.errorTileUrl, src = tile.getAttribute("src");
267
+ if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
267
268
  done(e, tile);
268
269
  }
269
270
  _getZoomForUrl() {
@@ -273,8 +274,8 @@ var TileLayer = class TileLayer extends GridLayer {
273
274
  return zoom + zoomOffset;
274
275
  }
275
276
  _getSubdomain(tilePoint) {
276
- const index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
277
- return this.options.subdomains[index];
277
+ const { subdomains } = this.options;
278
+ return subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];
278
279
  }
279
280
  _abortLoading() {
280
281
  let i, tile;
@@ -307,7 +308,6 @@ var TileLayer = class TileLayer extends GridLayer {
307
308
  return Math.round(super._clampZoom(zoom));
308
309
  }
309
310
  };
310
- //#endregion
311
311
  export { TileLayer };
312
312
 
313
313
  //# sourceMappingURL=TileLayer.js.map