maplair 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/esm/Maplair.js +5 -4
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +1 -2
  6. package/dist/esm/control/ButtonControl.js +1 -2
  7. package/dist/esm/control/ContextMenu.js +1 -2
  8. package/dist/esm/control/Control.js +1 -2
  9. package/dist/esm/control/FullscreenControl.js +1 -2
  10. package/dist/esm/control/LayersControl.js +27 -31
  11. package/dist/esm/control/LayersControl.js.map +1 -1
  12. package/dist/esm/control/LegendControl.js +1 -2
  13. package/dist/esm/control/MiniMapControl.js +1 -2
  14. package/dist/esm/control/RotateControl.js +1 -2
  15. package/dist/esm/control/ScaleControl.js +1 -2
  16. package/dist/esm/control/SearchControl.js +1 -2
  17. package/dist/esm/control/SideBySideControl.js +1 -2
  18. package/dist/esm/control/TextControl.js +1 -2
  19. package/dist/esm/control/TimeControl.js +1 -2
  20. package/dist/esm/control/ZoomControl.js +18 -29
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Class.js +2 -9
  23. package/dist/esm/core/Class.js.map +1 -1
  24. package/dist/esm/core/Events.js +2 -2
  25. package/dist/esm/core/Events.js.map +1 -1
  26. package/dist/esm/core/Handler.js +10 -3
  27. package/dist/esm/core/Handler.js.map +1 -1
  28. package/dist/esm/core/I18n.js +1 -2
  29. package/dist/esm/core/Util.js +2 -3
  30. package/dist/esm/core/Util.js.map +1 -1
  31. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  32. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  33. package/dist/esm/dom/DomEvent.js +10 -18
  34. package/dist/esm/dom/DomEvent.js.map +1 -1
  35. package/dist/esm/dom/DomUtil.js +1 -2
  36. package/dist/esm/dom/Draggable.js +4 -3
  37. package/dist/esm/dom/Draggable.js.map +1 -1
  38. package/dist/esm/dom/PosAnimation.js +1 -2
  39. package/dist/esm/geo/LatLng.js +1 -2
  40. package/dist/esm/geo/LatLngBounds.js +9 -15
  41. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  42. package/dist/esm/geo/crs/CRS.js +1 -2
  43. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  44. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  45. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  46. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  47. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  48. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  49. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  50. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  51. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  52. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  53. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  54. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  55. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  56. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  57. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  58. package/dist/esm/geometry/Bounds.js +10 -14
  59. package/dist/esm/geometry/Bounds.js.map +1 -1
  60. package/dist/esm/geometry/LineUtil.js +2 -3
  61. package/dist/esm/geometry/LineUtil.js.map +1 -1
  62. package/dist/esm/geometry/Point.js +1 -2
  63. package/dist/esm/geometry/PolyUtil.js +17 -25
  64. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  65. package/dist/esm/geometry/Transformation.js +1 -2
  66. package/dist/esm/layer/BlanketOverlay.js +1 -2
  67. package/dist/esm/layer/Classification.js +1 -2
  68. package/dist/esm/layer/DivOverlay.js +2 -3
  69. package/dist/esm/layer/DivOverlay.js.map +1 -1
  70. package/dist/esm/layer/FeatureGroup.js +5 -4
  71. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  72. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  73. package/dist/esm/layer/GeoJSON.js +8 -10
  74. package/dist/esm/layer/GeoJSON.js.map +1 -1
  75. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  76. package/dist/esm/layer/HeatLayer.js +2 -3
  77. package/dist/esm/layer/HeatLayer.js.map +1 -1
  78. package/dist/esm/layer/ImageOverlay.js +2 -3
  79. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  80. package/dist/esm/layer/Layer.js +1 -2
  81. package/dist/esm/layer/LayerGroup.js +2 -3
  82. package/dist/esm/layer/LayerGroup.js.map +1 -1
  83. package/dist/esm/layer/Popup.js +9 -16
  84. package/dist/esm/layer/Popup.js.map +1 -1
  85. package/dist/esm/layer/SVGOverlay.js +1 -2
  86. package/dist/esm/layer/Tooltip.js +16 -17
  87. package/dist/esm/layer/Tooltip.js.map +1 -1
  88. package/dist/esm/layer/VideoOverlay.js +1 -2
  89. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  90. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  91. package/dist/esm/layer/marker/DivIcon.js +1 -2
  92. package/dist/esm/layer/marker/Icon.js +2 -2
  93. package/dist/esm/layer/marker/Icon.js.map +1 -1
  94. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  95. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  96. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  97. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  98. package/dist/esm/layer/marker/Marker.js +54 -14
  99. package/dist/esm/layer/marker/Marker.js.map +1 -1
  100. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  101. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  102. package/dist/esm/layer/tile/GridLayer.js +4 -4
  103. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  104. package/dist/esm/layer/tile/TileLayer.js +8 -8
  105. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  106. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  107. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  108. package/dist/esm/layer/vector/Canvas.js +7 -14
  109. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  110. package/dist/esm/layer/vector/Circle.js +5 -3
  111. package/dist/esm/layer/vector/Circle.js.map +1 -1
  112. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  113. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  114. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  115. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  116. package/dist/esm/layer/vector/Path.js +1 -2
  117. package/dist/esm/layer/vector/Polygon.js +2 -3
  118. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  119. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  120. package/dist/esm/layer/vector/Polyline.js +2 -3
  121. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  122. package/dist/esm/layer/vector/Rectangle.js +1 -2
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  124. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  125. package/dist/esm/layer/vector/Renderer.js +1 -2
  126. package/dist/esm/layer/vector/SVG.js +7 -4
  127. package/dist/esm/layer/vector/SVG.js.map +1 -1
  128. package/dist/esm/map/Hash.js +1 -2
  129. package/dist/esm/map/Map.Rotation.js +31 -16
  130. package/dist/esm/map/Map.Rotation.js.map +1 -1
  131. package/dist/esm/map/Map.js +10 -17
  132. package/dist/esm/map/Map.js.map +1 -1
  133. package/dist/esm/map/MapSync.js +1 -2
  134. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  135. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  136. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  137. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  138. package/dist/esm/map/handler/DragHandler.js +1 -2
  139. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  140. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  141. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  144. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  145. package/dist/esm/package.js +2 -3
  146. package/dist/maplair-global-src.js +489 -613
  147. package/dist/maplair-global-src.js.map +1 -1
  148. package/dist/maplair-global.js +2 -2
  149. package/dist/maplair-global.js.map +1 -1
  150. package/dist/maplair-src.js +485 -609
  151. package/dist/maplair-src.js.map +1 -1
  152. package/dist/maplair.css +1 -1263
  153. package/dist/maplair.js +2 -2
  154. package/dist/maplair.js.map +1 -1
  155. package/package.json +4 -8
  156. package/src/Maplair.all.js +0 -1
  157. package/src/control/LayersControl.js +39 -52
  158. package/src/control/ZoomControl.js +17 -31
  159. package/src/core/Class.js +5 -14
  160. package/src/core/Events.js +2 -0
  161. package/src/core/Handler.js +11 -1
  162. package/src/core/Util.js +1 -1
  163. package/src/dom/DomEvent.js +9 -19
  164. package/src/dom/Draggable.js +5 -1
  165. package/src/geo/LatLngBounds.js +8 -15
  166. package/src/geo/crs/EPSG3395.js +3 -3
  167. package/src/geo/crs/EPSG3857.js +3 -3
  168. package/src/geo/crs/EPSG4326.js +2 -2
  169. package/src/geo/crs/SimpleCRS.js +2 -2
  170. package/src/geo/index.js +1 -2
  171. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  172. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  173. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  174. package/src/geo/projection/index.js +5 -5
  175. package/src/geometry/Bounds.js +12 -17
  176. package/src/geometry/LineUtil.js +1 -1
  177. package/src/geometry/PolyUtil.js +23 -31
  178. package/src/layer/DivOverlay.js +1 -1
  179. package/src/layer/FeatureGroup.js +8 -2
  180. package/src/layer/GeoJSON.js +10 -13
  181. package/src/layer/HeatLayer.js +1 -1
  182. package/src/layer/ImageOverlay.js +2 -2
  183. package/src/layer/LayerGroup.js +1 -1
  184. package/src/layer/Popup.js +9 -19
  185. package/src/layer/Tooltip.js +19 -17
  186. package/src/layer/marker/DefaultIcon.js +33 -5
  187. package/src/layer/marker/Icon.js +2 -0
  188. package/src/layer/marker/Marker.Drag.js +53 -5
  189. package/src/layer/marker/Marker.Move.js +3 -4
  190. package/src/layer/marker/Marker.js +64 -13
  191. package/src/layer/tile/GridLayer.js +5 -2
  192. package/src/layer/tile/TileLayer.js +9 -6
  193. package/src/layer/tile/WMSTileLayer.js +5 -2
  194. package/src/layer/vector/Canvas.js +10 -14
  195. package/src/layer/vector/Circle.js +7 -1
  196. package/src/layer/vector/CircleMarker.js +2 -1
  197. package/src/layer/vector/Polygon.js +1 -1
  198. package/src/layer/vector/Polyline.js +1 -1
  199. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  200. package/src/layer/vector/SVG.js +12 -2
  201. package/src/map/Map.Rotation.js +28 -4
  202. package/src/map/Map.js +17 -21
  203. package/src/map/handler/BoxZoomHandler.js +21 -42
  204. package/src/map/handler/KeyboardHandler.js +34 -53
  205. package/src/maplair.css +5 -0
  206. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  207. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  208. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  209. package/dist/esm/geo/projection/index.js +0 -14
  210. package/dist/esm/geo/projection/index.js.map +0 -1
  211. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  212. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  213. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -1 +1 @@
1
- {"version":3,"file":"GridLayer.js","names":["Util.throttle","DomUtil.create","DomUtil.getPosition","Util.wrapNum"],"sources":["../../../../src/layer/tile/GridLayer.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Point} from '../../geometry/Point.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\n/** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */\n/** @import {LayerOptions} from '../Layer.js' */\n\n/**\n * Options of `GridLayer`.\n * @typedef {object} GridLayerOptions\n * @property {number|Point} [tileSize=256] Width and height of tiles in the grid. Use a\n * number if width and height are equal, or `Point(width, height)` otherwise.\n * @property {number} [opacity=1] Opacity of the tiles. Can be used in the `createTile()`\n * function.\n * @property {string|null} [placeholder=null] A CSS\n * [`background`](https://developer.mozilla.org/docs/Web/CSS/background) shown in place\n * of tiles while they are loading, e.g. `'#ddd'` or\n * `'url(loading.svg) center no-repeat #eee'`. Tiles with a placeholder appear without\n * fading in.\n * @property {boolean} [updateWhenIdle=false] Load new tiles only when panning ends.\n * @property {boolean} [updateWhenZooming=true] By default, a smooth zoom animation\n * (during a [pinch zoom](#map-pinchzoom) or a [`flyTo()`](#map-flyto)) will update grid\n * layers every integer zoom level. Setting this option to `false` will update the grid\n * layer only when the smooth animation ends.\n * @property {number} [updateInterval=200] Tiles will not update more than once every\n * `updateInterval` milliseconds when panning.\n * @property {number} [zIndex=1] The explicit zIndex of the tile layer.\n * @property {LatLngBoundsExpression|null} [bounds=null] If set, tiles will only be\n * loaded inside the set `LatLngBounds`.\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will\n * be displayed (inclusive).\n * @property {number} [maxZoom] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxNativeZoom] Maximum zoom number the tile source has available.\n * If it is specified, the tiles on all zoom levels higher than `maxNativeZoom` will be\n * loaded from `maxNativeZoom` level and auto-scaled.\n * @property {number} [minNativeZoom] Minimum zoom number the tile source has available.\n * If it is specified, the tiles on all zoom levels lower than `minNativeZoom` will be\n * loaded from `minNativeZoom` level and auto-scaled.\n * @property {boolean} [noWrap=false] Whether the layer is wrapped around the\n * antimeridian. If `true`, the GridLayer will only be displayed once at low zoom\n * levels. Has no effect when the [map CRS](#maplairmapoptions-crs) doesn't wrap around.\n * Can be used in combination with [`bounds`](#gridlayeroptions-bounds) to prevent\n * requesting tiles outside the CRS limits.\n * @property {string} [pane='tilePane'] `Map pane` where the grid layer will be added.\n * @property {string} [className=''] A custom class name to assign to the tile layer.\n * Empty by default.\n * @property {boolean} [pixelated=false] Whether to scale the tiles with\n * nearest-neighbour interpolation (`image-rendering: pixelated`) instead of smoothing\n * them, so that their pixels stay crisp, e.g. while zooming or beyond `maxNativeZoom`.\n * Useful for raster data, pixel art or scientific imagery.\n * @property {number} [keepBuffer=2] When panning the map, keep this many rows and\n * columns of tiles before unloading them.\n * @extends LayerOptions\n */\n\n/**\n * The callback of asynchronous `createTile()`, to be called with an error (or `null`)\n * and the tile when the tile has finished loading and drawing.\n * @typedef {(error: any, tile: HTMLElement) => void} TileDoneCallback\n */\n\n/**\n * Generic class for handling a tiled grid of HTML elements. This is the base class for\n * all tile layers and replaces `TileLayer.Canvas`. GridLayer can be extended to create\n * a tiled grid of HTML elements like `<canvas>`, `<img>` or `<div>`. GridLayer will\n * handle creating and animating these DOM elements for you.\n *\n * Layers extending `GridLayer` shall reimplement the [`createTile()`](#gridlayer-createtile)\n * method.\n *\n * @example\n * ### Synchronous usage\n *\n * To create a custom layer, extend GridLayer and implement the `createTile()` method,\n * which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level)\n * coordinates to draw your tile.\n *\n * ```js\n * class CanvasLayer extends GridLayer {\n * createTile(coords) {\n * // create a <canvas> element for drawing\n * const tile = DomUtil.create('canvas', 'maplair-tile');\n *\n * // setup tile width and height according to the options\n * const size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // get a canvas context and draw something on it using coords.x, coords.y and coords.z\n * const ctx = tile.getContext('2d');\n *\n * // return the tile so it can be rendered on screen\n * return tile;\n * }\n * }\n * ```\n *\n * @example\n * ### Asynchronous usage\n *\n * Tile creation can also be asynchronous, this is useful when using a third-party\n * drawing library. Once the tile is finished drawing it can be passed to the `done()`\n * callback.\n *\n * ```js\n * class CanvasLayer extends GridLayer {\n * createTile(coords, done) {\n * const error;\n *\n * // create a <canvas> element for drawing\n * const tile = DomUtil.create('canvas', 'maplair-tile');\n *\n * // setup tile width and height according to the options\n * const size = this.getTileSize();\n * tile.width = size.x;\n * tile.height = size.y;\n *\n * // draw something asynchronously and pass the tile to the done() callback\n * setTimeout(function() {\n * done(error, tile);\n * }, 1000);\n *\n * return tile;\n * }\n * }\n * ```\n *\n * @fires loading {MaplairEvent} Fired when the grid layer starts loading tiles.\n * @fires tileunload {TileEvent} Fired when a tile is removed (e.g. when a tile goes off\n * the screen).\n * @fires tileloadstart {TileEvent} Fired when a tile is requested and starts loading.\n * @fires tileerror {TileErrorEvent} Fired when there is an error loading a tile.\n * @fires tileload {TileEvent} Fired when a tile loads.\n * @fires load {MaplairEvent} Fired when the grid layer loaded all visible tiles.\n */\nexport class GridLayer extends Layer {\n\n\tstatic defaultOptions = {\n\t\ttileSize: 256,\n\t\topacity: 1,\n\t\tplaceholder: null,\n\t\tupdateWhenIdle: false,\n\t\tupdateWhenZooming: true,\n\t\tupdateInterval: 200,\n\t\tzIndex: 1,\n\t\tbounds: null,\n\t\tminZoom: 0,\n\t\tmaxZoom: undefined,\n\t\tmaxNativeZoom: undefined,\n\t\tminNativeZoom: undefined,\n\t\tnoWrap: false,\n\t\tpane: 'tilePane',\n\t\tclassName: '',\n\t\tpixelated: false,\n\t\tkeepBuffer: 2\n\t};\n\n\t/**\n\t * Creates a new instance of GridLayer with the supplied options.\n\t * @param {GridLayerOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis.callInitHooks(GridLayer);\n\t}\n\n\t/**\n\t * Creates the container of the tiles and loads the tiles.\n\t * @overload\n\t * @param {MaplairMap} map\n\t * @returns {void}\n\t */\n\tonAdd() {\n\t\tthis._initContainer();\n\n\t\tthis._levels = {};\n\t\tthis._tiles = {};\n\n\t\tthis._resetView(); // implicit _update() call\n\t}\n\n\t/**\n\t * Registers the zoom limits of the layer on the map.\n\t * @param {MaplairMap} map\n\t */\n\tbeforeAdd(map) {\n\t\tmap._addZoomLimit(this);\n\t}\n\n\t/**\n\t * Removes the tiles from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis._removeKeptLevel();\n\t\tthis._removeAllTiles();\n\t\tthis._container.remove();\n\t\tmap._removeZoomLimit(this);\n\t\tthis._container = null;\n\t\tthis._tileZoom = undefined;\n\t\tclearTimeout(this._pruneTimeout);\n\t\tcancelAnimationFrame(this._fadePruneFrame);\n\t\tthis._fadePruneFrame = 0;\n\t}\n\n\t/**\n\t * Brings the tile layer to the top of all tile layers.\n\t * @returns {this}\n\t */\n\tbringToFront() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toFront(this._container);\n\t\t\tthis._setAutoZIndex(Math.max);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Brings the tile layer to the bottom of all tile layers.\n\t * @returns {this}\n\t */\n\tbringToBack() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toBack(this._container);\n\t\t\tthis._setAutoZIndex(Math.min);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the HTML element that contains the tiles for this layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetContainer() {\n\t\treturn this._container;\n\t}\n\n\t/**\n\t * Changes the [opacity](#gridlayeroptions-opacity) of the grid layer.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tthis._updateOpacity();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Changes the [zIndex](#gridlayeroptions-zindex) of the grid layer.\n\t * @param {number} zIndex\n\t * @returns {this}\n\t */\n\tsetZIndex(zIndex) {\n\t\tthis.options.zIndex = zIndex;\n\t\tthis._updateZIndex();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if any tile in the grid layer has not finished loading.\n\t * @returns {boolean}\n\t */\n\tisLoading() {\n\t\treturn this._loading;\n\t}\n\n\t/**\n\t * Causes the layer to clear all the tiles and request them again.\n\t * @returns {this}\n\t */\n\tredraw() {\n\t\tif (this._map) {\n\t\t\tthis._removeAllTiles();\n\t\t\tconst tileZoom = this._clampZoom(Math.round(this._map.getZoom()));\n\t\t\tif (tileZoom !== this._tileZoom) {\n\t\t\t\tthis._tileZoom = tileZoom;\n\t\t\t\tthis._updateLevels();\n\t\t\t}\n\t\t\tthis._update();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tviewprereset: this._invalidateAll,\n\t\t\tviewreset: this._resetView,\n\t\t\tzoom: this._resetView,\n\t\t\tmoveend: this._onMoveEnd,\n\t\t\tworldcopyjump: this._onWorldCopyJump,\n\t\t\tzoomanim: this._animateZoom\n\t\t};\n\n\t\tif (!this.options.updateWhenIdle) {\n\t\t\t// update tiles on move, but not more often than once per given interval\n\t\t\tif (!this._onMove) {\n\t\t\t\tthis._onMove = Util.throttle(this._onMoveEnd, this.options.updateInterval, this);\n\t\t\t}\n\n\t\t\tevents.move = this._onMove;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, must be overridden by classes extending `GridLayer`.\n\t * Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback\n\t * is specified, it must be called when the tile has finished loading and drawing.\n\t * @group Extension methods\n\t * @overload\n\t * @param {Point} coords The `x`, `y` and `z` (zoom level) coordinates of the tile.\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLElement}\n\t */\n\t// without parameters: `createTile.length` tells whether a subclass creates tiles\n\t// asynchronously, see `_addTile()`\n\tcreateTile() {\n\t\treturn document.createElement('div');\n\t}\n\n\t/**\n\t * Normalizes the [tileSize option](#gridlayeroptions-tilesize) into a point. Used by\n\t * the `createTile()` method.\n\t * @returns {Point}\n\t */\n\tgetTileSize() {\n\t\tconst s = this.options.tileSize;\n\t\treturn s instanceof Point ? s : new Point(s, s);\n\t}\n\n\t_updateZIndex() {\n\t\tif (this._container && this.options.zIndex !== undefined && this.options.zIndex !== null) {\n\t\t\tthis._container.style.zIndex = `${this.options.zIndex}`;\n\t\t}\n\t}\n\n\t_setAutoZIndex(compare) {\n\t\t// go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)\n\n\t\tconst layers = this.getPane().children;\n\t\tlet edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min\n\n\t\tfor (const layer of layers) {\n\t\t\tconst zIndex = layer.style.zIndex;\n\n\t\t\tif (layer !== this._container && zIndex) {\n\t\t\t\tedgeZIndex = compare(edgeZIndex, +zIndex);\n\t\t\t}\n\t\t}\n\n\t\tif (isFinite(edgeZIndex)) {\n\t\t\tthis.options.zIndex = edgeZIndex + compare(-1, 1);\n\t\t\tthis._updateZIndex();\n\t\t}\n\t}\n\n\t_updateOpacity() {\n\t\tif (!this._map) { return; }\n\n\t\tthis._container.style.opacity = `${this.options.opacity}`;\n\t}\n\n\t_onOpaqueTile() {}\n\n\t_initContainer() {\n\t\tif (this._container) { return; }\n\n\t\tthis._container = DomUtil.create('div', `maplair-layer ${this.options.className ?? ''}`);\n\t\tthis._container.classList.toggle('maplair-pixelated', !!this.options.pixelated);\n\t\tthis._updateZIndex();\n\n\t\tif (this.options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\tthis.getPane().appendChild(this._container);\n\t}\n\n\t// Keeps the loaded tiles of the current level visible below the tiles loaded\n\t// next (e.g. after changing the URL), until these have loaded, to avoid flickering.\n\t_keepCurrentTiles() {\n\t\tconst zoom = this._tileZoom,\n\t\tlevel = this._levels?.[zoom];\n\t\t// keep the first level if the next one has not loaded yet\n\t\tif (!this._map || !level || this._keptLevel) { return; }\n\n\t\tconst tiles = [];\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (tile.coords.z === zoom && tile.loaded) {\n\t\t\t\ttiles.push(tile);\n\t\t\t\tdelete this._tiles[key];\n\t\t\t}\n\t\t}\n\t\tdelete this._levels[zoom];\n\t\tlevel.el.style.zIndex = -1;\n\t\tthis._keptLevel = {level, tiles};\n\t\t// new level for the next tiles\n\t\tthis._updateLevels();\n\n\t\tthis.on('load', this._onLoadKeptLevel, this);\n\t\tthis._map.on('zoomstart viewprereset', this._removeKeptLevel, this);\n\t}\n\n\t_onLoadKeptLevel() {\n\t\tif (this._map._fadeAnimated) {\n\t\t\t// after the new tiles faded in\n\t\t\tclearTimeout(this._keptLevelTimeout);\n\t\t\tthis._keptLevelTimeout = setTimeout(this._removeKeptLevel.bind(this), 250);\n\t\t} else {\n\t\t\tthis._removeKeptLevel();\n\t\t}\n\t}\n\n\t_removeKeptLevel() {\n\t\tif (!this._keptLevel) { return; }\n\t\tconst {level, tiles} = this._keptLevel;\n\t\tthis._keptLevel = null;\n\t\tclearTimeout(this._keptLevelTimeout);\n\t\tthis.off('load', this._onLoadKeptLevel, this);\n\t\tthis._map.off('zoomstart viewprereset', this._removeKeptLevel, this);\n\n\t\tlevel.el.remove();\n\t\tfor (const tile of tiles) {\n\t\t\tthis.fire('tileunload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords: tile.coords\n\t\t\t});\n\t\t}\n\t}\n\n\t_updateLevels() {\n\n\t\tconst zoom = this._tileZoom,\n\t\tmaxZoom = this.options.maxZoom;\n\n\t\tif (zoom === undefined) { return undefined; }\n\n\t\tfor (let z of Object.keys(this._levels)) {\n\t\t\tz = Number(z);\n\t\t\tif (this._levels[z].el.children.length || z === zoom) {\n\t\t\t\tthis._levels[z].el.style.zIndex = `${maxZoom - Math.abs(zoom - z)}`;\n\t\t\t\tthis._onUpdateLevel(z);\n\t\t\t} else {\n\t\t\t\tthis._levels[z].el.remove();\n\t\t\t\tthis._removeTilesAtZoom(z);\n\t\t\t\tthis._onRemoveLevel(z);\n\t\t\t\tdelete this._levels[z];\n\t\t\t}\n\t\t}\n\n\t\tlet level = this._levels[zoom];\n\t\tconst map = this._map;\n\n\t\tif (!level) {\n\t\t\tlevel = this._levels[zoom] = {};\n\n\t\t\tlevel.el = DomUtil.create('div', 'maplair-tile-container maplair-zoom-animated', this._container);\n\t\t\tlevel.el.style.zIndex = `${maxZoom}`;\n\n\t\t\tlevel.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();\n\t\t\tlevel.zoom = zoom;\n\n\t\t\tthis._setZoomTransform(level, map.getCenter(), map.getZoom());\n\n\t\t\t// force reading offsetWidth so the browser considers the newly added element for transition\n\t\t\tUtil.falseFn(level.el.offsetWidth);\n\n\t\t\tthis._onCreateLevel(level);\n\t\t}\n\n\t\tthis._level = level;\n\n\t\treturn level;\n\t}\n\n\t_onUpdateLevel() {}\n\n\t_onRemoveLevel() {}\n\n\t_onCreateLevel() {}\n\n\t_pruneTiles() {\n\t\tif (!this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst zoom = this._map.getZoom();\n\t\tif (zoom > this.options.maxZoom ||\n\t\t\tzoom < this.options.minZoom) {\n\t\t\tthis._removeAllTiles();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\ttile.retain = tile.current;\n\t\t}\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tif (tile.current && !tile.active) {\n\t\t\t\tconst coords = tile.coords;\n\t\t\t\tif (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {\n\t\t\t\t\tthis._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (!tile.retain) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTilesAtZoom(zoom) {\n\t\tfor (const [key, tile] of Object.entries(this._tiles)) {\n\t\t\tif (tile.coords.z === zoom) {\n\t\t\t\tthis._removeTile(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeAllTiles() {\n\t\tfor (const key of Object.keys(this._tiles)) {\n\t\t\tthis._removeTile(key);\n\t\t}\n\t}\n\n\t_invalidateAll(e) {\n\t\t// a zoom without animation keeps the old levels until new tiles load, like the end of an animated one,\n\t\t// unless the view jumps somewhere else\n\t\tconst map = this._map;\n\t\tif (e?.zoom !== undefined && e.zoom !== map.getZoom() && map.getBounds().contains(e.center)) { return; }\n\n\t\tfor (const z of Object.keys(this._levels)) {\n\t\t\tthis._levels[z].el.remove();\n\t\t\tthis._onRemoveLevel(Number(z));\n\t\t\tdelete this._levels[z];\n\t\t}\n\t\tthis._removeAllTiles();\n\n\t\tthis._tileZoom = undefined;\n\t}\n\n\t_retainParent(x, y, z, minZoom) {\n\t\tfor (z--; z >= minZoom; z--) {\n\t\t\tx = Math.floor(x / 2);\n\t\t\ty = Math.floor(y / 2);\n\t\t\tif (this._retain(x, y, z)) { return true; }\n\t\t}\n\t\treturn false;\n\t}\n\n\t_retainChildren(x, y, z, maxZoom) {\n\t\tfor (let i = 2 * x; i < 2 * x + 2; i++) {\n\t\t\tfor (let j = 2 * y; j < 2 * y + 2; j++) {\n\t\t\t\tif (!this._retain(i, j, z + 1) && z + 1 < maxZoom) {\n\t\t\t\t\tthis._retainChildren(i, j, z + 1, maxZoom);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// retains the tile if it's loaded; returns true if it's active, so there's no need to look further\n\t_retain(x, y, z) {\n\t\tconst tile = this._tiles[this._tileCoordsToKey({x, y, z})];\n\t\tif (tile?.loaded) { tile.retain = true; }\n\t\treturn tile?.active;\n\t}\n\n\t_resetView(e) {\n\t\tconst animating = e && (e.pinch || e.flyTo || e.continuous);\n\t\tthis._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);\n\t}\n\n\t_animateZoom(e) {\n\t\tthis._setView(e.center, e.zoom, true, e.noUpdate);\n\t}\n\n\t_clampZoom(zoom) {\n\t\tconst options = this.options;\n\n\t\tif (undefined !== options.minNativeZoom && zoom < options.minNativeZoom) {\n\t\t\treturn options.minNativeZoom;\n\t\t}\n\n\t\tif (undefined !== options.maxNativeZoom && options.maxNativeZoom < zoom) {\n\t\t\treturn options.maxNativeZoom;\n\t\t}\n\n\t\treturn zoom;\n\t}\n\n\t_setView(center, zoom, noPrune, noUpdate) {\n\t\tlet tileZoom = Math.round(zoom);\n\t\tif ((this.options.maxZoom !== undefined && tileZoom > this.options.maxZoom) ||\n\t\t (this.options.minZoom !== undefined && tileZoom < this.options.minZoom)) {\n\t\t\ttileZoom = undefined;\n\t\t} else {\n\t\t\ttileZoom = this._clampZoom(tileZoom);\n\t\t}\n\n\t\tconst tileZoomChanged = this.options.updateWhenZooming && (tileZoom !== this._tileZoom);\n\n\t\tif (!noUpdate || tileZoomChanged) {\n\n\t\t\tthis._tileZoom = tileZoom;\n\n\t\t\tif (this._abortLoading) {\n\t\t\t\tthis._abortLoading();\n\t\t\t}\n\n\t\t\tthis._updateLevels();\n\t\t\tthis._resetGrid();\n\n\t\t\tif (tileZoom !== undefined) {\n\t\t\t\tthis._update(center);\n\t\t\t}\n\n\t\t\tif (!noPrune) {\n\t\t\t\tthis._pruneTiles();\n\t\t\t}\n\n\t\t\t// Flag to prevent finished tile fades from pruning tiles during\n\t\t\t// a zoom anim or a pinch gesture\n\t\t\tthis._noPrune = !!noPrune;\n\t\t}\n\n\t\tthis._setZoomTransforms(center, zoom);\n\t}\n\n\t_setZoomTransforms(center, zoom) {\n\t\tfor (const level of Object.values(this._levels)) {\n\t\t\tthis._setZoomTransform(level, center, zoom);\n\t\t}\n\t}\n\n\t_setZoomTransform(level, center, zoom) {\n\t\tconst scale = this._map.getZoomScale(zoom, level.zoom),\n\t\ttranslate = level.origin.multiplyBy(scale)\n\t\t\t.subtract(this._map._getNewPixelOrigin(center, zoom)).round();\n\n\t\tDomUtil.setTransform(level.el, translate, scale);\n\t}\n\n\t_resetGrid() {\n\t\tconst map = this._map,\n\t\tcrs = map.options.crs,\n\t\ttileSize = this._tileSize = this.getTileSize(),\n\t\ttileZoom = this._tileZoom;\n\n\t\tconst bounds = this._map.getPixelWorldBounds(this._tileZoom);\n\t\tif (bounds) {\n\t\t\tthis._globalTileRange = this._pxBoundsToTileRange(bounds);\n\t\t}\n\n\t\tthis._wrapX = crs.wrapLng && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x),\n\t\t\tMath.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.x)\n\t\t];\n\t\tthis._wrapY = crs.wrapLat && !this.options.noWrap && [\n\t\t\tMath.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.y),\n\t\t\tMath.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)\n\t\t];\n\t}\n\n\t_onMoveEnd() {\n\t\tif (!this._map || this._map._animatingZoom) { return; }\n\n\t\tthis._update();\n\t}\n\n\t_onWorldCopyJump({worlds}) {\n\t\t// noWrap tiles cannot be reused in another world copy.\n\t\tif (!this._wrapX) { return; }\n\n\t\tconst tileSize = this.getTileSize(),\n\t\ttiles = {};\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tconst {coords, el} = tile,\n\t\t\tdx = worlds * this._map.getPixelWorldBounds(coords.z).getSize().x;\n\n\t\t\t// tiles can't be shifted by a fraction of a column, so leave those to be reloaded\n\t\t\tif (dx % tileSize.x === 0) {\n\t\t\t\tcoords.x -= dx / tileSize.x;\n\t\t\t\tDomUtil.setPosition(el, DomUtil.getPosition(el).subtract([dx, 0]), true);\n\t\t\t}\n\t\t\ttiles[this._tileCoordsToKey(coords)] = tile;\n\t\t}\n\n\t\tthis._tiles = tiles;\n\t}\n\n\t_getTiledPixelBounds(center) {\n\t\tconst map = this._map,\n\t\tmapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),\n\t\tscale = map.getZoomScale(mapZoom, this._tileZoom),\n\t\tpixelCenter = map.project(center, this._tileZoom).floor(),\n\t\thalfSize = map.getSize().divideBy(scale * 2);\n\n\t\treturn new Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));\n\t}\n\n\t// Private method to load tiles in the grid's active zoom level according to map bounds\n\t_update(center) {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\t\tconst zoom = this._clampZoom(map.getZoom());\n\n\t\tif (center === undefined) { center = map.getCenter(); }\n\t\tif (this._tileZoom === undefined) { return; }\t// if out of minzoom/maxzoom\n\n\t\tconst pixelBounds = this._getTiledPixelBounds(center),\n\t\ttileRange = this._pxBoundsToTileRange(pixelBounds),\n\t\ttileCenter = tileRange.getCenter(),\n\t\tqueue = [],\n\t\tmargin = this.options.keepBuffer,\n\t\tnoPruneRange = new Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),\n\t\t\ttileRange.getTopRight().add([margin, -margin]));\n\n\t\t// Sanity check: panic if the tile range contains Infinity somewhere.\n\t\tif (!(isFinite(tileRange.min.x) &&\n\t\t isFinite(tileRange.min.y) &&\n\t\t isFinite(tileRange.max.x) &&\n\t\t isFinite(tileRange.max.y))) { throw new Error('Attempted to load an infinite number of tiles'); }\n\n\t\tfor (const tile of Object.values(this._tiles)) {\n\t\t\tconst c = tile.coords;\n\t\t\tif (c.z !== this._tileZoom || !noPruneRange.contains(new Point(c.x, c.y))) {\n\t\t\t\ttile.current = false;\n\t\t\t}\n\t\t}\n\n\t\t// _update just loads more tiles. If the tile zoom level differs too much\n\t\t// from the map's, let _setView reset levels and prune old tiles.\n\t\tif (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }\n\n\t\t// create a queue of coordinates to load tiles from\n\t\tfor (let j = tileRange.min.y; j <= tileRange.max.y; j++) {\n\t\t\tfor (let i = tileRange.min.x; i <= tileRange.max.x; i++) {\n\t\t\t\tconst coords = new Point(i, j);\n\t\t\t\tcoords.z = this._tileZoom;\n\n\t\t\t\tif (!this._isValidTile(coords)) { continue; }\n\n\t\t\t\tconst tile = this._tiles[this._tileCoordsToKey(coords)];\n\t\t\t\tif (tile) {\n\t\t\t\t\ttile.current = true;\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push(coords);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// sort tile queue to load tiles in order of their distance to center\n\t\tqueue.sort((a, b) => a.distanceTo(tileCenter) - b.distanceTo(tileCenter));\n\n\t\tif (queue.length !== 0) {\n\t\t\t// if it's the first batch of tiles to load\n\t\t\tif (!this._loading) {\n\t\t\t\tthis._loading = true;\n\t\t\t\tthis.fire('loading');\n\t\t\t\tthis._map._onLayerLoading();\n\t\t\t}\n\n\t\t\t// create DOM fragment to append tiles in one batch\n\t\t\tconst fragment = document.createDocumentFragment();\n\n\t\t\tfor (const q of queue) {\n\t\t\t\tthis._addTile(q, fragment);\n\t\t\t}\n\n\t\t\tthis._level.el.appendChild(fragment);\n\t\t}\n\t}\n\n\t_isValidTile(coords) {\n\t\tconst crs = this._map.options.crs;\n\n\t\tif (!crs.infinite) {\n\t\t\t// don't load tile if it's out of bounds and not wrapped\n\t\t\tconst bounds = this._globalTileRange;\n\t\t\tif ((!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\n\t\t\t (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; }\n\t\t}\n\n\t\tif (!this.options.bounds) { return true; }\n\n\t\t// don't load tile if it doesn't intersect the bounds in options\n\t\tconst tileBounds = this._tileCoordsToBounds(coords);\n\t\treturn LatLngBounds.from(this.options.bounds).overlaps(tileBounds);\n\t}\n\n\t_tileCoordsToNwSe(coords) {\n\t\tconst map = this._map,\n\t\ttileSize = this.getTileSize(),\n\t\tnwPoint = coords.scaleBy(tileSize),\n\t\tsePoint = nwPoint.add(tileSize),\n\t\tnw = map.unproject(nwPoint, coords.z),\n\t\tse = map.unproject(sePoint, coords.z);\n\t\treturn [nw, se];\n\t}\n\n\t// converts tile coordinates to its geographical bounds\n\t_tileCoordsToBounds(coords) {\n\t\tconst bp = this._tileCoordsToNwSe(coords);\n\t\tlet bounds = new LatLngBounds(bp[0], bp[1]);\n\n\t\tif (!this.options.noWrap) {\n\t\t\tbounds = this._map.wrapLatLngBounds(bounds);\n\t\t}\n\t\treturn bounds;\n\t}\n\t// converts tile coordinates to key for the tile cache\n\t_tileCoordsToKey(coords) {\n\t\treturn `${coords.x}:${coords.y}:${coords.z}`;\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\ttile.el.remove();\n\n\t\tdelete this._tiles[key];\n\n\t\tthis.fire('tileunload', {\n\t\t\ttile: tile.el,\n\t\t\tcoords: tile.coords\n\t\t});\n\t}\n\n\t_initTile(tile) {\n\t\ttile.classList.add('maplair-tile');\n\n\t\tconst tileSize = this.getTileSize();\n\t\ttile.style.width = `${tileSize.x}px`;\n\t\ttile.style.height = `${tileSize.y}px`;\n\n\t\tif (this.options.placeholder) {\n\t\t\ttile.style.background = this.options.placeholder;\n\t\t}\n\t}\n\n\t_addTile(coords, container) {\n\t\tconst tilePos = this._getTilePos(coords),\n\t\tkey = this._tileCoordsToKey(coords);\n\n\t\tconst tile = this.createTile(this._wrapCoords(coords), this._tileReady.bind(this, coords));\n\n\t\tthis._initTile(tile);\n\n\t\t// if createTile is defined with a second argument (\"done\" callback),\n\t\t// we know that tile is async and will be ready later; otherwise\n\t\tif (this.createTile.length < 2) {\n\t\t\t// mark tile as ready, but delay one frame for opacity animation to happen\n\t\t\trequestAnimationFrame(this._tileReady.bind(this, coords, null, tile));\n\t\t}\n\n\t\t// 2D, so tiles raster into the level's layer: as separate layers they get compositor edge antialiasing,\n\t\t// and the overlapping edge ramps show as light seams under plus-lighter blending\n\t\tDomUtil.setPosition(tile, tilePos, true);\n\n\t\t// save tile in cache\n\t\tthis._tiles[key] = {\n\t\t\tel: tile,\n\t\t\tcoords,\n\t\t\tcurrent: true\n\t\t};\n\n\t\tcontainer.appendChild(tile);\n\t\tthis.fire('tileloadstart', {\n\t\t\ttile,\n\t\t\tcoords\n\t\t});\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (err) {\n\t\t\tthis.fire('tileerror', {\n\t\t\t\terror: err,\n\t\t\t\ttile,\n\t\t\t\tcoords\n\t\t\t});\n\t\t}\n\n\t\tconst key = this._tileCoordsToKey(coords);\n\n\t\ttile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\tif (this.options.placeholder) {\n\t\t\ttile.el.style.background = '';\n\t\t}\n\t\t// fading in with a placeholder would show the map below instead of the placeholder at first\n\t\tif (!this._map._fadeAnimated || this.options.placeholder) {\n\t\t\ttile.active = true;\n\t\t\tthis._pruneTiles();\n\t\t} else if (!tile.loaded) { // with errorTileUrl, a tile is ready twice (on error and on fallback load)\n\t\t\t// while fading, the tile is a compositor layer of its own where plus-lighter would light up its\n\t\t\t// antialiased edges, so it's blended normally until the fade ends\n\t\t\ttile.el.classList.add('maplair-tile-fading');\n\t\t\ttile.el.animate({opacity: [0, 1]}, 200).onfinish = this._onTileFaded.bind(this, tile);\n\t\t}\n\t\ttile.loaded = true;\n\n\t\tif (!err) {\n\t\t\ttile.el.classList.add('maplair-tile-loaded');\n\n\t\t\tthis.fire('tileload', {\n\t\t\t\ttile: tile.el,\n\t\t\t\tcoords\n\t\t\t});\n\t\t}\n\n\t\tif (this._noTilesToLoad()) {\n\t\t\tthis._loading = false;\n\t\t\tthis.fire('load');\n\t\t\tthis._map._scheduleIdleCheck();\n\n\t\t\tif (!this._map._fadeAnimated) {\n\t\t\t\trequestAnimationFrame(this._pruneTiles.bind(this));\n\t\t\t} else {\n\t\t\t\t// Wait a bit more than 0.2 secs (the duration of the tile fade-in)\n\t\t\t\t// to trigger a pruning.\n\t\t\t\tthis._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);\n\t\t\t}\n\t\t}\n\t}\n\n\t_onTileFaded(tile) {\n\t\ttile.el.classList.remove('maplair-tile-fading');\n\t\t// the tile's key may have changed after a world copy jump, so look it up again\n\t\tif (this._tiles[this._tileCoordsToKey(tile.coords)] !== tile) { return; }\n\n\t\ttile.active = true;\n\t\tthis._onOpaqueTile(tile);\n\n\t\t// one prune for all the tiles that finish fading in the same frame\n\t\tif (this._noPrune || this._fadePruneFrame) { return; }\n\t\tthis._fadePruneFrame = requestAnimationFrame(() => {\n\t\t\tthis._fadePruneFrame = 0;\n\t\t\tif (!this._noPrune) { this._pruneTiles(); }\n\t\t});\n\t}\n\n\t_getTilePos(coords) {\n\t\treturn coords.scaleBy(this.getTileSize()).subtract(this._level.origin);\n\t}\n\n\t_wrapCoords(coords) {\n\t\tconst newCoords = new Point(\n\t\t\tthis._wrapX ? Util.wrapNum(coords.x, this._wrapX) : coords.x,\n\t\t\tthis._wrapY ? Util.wrapNum(coords.y, this._wrapY) : coords.y);\n\t\tnewCoords.z = coords.z;\n\t\treturn newCoords;\n\t}\n\n\t_pxBoundsToTileRange(bounds) {\n\t\tconst tileSize = this.getTileSize();\n\t\treturn new Bounds(\n\t\t\tbounds.min.unscaleBy(tileSize).floor(),\n\t\t\tbounds.max.unscaleBy(tileSize).ceil().subtract([1, 1]));\n\t}\n\n\t_noTilesToLoad() {\n\t\treturn Object.values(this._tiles).every(t => t.loaded);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAQ;EAEhE,KAAK,SAAS;EACd,KAAK,cAAc,IAAI;EAGvB,IAAI,KAAK,YAAY,KAAK,iBAAmB;EAC7C,KAAK,kBAAkB,4BAA4B;GAClD,KAAK,kBAAkB;GACvB,IAAI,CAAC,KAAK,UAAY,KAAK,YAAY;EACxC,CAAC;CACF;CAEA,YAAY,QAAQ;EACnB,OAAO,OAAO,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK,OAAO,MAAM;CACtE;CAEA,YAAY,QAAQ;EACnB,MAAM,YAAY,IAAI,MACrB,KAAK,SAASC,QAAa,OAAO,GAAG,KAAK,MAAM,IAAI,OAAO,GAC3D,KAAK,SAASA,QAAa,OAAO,GAAG,KAAK,MAAM,IAAI,OAAO,CAAC;EAC7D,UAAU,IAAI,OAAO;EACrB,OAAO;CACR;CAEA,qBAAqB,QAAQ;EAC5B,MAAM,WAAW,KAAK,YAAY;EAClC,OAAO,IAAI,OACV,OAAO,IAAI,UAAU,QAAQ,CAAC,CAAC,MAAM,GACrC,OAAO,IAAI,UAAU,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;CACxD;CAEA,iBAAiB;EAChB,OAAO,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,OAAM,MAAK,EAAE,MAAM;CACtD;AACD"}
1
+ {"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,KAAA;EACT,eAAe,KAAA;EACf,eAAe,KAAA;EACf,QAAQ;EACR,MAAM;EACN,WAAW;EACX,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,CAAC,SAAS,KAAK,OAAO,MAAM;CACtE;CAEA,YAAY,QAAQ;EACnB,MAAM,YAAY,IAAI,MACrB,KAAK,SAASC,QAAa,OAAO,GAAG,KAAK,MAAM,IAAI,OAAO,GAC3D,KAAK,SAASA,QAAa,OAAO,GAAG,KAAK,MAAM,IAAI,OAAO,CAAC;EAC7D,UAAU,IAAI,OAAO;EACrB,OAAO;CACR;CAEA,qBAAqB,QAAQ;EAC5B,MAAM,WAAW,KAAK,YAAY;EAClC,OAAO,IAAI,OACV,OAAO,IAAI,UAAU,QAAQ,CAAC,CAAC,MAAM,GACrC,OAAO,IAAI,UAAU,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;CACxD;CAEA,iBAAiB;EAChB,OAAO,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,OAAM,MAAK,EAAE,MAAM;CACtD;AACD"}
@@ -1,9 +1,9 @@
1
1
  import { setOptions, template } from "../../core/Util.js";
2
+ import { Point } from "../../geometry/Point.js";
2
3
  import { on } from "../../dom/DomEvent.js";
3
4
  import { I18n } from "../../core/I18n.js";
4
5
  import { GridLayer } from "./GridLayer.js";
5
- //#region src/layer/tile/TileLayer.js
6
- /** @import {Point} from '../../geometry/Point.js' */
6
+ // src/layer/tile/TileLayer.js
7
7
  /** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */
8
8
  /** @import {TileEvent} from '../../core/Events.js' */
9
9
  const osmHosts = ["tile.openstreetmap.org", "tile.osm.org"];
@@ -136,7 +136,8 @@ var TileLayer = class TileLayer extends GridLayer {
136
136
  Object.assign(this.options, this._nonRetinaOptions);
137
137
  this._retina = window.devicePixelRatio > 1;
138
138
  if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
139
- this.options.tileSize = Math.floor(this.options.tileSize / 2);
139
+ const tileSize = this.options.tileSize;
140
+ this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
140
141
  if (!this.options.zoomReverse) {
141
142
  this.options.zoomOffset++;
142
143
  this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
@@ -262,8 +263,8 @@ var TileLayer = class TileLayer extends GridLayer {
262
263
  done(null, tile);
263
264
  }
264
265
  _tileOnError(done, tile, e) {
265
- const errorUrl = this.options.errorTileUrl;
266
- if (errorUrl && tile.getAttribute("src") !== errorUrl) tile.src = errorUrl;
266
+ const errorUrl = this.options.errorTileUrl, src = tile.getAttribute("src");
267
+ if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
267
268
  done(e, tile);
268
269
  }
269
270
  _getZoomForUrl() {
@@ -273,8 +274,8 @@ var TileLayer = class TileLayer extends GridLayer {
273
274
  return zoom + zoomOffset;
274
275
  }
275
276
  _getSubdomain(tilePoint) {
276
- const index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
277
- return this.options.subdomains[index];
277
+ const { subdomains } = this.options;
278
+ return subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];
278
279
  }
279
280
  _abortLoading() {
280
281
  let i, tile;
@@ -307,7 +308,6 @@ var TileLayer = class TileLayer extends GridLayer {
307
308
  return Math.round(super._clampZoom(zoom));
308
309
  }
309
310
  };
310
- //#endregion
311
311
  export { TileLayer };
312
312
 
313
313
  //# sourceMappingURL=TileLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TileLayer.js","names":["Util.setOptions","Util.template"],"sources":["../../../../src/layer/tile/TileLayer.js"],"sourcesContent":["import {GridLayer} from './GridLayer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {I18n} from '../../core/I18n.js';\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */\n/** @import {TileEvent} from '../../core/Events.js' */\n\nconst osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];\nconst hostRe = /^(https?:)?\\/\\/([^/?#:]*)/i;\nconst httpRe = /^http:/i;\n\nfunction isOSMUrl(url) {\n\tconst host = hostRe.exec(url)?.[2] ?? '';\n\treturn osmHosts.some(osmHost => host === osmHost || host.endsWith(`.${osmHost}`));\n}\n\n// OSM tiles are upgraded to HTTPS so that the referrer policy works\nconst upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : url);\n\n/**\n * Options of `TileLayer`.\n * @typedef {object} TileLayerOptions\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxZoom=18] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {string|string[]} [subdomains='abc'] Subdomains of the tile service. Can be\n * passed in the form of one string (where each letter is a subdomain name) or an array\n * of strings.\n * @property {string} [errorTileUrl=''] URL to the tile image to show in place of the\n * tile that failed to load.\n * @property {number} [zoomOffset=0] The zoom number used in tile URLs will be offset\n * with this value.\n * @property {boolean} [tms=false] If `true`, inverses Y axis numbering for tiles (turn\n * this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).\n * @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile\n * URLs will be reversed (`maxZoom - zoom` instead of `zoom`).\n * @property {boolean} [detectRetina=false] If `true` and user is on a retina display, it\n * will request four tiles of half the specified size and a bigger zoom level in place\n * of one to utilize the high resolution.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the tiles. If a String is provided, all tiles will have their crossOrigin\n * attribute set to the String provided. This is needed if you want to access tile pixel\n * data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n * @property {ReferrerPolicy} [referrerPolicy='strict-origin-when-cross-origin'] Sets the\n * tiles' `referrerPolicy` attribute set to the String provided. See\n * [`HTMLImageElement.referrerPolicy`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy)\n * for possible values.\n *\n * Tile providers might require you to use a specific referrer policy (e.g. to verify\n * API tokens or prevent abuse). Specifically, if you are using tiles from\n * `tile.openstreetmap.org` or `tile.osm.org`, you\n * [should not change this value](https://operations.osmfoundation.org/policies/tiles/).\n * @property {RequestInit|null} [fetchOptions=null] If set, the tiles are loaded with\n * [`fetch()`](https://developer.mozilla.org/docs/Web/API/Window/fetch) using these\n * options (see [`RequestInit`](https://developer.mozilla.org/docs/Web/API/RequestInit)),\n * e.g. `{headers: {Authorization: 'Bearer …'}}` for tile servers requiring custom HTTP\n * headers. Requests of tiles that are no longer needed (e.g. after panning or zooming\n * away) are aborted. Cross-origin tile servers have to allow such requests with\n * [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) headers.\n * @extends GridLayerOptions\n */\n\n/**\n * Used to load and display tile layers on the map. Note that most tile servers require\n * attribution, which you can set under `Layer`. Extends `GridLayer`.\n *\n * ### URL template\n *\n * A string of the following form:\n *\n * ```\n * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'\n * ```\n *\n * `{s}` means one of the available subdomains (used sequentially to help with browser\n * parallel requests per domain limitation; subdomain values are specified in options;\n * `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` —\n * tile coordinates. `{r}` can be used to add \"@2x\" to the URL to load retina tiles.\n *\n * You can use custom keys in the template, which will be [evaluated](#util-template)\n * from TileLayer options, like this:\n *\n * ```\n * new TileLayer('https://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});\n * ```\n *\n * Layers extending `TileLayer` might reimplement the [`getTileUrl()`](#tilelayer-gettileurl)\n * method.\n *\n * @example\n * ```js\n * new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>'}).addTo(map);\n * ```\n *\n * @fires tileabort {TileEvent} Fired when a tile was loading but is now not wanted.\n */\nexport class TileLayer extends GridLayer {\n\n\tstatic defaultOptions = {\n\t\tminZoom: 0,\n\t\tmaxZoom: 18,\n\t\tsubdomains: 'abc',\n\t\terrorTileUrl: '',\n\t\tzoomOffset: 0,\n\t\ttms: false,\n\t\tzoomReverse: false,\n\t\tdetectRetina: false,\n\t\tcrossOrigin: false,\n\t\treferrerPolicy: 'strict-origin-when-cross-origin',\n\t\tfetchOptions: null\n\n\t};\n\n\t/**\n\t * Instantiates a tile layer object given a [URL template](#tilelayer) and optionally an\n\t * options object.\n\t * @param {string} url The URL template.\n\t * @param {TileLayerOptions & Record<string, unknown>} [options] The options, and the values\n\t * of custom keys of the URL template.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(options);\n\n\t\toptions = Util.setOptions(this, options);\n\n\t\t// Set required OpenStreetMap attribution if it hasn't been specified\n\t\tif (isOSMUrl(url) && options.attribution === null) {\n\t\t\toptions.attribution = `&copy; <a href=\"https://www.openstreetmap.org/copyright\">${I18n.translate('OpenStreetMap contributors')}</a>`;\n\t\t}\n\t\tthis._url = upgradeOSMUrl(url);\n\n\t\tconst {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom} = this.options;\n\t\tthis._nonRetinaOptions = {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom};\n\t\tthis._applyRetina();\n\n\t\tif (typeof this.options.subdomains === 'string') {\n\t\t\tthis.options.subdomains = this.options.subdomains.split('');\n\t\t}\n\n\t\tthis.callInitHooks(TileLayer);\n\t}\n\n\t// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels.\n\t_applyRetina() {\n\t\tObject.assign(this.options, this._nonRetinaOptions);\n\t\tthis._retina = window.devicePixelRatio > 1;\n\n\t\tif (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {\n\n\t\t\tthis.options.tileSize = Math.floor(this.options.tileSize / 2);\n\n\t\t\tif (!this.options.zoomReverse) {\n\t\t\t\tthis.options.zoomOffset++;\n\t\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);\n\t\t\t\t// do not request tiles beyond the native zoom levels\n\t\t\t\tif (this.options.maxNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);\n\t\t\t\t}\n\t\t\t\tif (this.options.minNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.options.zoomOffset--;\n\t\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);\n\t\t\t}\n\n\t\t\tthis.options.minZoom = Math.max(0, this.options.minZoom);\n\t\t} else if (!this.options.zoomReverse) {\n\t\t\t// make sure maxZoom is gte minZoom\n\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);\n\t\t} else {\n\t\t\t// make sure minZoom is lte maxZoom\n\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);\n\t\t}\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 = super.getEvents();\n\t\tevents.pixelratiochange = this._onPixelRatioChange;\n\t\treturn events;\n\t}\n\n\t// Loads the tiles for the new resolution, see the map's `pixelratiochange` event.\n\t_onPixelRatioChange() {\n\t\tif ((window.devicePixelRatio > 1) === this._retina) { return; }\n\t\tconst map = this._map;\n\t\tthis._applyRetina();\n\t\tif (this.options.detectRetina) {\n\t\t\tmap._removeZoomLimit(this);\n\t\t\tmap._addZoomLimit(this);\n\t\t\tthis._invalidateAll();\n\t\t\tthis._resetView();\n\t\t} else if (this._url.includes('{r}')) {\n\t\t\tthis.redraw();\n\t\t}\n\t}\n\n\t/**\n\t * Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).\n\t * If the URL does not change, the layer will not be redrawn unless\n\t * the noRedraw parameter is set to false.\n\t * The current tiles stay visible until the new tiles have loaded, to avoid flickering.\n\t * @param {string} url\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetUrl(url, noRedraw) {\n\t\turl = upgradeOSMUrl(url);\n\n\t\tif (this._url === url && noRedraw === undefined) {\n\t\t\tnoRedraw = true;\n\t\t}\n\n\t\tthis._url = url;\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)\n\t * to return an `<img>` HTML element with the appropriate image URL given `coords`. The\n\t * `done` callback is called when the tile has been loaded.\n\t * @param {Point} coords\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLImageElement}\n\t */\n\tcreateTile(coords, done) {\n\t\tconst tile = document.createElement('img');\n\n\t\tDomEvent.on(tile, 'load', this._tileOnLoad.bind(this, done, tile));\n\t\tDomEvent.on(tile, 'error', this._tileOnError.bind(this, done, tile));\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\ttile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\t// for this new option we follow the documented behavior\n\t\t// more closely by only setting the property when string\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\ttile.referrerPolicy = this.options.referrerPolicy;\n\t\t}\n\n\t\t// The alt attribute is set to the empty string,\n\t\t// allowing screen readers to ignore the decorative image tiles.\n\t\t// https://www.w3.org/WAI/tutorials/images/decorative/\n\t\t// https://www.w3.org/TR/html-aria/#el-img-empty-alt\n\t\ttile.alt = '';\n\n\t\tconst url = this.getTileUrl(coords);\n\t\tif (this.options.fetchOptions) {\n\t\t\tthis._fetchTile(tile, url, done);\n\t\t} else {\n\t\t\ttile.src = url;\n\t\t}\n\n\t\treturn tile;\n\t}\n\n\t// Loads the tile image with `fetch()`, see the `fetchOptions` option.\n\t_fetchTile(tile, url, done) {\n\t\tconst controller = new AbortController(),\n\t\toptions = {signal: controller.signal, ...this.options.fetchOptions};\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\toptions.referrerPolicy ??= this.options.referrerPolicy;\n\t\t}\n\n\t\tthis._tileFetches ??= new Map();\n\t\tthis._tileFetches.set(tile, controller);\n\n\t\tfetch(url, options)\n\t\t\t.then((response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Failed to load the tile ${url}: HTTP ${response.status}`);\n\t\t\t\t}\n\t\t\t\treturn response.blob();\n\t\t\t})\n\t\t\t.then((blob) => {\n\t\t\t\t// revoked in `_tileOnLoad()`\n\t\t\t\ttile.src = URL.createObjectURL(blob);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\tthis._tileOnError(done, tile, error);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => this._tileFetches.delete(tile));\n\t}\n\n\t// Aborts the request of a tile loaded with `fetch()`, returns whether there was one.\n\t_abortTileFetch(tile) {\n\t\tconst controller = this._tileFetches?.get(tile);\n\t\tif (!controller) { return false; }\n\t\tcontroller.abort();\n\t\tthis._tileFetches.delete(tile);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL for a tile given its coordinates.\n\t * Classes extending `TileLayer` can override this function to provide custom tile URL\n\t * naming schemes.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\t\tconst data = Object.create(this.options);\n\t\tObject.assign(data, {\n\t\t\tr: window.devicePixelRatio > 1 ? '@2x' : '',\n\t\t\ts: this._getSubdomain(coords),\n\t\t\tx: coords.x,\n\t\t\ty: coords.y,\n\t\t\tz: this._getZoomForUrl()\n\t\t});\n\t\tif (this._map && !this._map.options.crs.infinite) {\n\t\t\tconst invertedY = this._globalTileRange.max.y - coords.y;\n\t\t\tif (this.options.tms) {\n\t\t\t\tdata['y'] = invertedY;\n\t\t\t}\n\t\t\tdata['-y'] = invertedY;\n\t\t}\n\n\t\treturn Util.template(this._url, data);\n\t}\n\n\t_tileOnLoad(done, tile) {\n\t\tif (tile.src.startsWith('blob:')) {\n\t\t\t// the image keeps its data, see `_fetchTile()`\n\t\t\tURL.revokeObjectURL(tile.src);\n\t\t}\n\t\tdone(null, tile);\n\t}\n\n\t_tileOnError(done, tile, e) {\n\t\tconst errorUrl = this.options.errorTileUrl;\n\t\tif (errorUrl && tile.getAttribute('src') !== errorUrl) {\n\t\t\ttile.src = errorUrl;\n\t\t}\n\t\tdone(e, tile);\n\t}\n\n\t_getZoomForUrl() {\n\t\tlet zoom = this._tileZoom;\n\t\tconst maxZoom = this.options.maxZoom,\n\t\tzoomReverse = this.options.zoomReverse,\n\t\tzoomOffset = this.options.zoomOffset;\n\n\t\tif (zoomReverse) {\n\t\t\tzoom = maxZoom - zoom;\n\t\t}\n\n\t\treturn zoom + zoomOffset;\n\t}\n\n\t_getSubdomain(tilePoint) {\n\t\tconst index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;\n\t\treturn this.options.subdomains[index];\n\t}\n\n\t// stops loading all tiles in the background layer\n\t_abortLoading() {\n\t\tlet i, tile;\n\t\tfor (i of Object.keys(this._tiles)) {\n\t\t\tif (this._tiles[i].coords.z !== this._tileZoom) {\n\t\t\t\ttile = this._tiles[i].el;\n\n\t\t\t\tif (this._abortTileFetch(tile) || !tile.complete) {\n\t\t\t\t\ttile.setAttribute('src', '');\n\t\t\t\t\tconst coords = this._tiles[i].coords;\n\t\t\t\t\ttile.remove();\n\t\t\t\t\tdelete this._tiles[i];\n\t\t\t\t\tthis.fire('tileabort', {\n\t\t\t\t\t\ttile,\n\t\t\t\t\t\tcoords\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\t// Cancels any pending http requests associated with the tile\n\t\tthis._abortTileFetch(tile.el);\n\t\ttile.el.setAttribute('src', '');\n\n\t\treturn super._removeTile(key);\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (!this._map || (tile && tile.getAttribute('src') === '')) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn super._tileReady(coords, err, tile);\n\t}\n\n\t_clampZoom(zoom) {\n\t\treturn Math.round(super._clampZoom(zoom));\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,WAAW,CAAC,0BAA0B,cAAc;AAC1D,MAAM,SAAS;AACf,MAAM,SAAS;AAEf,SAAS,SAAS,KAAK;CACtB,MAAM,OAAO,OAAO,KAAK,GAAG,CAAC,GAAG,MAAM;CACtC,OAAO,SAAS,MAAK,YAAW,SAAS,WAAW,KAAK,SAAS,IAAI,SAAS,CAAC;AACjF;AAGA,MAAM,iBAAgB,QAAQ,SAAS,GAAG,IAAI,IAAI,QAAQ,QAAQ,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkF9E,IAAa,YAAb,MAAa,kBAAkB,UAAU;CAExC,OAAO,iBAAiB;EACvB,SAAS;EACT,SAAS;EACT,YAAY;EACZ,cAAc;EACd,YAAY;EACZ,KAAK;EACL,aAAa;EACb,cAAc;EACd,aAAa;EACb,gBAAgB;EAChB,cAAc;CAEf;;;;;;;;CASA,YAAY,KAAK,SAAS;EACzB,MAAM,OAAO;EAEb,UAAUA,WAAgB,MAAM,OAAO;EAGvC,IAAI,SAAS,GAAG,KAAK,QAAQ,gBAAgB,MAC5C,QAAQ,cAAc,4DAA4D,KAAK,UAAU,4BAA4B,EAAE;EAEhI,KAAK,OAAO,cAAc,GAAG;EAE7B,MAAM,EAAC,UAAU,YAAY,SAAS,SAAS,eAAe,kBAAiB,KAAK;EACpF,KAAK,oBAAoB;GAAC;GAAU;GAAY;GAAS;GAAS;GAAe;EAAa;EAC9F,KAAK,aAAa;EAElB,IAAI,OAAO,KAAK,QAAQ,eAAe,UACtC,KAAK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["Util.setOptions","Util.template"],"sources":["../../../../src/layer/tile/TileLayer.js"],"sourcesContent":["import {GridLayer} from './GridLayer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {I18n} from '../../core/I18n.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */\n/** @import {TileEvent} from '../../core/Events.js' */\n\nconst osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];\nconst hostRe = /^(https?:)?\\/\\/([^/?#:]*)/i;\nconst httpRe = /^http:/i;\n\nfunction isOSMUrl(url) {\n\tconst host = hostRe.exec(url)?.[2] ?? '';\n\treturn osmHosts.some(osmHost => host === osmHost || host.endsWith(`.${osmHost}`));\n}\n\n// OSM tiles are upgraded to HTTPS so that the referrer policy works\nconst upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : url);\n\n/**\n * Options of `TileLayer`.\n * @typedef {object} TileLayerOptions\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxZoom=18] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {string|string[]} [subdomains='abc'] Subdomains of the tile service. Can be\n * passed in the form of one string (where each letter is a subdomain name) or an array\n * of strings.\n * @property {string} [errorTileUrl=''] URL to the tile image to show in place of the\n * tile that failed to load.\n * @property {number} [zoomOffset=0] The zoom number used in tile URLs will be offset\n * with this value.\n * @property {boolean} [tms=false] If `true`, inverses Y axis numbering for tiles (turn\n * this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).\n * @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile\n * URLs will be reversed (`maxZoom - zoom` instead of `zoom`).\n * @property {boolean} [detectRetina=false] If `true` and user is on a retina display, it\n * will request four tiles of half the specified size and a bigger zoom level in place\n * of one to utilize the high resolution.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the tiles. If a String is provided, all tiles will have their crossOrigin\n * attribute set to the String provided. This is needed if you want to access tile pixel\n * data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n * @property {ReferrerPolicy} [referrerPolicy='strict-origin-when-cross-origin'] Sets the\n * tiles' `referrerPolicy` attribute set to the String provided. See\n * [`HTMLImageElement.referrerPolicy`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy)\n * for possible values.\n *\n * Tile providers might require you to use a specific referrer policy (e.g. to verify\n * API tokens or prevent abuse). Specifically, if you are using tiles from\n * `tile.openstreetmap.org` or `tile.osm.org`, you\n * [should not change this value](https://operations.osmfoundation.org/policies/tiles/).\n * @property {RequestInit|null} [fetchOptions=null] If set, the tiles are loaded with\n * [`fetch()`](https://developer.mozilla.org/docs/Web/API/Window/fetch) using these\n * options (see [`RequestInit`](https://developer.mozilla.org/docs/Web/API/RequestInit)),\n * e.g. `{headers: {Authorization: 'Bearer …'}}` for tile servers requiring custom HTTP\n * headers. Requests of tiles that are no longer needed (e.g. after panning or zooming\n * away) are aborted. Cross-origin tile servers have to allow such requests with\n * [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) headers.\n * @extends GridLayerOptions\n */\n\n/**\n * Used to load and display tile layers on the map. Note that most tile servers require\n * attribution, which you can set under `Layer`. Extends `GridLayer`.\n *\n * ### URL template\n *\n * A string of the following form:\n *\n * ```\n * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'\n * ```\n *\n * `{s}` means one of the available subdomains (used sequentially to help with browser\n * parallel requests per domain limitation; subdomain values are specified in options;\n * `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` —\n * tile coordinates. `{r}` can be used to add \"@2x\" to the URL to load retina tiles.\n *\n * You can use custom keys in the template, which will be [evaluated](#util-template)\n * from TileLayer options, like this:\n *\n * ```\n * new TileLayer('https://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});\n * ```\n *\n * Layers extending `TileLayer` might reimplement the [`getTileUrl()`](#tilelayer-gettileurl)\n * method.\n *\n * @example\n * ```js\n * new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>'}).addTo(map);\n * ```\n *\n * @fires tileabort {TileEvent} Fired when a tile was loading but is now not wanted.\n */\nexport class TileLayer extends GridLayer {\n\n\tstatic defaultOptions = {\n\t\tminZoom: 0,\n\t\tmaxZoom: 18,\n\t\tsubdomains: 'abc',\n\t\terrorTileUrl: '',\n\t\tzoomOffset: 0,\n\t\ttms: false,\n\t\tzoomReverse: false,\n\t\tdetectRetina: false,\n\t\tcrossOrigin: false,\n\t\treferrerPolicy: 'strict-origin-when-cross-origin',\n\t\tfetchOptions: null\n\n\t};\n\n\t/**\n\t * Instantiates a tile layer object given a [URL template](#tilelayer) and optionally an\n\t * options object.\n\t * @param {string} url The URL template.\n\t * @param {TileLayerOptions & Record<string, unknown>} [options] The options, and the values\n\t * of custom keys of the URL template.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(options);\n\n\t\toptions = Util.setOptions(this, options);\n\n\t\t// Set required OpenStreetMap attribution if it hasn't been specified\n\t\tif (isOSMUrl(url) && options.attribution === null) {\n\t\t\toptions.attribution = `&copy; <a href=\"https://www.openstreetmap.org/copyright\">${I18n.translate('OpenStreetMap contributors')}</a>`;\n\t\t}\n\t\tthis._url = upgradeOSMUrl(url);\n\n\t\tconst {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom} = this.options;\n\t\tthis._nonRetinaOptions = {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom};\n\t\tthis._applyRetina();\n\n\t\tif (typeof this.options.subdomains === 'string') {\n\t\t\tthis.options.subdomains = this.options.subdomains.split('');\n\t\t}\n\n\t\tthis.callInitHooks(TileLayer);\n\t}\n\n\t// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels.\n\t_applyRetina() {\n\t\tObject.assign(this.options, this._nonRetinaOptions);\n\t\tthis._retina = window.devicePixelRatio > 1;\n\n\t\tif (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {\n\n\t\t\tconst tileSize = this.options.tileSize;\n\t\t\tthis.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);\n\n\t\t\tif (!this.options.zoomReverse) {\n\t\t\t\tthis.options.zoomOffset++;\n\t\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);\n\t\t\t\t// do not request tiles beyond the native zoom levels\n\t\t\t\tif (this.options.maxNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);\n\t\t\t\t}\n\t\t\t\tif (this.options.minNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.options.zoomOffset--;\n\t\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);\n\t\t\t}\n\n\t\t\tthis.options.minZoom = Math.max(0, this.options.minZoom);\n\t\t} else if (!this.options.zoomReverse) {\n\t\t\t// make sure maxZoom is gte minZoom\n\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);\n\t\t} else {\n\t\t\t// make sure minZoom is lte maxZoom\n\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);\n\t\t}\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 = super.getEvents();\n\t\tevents.pixelratiochange = this._onPixelRatioChange;\n\t\treturn events;\n\t}\n\n\t// Loads the tiles for the new resolution, see the map's `pixelratiochange` event.\n\t_onPixelRatioChange() {\n\t\tif ((window.devicePixelRatio > 1) === this._retina) { return; }\n\t\tconst map = this._map;\n\t\tthis._applyRetina();\n\t\tif (this.options.detectRetina) {\n\t\t\tmap._removeZoomLimit(this);\n\t\t\tmap._addZoomLimit(this);\n\t\t\tthis._invalidateAll();\n\t\t\tthis._resetView();\n\t\t} else if (this._url.includes('{r}')) {\n\t\t\tthis.redraw();\n\t\t}\n\t}\n\n\t/**\n\t * Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).\n\t * If the URL does not change, the layer will not be redrawn unless\n\t * the noRedraw parameter is set to false.\n\t * The current tiles stay visible until the new tiles have loaded, to avoid flickering.\n\t * @param {string} url\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetUrl(url, noRedraw) {\n\t\turl = upgradeOSMUrl(url);\n\n\t\tif (this._url === url && noRedraw === undefined) {\n\t\t\tnoRedraw = true;\n\t\t}\n\n\t\tthis._url = url;\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)\n\t * to return an `<img>` HTML element with the appropriate image URL given `coords`. The\n\t * `done` callback is called when the tile has been loaded.\n\t * @param {Point} coords\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLImageElement}\n\t */\n\tcreateTile(coords, done) {\n\t\tconst tile = document.createElement('img');\n\n\t\tDomEvent.on(tile, 'load', this._tileOnLoad.bind(this, done, tile));\n\t\tDomEvent.on(tile, 'error', this._tileOnError.bind(this, done, tile));\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\ttile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\t// for this new option we follow the documented behavior\n\t\t// more closely by only setting the property when string\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\ttile.referrerPolicy = this.options.referrerPolicy;\n\t\t}\n\n\t\t// The alt attribute is set to the empty string,\n\t\t// allowing screen readers to ignore the decorative image tiles.\n\t\t// https://www.w3.org/WAI/tutorials/images/decorative/\n\t\t// https://www.w3.org/TR/html-aria/#el-img-empty-alt\n\t\ttile.alt = '';\n\n\t\tconst url = this.getTileUrl(coords);\n\t\tif (this.options.fetchOptions) {\n\t\t\tthis._fetchTile(tile, url, done);\n\t\t} else {\n\t\t\ttile.src = url;\n\t\t}\n\n\t\treturn tile;\n\t}\n\n\t// Loads the tile image with `fetch()`, see the `fetchOptions` option.\n\t_fetchTile(tile, url, done) {\n\t\tconst controller = new AbortController(),\n\t\toptions = {signal: controller.signal, ...this.options.fetchOptions};\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\toptions.referrerPolicy ??= this.options.referrerPolicy;\n\t\t}\n\n\t\tthis._tileFetches ??= new Map();\n\t\tthis._tileFetches.set(tile, controller);\n\n\t\tfetch(url, options)\n\t\t\t.then((response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Failed to load the tile ${url}: HTTP ${response.status}`);\n\t\t\t\t}\n\t\t\t\treturn response.blob();\n\t\t\t})\n\t\t\t.then((blob) => {\n\t\t\t\t// revoked in `_tileOnLoad()`\n\t\t\t\ttile.src = URL.createObjectURL(blob);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\tthis._tileOnError(done, tile, error);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => this._tileFetches.delete(tile));\n\t}\n\n\t// Aborts the request of a tile loaded with `fetch()`, returns whether there was one.\n\t_abortTileFetch(tile) {\n\t\tconst controller = this._tileFetches?.get(tile);\n\t\tif (!controller) { return false; }\n\t\tcontroller.abort();\n\t\tthis._tileFetches.delete(tile);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL for a tile given its coordinates.\n\t * Classes extending `TileLayer` can override this function to provide custom tile URL\n\t * naming schemes.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\t\tconst data = Object.create(this.options);\n\t\tObject.assign(data, {\n\t\t\tr: window.devicePixelRatio > 1 ? '@2x' : '',\n\t\t\ts: this._getSubdomain(coords),\n\t\t\tx: coords.x,\n\t\t\ty: coords.y,\n\t\t\tz: this._getZoomForUrl()\n\t\t});\n\t\tif (this._map && !this._map.options.crs.infinite) {\n\t\t\tconst invertedY = this._globalTileRange.max.y - coords.y;\n\t\t\tif (this.options.tms) {\n\t\t\t\tdata['y'] = invertedY;\n\t\t\t}\n\t\t\tdata['-y'] = invertedY;\n\t\t}\n\n\t\treturn Util.template(this._url, data);\n\t}\n\n\t_tileOnLoad(done, tile) {\n\t\tif (tile.src.startsWith('blob:')) {\n\t\t\t// the image keeps its data, see `_fetchTile()`\n\t\t\tURL.revokeObjectURL(tile.src);\n\t\t}\n\t\tdone(null, tile);\n\t}\n\n\t_tileOnError(done, tile, e) {\n\t\tconst errorUrl = this.options.errorTileUrl,\n\t\tsrc = tile.getAttribute('src');\n\t\t// removed tiles get an empty src to cancel their request, which fires error too\n\t\tif (errorUrl && src !== errorUrl && (src || tile.isConnected)) {\n\t\t\ttile.src = errorUrl;\n\t\t}\n\t\tdone(e, tile);\n\t}\n\n\t_getZoomForUrl() {\n\t\tlet zoom = this._tileZoom;\n\t\tconst maxZoom = this.options.maxZoom,\n\t\tzoomReverse = this.options.zoomReverse,\n\t\tzoomOffset = this.options.zoomOffset;\n\n\t\tif (zoomReverse) {\n\t\t\tzoom = maxZoom - zoom;\n\t\t}\n\n\t\treturn zoom + zoomOffset;\n\t}\n\n\t_getSubdomain(tilePoint) {\n\t\tconst {subdomains} = this.options;\n\t\treturn subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];\n\t}\n\n\t// stops loading all tiles in the background layer\n\t_abortLoading() {\n\t\tlet i, tile;\n\t\tfor (i of Object.keys(this._tiles)) {\n\t\t\tif (this._tiles[i].coords.z !== this._tileZoom) {\n\t\t\t\ttile = this._tiles[i].el;\n\n\t\t\t\tif (this._abortTileFetch(tile) || !tile.complete) {\n\t\t\t\t\ttile.setAttribute('src', '');\n\t\t\t\t\tconst coords = this._tiles[i].coords;\n\t\t\t\t\ttile.remove();\n\t\t\t\t\tdelete this._tiles[i];\n\t\t\t\t\tthis.fire('tileabort', {\n\t\t\t\t\t\ttile,\n\t\t\t\t\t\tcoords\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\t// Cancels any pending http requests associated with the tile\n\t\tthis._abortTileFetch(tile.el);\n\t\ttile.el.setAttribute('src', '');\n\n\t\treturn super._removeTile(key);\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (!this._map || (tile && tile.getAttribute('src') === '')) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn super._tileReady(coords, err, tile);\n\t}\n\n\t_clampZoom(zoom) {\n\t\treturn Math.round(super._clampZoom(zoom));\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,WAAW,CAAC,0BAA0B,cAAc;AAC1D,MAAM,SAAS;AACf,MAAM,SAAS;AAEf,SAAS,SAAS,KAAK;CACtB,MAAM,OAAO,OAAO,KAAK,GAAG,CAAC,GAAG,MAAM;CACtC,OAAO,SAAS,MAAK,YAAW,SAAS,WAAW,KAAK,SAAS,IAAI,SAAS,CAAC;AACjF;AAGA,MAAM,iBAAgB,QAAQ,SAAS,GAAG,IAAI,IAAI,QAAQ,QAAQ,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkF9E,IAAa,YAAb,MAAa,kBAAkB,UAAU;CAExC,OAAO,iBAAiB;EACvB,SAAS;EACT,SAAS;EACT,YAAY;EACZ,cAAc;EACd,YAAY;EACZ,KAAK;EACL,aAAa;EACb,cAAc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IAC9B,KAAK,OAAO;IACZ,OAAO,KAAK,OAAO;IACnB,KAAK,KAAK,aAAa;KACtB;KACA;IACD,CAAC;GACF;EACD;CAEF;CAEA,YAAY,KAAK;EAChB,MAAM,OAAO,KAAK,OAAO;EACzB,IAAI,CAAC,MAAQ;EAGb,KAAK,gBAAgB,KAAK,EAAE;EAC5B,KAAK,GAAG,aAAa,OAAO,EAAE;EAE9B,OAAO,MAAM,YAAY,GAAG;CAC7B;CAEA,WAAW,QAAQ,KAAK,MAAM;EAC7B,IAAI,CAAC,KAAK,QAAS,QAAQ,KAAK,aAAa,KAAK,MAAM,IACvD;EAGD,OAAO,MAAM,WAAW,QAAQ,KAAK,IAAI;CAC1C;CAEA,WAAW,MAAM;EAChB,OAAO,KAAK,MAAM,MAAM,WAAW,IAAI,CAAC;CACzC;AACD"}
@@ -1,7 +1,7 @@
1
1
  import { Bounds } from "../../geometry/Bounds.js";
2
2
  import { EPSG4326 } from "../../geo/crs/EPSG4326.js";
3
3
  import { TileLayer } from "./TileLayer.js";
4
- //#region src/layer/tile/WMSTileLayer.js
4
+ // src/layer/tile/WMSTileLayer.js
5
5
  /** @import {CRS} from '../../geo/crs/CRS.js' */
6
6
  /** @import {Point} from '../../geometry/Point.js' */
7
7
  /** @import {MaplairMap} from '../../map/Map.js' */
@@ -98,8 +98,9 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
98
98
  _updateCrs() {
99
99
  this._crs = this.options.crs ?? this._map.options.crs;
100
100
  this._wmsVersion = parseFloat(this.wmsParams.version);
101
- const projectionKey = this._wmsVersion >= 1.3 ? "crs" : "srs";
102
- this.wmsParams[projectionKey] = this._crs.code;
101
+ delete this.wmsParams.srs;
102
+ delete this.wmsParams.crs;
103
+ this.wmsParams[this._wmsVersion >= 1.3 ? "crs" : "srs"] = this._crs.code;
103
104
  }
104
105
  /**
105
106
  * Returns the map events the layer listens to, see `Layer`.
@@ -168,6 +169,7 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
168
169
  */
169
170
  setParams(params, noRedraw) {
170
171
  Object.assign(this.wmsParams, params);
172
+ if (this._map) this._updateCrs();
171
173
  if (!noRedraw) {
172
174
  this._keepCurrentTiles();
173
175
  this.redraw();
@@ -175,7 +177,6 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
175
177
  return this;
176
178
  }
177
179
  };
178
- //#endregion
179
180
  export { WMSTileLayer };
180
181
 
181
182
  //# sourceMappingURL=WMSTileLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WMSTileLayer.js","names":[],"sources":["../../../../src/layer/tile/WMSTileLayer.js"],"sourcesContent":["import {TileLayer} from './TileLayer.js';\nimport {EPSG4326} from '../../geo/crs/EPSG4326.js';\nimport {Bounds} from '../../geometry/Bounds.js';\n/** @import {CRS} from '../../geo/crs/CRS.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {TileLayerOptions} from './TileLayer.js' */\n\n/**\n * Options of `WMSTileLayer`. If any custom options not documented here are used, they\n * will be sent to the WMS server as extra parameters in each request URL. This can be\n * useful for\n * [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\n * @typedef {object} WMSTileLayerOptions\n * @property {string} [layers=''] **(required)** Comma-separated list of WMS layers to\n * show.\n * @property {string} [styles=''] Comma-separated list of WMS styles.\n * @property {string} [format='image/jpeg'] WMS image format (use `'image/png'` for\n * layers with transparency).\n * @property {boolean} [transparent=false] If `true`, the WMS service will return images\n * with transparency.\n * @property {string} [version='1.1.1'] Version of the WMS service to use.\n * @property {CRS|null} [crs=null] Coordinate Reference System to use for the WMS\n * requests, defaults to map CRS. Don't change this if you're not sure what it means.\n * @property {boolean} [uppercase=false] If `true`, WMS request parameter keys will be\n * uppercase.\n * @extends TileLayerOptions\n */\n\n/**\n * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile\n * layers on the map. Extends `TileLayer`.\n *\n * @example\n * ```js\n * const nexrad = new WMSTileLayer(\"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi\", {\n * \tlayers: 'nexrad-n0r-900913',\n * \tformat: 'image/png',\n * \ttransparent: true,\n * \tattribution: \"Weather data © 2012 IEM Nexrad\"\n * });\n * ```\n */\nexport class WMSTileLayer extends TileLayer {\n\n\t/**\n\t * The default WMS parameters, which the options override, see `WMSTileLayerOptions`.\n\t * @type {Record<string, any>}\n\t */\n\tstatic defaultWmsParams = {\n\t\tservice: 'WMS',\n\t\trequest: 'GetMap',\n\t\tlayers: '',\n\t\tstyles: '',\n\t\tformat: 'image/jpeg',\n\t\ttransparent: false,\n\t\tversion: '1.1.1'\n\t};\n\n\tstatic defaultOptions = {\n\t\tcrs: null,\n\t\tuppercase: false\n\t};\n\n\t/**\n\t * Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS\n\t * parameters/options object.\n\t * @param {string} url The base URL of the WMS service.\n\t * @param {WMSTileLayerOptions & Record<string, unknown>} options The options and WMS\n\t * parameters.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(url, options);\n\n\t\tconst wmsParams = {...WMSTileLayer.defaultWmsParams};\n\n\t\t// Options that are unknown in the prototype chain are considered WMS params.\n\t\tfor (const [key, value] of Object.entries(options)) {\n\t\t\tif (!(key in WMSTileLayer.defaultOptions)) {\n\t\t\t\twmsParams[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * The parameters of the WMS requests, see `setParams()`.\n\t\t * @type {Record<string, any>}\n\t\t */\n\t\tthis.wmsParams = wmsParams;\n\t\tthis._updateWmsSize();\n\n\t\tthis.callInitHooks(WMSTileLayer);\n\t}\n\n\t// The size of the requested images: the tile size, doubled on retina displays with `detectRetina`.\n\t_updateWmsSize() {\n\t\tconst realRetina = this.options.detectRetina && window.devicePixelRatio > 1 ? 2 : 1;\n\t\tconst tileSize = this.getTileSize();\n\n\t\tthis.wmsParams.width = tileSize.x * realRetina;\n\t\tthis.wmsParams.height = tileSize.y * realRetina;\n\t}\n\n\t_applyRetina() {\n\t\tsuper._applyRetina();\n\t\tif (this.wmsParams) {\n\t\t\tthis._updateWmsSize();\n\t\t}\n\t}\n\n\t/**\n\t * Uses the CRS of the map (unless the `crs` option is set) and loads the tiles.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._updateCrs();\n\t\tsuper.onAdd(map);\n\t}\n\n\t_updateCrs() {\n\t\tthis._crs = this.options.crs ?? this._map.options.crs;\n\t\tthis._wmsVersion = parseFloat(this.wmsParams.version);\n\n\t\tconst projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';\n\t\tthis.wmsParams[projectionKey] = this._crs.code;\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 = super.getEvents();\n\t\tevents.crschange = this._updateCrs;\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL of the `GetMap` request for a tile given its\n\t * coordinates.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\n\t\tconst tileBounds = this._tileCoordsToNwSe(coords),\n\t\tcrs = this._crs,\n\t\tbounds = new Bounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),\n\t\tmin = bounds.min,\n\t\tmax = bounds.max,\n\t\tbbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?\n\t\t\t[min.y, min.x, max.y, max.x] :\n\t\t\t[min.x, min.y, max.x, max.y]).join(',');\n\t\tconst url = new URL(super.getTileUrl(coords), document.baseURI);\n\t\tfor (const [k, v] of Object.entries({...this.wmsParams, bbox})) {\n\t\t\turl.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Returns the URL of the legend image (a `GetLegendGraphic` request) of the first\n\t * of the `layers` (with its style, if any), with the version, format and `uppercase`\n\t * option of the layer. `params` change or add parameters, e.g. `{layer: 'roads',\n\t * width: 20, height: 20}` or vendor parameters like `legend_options`.\n\t * @param {Record<string, any>} [params]\n\t * @returns {string}\n\t */\n\tgetLegendUrl(params) {\n\t\tconst {version, format, layers, styles} = this.wmsParams,\n\t\turl = new URL(this._url, document.baseURI);\n\t\tfor (const [k, v] of Object.entries({\n\t\t\tservice: 'WMS',\n\t\t\trequest: 'GetLegendGraphic',\n\t\t\tversion,\n\t\t\tformat,\n\t\t\tlayer: layers.split(',')[0],\n\t\t\tstyle: styles?.split(',')[0] || undefined,\n\t\t\t// required by the WMS 1.3 profile of SLD\n\t\t\tsld_version: parseFloat(version) >= 1.3 ? '1.1.0' : undefined,\n\t\t\t...params\n\t\t})) {\n\t\t\tif (v !== undefined) {\n\t\t\t\turl.searchParams.set(this.options.uppercase ? k.toUpperCase() : k, v);\n\t\t\t}\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Merges an object with the new parameters and re-requests tiles on the current screen\n\t * (unless `noRedraw` was set to true). The current tiles stay visible until the new\n\t * tiles have loaded, to avoid flickering.\n\t * @param {Record<string, any>} params\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetParams(params, noRedraw) {\n\n\t\tObject.assign(this.wmsParams, params);\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,eAAb,MAAa,qBAAqB,UAAU;;;;;CAM3C,OAAO,mBAAmB;EACzB,SAAS;EACT,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,aAAa;EACb,SAAS;CACV;CAEA,OAAO,iBAAiB;EACvB,KAAK;EACL,WAAW;CACZ;;;;;;;;CASA,YAAY,KAAK,SAAS;EACzB,MAAM,KAAK,OAAO;EAElB,MAAM,YAAY,EAAC,GAA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I,IAAI,MAAM,WAAW,MAAM,GAAG,SAAS,OAAO;EAC9D,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ;GAAC,GAAG,KAAK;GAAW;EAAI,CAAC,GAC5D,IAAI,aAAa,OAAO,KAAK,QAAQ,YAAY,EAAE,YAAY,IAAI,GAAG,GAAG,GAAG;EAE7E,OAAO,IAAI,SAAS;CACrB;;;;;;;;;CAUA,aAAa,QAAQ;EACpB,MAAM,EAAC,SAAS,QAAQ,QAAQ,WAAU,KAAK,WAC/C,MAAM,IAAI,IAAI,KAAK,MAAM,SAAS,OAAO;EACzC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ;GACnC,SAAS;GACT,SAAS;GACT;GACA;GACA,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;GACzB,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC,MAAM,KAAA;GAEhC,aAAa,WAAW,OAAO,KAAK,MAAM,UAAU,KAAA;GACpD,GAAG;EACJ,CAAC,GACA,IAAI,MAAM,KAAA,GACT,IAAI,aAAa,IAAI,KAAK,QAAQ,YAAY,EAAE,YAAY,IAAI,GAAG,CAAC;EAGtE,OAAO,IAAI,SAAS;CACrB;;;;;;;;;CAUA,UAAU,QAAQ,UAAU;EAE3B,OAAO,OAAO,KAAK,WAAW,MAAM;EAEpC,IAAI,CAAC,UAAU;GACd,KAAK,kBAAkB;GACvB,KAAK,OAAO;EACb;EAEA,OAAO;CACR;AACD"}
1
+ {"version":3,"file":"WMSTileLayer.js","names":[],"sources":["../../../../src/layer/tile/WMSTileLayer.js"],"sourcesContent":["import {TileLayer} from './TileLayer.js';\nimport {EPSG4326} from '../../geo/crs/EPSG4326.js';\nimport {Bounds} from '../../geometry/Bounds.js';\n/** @import {CRS} from '../../geo/crs/CRS.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {TileLayerOptions} from './TileLayer.js' */\n\n/**\n * Options of `WMSTileLayer`. If any custom options not documented here are used, they\n * will be sent to the WMS server as extra parameters in each request URL. This can be\n * useful for\n * [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\n * @typedef {object} WMSTileLayerOptions\n * @property {string} [layers=''] **(required)** Comma-separated list of WMS layers to\n * show.\n * @property {string} [styles=''] Comma-separated list of WMS styles.\n * @property {string} [format='image/jpeg'] WMS image format (use `'image/png'` for\n * layers with transparency).\n * @property {boolean} [transparent=false] If `true`, the WMS service will return images\n * with transparency.\n * @property {string} [version='1.1.1'] Version of the WMS service to use.\n * @property {CRS|null} [crs=null] Coordinate Reference System to use for the WMS\n * requests, defaults to map CRS. Don't change this if you're not sure what it means.\n * @property {boolean} [uppercase=false] If `true`, WMS request parameter keys will be\n * uppercase.\n * @extends TileLayerOptions\n */\n\n/**\n * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile\n * layers on the map. Extends `TileLayer`.\n *\n * @example\n * ```js\n * const nexrad = new WMSTileLayer(\"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi\", {\n * \tlayers: 'nexrad-n0r-900913',\n * \tformat: 'image/png',\n * \ttransparent: true,\n * \tattribution: \"Weather data © 2012 IEM Nexrad\"\n * });\n * ```\n */\nexport class WMSTileLayer extends TileLayer {\n\n\t/**\n\t * The default WMS parameters, which the options override, see `WMSTileLayerOptions`.\n\t * @type {Record<string, any>}\n\t */\n\tstatic defaultWmsParams = {\n\t\tservice: 'WMS',\n\t\trequest: 'GetMap',\n\t\tlayers: '',\n\t\tstyles: '',\n\t\tformat: 'image/jpeg',\n\t\ttransparent: false,\n\t\tversion: '1.1.1'\n\t};\n\n\tstatic defaultOptions = {\n\t\tcrs: null,\n\t\tuppercase: false\n\t};\n\n\t/**\n\t * Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS\n\t * parameters/options object.\n\t * @param {string} url The base URL of the WMS service.\n\t * @param {WMSTileLayerOptions & Record<string, unknown>} options The options and WMS\n\t * parameters.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(url, options);\n\n\t\tconst wmsParams = {...WMSTileLayer.defaultWmsParams};\n\n\t\t// Options that are unknown in the prototype chain are considered WMS params.\n\t\tfor (const [key, value] of Object.entries(options)) {\n\t\t\tif (!(key in WMSTileLayer.defaultOptions)) {\n\t\t\t\twmsParams[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * The parameters of the WMS requests, see `setParams()`.\n\t\t * @type {Record<string, any>}\n\t\t */\n\t\tthis.wmsParams = wmsParams;\n\t\tthis._updateWmsSize();\n\n\t\tthis.callInitHooks(WMSTileLayer);\n\t}\n\n\t// The size of the requested images: the tile size, doubled on retina displays with `detectRetina`.\n\t_updateWmsSize() {\n\t\tconst realRetina = this.options.detectRetina && window.devicePixelRatio > 1 ? 2 : 1;\n\t\tconst tileSize = this.getTileSize();\n\n\t\tthis.wmsParams.width = tileSize.x * realRetina;\n\t\tthis.wmsParams.height = tileSize.y * realRetina;\n\t}\n\n\t_applyRetina() {\n\t\tsuper._applyRetina();\n\t\tif (this.wmsParams) {\n\t\t\tthis._updateWmsSize();\n\t\t}\n\t}\n\n\t/**\n\t * Uses the CRS of the map (unless the `crs` option is set) and loads the tiles.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._updateCrs();\n\t\tsuper.onAdd(map);\n\t}\n\n\t_updateCrs() {\n\t\tthis._crs = this.options.crs ?? this._map.options.crs;\n\t\tthis._wmsVersion = parseFloat(this.wmsParams.version);\n\n\t\tdelete this.wmsParams.srs;\n\t\tdelete this.wmsParams.crs;\n\t\tthis.wmsParams[this._wmsVersion >= 1.3 ? 'crs' : 'srs'] = this._crs.code;\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 = super.getEvents();\n\t\tevents.crschange = this._updateCrs;\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL of the `GetMap` request for a tile given its\n\t * coordinates.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\n\t\tconst tileBounds = this._tileCoordsToNwSe(coords),\n\t\tcrs = this._crs,\n\t\tbounds = new Bounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),\n\t\tmin = bounds.min,\n\t\tmax = bounds.max,\n\t\tbbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?\n\t\t\t[min.y, min.x, max.y, max.x] :\n\t\t\t[min.x, min.y, max.x, max.y]).join(',');\n\t\tconst url = new URL(super.getTileUrl(coords), document.baseURI);\n\t\tfor (const [k, v] of Object.entries({...this.wmsParams, bbox})) {\n\t\t\turl.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Returns the URL of the legend image (a `GetLegendGraphic` request) of the first\n\t * of the `layers` (with its style, if any), with the version, format and `uppercase`\n\t * option of the layer. `params` change or add parameters, e.g. `{layer: 'roads',\n\t * width: 20, height: 20}` or vendor parameters like `legend_options`.\n\t * @param {Record<string, any>} [params]\n\t * @returns {string}\n\t */\n\tgetLegendUrl(params) {\n\t\tconst {version, format, layers, styles} = this.wmsParams,\n\t\turl = new URL(this._url, document.baseURI);\n\t\tfor (const [k, v] of Object.entries({\n\t\t\tservice: 'WMS',\n\t\t\trequest: 'GetLegendGraphic',\n\t\t\tversion,\n\t\t\tformat,\n\t\t\tlayer: layers.split(',')[0],\n\t\t\tstyle: styles?.split(',')[0] || undefined,\n\t\t\t// required by the WMS 1.3 profile of SLD\n\t\t\tsld_version: parseFloat(version) >= 1.3 ? '1.1.0' : undefined,\n\t\t\t...params\n\t\t})) {\n\t\t\tif (v !== undefined) {\n\t\t\t\turl.searchParams.set(this.options.uppercase ? k.toUpperCase() : k, v);\n\t\t\t}\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Merges an object with the new parameters and re-requests tiles on the current screen\n\t * (unless `noRedraw` was set to true). The current tiles stay visible until the new\n\t * tiles have loaded, to avoid flickering.\n\t * @param {Record<string, any>} params\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetParams(params, noRedraw) {\n\n\t\tObject.assign(this.wmsParams, params);\n\n\t\tif (this._map) { this._updateCrs(); }\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,eAAb,MAAa,qBAAqB,UAAU;;;;;CAM3C,OAAO,mBAAmB;EACzB,SAAS;EACT,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,aAAa;EACb,SAAS;CACV;CAEA,OAAO,iBAAiB;EACvB,KAAK;EACL,WAAW;CACZ;;;;;;;;CASA,YAAY,KAAK,SAAS;EACzB,MAAM,KAAK,OAAO;EAElB,MAAM,YAAY,EAAC,GAAG,aAAa,iBAAgB;EAGnD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,EAAE,OAAO,aAAa,iBACzB,UAAU,OAAO;;;;;EAQnB,KAAK,YAAY;EACjB,KAAK,eAAe;EAEpB,KAAK,cAAc,YAAY;CAChC;CAGA,iBAAiB;EAChB,MAAM,aAAa,KAAK,QAAQ,gBAAgB,OAAO,mBAAmB,IAAI,IAAI;EAClF,MAAM,WAAW,KAAK,YAAY;EAElC,KAAK,UAAU,QAAQ,SAAS,IAAI;EACpC,KAAK,UAAU,SAAS,SAAS,IAAI;CACtC;CAEA,eAAe;EACd,MAAM,aAAa;EACnB,IAAI,KAAK,WACR,KAAK,eAAe;CAEtB;;;;;CAMA,MAAM,KAAK;EACV,KAAK,WAAW;EAChB,MAAM,MAAM,GAAG;CAChB;CAEA,aAAa;EACZ,KAAK,OAAO,KAAK,QA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M,KAAA;GAEhC,aAAa,WAAW,OAAO,KAAK,MAAM,UAAU,KAAA;GACpD,GAAG;EACJ,CAAC,GACA,IAAI,MAAM,KAAA,GACT,IAAI,aAAa,IAAI,KAAK,QAAQ,YAAY,EAAE,YAAY,IAAI,GAAG,CAAC;EAGtE,OAAO,IAAI,SAAS;CACrB;;;;;;;;;CAUA,UAAU,QAAQ,UAAU;EAE3B,OAAO,OAAO,KAAK,WAAW,MAAM;EAEpC,IAAI,KAAK,MAAQ,KAAK,WAAW;EAEjC,IAAI,CAAC,UAAU;GACd,KAAK,kBAAkB;GACvB,KAAK,OAAO;EACb;EAEA,OAAO;CACR;AACD"}
@@ -2,7 +2,7 @@ import { stamp } from "../../core/Util.js";
2
2
  import { on } from "../../dom/DomEvent.js";
3
3
  import { Bounds } from "../../geometry/Bounds.js";
4
4
  import { Renderer } from "./Renderer.js";
5
- //#region src/layer/vector/Canvas.js
5
+ // src/layer/vector/Canvas.js
6
6
  /** @import {MaplairMap} from '../../map/Map.js' */
7
7
  /** @import {EventListener} from '../../core/Events.js' */
8
8
  /** @import {RendererOptions} from './Renderer.js' */
@@ -159,10 +159,8 @@ var Canvas = class Canvas extends Renderer {
159
159
  this._requestRedraw(layer);
160
160
  }
161
161
  _updateDashArray(layer) {
162
- if (typeof layer.options.dashArray === "string") {
163
- const parts = layer.options.dashArray.split(DASH_SEPARATOR_RE);
164
- layer.options._dashArray = parts.map((n) => Number(n)).filter((n) => !isNaN(n));
165
- } else layer.options._dashArray = layer.options.dashArray;
162
+ if (typeof layer.options.dashArray === "string") layer._dashArray = layer.options.dashArray.split(DASH_SEPARATOR_RE).map((n) => Number(n)).filter((n) => !isNaN(n));
163
+ else layer._dashArray = layer.options.dashArray;
166
164
  }
167
165
  _requestRedraw(layer) {
168
166
  if (!this._map) return;
@@ -233,14 +231,10 @@ var Canvas = class Canvas extends Renderer {
233
231
  }
234
232
  _updateCircle(layer) {
235
233
  if (!this._drawing || layer._empty()) return;
236
- const p = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), s = (Math.max(Math.round(layer._pxRadiusY), 1) || r) / r;
237
- if (s !== 1) {
238
- ctx.save();
239
- ctx.scale(1, s);
240
- }
234
+ const { x, y } = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), ry = Math.max(Math.round(layer._pxRadiusY), 1) || r;
241
235
  ctx.beginPath();
242
- ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);
243
- if (s !== 1) ctx.restore();
236
+ if (ry === r) ctx.arc(x, y, r, 0, Math.PI * 2);
237
+ else ctx.ellipse(x, y, r, ry, 0, 0, Math.PI * 2);
244
238
  this._fillStroke(ctx, layer);
245
239
  }
246
240
  _fillStroke(ctx, layer) {
@@ -252,7 +246,7 @@ var Canvas = class Canvas extends Renderer {
252
246
  }
253
247
  if (options.stroke && options.weight !== 0) {
254
248
  ctx.lineDashOffset = Number(options.dashOffset ?? 0);
255
- ctx.setLineDash(options._dashArray ?? []);
249
+ ctx.setLineDash(layer._dashArray ?? []);
256
250
  ctx.globalAlpha = options.opacity;
257
251
  ctx.lineWidth = options.weight;
258
252
  ctx.strokeStyle = options.color;
@@ -342,7 +336,6 @@ var Canvas = class Canvas extends Renderer {
342
336
  this._requestRedraw(layer);
343
337
  }
344
338
  };
345
- //#endregion
346
339
  export { Canvas };
347
340
 
348
341
  //# sourceMappingURL=Canvas.js.map