maplair 4.3.0 → 4.4.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 (179) hide show
  1. package/CHANGELOG.md +89 -8
  2. package/dist/esm/control/AttributionControl.js +10 -10
  3. package/dist/esm/control/AttributionControl.js.map +1 -1
  4. package/dist/esm/control/ButtonControl.js +0 -1
  5. package/dist/esm/control/ButtonControl.js.map +1 -1
  6. package/dist/esm/control/ContextMenu.js +1 -1
  7. package/dist/esm/control/ContextMenu.js.map +1 -1
  8. package/dist/esm/control/Control.js +16 -11
  9. package/dist/esm/control/Control.js.map +1 -1
  10. package/dist/esm/control/FullscreenControl.js +0 -1
  11. package/dist/esm/control/FullscreenControl.js.map +1 -1
  12. package/dist/esm/control/LayersControl.js +13 -9
  13. package/dist/esm/control/LayersControl.js.map +1 -1
  14. package/dist/esm/control/RotateControl.js +0 -1
  15. package/dist/esm/control/RotateControl.js.map +1 -1
  16. package/dist/esm/control/ScaleControl.js +4 -5
  17. package/dist/esm/control/ScaleControl.js.map +1 -1
  18. package/dist/esm/control/SideBySideControl.js +3 -2
  19. package/dist/esm/control/SideBySideControl.js.map +1 -1
  20. package/dist/esm/control/ZoomControl.js +13 -13
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Events.js +3 -2
  23. package/dist/esm/core/Events.js.map +1 -1
  24. package/dist/esm/core/Util.js +16 -4
  25. package/dist/esm/core/Util.js.map +1 -1
  26. package/dist/esm/dom/DomEvent.PointerEvents.js +55 -2
  27. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  28. package/dist/esm/dom/DomEvent.js +4 -7
  29. package/dist/esm/dom/DomEvent.js.map +1 -1
  30. package/dist/esm/dom/DomUtil.js +5 -5
  31. package/dist/esm/dom/DomUtil.js.map +1 -1
  32. package/dist/esm/dom/Draggable.js +4 -6
  33. package/dist/esm/dom/Draggable.js.map +1 -1
  34. package/dist/esm/geo/LatLng.js +23 -34
  35. package/dist/esm/geo/LatLng.js.map +1 -1
  36. package/dist/esm/geo/LatLngBounds.js +6 -3
  37. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  38. package/dist/esm/geometry/Bounds.js +2 -2
  39. package/dist/esm/geometry/Bounds.js.map +1 -1
  40. package/dist/esm/geometry/Point.js +12 -17
  41. package/dist/esm/geometry/Point.js.map +1 -1
  42. package/dist/esm/geometry/Transformation.js +1 -7
  43. package/dist/esm/geometry/Transformation.js.map +1 -1
  44. package/dist/esm/layer/BlanketOverlay.js +1 -1
  45. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  46. package/dist/esm/layer/DivOverlay.js +23 -23
  47. package/dist/esm/layer/DivOverlay.js.map +1 -1
  48. package/dist/esm/layer/ImageOverlay.js +7 -4
  49. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  50. package/dist/esm/layer/Layer.js +11 -6
  51. package/dist/esm/layer/Layer.js.map +1 -1
  52. package/dist/esm/layer/Popup.js +30 -11
  53. package/dist/esm/layer/Popup.js.map +1 -1
  54. package/dist/esm/layer/Tooltip.js +18 -35
  55. package/dist/esm/layer/Tooltip.js.map +1 -1
  56. package/dist/esm/layer/VideoOverlay.js +2 -2
  57. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  58. package/dist/esm/layer/marker/DivIcon.js +4 -8
  59. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  60. package/dist/esm/layer/marker/Icon.js +16 -15
  61. package/dist/esm/layer/marker/Icon.js.map +1 -1
  62. package/dist/esm/layer/marker/Marker.Drag.js +6 -7
  63. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  64. package/dist/esm/layer/marker/Marker.js +49 -48
  65. package/dist/esm/layer/marker/Marker.js.map +1 -1
  66. package/dist/esm/layer/marker/SvgIcon.js +1 -1
  67. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  68. package/dist/esm/layer/tile/GridLayer.js +18 -16
  69. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  70. package/dist/esm/layer/tile/TileLayer.js +9 -9
  71. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  72. package/dist/esm/layer/vector/Canvas.js +44 -93
  73. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  74. package/dist/esm/layer/vector/Circle.js +7 -7
  75. package/dist/esm/layer/vector/Circle.js.map +1 -1
  76. package/dist/esm/layer/vector/CircleMarker.js +9 -1
  77. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  78. package/dist/esm/layer/vector/Path.js +10 -5
  79. package/dist/esm/layer/vector/Path.js.map +1 -1
  80. package/dist/esm/layer/vector/Polygon.js +10 -11
  81. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  82. package/dist/esm/layer/vector/Polyline.js +19 -26
  83. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  84. package/dist/esm/layer/vector/Renderer.getRenderer.js +2 -1
  85. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  86. package/dist/esm/layer/vector/Renderer.js +16 -0
  87. package/dist/esm/layer/vector/Renderer.js.map +1 -1
  88. package/dist/esm/layer/vector/SVG.js +3 -3
  89. package/dist/esm/layer/vector/SVG.js.map +1 -1
  90. package/dist/esm/map/Map.Rotation.js +6 -9
  91. package/dist/esm/map/Map.Rotation.js.map +1 -1
  92. package/dist/esm/map/Map.js +104 -49
  93. package/dist/esm/map/Map.js.map +1 -1
  94. package/dist/esm/map/MapSync.js +1 -4
  95. package/dist/esm/map/MapSync.js.map +1 -1
  96. package/dist/esm/map/handler/BoxZoomHandler.js +2 -0
  97. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  98. package/dist/esm/map/handler/DisplaceHandler.js +68 -30
  99. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  100. package/dist/esm/map/handler/KeyboardHandler.js +3 -5
  101. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  102. package/dist/esm/map/handler/PinchZoomHandler.js +3 -6
  103. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  104. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -6
  105. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  106. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -4
  107. package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
  108. package/dist/esm/map/handler/TapHoldHandler.js +8 -20
  109. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  110. package/dist/esm/package.js +1 -1
  111. package/dist/maplair-global-src.js +698 -687
  112. package/dist/maplair-global-src.js.map +1 -1
  113. package/dist/maplair-global.js +2 -2
  114. package/dist/maplair-global.js.map +1 -1
  115. package/dist/maplair-src.js +698 -687
  116. package/dist/maplair-src.js.map +1 -1
  117. package/dist/maplair.css +1 -1
  118. package/dist/maplair.js +2 -2
  119. package/dist/maplair.js.map +1 -1
  120. package/i18n/en.json +1 -0
  121. package/package.json +1 -1
  122. package/src/control/AttributionControl.js +9 -9
  123. package/src/control/ButtonControl.js +0 -1
  124. package/src/control/ContextMenu.js +1 -1
  125. package/src/control/Control.js +13 -16
  126. package/src/control/FullscreenControl.js +0 -1
  127. package/src/control/LayersControl.js +14 -10
  128. package/src/control/RotateControl.js +0 -1
  129. package/src/control/ScaleControl.js +4 -5
  130. package/src/control/SideBySideControl.js +4 -2
  131. package/src/control/ZoomControl.js +10 -13
  132. package/src/core/Events.js +6 -2
  133. package/src/core/Util.js +16 -3
  134. package/src/dom/DomEvent.PointerEvents.js +47 -1
  135. package/src/dom/DomEvent.js +5 -17
  136. package/src/dom/DomUtil.js +5 -5
  137. package/src/dom/Draggable.js +5 -6
  138. package/src/geo/LatLng.js +22 -36
  139. package/src/geo/LatLngBounds.js +10 -4
  140. package/src/geometry/Bounds.js +3 -3
  141. package/src/geometry/Point.js +18 -26
  142. package/src/geometry/Transformation.js +1 -8
  143. package/src/layer/BlanketOverlay.js +1 -1
  144. package/src/layer/DivOverlay.js +28 -30
  145. package/src/layer/ImageOverlay.js +9 -7
  146. package/src/layer/Layer.js +18 -6
  147. package/src/layer/Popup.js +38 -17
  148. package/src/layer/Tooltip.js +17 -44
  149. package/src/layer/VideoOverlay.js +2 -2
  150. package/src/layer/marker/DivIcon.js +3 -6
  151. package/src/layer/marker/Icon.js +19 -18
  152. package/src/layer/marker/Marker.Drag.js +16 -18
  153. package/src/layer/marker/Marker.js +66 -59
  154. package/src/layer/marker/SvgIcon.js +1 -1
  155. package/src/layer/tile/GridLayer.js +21 -23
  156. package/src/layer/tile/TileLayer.js +17 -14
  157. package/src/layer/vector/Canvas.js +52 -148
  158. package/src/layer/vector/Circle.js +11 -9
  159. package/src/layer/vector/CircleMarker.js +11 -1
  160. package/src/layer/vector/Path.js +11 -5
  161. package/src/layer/vector/Polygon.js +11 -10
  162. package/src/layer/vector/Polyline.js +20 -21
  163. package/src/layer/vector/Renderer.getRenderer.js +2 -1
  164. package/src/layer/vector/Renderer.js +21 -3
  165. package/src/layer/vector/SVG.js +3 -3
  166. package/src/map/Map.Rotation.js +7 -6
  167. package/src/map/Map.js +135 -54
  168. package/src/map/MapSync.js +1 -1
  169. package/src/map/handler/BoxZoomHandler.js +2 -0
  170. package/src/map/handler/DisplaceHandler.js +53 -7
  171. package/src/map/handler/KeyboardHandler.js +5 -10
  172. package/src/map/handler/PinchZoomHandler.js +3 -3
  173. package/src/map/handler/ScrollWheelZoomHandler.js +3 -3
  174. package/src/map/handler/TapDragZoomHandler.js +1 -1
  175. package/src/map/handler/TapHoldHandler.js +13 -25
  176. package/src/maplair.css +38 -9
  177. package/dist/esm/dom/DomEvent.DoubleTap.js +0 -90
  178. package/dist/esm/dom/DomEvent.DoubleTap.js.map +0 -1
  179. package/src/dom/DomEvent.DoubleTap.js +0 -143
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.js","names":["DomUtil.getPosition"],"sources":["../../../../src/layer/marker/Marker.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport {DefaultIcon} from './DefaultIcon.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {MarkerDrag} from './Marker.Drag.js';\nimport {pointToGeoJSON} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {Icon} from './Icon.js' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {InteractiveLayerOptions} from '../Layer.js' */\n\n/**\n * Options of `Marker`.\n * @typedef {object} MarkerOptions\n * @property {Icon} [icon=new DefaultIcon()] Icon instance to use for rendering the\n * marker. See [Icon documentation](#Icon) for details on how to customize the marker\n * icon. If not specified, a common instance of `DefaultIcon` is used.\n * @property {boolean} [keyboard=true] Whether the marker can be tabbed to with a keyboard\n * and, if interactive, clicked by pressing Enter or Space.\n * @property {string} [title=''] Text for the browser tooltip that appear on marker hover\n * (no tooltip by default).\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {string} [alt='Marker'] Text for the `alt` attribute of the icon image.\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {number} [zIndexOffset=0] By default, marker images zIndex is set\n * automatically based on its latitude. Use this option if you want to put the marker on\n * top of all others (or below), specifying a high value like `1000` (or high negative\n * value, respectively).\n * @property {number} [opacity=1] The opacity of the marker.\n * @property {number|null} [rotation=null] Rotation of the marker icon in degrees,\n * clockwise, around the icon anchor, e.g. for the heading of a vehicle. A rotated\n * marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong\n * under a tilted one. `null` means no rotation.\n * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of\n * others when you hover the pointer over it.\n * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`\n * feature.\n * @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.\n * @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will\n * be added.\n * @property {boolean} [shadow=true] Whether to show the shadow of the marker's icon. Each\n * shadow is an additional element on the page, so disabling shadows noticeably reduces\n * the browser's rendering work when showing many markers (e.g. several thousands),\n * especially while panning and zooming. To disable shadows for all markers, use\n * `Marker.mergeOptions({shadow: false})`.\n * @property {boolean} [bubblingPointerEvents=false] When `true`, a pointer event on this\n * marker will trigger the same event on the map (unless\n * [`DomEvent.stopPropagation`](#domevent-stoppropagation) is used).\n * @property {boolean} [autoPanOnFocus=true] When `true`, the map will pan whenever the\n * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is\n * visible within the map's bounds.\n * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or\n * not. A focused draggable marker can also be moved with the arrow keys, by 10 pixels\n * or 30 with Shift.\n * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker\n * near its edge or not.\n * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the\n * left/right and to the top/bottom) of the map edge to start panning the map.\n * @property {number} [autoPanSpeed=10] Number of pixels the map should pan by.\n * @extends InteractiveLayerOptions\n */\n\n/**\n * The event object of `move` and `drag` of markers.\n * @typedef {object} MarkerMoveEvent\n * @property {LatLng} latlng The new position of the marker.\n * @property {LatLng} [oldLatLng] The previous position of the marker.\n * @extends MaplairEvent\n */\n\n/**\n * Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\n *\n * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and\n * [popup methods](#Popup) like `bindPopup()` you can also use the methods below.\n *\n * @example\n * ```js\n * new Marker([50.5, 30.5]).addTo(map);\n * ```\n *\n * @fires move {MarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new\n * coordinates are included in event arguments as `oldLatLng`, `latlng`.\n */\nexport class Marker extends Layer {\n\n\tstatic defaultOptions = {\n\t\ticon: /* @__PURE__ */ new DefaultIcon(),\n\n\t\t// Option inherited from \"Interactive layer\" abstract class\n\t\tinteractive: true,\n\n\t\tkeyboard: true,\n\t\ttitle: '',\n\t\talt: 'Marker',\n\t\tzIndexOffset: 0,\n\t\topacity: 1,\n\t\trotation: null,\n\t\triseOnHover: false,\n\t\triseOffset: 250,\n\t\tpane: 'markerPane',\n\t\tshadowPane: 'shadowPane',\n\t\tshadow: true,\n\t\tbubblingPointerEvents: false,\n\t\tautoPanOnFocus: true,\n\t\tdraggable: false,\n\t\tautoPan: false,\n\t\tautoPanPadding: [50, 50],\n\t\tautoPanSpeed: 10\n\t};\n\n\t/**\n\t * Instantiates a Marker object given a geographical point and optionally an options\n\t * object.\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\n\t\tthis.callInitHooks(Marker);\n\t}\n\n\t/**\n\t * Adds the icon (and shadow) of the marker to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.on('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._initIcon();\n\t\tthis.update();\n\n\t\tif (map.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the icon (and shadow) of the marker from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this.dragging) {\n\t\t\t// remember whether dragging is on or off (`dragging.disable()`) for when the marker is added again\n\t\t\tthis.options.draggable = this.dragging.enabled();\n\t\t\tif (this.options.draggable) { this.dragging.removeHooks(); }\n\t\t}\n\t\tdelete this.dragging;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.off('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._removeIcon();\n\t\tthis._removeShadow();\n\t\tthis._culled = false;\n\t}\n\n\t/**\n\t * Returns the map events the marker listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tzoom: this.update,\n\t\t\tviewreset: this.update\n\t\t};\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tevents.moveend = this._updateCulling;\n\t\t}\n\t\treturn events;\n\t}\n\n\t/**\n\t * Returns the current geographical position of the marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Changes the marker position to the given point.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t\tthis.update();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Changes the [zIndex offset](#markeroptions-zindexoffset) of the marker.\n\t * @param {number} offset\n\t * @returns {this}\n\t */\n\tsetZIndexOffset(offset) {\n\t\tthis.options.zIndexOffset = offset;\n\t\treturn this.update();\n\t}\n\n\t/**\n\t * Returns the current icon used by the marker.\n\t * @returns {Icon}\n\t */\n\tgetIcon() {\n\t\treturn this.options.icon;\n\t}\n\n\t/**\n\t * Changes the marker icon.\n\t * @param {Icon} icon\n\t * @returns {this}\n\t */\n\tsetIcon(icon) {\n\n\t\tthis.options.icon = icon;\n\n\t\tif (this._map) {\n\t\t\tthis._initIcon();\n\t\t\tthis.update();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the instance of [`HTMLElement`](https://developer.mozilla.org/docs/Web/API/HTMLElement)\n\t * used by Marker layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetElement() {\n\t\treturn this._icon;\n\t}\n\n\t/**\n\t * Updates the position of the marker on the map, e.g. after a change of its options.\n\t * @returns {this}\n\t */\n\tupdate() {\n\n\t\tif (this._icon && this._map && !this._culled) {\n\t\t\tconst pos = this._map.latLngToLayerPoint(this._latlng)._round();\n\t\t\tthis._setPos(pos);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_initIcon() {\n\t\tconst options = this.options,\n\t\tclassToAdd = `maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;\n\n\t\tconst icon = options.icon.createIcon(this._icon);\n\t\tlet addIcon = false;\n\n\t\t// if we're not reusing the icon, remove the old one and init new one\n\t\tif (icon !== this._icon) {\n\t\t\tif (this._icon) {\n\t\t\t\tthis._removeIcon();\n\t\t\t}\n\t\t\taddIcon = true;\n\n\t\t\tif (options.title) {\n\t\t\t\ticon.title = options.title;\n\t\t\t}\n\n\t\t\tif (icon instanceof HTMLImageElement) {\n\t\t\t\ticon.alt = options.alt ?? '';\n\t\t\t}\n\t\t}\n\n\t\ticon.classList.add(classToAdd);\n\n\t\tif (options.keyboard) {\n\t\t\ticon.tabIndex = 0;\n\t\t\tif (options.interactive) {\n\t\t\t\ticon.setAttribute('role', 'button');\n\t\t\t}\n\t\t\tDomEvent.on(icon, 'keydown', this._onKeyDown, this);\n\t\t}\n\n\t\tthis._icon = icon;\n\n\t\tif (options.riseOnHover) {\n\t\t\tthis.on({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.on(icon, 'focus', this._panOnFocus, this);\n\t\t}\n\n\t\tconst newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;\n\t\tlet addShadow = false;\n\n\t\tif (newShadow !== this._shadow) {\n\t\t\tthis._removeShadow();\n\t\t\taddShadow = true;\n\t\t}\n\n\t\tif (newShadow) {\n\t\t\tnewShadow.classList.add(classToAdd);\n\t\t\tnewShadow.alt = '';\n\t\t}\n\t\tthis._shadow = newShadow;\n\n\n\t\tif (options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\n\t\tif (addIcon) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t}\n\t\tthis._initInteraction();\n\t\tif (newShadow && addShadow) {\n\t\t\tthis.getPane(options.shadowPane).appendChild(this._shadow);\n\t\t}\n\t}\n\n\t_removeIcon() {\n\t\tif (this.options.riseOnHover) {\n\t\t\tthis.off({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.off(this._icon, 'focus', this._panOnFocus, this);\n\t\t}\n\t\tDomEvent.off(this._icon, 'keydown', this._onKeyDown, this);\n\n\t\tthis._icon.remove();\n\t\tthis.removeInteractiveTarget(this._icon);\n\n\t\tthis._icon = null;\n\t}\n\n\t// With the map's `markerCulling` option, takes the icon and shadow of a marker\n\t// far outside of the map view off the page (and puts them back when needed),\n\t// so that the browser doesn't need to render, and the marker doesn't need\n\t// to reposition, them while panning and zooming.\n\t_updateCulling() {\n\t\tif (!this._icon || !this._map) { return; }\n\n\t\tconst map = this._map,\n\t\t// computed once per view for all markers, reset by the map on `move`\n\t\tbounds = map._cullingBounds ??= map.getBounds().pad(0.5),\n\t\tvisible = bounds.contains(this._latlng) ||\n\t\t\t!!this.dragging?._draggable?._moving ||\n\t\t\tthis._icon.contains(document.activeElement);\n\n\t\tif (visible === !this._culled) { return; }\n\t\tthis._culled = !visible;\n\n\t\tif (visible) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t\tif (this._shadow) {\n\t\t\t\tthis.getPane(this.options.shadowPane).appendChild(this._shadow);\n\t\t\t}\n\t\t\tthis.update();\n\t\t} else {\n\t\t\tthis._icon.remove();\n\t\t\tthis._shadow?.remove();\n\t\t}\n\t}\n\n\t_removeShadow() {\n\t\tthis._shadow?.remove();\n\t\tthis._shadow = null;\n\t}\n\n\t_setPos(pos) {\n\t\tthis._positionElements(pos);\n\n\t\tthis._zIndex = pos.y + this.options.zIndexOffset;\n\n\t\tthis._resetZIndex();\n\t}\n\n\t_positionElements(pos) {\n\t\tconst rotation = this.options.rotation;\n\n\t\tif (this._icon) {\n\t\t\tDomUtil.setPosition(this._icon, pos);\n\t\t\tif (rotation != null) {\n\t\t\t\tthis._icon.style.transform += ` rotate(${rotation}deg)`;\n\t\t\t}\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tDomUtil.setPosition(this._shadow, pos);\n\t\t\tthis._shadow.style.display = rotation == null ? '' : 'none';\n\t\t}\n\t}\n\n\t_updateZIndex(offset) {\n\t\tconst zIndex = String(this._zIndex + offset);\n\t\tif (this._icon && this._icon.style.zIndex !== zIndex) {\n\t\t\tthis._icon.style.zIndex = zIndex;\n\t\t}\n\t}\n\n\t_animateZoom(opt) {\n\t\tif (this._culled) { return; }\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)._round();\n\n\t\tthis._setPos(pos);\n\t}\n\n\t_updateInteractive() {\n\t\tif (!this._icon) { return; }\n\t\tif (this.options.keyboard) {\n\t\t\tif (this.options.interactive) {\n\t\t\t\tthis._icon.setAttribute('role', 'button');\n\t\t\t} else {\n\t\t\t\tthis._icon.removeAttribute('role');\n\t\t\t}\n\t\t}\n\t\tif (this.options.interactive) {\n\t\t\tthis._initInteraction();\n\t\t\tif (this._draggableBeforeNonInteractive) {\n\t\t\t\tthis.dragging?.enable();\n\t\t\t}\n\t\t} else {\n\t\t\tthis._icon.classList.remove('maplair-interactive');\n\t\t\tthis.removeInteractiveTarget(this._icon);\n\t\t\tthis._draggableBeforeNonInteractive = this.dragging?.enabled();\n\t\t\tthis.dragging?.disable();\n\t\t}\n\t}\n\n\t_initInteraction() {\n\n\t\tif (!this.options.interactive) { return; }\n\n\t\tthis._icon.classList.add('maplair-interactive');\n\n\t\tthis.addInteractiveTarget(this._icon);\n\n\t\tif (MarkerDrag) {\n\t\t\t// When the icon element is reused, the drag handler still refers to it. Keep that handler, because\n\t\t\t// replacing it ends a drag in progress and forgets that the marker has just been dragged.\n\t\t\tif (this.dragging?._draggable?._element === this._icon) {\n\t\t\t\t// the icon has reset the class names of the element\n\t\t\t\tthis._icon.classList.toggle('maplair-marker-draggable', this.dragging.enabled());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet draggable = this.options.draggable;\n\t\t\tif (this.dragging) {\n\t\t\t\tdraggable = this.dragging.enabled();\n\t\t\t\tthis.dragging.disable();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Marker dragging handler, see `Handler`. Only valid when the marker is on the\n\t\t\t * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).\n\t\t\t *\n\t\t\t * Interaction handlers are properties of a marker instance that allow you to\n\t\t\t * control interaction behavior in runtime, enabling or disabling certain\n\t\t\t * features such as dragging (see `Handler` methods). Example:\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * marker.dragging.disable();\n\t\t\t * ```\n\t\t\t * @group Interaction handlers\n\t\t\t * @type {MarkerDrag}\n\t\t\t */\n\t\t\tthis.dragging = new MarkerDrag(this);\n\n\t\t\tif (draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.\n\t * @returns {number|null}\n\t */\n\tgetRotation() {\n\t\treturn this.options.rotation;\n\t}\n\n\t/**\n\t * Changes the [rotation](#markeroptions-rotation) of the marker; `null` removes it.\n\t * @param {number|null} rotation\n\t * @returns {this}\n\t */\n\tsetRotation(rotation) {\n\t\tthis.options.rotation = rotation;\n\t\t// mid-zoom, the icon is transitioning to a position that update() can't compute yet; the zoom end applies it\n\t\tif (this._icon && !this._map._animatingZoom) {\n\t\t\tthis._positionElements(DomUtil.getPosition(this._icon));\n\t\t\tthis._popup?._updatePosition();\n\t\t\tthis._tooltip?._updatePosition();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Changes the opacity of the marker.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tif (this._map) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_updateOpacity() {\n\t\tconst opacity = this.options.opacity;\n\n\t\tif (this._icon) {\n\t\t\tthis._icon.style.opacity = `${opacity}`;\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tthis._shadow.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_bringToFront() {\n\t\tthis._updateZIndex(this.options.riseOffset);\n\t}\n\n\t_resetZIndex() {\n\t\tthis._updateZIndex(0);\n\t}\n\n\t_onKeyDown(e) {\n\t\t// a key pressed on a focusable element inside a DivIcon (e.g. a <button>) already clicks it natively\n\t\tif (this.options.interactive && e.target === this._icon && !e.repeat && (e.key === 'Enter' || e.key === ' ')) {\n\t\t\te.preventDefault(); // stop Space from scrolling the page\n\t\t\t// lets a popup opened by the click take the focus, see Popup.onAdd()\n\t\t\tthis._clickedByKeyboard = true;\n\t\t\tthis._icon.click();\n\t\t\tthis._clickedByKeyboard = false;\n\t\t}\n\t}\n\n\t_panOnFocus() {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\n\t\tconst icon = this._icon,\n\t\tstyle = getComputedStyle(icon),\n\t\tanchor = new Point(-parseFloat(style.marginLeft) || 0, -parseFloat(style.marginTop) || 0),\n\t\tsize = new Point(icon.offsetWidth, icon.offsetHeight);\n\n\t\tmap.panInside(this._latlng, {\n\t\t\tpaddingTopLeft: anchor,\n\t\t\tpaddingBottomRight: size.subtract(anchor)\n\t\t});\n\t}\n\n\t_getPopupAnchor() {\n\t\treturn this._rotateAnchor(this.options.icon.options.popupAnchor);\n\t}\n\n\t_getTooltipAnchor() {\n\t\treturn this._rotateAnchor(this.options.icon.options.tooltipAnchor);\n\t}\n\n\t// anchors are offsets from the icon anchor, which is also the rotation origin\n\t_rotateAnchor(anchor) {\n\t\tconst angle = this.options.rotation * Math.PI / 180;\n\t\tif (!angle || !anchor) { return anchor; }\n\n\t\tconst {x, y} = Point.from(anchor),\n\t\tcos = Math.cos(angle),\n\t\tsin = Math.sin(angle);\n\t\treturn new Point(x * cos - y * sin, x * sin + y * cos);\n\t}\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the marker (as a GeoJSON `Point` Feature).\n\t * @group Other methods\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\treturn pointToGeoJSON(this, precision);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAa,SAAb,MAAa,eAAe,MAAM;CAEjC,OAAO,iBAAiB;EACvB,sBAAsB,IAAI,YAAY;EAGtC,aAAa;EAEb,UAAU;EACV,OAAO;EACP,KAAK;EACL,cAAc;EACd,SAAS;EACT,UAAU;EACV,aAAa;EACb,YAAY;EACZ,MAAM;EACN,YAAY;EACZ,QAAQ;EACR,uBAAuB;EACvB,gBAAgB;EAChB,WAAW;EACX,SAAS;EACT,gBAAgB,CAAC,IAAI,EAAE;EACvB,cAAc;CACf;;;;;;;CAQA,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,UAAU,IAAI,OAAO,MAAM;EAEhC,KAAK,cAAc,MAAM;CAC1B;;;;;CAMA,MAAM,KAAK;EACV,KAAK,gBAAgB,KAAK,iBAAiB,IAAI,QAAQ;EAEvD,IAAI,KAAK,eACR,IAAI,GAAG,YAAY,KAAK,cAAc,IAAI;EAG3C,KAAK,UAAU;EACf,KAAK,OAAO;EAEZ,IAAI,IAAI,QAAQ,eACf,KAAK,eAAe;CAEtB;;;;;CAMA,SAAS,KAAK;EACb,I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AChE;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"}
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 {I18n} from '../../core/I18n.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] Text for the `alt` attribute of the icon image, the\n * translation of `'Marker'` by default.\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 while the pointer is over it. It always does while it has focus.\n * @property {number} [riseOffset=250] The z-index offset used when the marker gets on\n * top of others on hover or focus.\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: undefined,\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 ?? I18n.translate('Marker');\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 (this._popup?._source === this) {\n\t\t\tthis._popup._updateSourceAria(this._popup.isOpen());\n\t\t}\n\n\t\tDomEvent.on(icon, 'focusin focusout', this._updateRise, this);\n\t\tif (options.riseOnHover) {\n\t\t\tDomEvent.on(icon, 'pointerover pointerout', this._updateRise, this);\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().append(this._icon);\n\t\t}\n\t\tthis._initInteraction();\n\t\tif (newShadow && addShadow) {\n\t\t\tthis.getPane(options.shadowPane).append(this._shadow);\n\t\t}\n\t}\n\n\t_removeIcon() {\n\t\tDomEvent.off(this._icon, 'pointerover pointerout focusin focusout', this._updateRise, this);\n\t\tthis._hovered = this._focused = false;\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().append(this._icon);\n\t\t\tif (this._shadow) {\n\t\t\t\tthis.getPane(this.options.shadowPane).append(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._updateRise();\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\t// When the icon element is reused, the drag handler still refers to it. Keep that handler, because\n\t\t// replacing it ends a drag in progress and forgets that the marker has just been dragged.\n\t\tif (this.dragging?._draggable?._element === this._icon) {\n\t\t\t// the icon has reset the class names of the element\n\t\t\tthis._icon.classList.toggle('maplair-marker-draggable', this.dragging.enabled());\n\t\t\treturn;\n\t\t}\n\n\t\tlet draggable = this.options.draggable;\n\t\tif (this.dragging) {\n\t\t\tdraggable = this.dragging.enabled();\n\t\t\tthis.dragging.disable();\n\t\t}\n\n\t\t/**\n\t\t * Marker dragging handler, see `Handler`. Only valid when the marker is on the\n\t\t * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).\n\t\t *\n\t\t * Interaction handlers are properties of a marker instance that allow you to\n\t\t * control interaction behavior in runtime, enabling or disabling certain\n\t\t * features such as dragging (see `Handler` methods). Example:\n\t\t *\n\t\t * ```js\n\t\t * marker.dragging.disable();\n\t\t * ```\n\t\t * @group Interaction handlers\n\t\t * @type {MarkerDrag}\n\t\t */\n\t\tthis.dragging = new MarkerDrag(this);\n\n\t\tif (draggable) {\n\t\t\tthis.dragging.enable();\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\tfor (const el of [this._icon, this._shadow]) {\n\t\t\tif (el) {\n\t\t\t\tel.style.opacity = `${this.options.opacity}`;\n\t\t\t}\n\t\t}\n\t}\n\n\t_updateRise(e) {\n\t\tif (e?.type.startsWith('pointer')) {\n\t\t\tthis._hovered = e.type === 'pointerover';\n\t\t} else if (e) {\n\t\t\tthis._focused = e.type === 'focusin';\n\t\t}\n\t\tif (this._hovered || this._focused) {\n\t\t\tthis._bringToFront();\n\t\t} else {\n\t\t\tthis._resetZIndex();\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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"}
@@ -12,7 +12,7 @@ const glyphSize = 230;
12
12
  function svgElement(name, attributes, parent) {
13
13
  const el = document.createElementNS(svgNS, name);
14
14
  for (const [key, value] of Object.entries(attributes)) el.setAttribute(key, value);
15
- parent?.appendChild(el);
15
+ parent?.append(el);
16
16
  return el;
17
17
  }
18
18
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SvgIcon.js","names":[],"sources":["../../../../src/layer/marker/SvgIcon.js"],"sourcesContent":["import {DefaultIcon} from './DefaultIcon.js';\n/** @import {DefaultIconOptions} from './DefaultIcon.js' */\n\nconst svgNS = 'http://www.w3.org/2000/svg';\n\n// The outline of the marker in a 500×820 view box (see the iconUrl of DefaultIcon)\nconst 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',\nmarkerTransform = 'translate(-7889.1 -9807.44)scale(19.5417)',\nleafPath = 'm-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z',\nleafTransform = 'translate(250 258)scale(.068)',\n// The center of the glyph and its size in the view box\nglyphX = 250,\nglyphY = 270,\nglyphSize = 230;\n\nfunction svgElement(name, attributes, parent) {\n\tconst el = document.createElementNS(svgNS, name);\n\tfor (const [key, value] of Object.entries(attributes)) {\n\t\tel.setAttribute(key, value);\n\t}\n\tparent?.appendChild(el);\n\treturn el;\n}\n\n/**\n * Options of `SvgIcon`.\n * @typedef {object} SvgIconOptions\n * @property {string} [color='#d4462c'] The fill color of the marker, any CSS color. The\n * outline is a darker shade of it.\n * @property {string} [glyph] A character or emoji (or short text) shown in the marker\n * instead of the maple leaf.\n * @property {string} [glyphPath] The path data of an SVG glyph in a 24×24 view box (like\n * Material Design Icons), shown in the marker instead of the maple leaf.\n * @property {string} [glyphColor='white'] The color of the glyph or the maple leaf.\n * @extends DefaultIconOptions\n */\n\n/**\n * A marker icon in the shape of the default marker (with its shadow), drawn as\n * inline SVG in any color and with an optional glyph – a character, an emoji or an\n * SVG path (e.g. of an icon set) – instead of the white maple leaf. No image per\n * color is needed, and it stays sharp on any screen.\n *\n * Inspired by the [Leaflet.awesome-markers](https://github.com/lennardv2/Leaflet.awesome-markers),\n * [leaflet-color-markers](https://github.com/pointhi/leaflet-color-markers) and\n * [Leaflet.ExtraMarkers](https://github.com/coryasilva/Leaflet.ExtraMarkers) plugins.\n *\n * @example\n * ```js\n * new Marker([47.27, 11.40], {icon: new SvgIcon({color: '#2a81cb', glyph: 'P'})}).addTo(map);\n * new Marker([47.28, 11.41], {icon: new SvgIcon({color: 'green', glyph: '🚲'})}).addTo(map);\n * // a 24×24 SVG path, e.g. from Material Design Icons\n * new Marker([47.29, 11.42], {icon: new SvgIcon({color: 'purple', glyphPath: 'M12 2L2 22h20z'})}).addTo(map);\n * ```\n */\nexport class SvgIcon extends DefaultIcon {\n\n\tstatic defaultOptions = {\n\t\tcolor: '#d4462c',\n\t\tglyph: undefined,\n\t\tglyphPath: undefined,\n\t\tglyphColor: 'white'\n\t};\n\n\t/**\n\t * Creates an `SvgIcon` with the given options.\n\t * @param {[options?: SvgIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(SvgIcon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<div>` element with\n\t * the SVG of the marker, styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\tconst div = oldIcon?.tagName === 'DIV' ? oldIcon : document.createElement('div'),\n\t\toptions = this.options,\n\t\tsvg = svgElement('svg', {viewBox: '0 0 500 820', width: '100%', height: '100%', 'aria-hidden': 'true'});\n\n\t\tsvgElement('path', {\n\t\t\td: markerPath,\n\t\t\ttransform: markerTransform,\n\t\t\tfill: options.color,\n\t\t\tstroke: `color-mix(in srgb, ${options.color}, black 30%)`,\n\t\t\t'stroke-width': '1.1',\n\t\t\t'stroke-linejoin': 'miter'\n\t\t}, svg);\n\n\t\tif (options.glyphPath) {\n\t\t\tconst scale = glyphSize / 24;\n\t\t\tsvgElement('path', {\n\t\t\t\td: options.glyphPath,\n\t\t\t\tfill: options.glyphColor,\n\t\t\t\ttransform: `translate(${glyphX - glyphSize / 2} ${glyphY - glyphSize / 2})scale(${scale})`\n\t\t\t}, svg);\n\t\t} else if (options.glyph) {\n\t\t\tsvgElement('text', {\n\t\t\t\tx: glyphX,\n\t\t\t\ty: glyphY,\n\t\t\t\tfill: options.glyphColor,\n\t\t\t\t'font-size': glyphSize,\n\t\t\t\t'font-family': 'sans-serif',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t\t'text-anchor': 'middle',\n\t\t\t\t'dominant-baseline': 'central'\n\t\t\t}, svg).textContent = options.glyph;\n\t\t} else {\n\t\t\tsvgElement('path', {d: leafPath, transform: leafTransform, fill: options.glyphColor}, svg);\n\t\t}\n\n\t\tdiv.replaceChildren(svg);\n\t\tthis._setIconStyles(div, 'icon');\n\t\treturn div;\n\t}\n}\n"],"mappings":";;;AAGA,MAAM,QAAQ;AAGd,MAAM,aAAa;AACnB,MAAA,kBAAkB;AAClB,MAAA,WAAW;AACX,MAAA,gBAAgB;AAEhB,MAAA,SAAS;AACT,MAAA,SAAS;AACT,MAAA,YAAY;AAEZ,SAAS,WAAW,MAAM,YAAY,QAAQ;CAC7C,MAAM,KAAK,SAAS,gBAAgB,OAAO,IAAI;CAC/C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GACnD,GAAG,aAAa,KAAK,KAAK;CAE3B,QAAQ,YAAY,EAAE;CACtB,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,UAAb,MAAa,gBAAgB,YAAY;CAExC,OAAO,iBAAiB;EACvB,OAAO;EACP,OAAO,KAAA;EACP,WAAW,KAAA;EACX,YAAY;CACb;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;;;CAQA,WAAW,SAAS;EACnB,MAAM,MAAM,SAAS,YAAY,QAAQ,UAAU,SAAS,cAAc,KAAK,GAC/E,UAAU,KAAK,SACf,MAAM,WAAW,OAAO;GAAC,SAAS;GAAe,OAAO;GAAQ,QAAQ;GAAQ,eAAe;EAAM,CAAC;EAEtG,WAAW,QAAQ;GAClB,GAAG;GACH,WAAW;GACX,MAAM,QAAQ;GACd,QAAQ,sBAAsB,QAAQ,MAAM;GAC5C,gBAAgB;GAChB,mBAAmB;EACpB,GAAG,GAAG;EAEN,IAAI,QAAQ,WAAW;GACtB,MAAM,QAAQ,YAAY;GAC1B,WAAW,QAAQ;IAClB,GAAG,QAAQ;IACX,MAAM,QAAQ;IACd,WAAW,aAAa,SAAS,YAAY,EAAE,GAAG,SAAS,YAAY,EAAE,SAAS,MAAM;GACzF,GAAG,GAAG;EACP,OAAO,IAAI,QAAQ,OAClB,WAAW,QAAQ;GAClB,GAAG;GACH,GAAG;GACH,MAAM,QAAQ;GACd,aAAa;GACb,eAAe;GACf,eAAe;GACf,eAAe;GACf,qBAAqB;EACtB,GAAG,GAAG,CAAC,CAAC,cAAc,QAAQ;OAE9B,WAAW,QAAQ;GAAC,GAAG;GAAU,WAAW;GAAe,MAAM,QAAQ;EAAU,GAAG,GAAG;EAG1F,IAAI,gBAAgB,GAAG;EACvB,KAAK,eAAe,KAAK,MAAM;EAC/B,OAAO;CACR;AACD"}
1
+ {"version":3,"file":"SvgIcon.js","names":[],"sources":["../../../../src/layer/marker/SvgIcon.js"],"sourcesContent":["import {DefaultIcon} from './DefaultIcon.js';\n/** @import {DefaultIconOptions} from './DefaultIcon.js' */\n\nconst svgNS = 'http://www.w3.org/2000/svg';\n\n// The outline of the marker in a 500×820 view box (see the iconUrl of DefaultIcon)\nconst 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',\nmarkerTransform = 'translate(-7889.1 -9807.44)scale(19.5417)',\nleafPath = 'm-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z',\nleafTransform = 'translate(250 258)scale(.068)',\n// The center of the glyph and its size in the view box\nglyphX = 250,\nglyphY = 270,\nglyphSize = 230;\n\nfunction svgElement(name, attributes, parent) {\n\tconst el = document.createElementNS(svgNS, name);\n\tfor (const [key, value] of Object.entries(attributes)) {\n\t\tel.setAttribute(key, value);\n\t}\n\tparent?.append(el);\n\treturn el;\n}\n\n/**\n * Options of `SvgIcon`.\n * @typedef {object} SvgIconOptions\n * @property {string} [color='#d4462c'] The fill color of the marker, any CSS color. The\n * outline is a darker shade of it.\n * @property {string} [glyph] A character or emoji (or short text) shown in the marker\n * instead of the maple leaf.\n * @property {string} [glyphPath] The path data of an SVG glyph in a 24×24 view box (like\n * Material Design Icons), shown in the marker instead of the maple leaf.\n * @property {string} [glyphColor='white'] The color of the glyph or the maple leaf.\n * @extends DefaultIconOptions\n */\n\n/**\n * A marker icon in the shape of the default marker (with its shadow), drawn as\n * inline SVG in any color and with an optional glyph – a character, an emoji or an\n * SVG path (e.g. of an icon set) – instead of the white maple leaf. No image per\n * color is needed, and it stays sharp on any screen.\n *\n * Inspired by the [Leaflet.awesome-markers](https://github.com/lennardv2/Leaflet.awesome-markers),\n * [leaflet-color-markers](https://github.com/pointhi/leaflet-color-markers) and\n * [Leaflet.ExtraMarkers](https://github.com/coryasilva/Leaflet.ExtraMarkers) plugins.\n *\n * @example\n * ```js\n * new Marker([47.27, 11.40], {icon: new SvgIcon({color: '#2a81cb', glyph: 'P'})}).addTo(map);\n * new Marker([47.28, 11.41], {icon: new SvgIcon({color: 'green', glyph: '🚲'})}).addTo(map);\n * // a 24×24 SVG path, e.g. from Material Design Icons\n * new Marker([47.29, 11.42], {icon: new SvgIcon({color: 'purple', glyphPath: 'M12 2L2 22h20z'})}).addTo(map);\n * ```\n */\nexport class SvgIcon extends DefaultIcon {\n\n\tstatic defaultOptions = {\n\t\tcolor: '#d4462c',\n\t\tglyph: undefined,\n\t\tglyphPath: undefined,\n\t\tglyphColor: 'white'\n\t};\n\n\t/**\n\t * Creates an `SvgIcon` with the given options.\n\t * @param {[options?: SvgIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(SvgIcon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<div>` element with\n\t * the SVG of the marker, styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\tconst div = oldIcon?.tagName === 'DIV' ? oldIcon : document.createElement('div'),\n\t\toptions = this.options,\n\t\tsvg = svgElement('svg', {viewBox: '0 0 500 820', width: '100%', height: '100%', 'aria-hidden': 'true'});\n\n\t\tsvgElement('path', {\n\t\t\td: markerPath,\n\t\t\ttransform: markerTransform,\n\t\t\tfill: options.color,\n\t\t\tstroke: `color-mix(in srgb, ${options.color}, black 30%)`,\n\t\t\t'stroke-width': '1.1',\n\t\t\t'stroke-linejoin': 'miter'\n\t\t}, svg);\n\n\t\tif (options.glyphPath) {\n\t\t\tconst scale = glyphSize / 24;\n\t\t\tsvgElement('path', {\n\t\t\t\td: options.glyphPath,\n\t\t\t\tfill: options.glyphColor,\n\t\t\t\ttransform: `translate(${glyphX - glyphSize / 2} ${glyphY - glyphSize / 2})scale(${scale})`\n\t\t\t}, svg);\n\t\t} else if (options.glyph) {\n\t\t\tsvgElement('text', {\n\t\t\t\tx: glyphX,\n\t\t\t\ty: glyphY,\n\t\t\t\tfill: options.glyphColor,\n\t\t\t\t'font-size': glyphSize,\n\t\t\t\t'font-family': 'sans-serif',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t\t'text-anchor': 'middle',\n\t\t\t\t'dominant-baseline': 'central'\n\t\t\t}, svg).textContent = options.glyph;\n\t\t} else {\n\t\t\tsvgElement('path', {d: leafPath, transform: leafTransform, fill: options.glyphColor}, svg);\n\t\t}\n\n\t\tdiv.replaceChildren(svg);\n\t\tthis._setIconStyles(div, 'icon');\n\t\treturn div;\n\t}\n}\n"],"mappings":";;;AAGA,MAAM,QAAQ;AAGd,MAAM,aAAa;AACnB,MAAA,kBAAkB;AAClB,MAAA,WAAW;AACX,MAAA,gBAAgB;AAEhB,MAAA,SAAS;AACT,MAAA,SAAS;AACT,MAAA,YAAY;AAEZ,SAAS,WAAW,MAAM,YAAY,QAAQ;CAC7C,MAAM,KAAK,SAAS,gBAAgB,OAAO,IAAI;CAC/C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GACnD,GAAG,aAAa,KAAK,KAAK;CAE3B,QAAQ,OAAO,EAAE;CACjB,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,UAAb,MAAa,gBAAgB,YAAY;CAExC,OAAO,iBAAiB;EACvB,OAAO;EACP,OAAO,KAAA;EACP,WAAW,KAAA;EACX,YAAY;CACb;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;;;CAQA,WAAW,SAAS;EACnB,MAAM,MAAM,SAAS,YAAY,QAAQ,UAAU,SAAS,cAAc,KAAK,GAC/E,UAAU,KAAK,SACf,MAAM,WAAW,OAAO;GAAC,SAAS;GAAe,OAAO;GAAQ,QAAQ;GAAQ,eAAe;EAAM,CAAC;EAEtG,WAAW,QAAQ;GAClB,GAAG;GACH,WAAW;GACX,MAAM,QAAQ;GACd,QAAQ,sBAAsB,QAAQ,MAAM;GAC5C,gBAAgB;GAChB,mBAAmB;EACpB,GAAG,GAAG;EAEN,IAAI,QAAQ,WAAW;GACtB,MAAM,QAAQ,YAAY;GAC1B,WAAW,QAAQ;IAClB,GAAG,QAAQ;IACX,MAAM,QAAQ;IACd,WAAW,aAAa,SAAS,YAAY,EAAE,GAAG,SAAS,YAAY,EAAE,SAAS,MAAM;GACzF,GAAG,GAAG;EACP,OAAO,IAAI,QAAQ,OAClB,WAAW,QAAQ;GAClB,GAAG;GACH,GAAG;GACH,MAAM,QAAQ;GACd,aAAa;GACb,eAAe;GACf,eAAe;GACf,eAAe;GACf,qBAAqB;EACtB,GAAG,GAAG,CAAC,CAAC,cAAc,QAAQ;OAE9B,WAAW,QAAQ;GAAC,GAAG;GAAU,WAAW;GAAe,MAAM,QAAQ;EAAU,GAAG,GAAG;EAG1F,IAAI,gBAAgB,GAAG;EACvB,KAAK,eAAe,KAAK,MAAM;EAC/B,OAAO;CACR;AACD"}
@@ -63,10 +63,10 @@ import { LatLngBounds } from "../../geo/LatLngBounds.js";
63
63
  * @typedef {(error: any, tile: HTMLElement) => void} TileDoneCallback
64
64
  */
65
65
  /**
66
- * Generic class for handling a tiled grid of HTML elements. This is the base class for
67
- * all tile layers and replaces `TileLayer.Canvas`. GridLayer can be extended to create
68
- * a tiled grid of HTML elements like `<canvas>`, `<img>` or `<div>`. GridLayer will
69
- * handle creating and animating these DOM elements for you.
66
+ * Generic class for handling a tiled grid of HTML elements, and the base class of all
67
+ * tile layers. To show map tiles from a URL, use `TileLayer` (or `WMSTileLayer`).
68
+ * Extend `GridLayer` to create a tiled grid of your own elements like `<canvas>`,
69
+ * `<img>` or `<div>`; it handles creating and animating them for you.
70
70
  *
71
71
  * Layers extending `GridLayer` shall reimplement the [`createTile()`](#gridlayer-createtile)
72
72
  * method.
@@ -262,7 +262,7 @@ var GridLayer = class GridLayer extends Layer {
262
262
  redraw() {
263
263
  if (this._map) {
264
264
  this._removeAllTiles();
265
- const tileZoom = this._clampZoom(Math.round(this._map.getZoom()));
265
+ const tileZoom = this._getTileZoom(this._map.getZoom());
266
266
  if (tileZoom !== this._tileZoom) {
267
267
  this._tileZoom = tileZoom;
268
268
  this._updateLevels();
@@ -313,7 +313,7 @@ var GridLayer = class GridLayer extends Layer {
313
313
  return s instanceof Point ? s : new Point(s, s);
314
314
  }
315
315
  _updateZIndex() {
316
- if (this._container && this.options.zIndex !== void 0 && this.options.zIndex !== null) this._container.style.zIndex = `${this.options.zIndex}`;
316
+ if (this._container && this.options.zIndex != null) this._container.style.zIndex = `${this.options.zIndex}`;
317
317
  }
318
318
  _setAutoZIndex(compare) {
319
319
  const layers = this.getPane().children;
@@ -338,7 +338,7 @@ var GridLayer = class GridLayer extends Layer {
338
338
  this._container.classList.toggle("maplair-pixelated", !!this.options.pixelated);
339
339
  this._updateZIndex();
340
340
  if (this.options.opacity < 1) this._updateOpacity();
341
- this.getPane().appendChild(this._container);
341
+ this.getPane().append(this._container);
342
342
  }
343
343
  _keepCurrentTiles() {
344
344
  const zoom = this._tileZoom, level = this._levels?.[zoom];
@@ -412,8 +412,7 @@ var GridLayer = class GridLayer extends Layer {
412
412
  _onCreateLevel() {}
413
413
  _pruneTiles() {
414
414
  if (!this._map) return;
415
- const zoom = this._map.getZoom();
416
- if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
415
+ if (this._getTileZoom(this._map.getZoom()) === void 0) {
417
416
  this._removeAllTiles();
418
417
  return;
419
418
  }
@@ -468,6 +467,11 @@ var GridLayer = class GridLayer extends Layer {
468
467
  _animateZoom(e) {
469
468
  this._setView(e.center, e.zoom, true, e.noUpdate);
470
469
  }
470
+ _getTileZoom(zoom) {
471
+ const { minZoom, maxZoom = Infinity } = this.options;
472
+ if (zoom < minZoom || zoom > maxZoom) return;
473
+ return this._clampZoom(Math.round(zoom));
474
+ }
471
475
  _clampZoom(zoom) {
472
476
  const options = this.options;
473
477
  if (void 0 !== options.minNativeZoom && zoom < options.minNativeZoom) return options.minNativeZoom;
@@ -475,13 +479,11 @@ var GridLayer = class GridLayer extends Layer {
475
479
  return zoom;
476
480
  }
477
481
  _setView(center, zoom, noPrune, noUpdate) {
478
- let tileZoom = Math.round(zoom);
479
- if (this.options.maxZoom !== void 0 && tileZoom > this.options.maxZoom || this.options.minZoom !== void 0 && tileZoom < this.options.minZoom) tileZoom = void 0;
480
- else tileZoom = this._clampZoom(tileZoom);
482
+ const tileZoom = this._getTileZoom(zoom);
481
483
  const tileZoomChanged = this.options.updateWhenZooming && tileZoom !== this._tileZoom;
482
484
  if (!noUpdate || tileZoomChanged) {
483
485
  this._tileZoom = tileZoom;
484
- if (this._abortLoading) this._abortLoading();
486
+ this._abortLoading?.();
485
487
  this._updateLevels();
486
488
  this._resetGrid();
487
489
  if (tileZoom !== void 0) this._update(center);
@@ -550,7 +552,7 @@ var GridLayer = class GridLayer extends Layer {
550
552
  else queue.push(coords);
551
553
  }
552
554
  queue.sort((a, b) => a.distanceTo(tileCenter) - b.distanceTo(tileCenter));
553
- if (queue.length !== 0) {
555
+ if (queue.length) {
554
556
  if (!this._loading) {
555
557
  this._loading = true;
556
558
  this.fire("loading");
@@ -558,7 +560,7 @@ var GridLayer = class GridLayer extends Layer {
558
560
  }
559
561
  const fragment = document.createDocumentFragment();
560
562
  for (const q of queue) this._addTile(q, fragment);
561
- this._level.el.appendChild(fragment);
563
+ this._level.el.append(fragment);
562
564
  }
563
565
  }
564
566
  _isValidTile(coords) {
@@ -612,7 +614,7 @@ var GridLayer = class GridLayer extends Layer {
612
614
  coords,
613
615
  current: true
614
616
  };
615
- container.appendChild(tile);
617
+ container.append(tile);
616
618
  this.fire("tileloadstart", {
617
619
  tile,
618
620
  coords
@@ -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\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.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,K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AAC;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
+ {"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, and the base class of all\n * tile layers. To show map tiles from a URL, use `TileLayer` (or `WMSTileLayer`).\n * Extend `GridLayer` to create a tiled grid of your own elements like `<canvas>`,\n * `<img>` or `<div>`; it handles creating and animating them 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._getTileZoom(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 != 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().append(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\tif (this._getTileZoom(this._map.getZoom()) === undefined) {\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// The zoom of the tiles for the map zoom `zoom`, or undefined outside of the\n\t// `minZoom` and `maxZoom` of the layer, also between levels.\n\t_getTileZoom(zoom) {\n\t\tconst {minZoom, maxZoom = Infinity} = this.options;\n\t\tif (zoom < minZoom || zoom > maxZoom) { return undefined; }\n\t\treturn this._clampZoom(Math.round(zoom));\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\tconst tileZoom = this._getTileZoom(zoom);\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\tthis._abortLoading?.();\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) {\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.append(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.append(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.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,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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"}
@@ -141,13 +141,13 @@ var TileLayer = class TileLayer extends GridLayer {
141
141
  if (!this.options.zoomReverse) {
142
142
  this.options.zoomOffset++;
143
143
  this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
144
- if (this.options.maxNativeZoom !== void 0) this.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);
145
- if (this.options.minNativeZoom !== void 0) this.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);
146
144
  } else {
147
145
  this.options.zoomOffset--;
148
146
  this.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);
149
147
  }
150
148
  this.options.minZoom = Math.max(0, this.options.minZoom);
149
+ if (this.options.maxNativeZoom !== void 0) this.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);
150
+ if (this.options.minNativeZoom !== void 0) this.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);
151
151
  } else if (!this.options.zoomReverse) this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);
152
152
  else this.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);
153
153
  }
@@ -243,16 +243,17 @@ var TileLayer = class TileLayer extends GridLayer {
243
243
  * @returns {string}
244
244
  */
245
245
  getTileUrl(coords) {
246
- const data = Object.create(this.options);
246
+ const z = coords.z ?? this._tileZoom, data = Object.create(this.options);
247
247
  Object.assign(data, {
248
248
  r: window.devicePixelRatio > 1 ? "@2x" : "",
249
249
  s: this._getSubdomain(coords),
250
250
  x: coords.x,
251
251
  y: coords.y,
252
- z: this._getZoomForUrl()
252
+ z: this._getZoomForUrl(z)
253
253
  });
254
- if (this._map && !this._map.options.crs.infinite) {
255
- const invertedY = this._globalTileRange.max.y - coords.y;
254
+ const worldBounds = this._map?.getPixelWorldBounds(z);
255
+ if (worldBounds) {
256
+ const invertedY = this._pxBoundsToTileRange(worldBounds).max.y - coords.y;
256
257
  if (this.options.tms) data["y"] = invertedY;
257
258
  data["-y"] = invertedY;
258
259
  }
@@ -267,8 +268,7 @@ var TileLayer = class TileLayer extends GridLayer {
267
268
  if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
268
269
  done(e, tile);
269
270
  }
270
- _getZoomForUrl() {
271
- let zoom = this._tileZoom;
271
+ _getZoomForUrl(zoom) {
272
272
  const maxZoom = this.options.maxZoom, zoomReverse = this.options.zoomReverse, zoomOffset = this.options.zoomOffset;
273
273
  if (zoomReverse) zoom = maxZoom - zoom;
274
274
  return zoom + zoomOffset;
@@ -301,7 +301,7 @@ var TileLayer = class TileLayer extends GridLayer {
301
301
  return super._removeTile(key);
302
302
  }
303
303
  _tileReady(coords, err, tile) {
304
- if (!this._map || tile && tile.getAttribute("src") === "") return;
304
+ if (!this._map || tile?.getAttribute("src") === "") return;
305
305
  return super._tileReady(coords, err, tile);
306
306
  }
307
307
  _clampZoom(zoom) {