maplair 4.0.0-alpha.1

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 (262) hide show
  1. package/CHANGELOG.md +2804 -0
  2. package/LICENSE +27 -0
  3. package/README.md +40 -0
  4. package/dist/esm/Maplair.js +71 -0
  5. package/dist/esm/Maplair.js.map +1 -0
  6. package/dist/esm/_virtual/_rolldown/runtime.js +13 -0
  7. package/dist/esm/control/AttributionControl.js +79 -0
  8. package/dist/esm/control/AttributionControl.js.map +1 -0
  9. package/dist/esm/control/Control.js +81 -0
  10. package/dist/esm/control/Control.js.map +1 -0
  11. package/dist/esm/control/LayersControl.js +220 -0
  12. package/dist/esm/control/LayersControl.js.map +1 -0
  13. package/dist/esm/control/ScaleControl.js +72 -0
  14. package/dist/esm/control/ScaleControl.js.map +1 -0
  15. package/dist/esm/control/ZoomControl.js +86 -0
  16. package/dist/esm/control/ZoomControl.js.map +1 -0
  17. package/dist/esm/core/Browser.js +31 -0
  18. package/dist/esm/core/Browser.js.map +1 -0
  19. package/dist/esm/core/Class.js +52 -0
  20. package/dist/esm/core/Class.js.map +1 -0
  21. package/dist/esm/core/Events.js +149 -0
  22. package/dist/esm/core/Events.js.map +1 -0
  23. package/dist/esm/core/Handler.js +32 -0
  24. package/dist/esm/core/Handler.js.map +1 -0
  25. package/dist/esm/core/I18n.js +36 -0
  26. package/dist/esm/core/I18n.js.map +1 -0
  27. package/dist/esm/core/Util.js +71 -0
  28. package/dist/esm/core/Util.js.map +1 -0
  29. package/dist/esm/dom/DomEvent.DoubleTap.js +74 -0
  30. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -0
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +46 -0
  32. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -0
  33. package/dist/esm/dom/DomEvent.js +135 -0
  34. package/dist/esm/dom/DomEvent.js.map +1 -0
  35. package/dist/esm/dom/DomUtil.js +107 -0
  36. package/dist/esm/dom/DomUtil.js.map +1 -0
  37. package/dist/esm/dom/Draggable.js +107 -0
  38. package/dist/esm/dom/Draggable.js.map +1 -0
  39. package/dist/esm/dom/PosAnimation.js +56 -0
  40. package/dist/esm/dom/PosAnimation.js.map +1 -0
  41. package/dist/esm/geo/LatLng.js +65 -0
  42. package/dist/esm/geo/LatLng.js.map +1 -0
  43. package/dist/esm/geo/LatLngBounds.js +114 -0
  44. package/dist/esm/geo/LatLngBounds.js.map +1 -0
  45. package/dist/esm/geo/crs/CRS.js +51 -0
  46. package/dist/esm/geo/crs/CRS.js.map +1 -0
  47. package/dist/esm/geo/crs/EPSG3395.js +16 -0
  48. package/dist/esm/geo/crs/EPSG3395.js.map +1 -0
  49. package/dist/esm/geo/crs/EPSG3857.js +19 -0
  50. package/dist/esm/geo/crs/EPSG3857.js.map +1 -0
  51. package/dist/esm/geo/crs/EPSG4326.js +13 -0
  52. package/dist/esm/geo/crs/EPSG4326.js.map +1 -0
  53. package/dist/esm/geo/crs/EarthCRS.js +14 -0
  54. package/dist/esm/geo/crs/EarthCRS.js.map +1 -0
  55. package/dist/esm/geo/crs/SimpleCRS.js +23 -0
  56. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -0
  57. package/dist/esm/geo/projection/Projection.LonLat.js +19 -0
  58. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -0
  59. package/dist/esm/geo/projection/Projection.Mercator.js +33 -0
  60. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -0
  61. package/dist/esm/geo/projection/Projection.SphericalMercator.js +27 -0
  62. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -0
  63. package/dist/esm/geo/projection/index.js +14 -0
  64. package/dist/esm/geo/projection/index.js.map +1 -0
  65. package/dist/esm/geometry/Bounds.js +91 -0
  66. package/dist/esm/geometry/Bounds.js.map +1 -0
  67. package/dist/esm/geometry/LineUtil.js +169 -0
  68. package/dist/esm/geometry/LineUtil.js.map +1 -0
  69. package/dist/esm/geometry/Point.js +119 -0
  70. package/dist/esm/geometry/Point.js.map +1 -0
  71. package/dist/esm/geometry/PolyUtil.js +89 -0
  72. package/dist/esm/geometry/PolyUtil.js.map +1 -0
  73. package/dist/esm/geometry/Transformation.js +34 -0
  74. package/dist/esm/geometry/Transformation.js.map +1 -0
  75. package/dist/esm/layer/BlanketOverlay.js +87 -0
  76. package/dist/esm/layer/BlanketOverlay.js.map +1 -0
  77. package/dist/esm/layer/DivOverlay.js +192 -0
  78. package/dist/esm/layer/DivOverlay.js.map +1 -0
  79. package/dist/esm/layer/FeatureGroup.js +40 -0
  80. package/dist/esm/layer/FeatureGroup.js.map +1 -0
  81. package/dist/esm/layer/GeoJSON.js +192 -0
  82. package/dist/esm/layer/GeoJSON.js.map +1 -0
  83. package/dist/esm/layer/ImageOverlay.js +140 -0
  84. package/dist/esm/layer/ImageOverlay.js.map +1 -0
  85. package/dist/esm/layer/Layer.js +119 -0
  86. package/dist/esm/layer/Layer.js.map +1 -0
  87. package/dist/esm/layer/LayerGroup.js +58 -0
  88. package/dist/esm/layer/LayerGroup.js.map +1 -0
  89. package/dist/esm/layer/Popup.js +224 -0
  90. package/dist/esm/layer/Popup.js.map +1 -0
  91. package/dist/esm/layer/SVGOverlay.js +21 -0
  92. package/dist/esm/layer/SVGOverlay.js.map +1 -0
  93. package/dist/esm/layer/Tooltip.js +228 -0
  94. package/dist/esm/layer/Tooltip.js.map +1 -0
  95. package/dist/esm/layer/VideoOverlay.js +54 -0
  96. package/dist/esm/layer/VideoOverlay.js.map +1 -0
  97. package/dist/esm/layer/marker/DefaultIcon.js +50 -0
  98. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -0
  99. package/dist/esm/layer/marker/DivIcon.js +37 -0
  100. package/dist/esm/layer/marker/DivIcon.js.map +1 -0
  101. package/dist/esm/layer/marker/Icon.js +65 -0
  102. package/dist/esm/layer/marker/Icon.js.map +1 -0
  103. package/dist/esm/layer/marker/Marker.Drag.js +77 -0
  104. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -0
  105. package/dist/esm/layer/marker/Marker.js +235 -0
  106. package/dist/esm/layer/marker/Marker.js.map +1 -0
  107. package/dist/esm/layer/tile/GridLayer.js +447 -0
  108. package/dist/esm/layer/tile/GridLayer.js.map +1 -0
  109. package/dist/esm/layer/tile/TileLayer.js +139 -0
  110. package/dist/esm/layer/tile/TileLayer.js.map +1 -0
  111. package/dist/esm/layer/tile/WMSTileLayer.js +68 -0
  112. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -0
  113. package/dist/esm/layer/vector/Canvas.js +292 -0
  114. package/dist/esm/layer/vector/Canvas.js.map +1 -0
  115. package/dist/esm/layer/vector/Circle.js +35 -0
  116. package/dist/esm/layer/vector/Circle.js.map +1 -0
  117. package/dist/esm/layer/vector/CircleMarker.js +69 -0
  118. package/dist/esm/layer/vector/CircleMarker.js.map +1 -0
  119. package/dist/esm/layer/vector/Path.js +68 -0
  120. package/dist/esm/layer/vector/Path.js.map +1 -0
  121. package/dist/esm/layer/vector/Polygon.js +70 -0
  122. package/dist/esm/layer/vector/Polygon.js.map +1 -0
  123. package/dist/esm/layer/vector/Polyline.js +152 -0
  124. package/dist/esm/layer/vector/Polyline.js.map +1 -0
  125. package/dist/esm/layer/vector/Rectangle.js +25 -0
  126. package/dist/esm/layer/vector/Rectangle.js.map +1 -0
  127. package/dist/esm/layer/vector/Renderer.getRenderer.js +31 -0
  128. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -0
  129. package/dist/esm/layer/vector/Renderer.js +39 -0
  130. package/dist/esm/layer/vector/Renderer.js.map +1 -0
  131. package/dist/esm/layer/vector/SVG.js +115 -0
  132. package/dist/esm/layer/vector/SVG.js.map +1 -0
  133. package/dist/esm/map/Map.js +844 -0
  134. package/dist/esm/map/Map.js.map +1 -0
  135. package/dist/esm/map/handler/BoxZoomHandler.js +105 -0
  136. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -0
  137. package/dist/esm/map/handler/DoubleClickZoomHandler.js +27 -0
  138. package/dist/esm/map/handler/DoubleClickZoomHandler.js.map +1 -0
  139. package/dist/esm/map/handler/DragHandler.js +133 -0
  140. package/dist/esm/map/handler/DragHandler.js.map +1 -0
  141. package/dist/esm/map/handler/KeyboardHandler.js +117 -0
  142. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -0
  143. package/dist/esm/map/handler/PinchZoomHandler.js +96 -0
  144. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -0
  145. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +50 -0
  146. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -0
  147. package/dist/esm/map/handler/TapHoldHandler.js +77 -0
  148. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -0
  149. package/dist/esm/package.js +6 -0
  150. package/dist/esm/package.js.map +1 -0
  151. package/dist/images/layers.svg +1 -0
  152. package/dist/images/logo.svg +1 -0
  153. package/dist/images/marker-icon.svg +1 -0
  154. package/dist/images/marker-shadow.svg +1 -0
  155. package/dist/maplair-global-src.js +6810 -0
  156. package/dist/maplair-global-src.js.map +1 -0
  157. package/dist/maplair-global.js +12 -0
  158. package/dist/maplair-global.js.map +1 -0
  159. package/dist/maplair-src.js +6704 -0
  160. package/dist/maplair-src.js.map +1 -0
  161. package/dist/maplair.css +730 -0
  162. package/dist/maplair.js +7 -0
  163. package/dist/maplair.js.map +1 -0
  164. package/i18n/cs.json +12 -0
  165. package/i18n/de.json +12 -0
  166. package/i18n/en.json +12 -0
  167. package/i18n/es.json +12 -0
  168. package/i18n/fr.json +12 -0
  169. package/i18n/hu.json +12 -0
  170. package/i18n/it.json +12 -0
  171. package/i18n/rm.json +12 -0
  172. package/i18n/sk.json +12 -0
  173. package/i18n/sl.json +12 -0
  174. package/package.json +87 -0
  175. package/src/Maplair.js +24 -0
  176. package/src/control/AttributionControl.js +147 -0
  177. package/src/control/Control.js +174 -0
  178. package/src/control/LayersControl.js +444 -0
  179. package/src/control/ScaleControl.js +141 -0
  180. package/src/control/ZoomControl.js +147 -0
  181. package/src/control/index.js +5 -0
  182. package/src/core/Browser.js +75 -0
  183. package/src/core/Class.js +97 -0
  184. package/src/core/Events.js +334 -0
  185. package/src/core/Handler.js +59 -0
  186. package/src/core/I18n.js +76 -0
  187. package/src/core/Util.js +122 -0
  188. package/src/core/index.js +8 -0
  189. package/src/dom/DomEvent.DoubleTap.js +120 -0
  190. package/src/dom/DomEvent.PointerEvents.js +75 -0
  191. package/src/dom/DomEvent.js +282 -0
  192. package/src/dom/DomUtil.js +175 -0
  193. package/src/dom/Draggable.js +204 -0
  194. package/src/dom/PosAnimation.js +115 -0
  195. package/src/dom/index.js +9 -0
  196. package/src/geo/LatLng.js +163 -0
  197. package/src/geo/LatLngBounds.js +260 -0
  198. package/src/geo/crs/CRS.js +143 -0
  199. package/src/geo/crs/EPSG3395.js +19 -0
  200. package/src/geo/crs/EPSG3857.js +26 -0
  201. package/src/geo/crs/EPSG4326.js +21 -0
  202. package/src/geo/crs/EarthCRS.js +32 -0
  203. package/src/geo/crs/SimpleCRS.js +35 -0
  204. package/src/geo/crs/index.js +6 -0
  205. package/src/geo/index.js +7 -0
  206. package/src/geo/projection/Projection.LonLat.js +30 -0
  207. package/src/geo/projection/Projection.Mercator.js +53 -0
  208. package/src/geo/projection/Projection.SphericalMercator.js +46 -0
  209. package/src/geo/projection/index.js +26 -0
  210. package/src/geometry/Bounds.js +222 -0
  211. package/src/geometry/LineUtil.js +299 -0
  212. package/src/geometry/Point.js +239 -0
  213. package/src/geometry/PolyUtil.js +129 -0
  214. package/src/geometry/Transformation.js +67 -0
  215. package/src/geometry/index.js +8 -0
  216. package/src/images/layers.svg +1 -0
  217. package/src/images/logo.svg +1 -0
  218. package/src/images/marker-icon.svg +1 -0
  219. package/src/images/marker-shadow.svg +1 -0
  220. package/src/layer/BlanketOverlay.js +171 -0
  221. package/src/layer/DivOverlay.js +353 -0
  222. package/src/layer/FeatureGroup.js +93 -0
  223. package/src/layer/GeoJSON.js +432 -0
  224. package/src/layer/ImageOverlay.js +279 -0
  225. package/src/layer/Layer.js +273 -0
  226. package/src/layer/LayerGroup.js +129 -0
  227. package/src/layer/Popup.js +528 -0
  228. package/src/layer/SVGOverlay.js +47 -0
  229. package/src/layer/Tooltip.js +469 -0
  230. package/src/layer/VideoOverlay.js +111 -0
  231. package/src/layer/index.js +18 -0
  232. package/src/layer/marker/DefaultIcon.js +79 -0
  233. package/src/layer/marker/DivIcon.js +76 -0
  234. package/src/layer/marker/Icon.js +164 -0
  235. package/src/layer/marker/Marker.Drag.js +161 -0
  236. package/src/layer/marker/Marker.js +465 -0
  237. package/src/layer/marker/index.js +5 -0
  238. package/src/layer/tile/GridLayer.js +901 -0
  239. package/src/layer/tile/TileLayer.js +299 -0
  240. package/src/layer/tile/WMSTileLayer.js +133 -0
  241. package/src/layer/tile/index.js +3 -0
  242. package/src/layer/vector/Canvas.js +479 -0
  243. package/src/layer/vector/Circle.js +87 -0
  244. package/src/layer/vector/CircleMarker.js +110 -0
  245. package/src/layer/vector/Path.js +145 -0
  246. package/src/layer/vector/Polygon.js +160 -0
  247. package/src/layer/vector/Polyline.js +296 -0
  248. package/src/layer/vector/Rectangle.js +52 -0
  249. package/src/layer/vector/Renderer.getRenderer.js +48 -0
  250. package/src/layer/vector/Renderer.js +75 -0
  251. package/src/layer/vector/SVG.js +216 -0
  252. package/src/layer/vector/index.js +10 -0
  253. package/src/map/Map.js +1830 -0
  254. package/src/map/handler/BoxZoomHandler.js +156 -0
  255. package/src/map/handler/DoubleClickZoomHandler.js +62 -0
  256. package/src/map/handler/DragHandler.js +240 -0
  257. package/src/map/handler/KeyboardHandler.js +188 -0
  258. package/src/map/handler/PinchZoomHandler.js +157 -0
  259. package/src/map/handler/ScrollWheelZoomHandler.js +98 -0
  260. package/src/map/handler/TapHoldHandler.js +111 -0
  261. package/src/map/index.js +8 -0
  262. package/src/maplair.css +730 -0
@@ -0,0 +1,447 @@
1
+ import { falseFn, setOptions, throttle, wrapNum } from "../../core/Util.js";
2
+ import { Point } from "../../geometry/Point.js";
3
+ import Browser_default from "../../core/Browser.js";
4
+ import { create, setPosition, setTransform, toBack, toFront } from "../../dom/DomUtil.js";
5
+ import { Bounds } from "../../geometry/Bounds.js";
6
+ import { LatLngBounds } from "../../geo/LatLngBounds.js";
7
+ import { Layer } from "../Layer.js";
8
+ //#region src/layer/tile/GridLayer.js
9
+ var GridLayer = class GridLayer extends Layer {
10
+ static {
11
+ this.setDefaultOptions({
12
+ tileSize: 256,
13
+ opacity: 1,
14
+ updateWhenIdle: !Browser_default.reducedMotion,
15
+ updateWhenZooming: true,
16
+ updateInterval: Browser_default.reducedMotion ? 5e3 : 200,
17
+ zIndex: 1,
18
+ bounds: null,
19
+ minZoom: 0,
20
+ maxZoom: void 0,
21
+ maxNativeZoom: void 0,
22
+ minNativeZoom: void 0,
23
+ noWrap: false,
24
+ pane: "tilePane",
25
+ className: "",
26
+ keepBuffer: 2
27
+ });
28
+ }
29
+ constructor(options) {
30
+ super();
31
+ setOptions(this, options);
32
+ this.callInitHooks(GridLayer);
33
+ }
34
+ onAdd() {
35
+ this._initContainer();
36
+ this._levels = {};
37
+ this._tiles = {};
38
+ this._resetView();
39
+ }
40
+ beforeAdd(map) {
41
+ map._addZoomLimit(this);
42
+ }
43
+ onRemove(map) {
44
+ this._removeAllTiles();
45
+ this._container.remove();
46
+ map._removeZoomLimit(this);
47
+ this._container = null;
48
+ this._tileZoom = void 0;
49
+ clearTimeout(this._pruneTimeout);
50
+ }
51
+ bringToFront() {
52
+ if (this._map) {
53
+ toFront(this._container);
54
+ this._setAutoZIndex(Math.max);
55
+ }
56
+ return this;
57
+ }
58
+ bringToBack() {
59
+ if (this._map) {
60
+ toBack(this._container);
61
+ this._setAutoZIndex(Math.min);
62
+ }
63
+ return this;
64
+ }
65
+ getContainer() {
66
+ return this._container;
67
+ }
68
+ setOpacity(opacity) {
69
+ this.options.opacity = opacity;
70
+ this._updateOpacity();
71
+ return this;
72
+ }
73
+ setZIndex(zIndex) {
74
+ this.options.zIndex = zIndex;
75
+ this._updateZIndex();
76
+ return this;
77
+ }
78
+ isLoading() {
79
+ return this._loading;
80
+ }
81
+ redraw() {
82
+ if (this._map) {
83
+ this._removeAllTiles();
84
+ const tileZoom = this._clampZoom(this._map.getZoom());
85
+ if (tileZoom !== this._tileZoom) {
86
+ this._tileZoom = tileZoom;
87
+ this._updateLevels();
88
+ }
89
+ this._update();
90
+ }
91
+ return this;
92
+ }
93
+ getEvents() {
94
+ const events = {
95
+ viewprereset: this._invalidateAll,
96
+ viewreset: this._resetView,
97
+ zoom: this._resetView,
98
+ moveend: this._onMoveEnd
99
+ };
100
+ if (!this.options.updateWhenIdle) {
101
+ if (!this._onMove) this._onMove = throttle(this._onMoveEnd, this.options.updateInterval, this);
102
+ events.move = this._onMove;
103
+ }
104
+ if (this._zoomAnimated) events.zoomanim = this._animateZoom;
105
+ return events;
106
+ }
107
+ createTile() {
108
+ return document.createElement("div");
109
+ }
110
+ getTileSize() {
111
+ const s = this.options.tileSize;
112
+ return s instanceof Point ? s : new Point(s, s);
113
+ }
114
+ _updateZIndex() {
115
+ if (this._container && this.options.zIndex !== void 0 && this.options.zIndex !== null) this._container.style.zIndex = this.options.zIndex;
116
+ }
117
+ _setAutoZIndex(compare) {
118
+ const layers = this.getPane().children;
119
+ let edgeZIndex = -compare(-Infinity, Infinity);
120
+ for (const layer of layers) {
121
+ const zIndex = layer.style.zIndex;
122
+ if (layer !== this._container && zIndex) edgeZIndex = compare(edgeZIndex, +zIndex);
123
+ }
124
+ if (isFinite(edgeZIndex)) {
125
+ this.options.zIndex = edgeZIndex + compare(-1, 1);
126
+ this._updateZIndex();
127
+ }
128
+ }
129
+ _updateOpacity() {
130
+ if (!this._map) return;
131
+ this._container.style.opacity = this.options.opacity;
132
+ const now = Date.now();
133
+ let nextFrame = false, willPrune = false;
134
+ for (const tile of Object.values(this._tiles ?? {})) {
135
+ if (!tile.current || !tile.loaded) continue;
136
+ const fade = Math.min(1, (now - tile.loaded) / 200);
137
+ tile.el.style.opacity = fade;
138
+ if (fade < 1) nextFrame = true;
139
+ else {
140
+ if (tile.active) willPrune = true;
141
+ else this._onOpaqueTile(tile);
142
+ tile.active = true;
143
+ }
144
+ }
145
+ if (willPrune && !this._noPrune) this._pruneTiles();
146
+ if (nextFrame) {
147
+ cancelAnimationFrame(this._fadeFrame);
148
+ this._fadeFrame = requestAnimationFrame(this._updateOpacity.bind(this));
149
+ }
150
+ }
151
+ _onOpaqueTile() {}
152
+ _initContainer() {
153
+ if (this._container) return;
154
+ this._container = create("div", `maplair-layer ${this.options.className ?? ""}`);
155
+ this._updateZIndex();
156
+ if (this.options.opacity < 1) this._updateOpacity();
157
+ this.getPane().appendChild(this._container);
158
+ }
159
+ _updateLevels() {
160
+ const zoom = this._tileZoom, maxZoom = this.options.maxZoom;
161
+ if (zoom === void 0) return;
162
+ for (let z of Object.keys(this._levels)) {
163
+ z = Number(z);
164
+ if (this._levels[z].el.children.length || z === zoom) {
165
+ this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z);
166
+ this._onUpdateLevel(z);
167
+ } else {
168
+ this._levels[z].el.remove();
169
+ this._removeTilesAtZoom(z);
170
+ this._onRemoveLevel(z);
171
+ delete this._levels[z];
172
+ }
173
+ }
174
+ let level = this._levels[zoom];
175
+ const map = this._map;
176
+ if (!level) {
177
+ level = this._levels[zoom] = {};
178
+ level.el = create("div", "maplair-tile-container maplair-zoom-animated", this._container);
179
+ level.el.style.zIndex = maxZoom;
180
+ level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();
181
+ level.zoom = zoom;
182
+ this._setZoomTransform(level, map.getCenter(), map.getZoom());
183
+ falseFn(level.el.offsetWidth);
184
+ this._onCreateLevel(level);
185
+ }
186
+ this._level = level;
187
+ return level;
188
+ }
189
+ _onUpdateLevel() {}
190
+ _onRemoveLevel() {}
191
+ _onCreateLevel() {}
192
+ _pruneTiles() {
193
+ if (!this._map) return;
194
+ const zoom = this._map.getZoom();
195
+ if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
196
+ this._removeAllTiles();
197
+ return;
198
+ }
199
+ for (const tile of Object.values(this._tiles)) tile.retain = tile.current;
200
+ for (const tile of Object.values(this._tiles)) if (tile.current && !tile.active) {
201
+ const coords = tile.coords;
202
+ if (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) this._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);
203
+ }
204
+ for (const [key, tile] of Object.entries(this._tiles)) if (!tile.retain) this._removeTile(key);
205
+ }
206
+ _removeTilesAtZoom(zoom) {
207
+ for (const [key, tile] of Object.entries(this._tiles)) if (tile.coords.z === zoom) this._removeTile(key);
208
+ }
209
+ _removeAllTiles() {
210
+ for (const key of Object.keys(this._tiles)) this._removeTile(key);
211
+ }
212
+ _invalidateAll() {
213
+ for (const z of Object.keys(this._levels)) {
214
+ this._levels[z].el.remove();
215
+ this._onRemoveLevel(Number(z));
216
+ delete this._levels[z];
217
+ }
218
+ this._removeAllTiles();
219
+ this._tileZoom = void 0;
220
+ }
221
+ _retainParent(x, y, z, minZoom) {
222
+ const x2 = Math.floor(x / 2), y2 = Math.floor(y / 2), z2 = z - 1, coords2 = new Point(+x2, +y2);
223
+ coords2.z = +z2;
224
+ const key = this._tileCoordsToKey(coords2), tile = this._tiles[key];
225
+ if (tile?.active) {
226
+ tile.retain = true;
227
+ return true;
228
+ } else if (tile?.loaded) tile.retain = true;
229
+ if (z2 > minZoom) return this._retainParent(x2, y2, z2, minZoom);
230
+ return false;
231
+ }
232
+ _retainChildren(x, y, z, maxZoom) {
233
+ for (let i = 2 * x; i < 2 * x + 2; i++) for (let j = 2 * y; j < 2 * y + 2; j++) {
234
+ const coords = new Point(i, j);
235
+ coords.z = z + 1;
236
+ const key = this._tileCoordsToKey(coords), tile = this._tiles[key];
237
+ if (tile?.active) {
238
+ tile.retain = true;
239
+ continue;
240
+ } else if (tile?.loaded) tile.retain = true;
241
+ if (z + 1 < maxZoom) this._retainChildren(i, j, z + 1, maxZoom);
242
+ }
243
+ }
244
+ _resetView(e) {
245
+ const animating = e && (e.pinch || e.flyTo);
246
+ this._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);
247
+ }
248
+ _animateZoom(e) {
249
+ this._setView(e.center, e.zoom, true, e.noUpdate);
250
+ }
251
+ _clampZoom(zoom) {
252
+ const options = this.options;
253
+ if (void 0 !== options.minNativeZoom && zoom < options.minNativeZoom) return options.minNativeZoom;
254
+ if (void 0 !== options.maxNativeZoom && options.maxNativeZoom < zoom) return options.maxNativeZoom;
255
+ return zoom;
256
+ }
257
+ _setView(center, zoom, noPrune, noUpdate) {
258
+ let tileZoom = Math.round(zoom);
259
+ if (this.options.maxZoom !== void 0 && tileZoom > this.options.maxZoom || this.options.minZoom !== void 0 && tileZoom < this.options.minZoom) tileZoom = void 0;
260
+ else tileZoom = this._clampZoom(tileZoom);
261
+ const tileZoomChanged = this.options.updateWhenZooming && tileZoom !== this._tileZoom;
262
+ if (!noUpdate || tileZoomChanged) {
263
+ this._tileZoom = tileZoom;
264
+ if (this._abortLoading) this._abortLoading();
265
+ this._updateLevels();
266
+ this._resetGrid();
267
+ if (tileZoom !== void 0) this._update(center);
268
+ if (!noPrune) this._pruneTiles();
269
+ this._noPrune = !!noPrune;
270
+ }
271
+ this._setZoomTransforms(center, zoom);
272
+ }
273
+ _setZoomTransforms(center, zoom) {
274
+ for (const level of Object.values(this._levels)) this._setZoomTransform(level, center, zoom);
275
+ }
276
+ _setZoomTransform(level, center, zoom) {
277
+ const scale = this._map.getZoomScale(zoom, level.zoom), translate = level.origin.multiplyBy(scale).subtract(this._map._getNewPixelOrigin(center, zoom)).round();
278
+ setTransform(level.el, translate, scale);
279
+ }
280
+ _resetGrid() {
281
+ const map = this._map, crs = map.options.crs, tileSize = this._tileSize = this.getTileSize(), tileZoom = this._tileZoom;
282
+ const bounds = this._map.getPixelWorldBounds(this._tileZoom);
283
+ if (bounds) this._globalTileRange = this._pxBoundsToTileRange(bounds);
284
+ this._wrapX = crs.wrapLng && !this.options.noWrap && [Math.floor(map.project([0, crs.wrapLng[0]], tileZoom).x / tileSize.x), Math.ceil(map.project([0, crs.wrapLng[1]], tileZoom).x / tileSize.y)];
285
+ this._wrapY = crs.wrapLat && !this.options.noWrap && [Math.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.x), Math.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)];
286
+ }
287
+ _onMoveEnd() {
288
+ if (!this._map || this._map._animatingZoom) return;
289
+ this._update();
290
+ }
291
+ _getTiledPixelBounds(center) {
292
+ const map = this._map, mapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(), scale = map.getZoomScale(mapZoom, this._tileZoom), pixelCenter = map.project(center, this._tileZoom).floor(), halfSize = map.getSize().divideBy(scale * 2);
293
+ return new Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));
294
+ }
295
+ _update(center) {
296
+ const map = this._map;
297
+ if (!map) return;
298
+ const zoom = this._clampZoom(map.getZoom());
299
+ if (center === void 0) center = map.getCenter();
300
+ if (this._tileZoom === void 0) return;
301
+ const pixelBounds = this._getTiledPixelBounds(center), tileRange = this._pxBoundsToTileRange(pixelBounds), tileCenter = tileRange.getCenter(), queue = [], margin = this.options.keepBuffer, noPruneRange = new Bounds(tileRange.getBottomLeft().subtract([margin, -margin]), tileRange.getTopRight().add([margin, -margin]));
302
+ if (!(isFinite(tileRange.min.x) && isFinite(tileRange.min.y) && isFinite(tileRange.max.x) && isFinite(tileRange.max.y))) throw new Error("Attempted to load an infinite number of tiles");
303
+ for (const tile of Object.values(this._tiles)) {
304
+ const c = tile.coords;
305
+ if (c.z !== this._tileZoom || !noPruneRange.contains(new Point(c.x, c.y))) tile.current = false;
306
+ }
307
+ if (Math.abs(zoom - this._tileZoom) > 1) {
308
+ this._setView(center, zoom);
309
+ return;
310
+ }
311
+ for (let j = tileRange.min.y; j <= tileRange.max.y; j++) for (let i = tileRange.min.x; i <= tileRange.max.x; i++) {
312
+ const coords = new Point(i, j);
313
+ coords.z = this._tileZoom;
314
+ if (!this._isValidTile(coords)) continue;
315
+ const tile = this._tiles[this._tileCoordsToKey(coords)];
316
+ if (tile) tile.current = true;
317
+ else queue.push(coords);
318
+ }
319
+ queue.sort((a, b) => a.distanceTo(tileCenter) - b.distanceTo(tileCenter));
320
+ if (queue.length !== 0) {
321
+ if (!this._loading) {
322
+ this._loading = true;
323
+ this.fire("loading");
324
+ }
325
+ const fragment = document.createDocumentFragment();
326
+ for (const q of queue) this._addTile(q, fragment);
327
+ this._level.el.appendChild(fragment);
328
+ }
329
+ }
330
+ _isValidTile(coords) {
331
+ const crs = this._map.options.crs;
332
+ if (!crs.infinite) {
333
+ const bounds = this._globalTileRange;
334
+ if (!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x) || !crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y)) return false;
335
+ }
336
+ if (!this.options.bounds) return true;
337
+ const tileBounds = this._tileCoordsToBounds(coords);
338
+ return new LatLngBounds(this.options.bounds).overlaps(tileBounds);
339
+ }
340
+ _keyToBounds(key) {
341
+ return this._tileCoordsToBounds(this._keyToTileCoords(key));
342
+ }
343
+ _tileCoordsToNwSe(coords) {
344
+ const map = this._map, tileSize = this.getTileSize(), nwPoint = coords.scaleBy(tileSize), sePoint = nwPoint.add(tileSize);
345
+ return [map.unproject(nwPoint, coords.z), map.unproject(sePoint, coords.z)];
346
+ }
347
+ _tileCoordsToBounds(coords) {
348
+ const bp = this._tileCoordsToNwSe(coords);
349
+ let bounds = new LatLngBounds(bp[0], bp[1]);
350
+ if (!this.options.noWrap) bounds = this._map.wrapLatLngBounds(bounds);
351
+ return bounds;
352
+ }
353
+ _tileCoordsToKey(coords) {
354
+ return `${coords.x}:${coords.y}:${coords.z}`;
355
+ }
356
+ _keyToTileCoords(key) {
357
+ const k = key.split(":"), coords = new Point(+k[0], +k[1]);
358
+ coords.z = +k[2];
359
+ return coords;
360
+ }
361
+ _removeTile(key) {
362
+ const tile = this._tiles[key];
363
+ if (!tile) return;
364
+ tile.el.remove();
365
+ delete this._tiles[key];
366
+ this.fire("tileunload", {
367
+ tile: tile.el,
368
+ coords: this._keyToTileCoords(key)
369
+ });
370
+ }
371
+ _initTile(tile) {
372
+ tile.classList.add("maplair-tile");
373
+ const tileSize = this.getTileSize();
374
+ tile.style.width = `${tileSize.x}px`;
375
+ tile.style.height = `${tileSize.y}px`;
376
+ tile.onselectstart = falseFn;
377
+ tile.onpointermove = falseFn;
378
+ }
379
+ _addTile(coords, container) {
380
+ const tilePos = this._getTilePos(coords), key = this._tileCoordsToKey(coords);
381
+ const tile = this.createTile(this._wrapCoords(coords), this._tileReady.bind(this, coords));
382
+ this._initTile(tile);
383
+ if (this.createTile.length < 2) requestAnimationFrame(this._tileReady.bind(this, coords, null, tile));
384
+ setPosition(tile, tilePos);
385
+ this._tiles[key] = {
386
+ el: tile,
387
+ coords,
388
+ current: true
389
+ };
390
+ container.appendChild(tile);
391
+ this.fire("tileloadstart", {
392
+ tile,
393
+ coords
394
+ });
395
+ }
396
+ _tileReady(coords, err, tile) {
397
+ if (err) this.fire("tileerror", {
398
+ error: err,
399
+ tile,
400
+ coords
401
+ });
402
+ const key = this._tileCoordsToKey(coords);
403
+ tile = this._tiles[key];
404
+ if (!tile) return;
405
+ tile.loaded = Date.now();
406
+ if (this._map._fadeAnimated) {
407
+ tile.el.style.opacity = 0;
408
+ cancelAnimationFrame(this._fadeFrame);
409
+ this._fadeFrame = requestAnimationFrame(this._updateOpacity.bind(this));
410
+ } else {
411
+ tile.active = true;
412
+ this._pruneTiles();
413
+ }
414
+ if (!err) {
415
+ tile.el.classList.add("maplair-tile-loaded");
416
+ this.fire("tileload", {
417
+ tile: tile.el,
418
+ coords
419
+ });
420
+ }
421
+ if (this._noTilesToLoad()) {
422
+ this._loading = false;
423
+ this.fire("load");
424
+ if (!this._map._fadeAnimated) requestAnimationFrame(this._pruneTiles.bind(this));
425
+ else this._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);
426
+ }
427
+ }
428
+ _getTilePos(coords) {
429
+ return coords.scaleBy(this.getTileSize()).subtract(this._level.origin);
430
+ }
431
+ _wrapCoords(coords) {
432
+ const newCoords = new Point(this._wrapX ? wrapNum(coords.x, this._wrapX) : coords.x, this._wrapY ? wrapNum(coords.y, this._wrapY) : coords.y);
433
+ newCoords.z = coords.z;
434
+ return newCoords;
435
+ }
436
+ _pxBoundsToTileRange(bounds) {
437
+ const tileSize = this.getTileSize();
438
+ return new Bounds(bounds.min.unscaleBy(tileSize).floor(), bounds.max.unscaleBy(tileSize).ceil().subtract([1, 1]));
439
+ }
440
+ _noTilesToLoad() {
441
+ return Object.values(this._tiles).every((t) => t.loaded);
442
+ }
443
+ };
444
+ //#endregion
445
+ export { GridLayer };
446
+
447
+ //# sourceMappingURL=GridLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridLayer.js","names":["Browser","Util.throttle","DomUtil.create","Util.falseFn","Util.wrapNum"],"sources":["../../../../src/layer/tile/GridLayer.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport Browser from '../../core/Browser.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\n/*\n * @class GridLayer\n * @inherits Layer\n *\n * Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces `TileLayer.Canvas`.\n * GridLayer can be extended to create a tiled grid of HTML elements like `<canvas>`, `<img>` or `<div>`. GridLayer will handle creating and animating these DOM elements for you.\n *\n *\n * @section Synchronous usage\n * @example\n *\n * To create a custom layer, extend GridLayer and implement the `createTile()` method, which will be passed a `Point` object with the `x`, `y`, and `z` (zoom level) 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 * @section Asynchronous usage\n * @example\n *\n * Tile creation can also be asynchronous, this is useful when using a third-party drawing library. Once the tile is finished drawing it can be passed to the `done()` 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 * @section\n */\n\n\n// @constructor GridLayer(options?: GridLayer options)\n// Creates a new instance of GridLayer with the supplied options.\nexport class GridLayer extends Layer {\n\n\tstatic {\n\t// @section\n\t// @aka GridLayer options\n\t\tthis.setDefaultOptions({\n\t\t\t// @option tileSize: Number|Point = 256\n\t\t\t// Width and height of tiles in the grid. Use a number if width and height are equal, or `Point(width, height)` otherwise.\n\t\t\ttileSize: 256,\n\n\t\t\t// @option opacity: Number = 1.0\n\t\t\t// Opacity of the tiles. Can be used in the `createTile()` function.\n\t\t\topacity: 1,\n\n\t\t\t// @option updateWhenIdle: Boolean = *\n\t\t\t// Load new tiles only when panning ends.\n\t\t\t// Defaults to `false` (tiles are loaded _during_ panning) unless\n\t\t\t// the browser is configured for reduced motion.\n\t\t\tupdateWhenIdle: !Browser.reducedMotion,\n\n\t\t\t// @option updateWhenZooming: Boolean = true\n\t\t\t// By default, a smooth zoom animation (during a [pinch zoom](#map-pinchzoom) or a [`flyTo()`](#map-flyto)) will update grid layers every integer zoom level. Setting this option to `false` will update the grid layer only when the smooth animation ends.\n\t\t\tupdateWhenZooming: true,\n\n\t\t\t// @option updateInterval: Number = 200\n\t\t\t// Tiles will not update more than once every `updateInterval`\n\t\t\t// milliseconds when panning. The default value is increased to\n\t\t\t// five seconds if the browser is configured for reduced motion.\n\t\t\tupdateInterval: Browser.reducedMotion ? 5000 : 200,\n\n\t\t\t// @option zIndex: Number = 1\n\t\t\t// The explicit zIndex of the tile layer.\n\t\t\tzIndex: 1,\n\n\t\t\t// @option bounds: LatLngBounds = undefined\n\t\t\t// If set, tiles will only be loaded inside the set `LatLngBounds`.\n\t\t\tbounds: null,\n\n\t\t\t// @option minZoom: Number = 0\n\t\t\t// The minimum zoom level down to which this layer will be displayed (inclusive).\n\t\t\tminZoom: 0,\n\n\t\t\t// @option maxZoom: Number = undefined\n\t\t\t// The maximum zoom level up to which this layer will be displayed (inclusive).\n\t\t\tmaxZoom: undefined,\n\n\t\t\t// @option maxNativeZoom: Number = undefined\n\t\t\t// Maximum zoom number the tile source has available. If it is specified,\n\t\t\t// the tiles on all zoom levels higher than `maxNativeZoom` will be loaded\n\t\t\t// from `maxNativeZoom` level and auto-scaled.\n\t\t\tmaxNativeZoom: undefined,\n\n\t\t\t// @option minNativeZoom: Number = undefined\n\t\t\t// Minimum zoom number the tile source has available. If it is specified,\n\t\t\t// the tiles on all zoom levels lower than `minNativeZoom` will be loaded\n\t\t\t// from `minNativeZoom` level and auto-scaled.\n\t\t\tminNativeZoom: undefined,\n\n\t\t\t// @option noWrap: Boolean = false\n\t\t\t// Whether the layer is wrapped around the antimeridian. If `true`, the\n\t\t\t// GridLayer will only be displayed once at low zoom levels. Has no\n\t\t\t// effect when the [map CRS](#map-crs) doesn't wrap around. Can be used\n\t\t\t// in combination with [`bounds`](#gridlayer-bounds) to prevent requesting\n\t\t\t// tiles outside the CRS limits.\n\t\t\tnoWrap: false,\n\n\t\t\t// @option pane: String = 'tilePane'\n\t\t\t// `Map pane` where the grid layer will be added.\n\t\t\tpane: 'tilePane',\n\n\t\t\t// @option className: String = ''\n\t\t\t// A custom class name to assign to the tile layer. Empty by default.\n\t\t\tclassName: '',\n\n\t\t\t// @option keepBuffer: Number = 2\n\t\t\t// When panning the map, keep this many rows and columns of tiles before unloading them.\n\t\t\tkeepBuffer: 2\n\t\t});\n\t}\n\n\tconstructor(options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis.callInitHooks(GridLayer);\n\t}\n\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\tbeforeAdd(map) {\n\t\tmap._addZoomLimit(this);\n\t}\n\n\tonRemove(map) {\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}\n\n\t// @method bringToFront: this\n\t// Brings the tile layer to the top of all tile layers.\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// @method bringToBack: this\n\t// Brings the tile layer to the bottom of all tile layers.\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// @method getContainer: HTMLElement\n\t// Returns the HTML element that contains the tiles for this layer.\n\tgetContainer() {\n\t\treturn this._container;\n\t}\n\n\t// @method setOpacity(opacity: Number): this\n\t// Changes the [opacity](#gridlayer-opacity) of the grid layer.\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tthis._updateOpacity();\n\t\treturn this;\n\t}\n\n\t// @method setZIndex(zIndex: Number): this\n\t// Changes the [zIndex](#gridlayer-zindex) of the grid layer.\n\tsetZIndex(zIndex) {\n\t\tthis.options.zIndex = zIndex;\n\t\tthis._updateZIndex();\n\n\t\treturn this;\n\t}\n\n\t// @method isLoading: Boolean\n\t// Returns `true` if any tile in the grid layer has not finished loading.\n\tisLoading() {\n\t\treturn this._loading;\n\t}\n\n\t// @method redraw: this\n\t// Causes the layer to clear all the tiles and request them again.\n\tredraw() {\n\t\tif (this._map) {\n\t\t\tthis._removeAllTiles();\n\t\t\tconst tileZoom = this._clampZoom(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\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};\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\tif (this._zoomAnimated) {\n\t\t\tevents.zoomanim = this._animateZoom;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t// @section Extension methods\n\t// Layers extending `GridLayer` shall reimplement the following method.\n\t// @method createTile(coords: Object, done?: Function): HTMLElement\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\tcreateTile() {\n\t\treturn document.createElement('div');\n\t}\n\n\t// @section\n\t// @method getTileSize: Point\n\t// Normalizes the [tileSize option](#gridlayer-tilesize) into a point. Used by the `createTile()` method.\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\n\t\tconst now = Date.now();\n\t\tlet nextFrame = false,\n\t\twillPrune = false;\n\n\t\tfor (const tile of Object.values(this._tiles ?? {})) {\n\t\t\tif (!tile.current || !tile.loaded) { continue; }\n\n\t\t\tconst fade = Math.min(1, (now - tile.loaded) / 200);\n\n\t\t\ttile.el.style.opacity = fade;\n\t\t\tif (fade < 1) {\n\t\t\t\tnextFrame = true;\n\t\t\t} else {\n\t\t\t\tif (tile.active) {\n\t\t\t\t\twillPrune = true;\n\t\t\t\t} else {\n\t\t\t\t\tthis._onOpaqueTile(tile);\n\t\t\t\t}\n\t\t\t\ttile.active = true;\n\t\t\t}\n\t\t}\n\n\t\tif (willPrune && !this._noPrune) { this._pruneTiles(); }\n\n\t\tif (nextFrame) {\n\t\t\tcancelAnimationFrame(this._fadeFrame);\n\t\t\tthis._fadeFrame = requestAnimationFrame(this._updateOpacity.bind(this));\n\t\t}\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._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_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() {\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\tconst x2 = Math.floor(x / 2),\n\t\ty2 = Math.floor(y / 2),\n\t\tz2 = z - 1,\n\t\tcoords2 = new Point(+x2, +y2);\n\t\tcoords2.z = +z2;\n\n\t\tconst key = this._tileCoordsToKey(coords2),\n\t\ttile = this._tiles[key];\n\n\t\tif (tile?.active) {\n\t\t\ttile.retain = true;\n\t\t\treturn true;\n\n\t\t} else if (tile?.loaded) {\n\t\t\ttile.retain = true;\n\t\t}\n\n\t\tif (z2 > minZoom) {\n\t\t\treturn this._retainParent(x2, y2, z2, minZoom);\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t_retainChildren(x, y, z, maxZoom) {\n\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\n\t\t\t\tconst coords = new Point(i, j);\n\t\t\t\tcoords.z = z + 1;\n\n\t\t\t\tconst key = this._tileCoordsToKey(coords),\n\t\t\t\ttile = this._tiles[key];\n\n\t\t\t\tif (tile?.active) {\n\t\t\t\t\ttile.retain = true;\n\t\t\t\t\tcontinue;\n\n\t\t\t\t} else if (tile?.loaded) {\n\t\t\t\t\ttile.retain = true;\n\t\t\t\t}\n\n\t\t\t\tif (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_resetView(e) {\n\t\tconst animating = e && (e.pinch || e.flyTo);\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 _updateOpacity 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.y)\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.x),\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_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\t// @event loading: Event\n\t\t\t\t// Fired when the grid layer starts loading tiles.\n\t\t\t\tthis.fire('loading');\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 new LatLngBounds(this.options.bounds).overlaps(tileBounds);\n\t}\n\n\t_keyToBounds(key) {\n\t\treturn this._tileCoordsToBounds(this._keyToTileCoords(key));\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// converts tile cache key to coordinates\n\t_keyToTileCoords(key) {\n\t\tconst k = key.split(':'),\n\t\tcoords = new Point(+k[0], +k[1]);\n\t\tcoords.z = +k[2];\n\t\treturn coords;\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\t// @event tileunload: TileEvent\n\t\t// Fired when a tile is removed (e.g. when a tile goes off the screen).\n\t\tthis.fire('tileunload', {\n\t\t\ttile: tile.el,\n\t\t\tcoords: this._keyToTileCoords(key)\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\ttile.onselectstart = Util.falseFn;\n\t\ttile.onpointermove = Util.falseFn;\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\tDomUtil.setPosition(tile, tilePos);\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\t// @event tileloadstart: TileEvent\n\t\t// Fired when a tile is requested and starts loading.\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\t// @event tileerror: TileErrorEvent\n\t\t\t// Fired when there is an error loading a tile.\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\ttile.loaded = Date.now();\n\t\tif (this._map._fadeAnimated) {\n\t\t\ttile.el.style.opacity = 0;\n\t\t\tcancelAnimationFrame(this._fadeFrame);\n\t\t\tthis._fadeFrame = requestAnimationFrame(this._updateOpacity.bind(this));\n\t\t} else {\n\t\t\ttile.active = true;\n\t\t\tthis._pruneTiles();\n\t\t}\n\n\t\tif (!err) {\n\t\t\ttile.el.classList.add('maplair-tile-loaded');\n\n\t\t\t// @event tileload: TileEvent\n\t\t\t// Fired when a tile loads.\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\t// @event load: Event\n\t\t\t// Fired when the grid layer loaded all visible tiles.\n\t\t\tthis.fire('load');\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_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":";;;;;;;;AA2EA,IAAa,YAAb,MAAa,kBAAkB,MAAM;CAEpC;EAGC,KAAK,kBAAkB;GAGtB,UAAU;GAIV,SAAS;GAMT,gBAAgB,CAACA,gBAAQ;GAIzB,mBAAmB;GAMnB,gBAAgBA,gBAAQ,gBAAgB,MAAO;GAI/C,QAAQ;GAIR,QAAQ;GAIR,SAAS;GAIT,SAAS,KAAA;GAMT,eAAe,KAAA;GAMf,eAAe,KAAA;GAQf,QAAQ;GAIR,MAAM;GAIN,WAAW;GAIX,YAAY;EACb,CAAC;CACF;CAEA,YAAY,SAAS;EACpB,MAAM;EACN,WAAgB,MAAM,OAAO;EAE7B,KAAK,cAAc,SAAS;CAC7B;CAEA,QAAQ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AAK,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"}
@@ -0,0 +1,139 @@
1
+ import { falseFn, setOptions, template } from "../../core/Util.js";
2
+ import Browser_default from "../../core/Browser.js";
3
+ import { on } from "../../dom/DomEvent.js";
4
+ import { I18n } from "../../core/I18n.js";
5
+ import { GridLayer } from "./GridLayer.js";
6
+ //#region src/layer/tile/TileLayer.js
7
+ var TileLayer = class TileLayer extends GridLayer {
8
+ static {
9
+ this.setDefaultOptions({
10
+ minZoom: 0,
11
+ maxZoom: 18,
12
+ subdomains: "abc",
13
+ errorTileUrl: "",
14
+ zoomOffset: 0,
15
+ tms: false,
16
+ zoomReverse: false,
17
+ detectRetina: false,
18
+ crossOrigin: false,
19
+ referrerPolicy: "strict-origin-when-cross-origin"
20
+ });
21
+ }
22
+ constructor(url, options) {
23
+ super(options);
24
+ this._url = url;
25
+ options = setOptions(this, options);
26
+ const tileUrl = new URL(this._url, location.href);
27
+ const urlHostname = tileUrl.hostname;
28
+ if (["tile.openstreetmap.org", "tile.osm.org"].some((host) => urlHostname.endsWith(host))) {
29
+ if (options.attribution === null) options.attribution = `&copy; <a href="https://www.openstreetmap.org/copyright">${I18n.translate("OpenStreetMap contributors")}</a>`;
30
+ if (tileUrl.protocol === "http:") {
31
+ tileUrl.protocol = "https:";
32
+ this._url = tileUrl.toString();
33
+ }
34
+ }
35
+ if (this.options.detectRetina && Browser_default.retina && this.options.maxZoom > 0) {
36
+ this.options.tileSize = Math.floor(this.options.tileSize / 2);
37
+ if (!this.options.zoomReverse) {
38
+ this.options.zoomOffset++;
39
+ this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
40
+ } else {
41
+ this.options.zoomOffset--;
42
+ this.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);
43
+ }
44
+ this.options.minZoom = Math.max(0, this.options.minZoom);
45
+ } else if (!this.options.zoomReverse) this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);
46
+ else this.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);
47
+ if (typeof this.options.subdomains === "string") this.options.subdomains = this.options.subdomains.split("");
48
+ this.on("tileunload", this._onTileRemove);
49
+ this.callInitHooks(TileLayer);
50
+ }
51
+ setUrl(url, noRedraw) {
52
+ if (this._url === url && noRedraw === void 0) noRedraw = true;
53
+ this._url = url;
54
+ if (!noRedraw) this.redraw();
55
+ return this;
56
+ }
57
+ createTile(coords, done) {
58
+ const tile = document.createElement("img");
59
+ on(tile, "load", this._tileOnLoad.bind(this, done, tile));
60
+ on(tile, "error", this._tileOnError.bind(this, done, tile));
61
+ if (this.options.crossOrigin || this.options.crossOrigin === "") tile.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
62
+ if (typeof this.options.referrerPolicy === "string") tile.referrerPolicy = this.options.referrerPolicy;
63
+ tile.alt = "";
64
+ tile.src = this.getTileUrl(coords);
65
+ return tile;
66
+ }
67
+ getTileUrl(coords) {
68
+ const data = Object.create(this.options);
69
+ Object.assign(data, {
70
+ r: Browser_default.retina ? "@2x" : "",
71
+ s: this._getSubdomain(coords),
72
+ x: coords.x,
73
+ y: coords.y,
74
+ z: this._getZoomForUrl()
75
+ });
76
+ if (this._map && !this._map.options.crs.infinite) {
77
+ const invertedY = this._globalTileRange.max.y - coords.y;
78
+ if (this.options.tms) data["y"] = invertedY;
79
+ data["-y"] = invertedY;
80
+ }
81
+ return template(this._url, data);
82
+ }
83
+ _tileOnLoad(done, tile) {
84
+ done(null, tile);
85
+ }
86
+ _tileOnError(done, tile, e) {
87
+ const errorUrl = this.options.errorTileUrl;
88
+ if (errorUrl && tile.getAttribute("src") !== errorUrl) tile.src = errorUrl;
89
+ done(e, tile);
90
+ }
91
+ _onTileRemove(e) {
92
+ e.tile.onload = null;
93
+ }
94
+ _getZoomForUrl() {
95
+ let zoom = this._tileZoom;
96
+ const maxZoom = this.options.maxZoom, zoomReverse = this.options.zoomReverse, zoomOffset = this.options.zoomOffset;
97
+ if (zoomReverse) zoom = maxZoom - zoom;
98
+ return zoom + zoomOffset;
99
+ }
100
+ _getSubdomain(tilePoint) {
101
+ const index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
102
+ return this.options.subdomains[index];
103
+ }
104
+ _abortLoading() {
105
+ let i, tile;
106
+ for (i of Object.keys(this._tiles)) if (this._tiles[i].coords.z !== this._tileZoom) {
107
+ tile = this._tiles[i].el;
108
+ tile.onload = falseFn;
109
+ tile.onerror = falseFn;
110
+ if (!tile.complete) {
111
+ tile.setAttribute("src", "");
112
+ const coords = this._tiles[i].coords;
113
+ tile.remove();
114
+ delete this._tiles[i];
115
+ this.fire("tileabort", {
116
+ tile,
117
+ coords
118
+ });
119
+ }
120
+ }
121
+ }
122
+ _removeTile(key) {
123
+ const tile = this._tiles[key];
124
+ if (!tile) return;
125
+ tile.el.setAttribute("src", "");
126
+ return super._removeTile(key);
127
+ }
128
+ _tileReady(coords, err, tile) {
129
+ if (!this._map || tile && tile.getAttribute("src") === "") return;
130
+ return super._tileReady(coords, err, tile);
131
+ }
132
+ _clampZoom(zoom) {
133
+ return Math.round(super._clampZoom(zoom));
134
+ }
135
+ };
136
+ //#endregion
137
+ export { TileLayer };
138
+
139
+ //# sourceMappingURL=TileLayer.js.map