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 @@
1
+ {"version":3,"file":"ImageOverlay.js","names":["DomUtil.create","Util.splitWords","Util.falseFn"],"sources":["../../../src/layer/ImageOverlay.js"],"sourcesContent":["import {Layer} from './Layer.js';\nimport * as Util from '../core/Util.js';\nimport {LatLngBounds} from '../geo/LatLngBounds.js';\nimport {Bounds} from '../geometry/Bounds.js';\nimport * as DomUtil from '../dom/DomUtil.js';\n\n/*\n * @class ImageOverlay\n * @inherits Interactive layer\n *\n * Used to load and display a single image over specific bounds of the map. Extends `Layer`.\n *\n * @example\n *\n * ```js\n * const imageUrl = 'https://maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',\n * \timageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];\n * new ImageOverlay(imageUrl, imageBounds).addTo(map);\n * ```\n */\n\n// @constructor ImageOverlay(imageUrl: String, bounds: LatLngBounds, options?: ImageOverlay options)\n// Instantiates an image overlay object given the URL of the image and the\n// geographical bounds it is tied to.\nexport class ImageOverlay extends Layer {\n\n\tstatic {\n\t\t// @section\n\t\t// @aka ImageOverlay options\n\t\tthis.setDefaultOptions({\n\t\t\t// @option opacity: Number = 1.0\n\t\t\t// The opacity of the image overlay.\n\t\t\topacity: 1,\n\n\t\t\t// @option alt: String = ''\n\t\t\t// Text for the `alt` attribute of the image (useful for accessibility).\n\t\t\talt: '',\n\n\t\t\t// @option interactive: Boolean = false\n\t\t\t// If `true`, the image overlay will emit [pointer events](#interactive-layer) when clicked or hovered.\n\t\t\tinteractive: false,\n\n\t\t\t// @option crossOrigin: Boolean|String = false\n\t\t\t// Whether the crossOrigin attribute will be added to the image.\n\t\t\t// If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data.\n\t\t\t// Refer to [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) for valid String values.\n\t\t\tcrossOrigin: false,\n\n\t\t\t// @option errorOverlayUrl: String = ''\n\t\t\t// URL to the overlay image to show in place of the overlay that failed to load.\n\t\t\terrorOverlayUrl: '',\n\n\t\t\t// @option zIndex: Number = 1\n\t\t\t// The explicit [zIndex](https://developer.mozilla.org/docs/Web/CSS/CSS_Positioning/Understanding_z_index) of the overlay layer.\n\t\t\tzIndex: 1,\n\n\t\t\t// @option className: String = ''\n\t\t\t// A custom class name to assign to the image. Empty by default.\n\t\t\tclassName: '',\n\n\t\t\t// @option decoding: String = 'auto'\n\t\t\t// Tells the browser whether to decode the image in a synchronous fashion,\n\t\t\t// as per the [`decoding` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding).\n\t\t\t// If the image overlay is flickering when being added/removed, set\n\t\t\t// this option to `'sync'`.\n\t\t\tdecoding: 'auto'\n\t\t});\n\t}\n\n\tconstructor(url, bounds, options) { // (String, LatLngBounds, Object)\n\t\tsuper();\n\t\tthis._url = url;\n\t\tthis._bounds = new LatLngBounds(bounds);\n\n\t\tUtil.setOptions(this, options);\n\n\t\tthis.callInitHooks(ImageOverlay);\n\t}\n\n\tonAdd() {\n\t\tif (!this._image) {\n\t\t\tthis._initImage();\n\n\t\t\tif (this.options.opacity < 1) {\n\t\t\t\tthis._updateOpacity();\n\t\t\t}\n\t\t}\n\n\t\tif (this.options.interactive) {\n\t\t\tthis._image.classList.add('maplair-interactive');\n\t\t\tthis.addInteractiveTarget(this._image);\n\t\t}\n\n\t\tthis.getPane().appendChild(this._image);\n\t\tthis._reset();\n\t}\n\n\tonRemove() {\n\t\tthis._image.remove();\n\t\tif (this.options.interactive) {\n\t\t\tthis.removeInteractiveTarget(this._image);\n\t\t}\n\t}\n\n\t// @method setOpacity(opacity: Number): this\n\t// Sets the opacity of the overlay.\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\n\t\tif (this._image) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\t\treturn this;\n\t}\n\n\tsetStyle(styleOpts) {\n\t\tif (styleOpts.opacity) {\n\t\t\tthis.setOpacity(styleOpts.opacity);\n\t\t}\n\t\treturn this;\n\t}\n\n\t// @method bringToFront(): this\n\t// Brings the layer to the top of all overlays.\n\tbringToFront() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toFront(this._image);\n\t\t}\n\t\treturn this;\n\t}\n\n\t// @method bringToBack(): this\n\t// Brings the layer to the bottom of all overlays.\n\tbringToBack() {\n\t\tif (this._map) {\n\t\t\tDomUtil.toBack(this._image);\n\t\t}\n\t\treturn this;\n\t}\n\n\t// @method setUrl(url: String): this\n\t// Changes the URL of the image.\n\tsetUrl(url) {\n\t\tthis._url = url;\n\n\t\tif (this._image) {\n\t\t\tthis._image.src = url;\n\t\t}\n\t\treturn this;\n\t}\n\n\t// @method setBounds(bounds: LatLngBounds): this\n\t// Update the bounds that this ImageOverlay covers\n\tsetBounds(bounds) {\n\t\tthis._bounds = new LatLngBounds(bounds);\n\n\t\tif (this._map) {\n\t\t\tthis._reset();\n\t\t}\n\t\treturn this;\n\t}\n\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tzoom: this._reset,\n\t\t\tviewreset: this._reset\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// @method setZIndex(value: Number): this\n\t// Changes the [zIndex](#imageoverlay-zindex) of the image overlay.\n\tsetZIndex(value) {\n\t\tthis.options.zIndex = value;\n\t\tthis._updateZIndex();\n\t\treturn this;\n\t}\n\n\t// @method getBounds(): LatLngBounds\n\t// Get the bounds that this ImageOverlay covers\n\tgetBounds() {\n\t\treturn this._bounds;\n\t}\n\n\t// @method getElement(): HTMLElement\n\t// Returns the instance of [`HTMLImageElement`](https://developer.mozilla.org/docs/Web/API/HTMLImageElement)\n\t// used by this overlay.\n\tgetElement() {\n\t\treturn this._image;\n\t}\n\n\t_initImage() {\n\t\tconst wasElementSupplied = this._url.tagName === 'IMG';\n\t\tconst img = this._image = wasElementSupplied ? this._url : DomUtil.create('img');\n\n\t\timg.classList.add('maplair-image-layer');\n\t\tif (this._zoomAnimated) { img.classList.add('maplair-zoom-animated'); }\n\t\tif (this.options.className) { img.classList.add(...Util.splitWords(this.options.className)); }\n\n\t\timg.onselectstart = Util.falseFn;\n\t\timg.onpointermove = Util.falseFn;\n\n\t\t// @event load: Event\n\t\t// Fired when the ImageOverlay layer has loaded its image\n\t\timg.onload = this.fire.bind(this, 'load');\n\t\timg.onerror = this._overlayOnError.bind(this);\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\timg.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\timg.decoding = this.options.decoding;\n\n\t\tif (this.options.zIndex) {\n\t\t\tthis._updateZIndex();\n\t\t}\n\n\t\tif (wasElementSupplied) {\n\t\t\tthis._url = img.src;\n\t\t\treturn;\n\t\t}\n\n\t\timg.src = this._url;\n\t\timg.alt = this.options.alt;\n\t}\n\n\t_animateZoom(e) {\n\t\tconst scale = this._map.getZoomScale(e.zoom),\n\t\toffset = this._map._latLngBoundsToNewLayerBounds(this._bounds, e.zoom, e.center).min;\n\n\t\tDomUtil.setTransform(this._image, offset, scale);\n\t}\n\n\t_reset() {\n\t\tconst image = this._image,\n\t\tbounds = new Bounds(\n\t\t\tthis._map.latLngToLayerPoint(this._bounds.getNorthWest()),\n\t\t\tthis._map.latLngToLayerPoint(this._bounds.getSouthEast())),\n\t\tsize = bounds.getSize();\n\n\t\tDomUtil.setPosition(image, bounds.min);\n\n\t\timage.style.width = `${size.x}px`;\n\t\timage.style.height = `${size.y}px`;\n\t}\n\n\t_updateOpacity() {\n\t\tthis._image.style.opacity = this.options.opacity;\n\t}\n\n\t_updateZIndex() {\n\t\tif (this._image && this.options.zIndex !== undefined && this.options.zIndex !== null) {\n\t\t\tthis._image.style.zIndex = this.options.zIndex;\n\t\t}\n\t}\n\n\t_overlayOnError() {\n\t\t// @event error: Event\n\t\t// Fired when the ImageOverlay layer fails to load its image\n\t\tthis.fire('error');\n\n\t\tconst errorUrl = this.options.errorOverlayUrl;\n\t\tif (errorUrl && this._url !== errorUrl) {\n\t\t\tthis._url = errorUrl;\n\t\t\tthis._image.src = errorUrl;\n\t\t}\n\t}\n\n\t// @method getCenter(): LatLng\n\t// Returns the center of the ImageOverlay.\n\tgetCenter() {\n\t\treturn this._bounds.getCenter();\n\t}\n}\n"],"mappings":";;;;;;AAwBA,IAAa,eAAb,MAAa,qBAAqB,MAAM;CAEvC;EAGC,KAAK,kBAAkB;GAGtB,SAAS;GAIT,KAAK;GAIL,aAAa;GAMb,aAAa;GAIb,iBAAiB;GAIjB,QAAQ;GAIR,WAAW;GAOX,UAAU;EACX,CAAC;CACF;CAEA,YAAY,KAAK,QAAQ,SAAS;EACjC,MAAM;EACN,KAAK,OAAO;EACZ,KAAK,UAAU,IAAI,aAAa,MAAM;EAEtC,WAAgB,MAAM,OAAO;EAE7B,KAAK,cAAc,YAAY;CAChC;CAEA,QAAQ;EACP,IAAI,CAAC,KAAK,QAAQ;GACjB,KAAK,WAAW;GAEhB,IAAI,KAAK,QAAQ,UAAU,GAC1B,KAAK,eAAe;EAEtB;EAEA,IAAI,KAAK,QAAQ,aAAa;GAC7B,KAAK,OAAO,UAAU,IAAI,qBAAqB;GAC/C,KAAK,qBAAqB,KAAK,MAAM;EACtC;EAEA,KAAK,QAAQ,CAAC,CAAC,YAAY,KAAK,MAAM;EACtC,KAAK,OAAO;CACb;CAEA,WAAW;EACV,KAAK,OAAO,OAAO;EACnB,IAAI,KAAK,QAAQ,aAChB,KAAK,wBAAwB,KAAK,MAAM;CAE1C;CAIA,WAAW,SAAS;EACnB,KAAK,QAAQ,UAAU;EAEvB,IAAI,KAAK,QACR,KAAK,eAAe;EAErB,OAAO;CACR;CAEA,SAAS,WAAW;EACnB,IAAI,UAAU,SACb,KAAK,WAAW,UAAU,OAAO;EAElC,OAAO;CACR;CAIA,eAAe;EACd,IAAI,KAAK,MACR,QAAgB,KAAK,MAAM;EAE5B,OAAO;CACR;CAIA,cAAc;EACb,IAAI,KAAK,MACR,OAAe,KAAK,MAAM;EAE3B,OAAO;CACR;CAIA,OAAO,KAAK;EAC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,KAAK,KAAK,aAAa,EAAE,IAAI,GAC3C,SAAS,KAAK,KAAK,8BAA8B,KAAK,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;EAEjF,aAAqB,KAAK,QAAQ,QAAQ,KAAK;CAChD;CAEA,SAAS;EACR,MAAM,QAAQ,KAAK,QACnB,SAAS,IAAI,OACZ,KAAK,KAAK,mBAAmB,KAAK,QAAQ,aAAa,CAAC,GACxD,KAAK,KAAK,mBAAmB,KAAK,QAAQ,aAAa,CAAC,CAAC,GAC1D,OAAO,OAAO,QAAQ;EAEtB,YAAoB,OAAO,OAAO,GAAG;EAErC,MAAM,MAAM,QAAS,GAAG,KAAK,EAAE;EAC/B,MAAM,MAAM,SAAS,GAAG,KAAK,EAAE;CAChC;CAEA,iBAAiB;EAChB,KAAK,OAAO,MAAM,UAAU,KAAK,QAAQ;CAC1C;CAEA,gBAAgB;EACf,IAAI,KAAK,UAAU,KAAK,QAAQ,WAAW,KAAA,KAAa,KAAK,QAAQ,WAAW,MAC/E,KAAK,OAAO,MAAM,SAAS,KAAK,QAAQ;CAE1C;CAEA,kBAAkB;EAGjB,KAAK,KAAK,OAAO;EAEjB,MAAM,WAAW,KAAK,QAAQ;EAC9B,IAAI,YAAY,KAAK,SAAS,UAAU;GACvC,KAAK,OAAO;GACZ,KAAK,OAAO,MAAM;EACnB;CACD;CAIA,YAAY;EACX,OAAO,KAAK,QAAQ,UAAU;CAC/B;AACD"}
@@ -0,0 +1,119 @@
1
+ import { stamp } from "../core/Util.js";
2
+ import { Evented } from "../core/Events.js";
3
+ //#region src/layer/Layer.js
4
+ var Layer = class extends Evented {
5
+ static {
6
+ this.setDefaultOptions({
7
+ pane: "overlayPane",
8
+ attribution: null,
9
+ bubblingPointerEvents: true
10
+ });
11
+ }
12
+ addTo(map) {
13
+ map.addLayer(this);
14
+ return this;
15
+ }
16
+ remove() {
17
+ return this.removeFrom(this._map || this._mapToAdd);
18
+ }
19
+ removeFrom(obj) {
20
+ obj?.removeLayer(this);
21
+ return this;
22
+ }
23
+ getPane(name) {
24
+ return this._map.getPane(name ? this.options[name] || name : this.options.pane);
25
+ }
26
+ addInteractiveTarget(targetEl) {
27
+ this._map._targets[stamp(targetEl)] = this;
28
+ return this;
29
+ }
30
+ removeInteractiveTarget(targetEl) {
31
+ delete this._map._targets[stamp(targetEl)];
32
+ return this;
33
+ }
34
+ getAttribution() {
35
+ return this.options.attribution;
36
+ }
37
+ _layerAdd(e) {
38
+ const map = e.target;
39
+ if (!map.hasLayer(this)) return;
40
+ this._map = map;
41
+ this._zoomAnimated = map._zoomAnimated;
42
+ if (this.getEvents) {
43
+ const events = this.getEvents();
44
+ map.on(events, this);
45
+ this.once("remove", () => map.off(events, this));
46
+ }
47
+ this.onAdd(map);
48
+ this.fire("add");
49
+ map.fire("layeradd", { layer: this });
50
+ }
51
+ static register(MaplairMap) {
52
+ MaplairMap.include({
53
+ addLayer(layer) {
54
+ if (!layer._layerAdd) throw new Error("The provided object is not a Layer.");
55
+ const id = stamp(layer);
56
+ if (this._layers[id]) return this;
57
+ this._layers[id] = layer;
58
+ layer._mapToAdd = this;
59
+ if (layer.beforeAdd) layer.beforeAdd(this);
60
+ this.whenReady(layer._layerAdd, layer);
61
+ return this;
62
+ },
63
+ removeLayer(layer) {
64
+ const id = stamp(layer);
65
+ if (!this._layers[id]) return this;
66
+ if (this._loaded) layer.onRemove(this);
67
+ delete this._layers[id];
68
+ if (this._loaded) {
69
+ this.fire("layerremove", { layer });
70
+ layer.fire("remove");
71
+ }
72
+ layer._map = layer._mapToAdd = null;
73
+ return this;
74
+ },
75
+ hasLayer(layer) {
76
+ return stamp(layer) in this._layers;
77
+ },
78
+ eachLayer(method, context) {
79
+ for (const layer of Object.values(this._layers)) method.call(context, layer);
80
+ return this;
81
+ },
82
+ _addLayers(layers) {
83
+ layers = layers ? Array.isArray(layers) ? layers : [layers] : [];
84
+ for (const layer of layers) this.addLayer(layer);
85
+ },
86
+ _addZoomLimit(layer) {
87
+ if (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) {
88
+ this._zoomBoundLayers[stamp(layer)] = layer;
89
+ this._updateZoomLevels();
90
+ }
91
+ },
92
+ _removeZoomLimit(layer) {
93
+ const id = stamp(layer);
94
+ if (this._zoomBoundLayers[id]) {
95
+ delete this._zoomBoundLayers[id];
96
+ this._updateZoomLevels();
97
+ }
98
+ },
99
+ _updateZoomLevels() {
100
+ let minZoom = Infinity, maxZoom = -Infinity;
101
+ const oldZoomSpan = this._getZoomSpan();
102
+ for (const l of Object.values(this._zoomBoundLayers)) {
103
+ const options = l.options;
104
+ minZoom = Math.min(minZoom, options.minZoom ?? Infinity);
105
+ maxZoom = Math.max(maxZoom, options.maxZoom ?? -Infinity);
106
+ }
107
+ this._layersMaxZoom = maxZoom === -Infinity ? void 0 : maxZoom;
108
+ this._layersMinZoom = minZoom === Infinity ? void 0 : minZoom;
109
+ if (oldZoomSpan !== this._getZoomSpan()) this.fire("zoomlevelschange");
110
+ if (this.options.maxZoom === void 0 && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) this.setZoom(this._layersMaxZoom);
111
+ if (this.options.minZoom === void 0 && this._layersMinZoom && this.getZoom() < this._layersMinZoom) this.setZoom(this._layersMinZoom);
112
+ }
113
+ });
114
+ }
115
+ };
116
+ //#endregion
117
+ export { Layer };
118
+
119
+ //# sourceMappingURL=Layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Layer.js","names":["Util.stamp"],"sources":["../../../src/layer/Layer.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as Util from '../core/Util.js';\n\n/*\n * @class Layer\n * @inherits Evented\n * @aka ILayer\n *\n * A set of methods from the Layer base class that all Maplair layers use.\n * Inherits all methods, options and events from `Evented`.\n *\n * @example\n *\n * ```js\n * const layer = new Marker(latlng).addTo(map);\n * layer.addTo(map);\n * layer.remove();\n * ```\n *\n * @event add: Event\n * Fired after the layer is added to a map\n *\n * @event remove: Event\n * Fired after the layer is removed from a map\n */\n\nexport class Layer extends Evented {\n\n\tstatic {\n\t\t// Classes extending `Layer` will inherit the following options:\n\t\tthis.setDefaultOptions({\n\t\t\t// @option pane: String = 'overlayPane'\n\t\t\t// By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default.\n\t\t\t// Not effective if the `renderer` option is set (the `renderer` option will override the `pane` option).\n\t\t\tpane: 'overlayPane',\n\n\t\t\t// @option attribution: String = null\n\t\t\t// String to be shown in the attribution control, e.g. \"&copy; OpenStreetMap contributors\". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.\n\t\t\tattribution: null,\n\n\t\t\tbubblingPointerEvents: true\n\t\t});\n\t}\n\n\t/* @section\n\t * Classes extending `Layer` will inherit the following methods:\n\t *\n\t * @method addTo(map: MaplairMap|LayerGroup): this\n\t * Adds the layer to the given map or layer group.\n\t */\n\taddTo(map) {\n\t\tmap.addLayer(this);\n\t\treturn this;\n\t}\n\n\t// @method remove: this\n\t// Removes the layer from the map it is currently active on.\n\tremove() {\n\t\treturn this.removeFrom(this._map || this._mapToAdd);\n\t}\n\n\t// @method removeFrom(map: MaplairMap): this\n\t// Removes the layer from the given map\n\t//\n\t// @alternative\n\t// @method removeFrom(group: LayerGroup): this\n\t// Removes the layer from the given `LayerGroup`\n\tremoveFrom(obj) {\n\t\tobj?.removeLayer(this);\n\t\treturn this;\n\t}\n\n\t// @method getPane(name? : String): HTMLElement\n\t// Returns the `HTMLElement` representing the named pane on the map. If `name` is omitted, returns the pane for this layer.\n\tgetPane(name) {\n\t\treturn this._map.getPane(name ? (this.options[name] || name) : this.options.pane);\n\t}\n\n\taddInteractiveTarget(targetEl) {\n\t\tthis._map._targets[Util.stamp(targetEl)] = this;\n\t\treturn this;\n\t}\n\n\tremoveInteractiveTarget(targetEl) {\n\t\tdelete this._map._targets[Util.stamp(targetEl)];\n\t\treturn this;\n\t}\n\n\t// @method getAttribution: String\n\t// Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution).\n\tgetAttribution() {\n\t\treturn this.options.attribution;\n\t}\n\n\t_layerAdd(e) {\n\t\tconst map = e.target;\n\n\t\t// check in case layer gets added and then removed before the map is ready\n\t\tif (!map.hasLayer(this)) { return; }\n\n\t\tthis._map = map;\n\t\tthis._zoomAnimated = map._zoomAnimated;\n\n\t\tif (this.getEvents) {\n\t\t\tconst events = this.getEvents();\n\t\t\tmap.on(events, this);\n\t\t\tthis.once('remove', () => map.off(events, this));\n\t\t}\n\n\t\tthis.onAdd(map);\n\n\t\tthis.fire('add');\n\t\tmap.fire('layeradd', {layer: this});\n\t}\n\n\t// Registers this default feature on the map class, called by `MaplairMap` itself.\n\tstatic register(MaplairMap) {\n\t\t/* @namespace MaplairMap\n\t\t * @section Layer events\n\t\t *\n\t\t * @event layeradd: LayerEvent\n\t\t * Fired when a new layer is added to the map.\n\t\t *\n\t\t * @event layerremove: LayerEvent\n\t\t * Fired when some layer is removed from the map\n\t\t *\n\t\t * @section Methods for Layers and Controls\n\t\t */\n\t\tMaplairMap.include({\n\t\t\t// @method addLayer(layer: Layer): this\n\t\t\t// Adds the given layer to the map\n\t\t\taddLayer(layer) {\n\t\t\t\tif (!layer._layerAdd) {\n\t\t\t\t\tthrow new Error('The provided object is not a Layer.');\n\t\t\t\t}\n\n\t\t\t\tconst id = Util.stamp(layer);\n\t\t\t\tif (this._layers[id]) { return this; }\n\t\t\t\tthis._layers[id] = layer;\n\n\t\t\t\tlayer._mapToAdd = this;\n\n\t\t\t\tif (layer.beforeAdd) {\n\t\t\t\t\tlayer.beforeAdd(this);\n\t\t\t\t}\n\n\t\t\t\tthis.whenReady(layer._layerAdd, layer);\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method removeLayer(layer: Layer): this\n\t\t\t// Removes the given layer from the map.\n\t\t\tremoveLayer(layer) {\n\t\t\t\tconst id = Util.stamp(layer);\n\n\t\t\t\tif (!this._layers[id]) { return this; }\n\n\t\t\t\tif (this._loaded) {\n\t\t\t\t\tlayer.onRemove(this);\n\t\t\t\t}\n\n\t\t\t\tdelete this._layers[id];\n\n\t\t\t\tif (this._loaded) {\n\t\t\t\t\tthis.fire('layerremove', {layer});\n\t\t\t\t\tlayer.fire('remove');\n\t\t\t\t}\n\n\t\t\t\tlayer._map = layer._mapToAdd = null;\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method hasLayer(layer: Layer): Boolean\n\t\t\t// Returns `true` if the given layer is currently added to the map\n\t\t\thasLayer(layer) {\n\t\t\t\treturn Util.stamp(layer) in this._layers;\n\t\t\t},\n\n\t\t\t/* @method eachLayer(fn: Function, context?: Object): this\n\t\t\t * Iterates over the layers of the map, optionally specifying context of the iterator function.\n\t\t\t * ```\n\t\t\t * map.eachLayer(function(layer){\n\t\t\t * layer.bindPopup('Hello');\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\teachLayer(method, context) {\n\t\t\t\tfor (const layer of Object.values(this._layers)) {\n\t\t\t\t\tmethod.call(context, layer);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t_addLayers(layers) {\n\t\t\t\tlayers = layers ? (Array.isArray(layers) ? layers : [layers]) : [];\n\n\t\t\t\tfor (const layer of layers) {\n\t\t\t\t\tthis.addLayer(layer);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t_addZoomLimit(layer) {\n\t\t\t\tif (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) {\n\t\t\t\t\tthis._zoomBoundLayers[Util.stamp(layer)] = layer;\n\t\t\t\t\tthis._updateZoomLevels();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t_removeZoomLimit(layer) {\n\t\t\t\tconst id = Util.stamp(layer);\n\n\t\t\t\tif (this._zoomBoundLayers[id]) {\n\t\t\t\t\tdelete this._zoomBoundLayers[id];\n\t\t\t\t\tthis._updateZoomLevels();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t_updateZoomLevels() {\n\t\t\t\tlet minZoom = Infinity,\n\t\t\t\tmaxZoom = -Infinity;\n\t\t\t\tconst oldZoomSpan = this._getZoomSpan();\n\n\t\t\t\tfor (const l of Object.values(this._zoomBoundLayers)) {\n\t\t\t\t\tconst options = l.options;\n\t\t\t\t\tminZoom = Math.min(minZoom, options.minZoom ?? Infinity);\n\t\t\t\t\tmaxZoom = Math.max(maxZoom, options.maxZoom ?? -Infinity);\n\t\t\t\t}\n\n\t\t\t\tthis._layersMaxZoom = maxZoom === -Infinity ? undefined : maxZoom;\n\t\t\t\tthis._layersMinZoom = minZoom === Infinity ? undefined : minZoom;\n\n\t\t\t\t// @section Map state change events\n\t\t\t\t// @event zoomlevelschange: Event\n\t\t\t\t// Fired when the number of zoomlevels on the map is changed due\n\t\t\t\t// to adding or removing a layer.\n\t\t\t\tif (oldZoomSpan !== this._getZoomSpan()) {\n\t\t\t\t\tthis.fire('zoomlevelschange');\n\t\t\t\t}\n\n\t\t\t\tif (this.options.maxZoom === undefined && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) {\n\t\t\t\t\tthis.setZoom(this._layersMaxZoom);\n\t\t\t\t}\n\t\t\t\tif (this.options.minZoom === undefined && this._layersMinZoom && this.getZoom() < this._layersMinZoom) {\n\t\t\t\t\tthis.setZoom(this._layersMinZoom);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/* @namespace Layer\n * @section Extension methods\n * @uninheritable\n *\n * Every layer should extend from `Layer` and (re-)implement the following methods.\n *\n * @method onAdd(map: MaplairMap): this\n * Should contain code that creates DOM elements for the layer, adds them to `map panes` where they should belong and puts listeners on relevant map events. Called on [`map.addLayer(layer)`](#map-addlayer).\n *\n * @method onRemove(map: MaplairMap): this\n * Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in [`onAdd`](#layer-onadd). Called on [`map.removeLayer(layer)`](#map-removelayer).\n *\n * @method getEvents(): Object\n * This optional method should return an object like `{ viewreset: this._reset }` for [`on`](#evented-on). The event handlers in this object will be automatically added and removed from the map with your layer.\n *\n * @method getAttribution(): String\n * This optional method should return a string containing HTML to be shown on the `Attribution control` whenever the layer is visible.\n *\n * @method beforeAdd(map: MaplairMap): this\n * Optional method. Called on [`map.addLayer(layer)`](#map-addlayer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only.\n */\n"],"mappings":";;;AA0BA,IAAa,QAAb,cAA2B,QAAQ;CAElC;EAEC,KAAK,kBAAkB;GAItB,MAAM;GAIN,aAAa;GAEb,uBAAuB;EACxB,CAAC;CACF;CAQA,MAAM,KAAK;EACV,IAAI,SAAS,IAAI;EACjB,OAAO;CACR;CAIA,SAAS;EACR,OAAO,KAAK,WAAW,KAAK,QAAQ,KAAK,SAAS;CACnD;CAQA,WAAW,KAAK;EACf,KAAK,YAAY,IAAI;EACrB,OAAO;CACR;CAIA,QAAQ,MAAM;EACb,OAAO,KAAK,KAAK,QAAQ,OAAQ,KAAK,QAAQ,SAAS,OAAQ,KAAK,QAAQ,IAAI;CACjF;CAEA,qBAAqB,UAAU;EAC9B,KAAK,KAAK,SAASA,MAAW,QAAQ,KAAK;EAC3C,OAAO;CACR;CAEA,wBAAwB,UAAU;EACjC,OAAO,KAAK,KAAK,SAASA,MAAW,QAAQ;EAC7C,OAAO;CACR;CAIA,iBAAiB;EAChB,OAAO,KAAK,QAAQ;CACrB;CAEA,UAAU,GAAG;EACZ,MAAM,MAAM,EAAE;EAGd,IAAI,CAAC,IAAI,SAAS,IAAI,GAAK;EAE3B,KAAK,OAAO;EACZ,KAAK,gBAAgB,IAAI;EAEzB,IAAI,KAAK,WAAW;GACnB,MAAM,SAAS,KAAK,UAAU;GAC9B,IAAI,GAAG,QAAQ,IAAI;GACnB,KAAK,KAAK,gBAAgB,IAAI,IAAI,QAAQ,IAAI,CAAC;EAChD;EAEA,KAAK,MAAM,GAAG;EAEd,KAAK,KAAK,KAAK;EACf,IAAI,KAAK,YAAY,EAAC,OAAO,KAAI,CAAC;CACnC;CAGA,OAAO,SAAS,YAAY;EAY3B,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C7B,KAAK,kBAAkB;IACxB;GACD;GAEA,oBAAoB;IACnB,IAAI,UAAU,UACd,UAAU;IACV,MAAM,cAAc,KAAK,aAAa;IAEtC,KAAK,MAAM,KAAK,OAAO,OAAO,KAAK,gBAAgB,GAAG;KACrD,MAAM,UAAU,EAAE;KAClB,UAAU,KAAK,IAAI,SAAS,QAAQ,WAAW,QAAQ;KACvD,UAAU,KAAK,IAAI,SAAS,QAAQ,WAAW,SAAS;IACzD;IAEA,KAAK,iBAAiB,YAAY,YAAY,KAAA,IAAY;IAC1D,KAAK,iBAAiB,YAAY,WAAW,KAAA,IAAY;IAMzD,IAAI,gBAAgB,KAAK,aAAa,GACrC,KAAK,KAAK,kBAAkB;IAG7B,IAAI,KAAK,QAAQ,YAAY,KAAA,KAAa,KAAK,kBAAkB,KAAK,QAAQ,IAAI,KAAK,gBACtF,KAAK,QAAQ,KAAK,cAAc;IAEjC,IAAI,KAAK,QAAQ,YAAY,KAAA,KAAa,KAAK,kBAAkB,KAAK,QAAQ,IAAI,KAAK,gBACtF,KAAK,QAAQ,KAAK,cAAc;GAElC;EACD,CAAC;CACF;AACD"}
@@ -0,0 +1,58 @@
1
+ import { setOptions, stamp } from "../core/Util.js";
2
+ import { Layer } from "./Layer.js";
3
+ //#region src/layer/LayerGroup.js
4
+ var LayerGroup = class LayerGroup extends Layer {
5
+ constructor(layers, options) {
6
+ super();
7
+ setOptions(this, options);
8
+ this._layers = {};
9
+ for (const layer of layers ?? []) this.addLayer(layer);
10
+ this.callInitHooks(LayerGroup);
11
+ }
12
+ addLayer(layer) {
13
+ const id = this.getLayerId(layer);
14
+ this._layers[id] = layer;
15
+ this._map?.addLayer(layer);
16
+ return this;
17
+ }
18
+ removeLayer(layer) {
19
+ const id = layer in this._layers ? layer : this.getLayerId(layer);
20
+ if (this._map && this._layers[id]) this._map.removeLayer(this._layers[id]);
21
+ delete this._layers[id];
22
+ return this;
23
+ }
24
+ hasLayer(layer) {
25
+ return (typeof layer === "number" ? layer : this.getLayerId(layer)) in this._layers;
26
+ }
27
+ clearLayers() {
28
+ return this.eachLayer(this.removeLayer, this);
29
+ }
30
+ onAdd(map) {
31
+ this.eachLayer(map.addLayer, map);
32
+ }
33
+ onRemove(map) {
34
+ this.eachLayer(map.removeLayer, map);
35
+ }
36
+ eachLayer(method, context) {
37
+ for (const layer of Object.values(this._layers)) method.call(context, layer);
38
+ return this;
39
+ }
40
+ getLayer(id) {
41
+ return this._layers[id];
42
+ }
43
+ getLayers() {
44
+ const layers = [];
45
+ this.eachLayer(layers.push, layers);
46
+ return layers;
47
+ }
48
+ setZIndex(zIndex) {
49
+ return this.eachLayer((l) => l.setZIndex?.(zIndex));
50
+ }
51
+ getLayerId(layer) {
52
+ return stamp(layer);
53
+ }
54
+ };
55
+ //#endregion
56
+ export { LayerGroup };
57
+
58
+ //# sourceMappingURL=LayerGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayerGroup.js","names":["Util.stamp"],"sources":["../../../src/layer/LayerGroup.js"],"sourcesContent":["\nimport {Layer} from './Layer.js';\nimport * as Util from '../core/Util.js';\n\n/*\n * @class LayerGroup\n * @inherits Interactive layer\n *\n * Used to group several layers and handle them as one. If you add it to the map,\n * any layers added or removed from the group will be added/removed on the map as\n * well. Extends `Layer`.\n *\n * @example\n *\n * ```js\n * new LayerGroup([marker1, marker2])\n * \t.addLayer(polyline)\n * \t.addTo(map);\n * ```\n */\n\n// @constructor LayerGroup(layers?: Layer[], options?: Object)\n// Create a layer group, optionally given an initial set of layers and an `options` object.\nexport class LayerGroup extends Layer {\n\n\tconstructor(layers, options) { // for compatibility of code using `LayerGroup.extend`\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis._layers = {};\n\n\t\tfor (const layer of layers ?? []) {\n\t\t\tthis.addLayer(layer);\n\t\t}\n\n\t\tthis.callInitHooks(LayerGroup);\n\t}\n\n\t// @method addLayer(layer: Layer): this\n\t// Adds the given layer to the group.\n\taddLayer(layer) {\n\t\tconst id = this.getLayerId(layer);\n\n\t\tthis._layers[id] = layer;\n\n\t\tthis._map?.addLayer(layer);\n\n\t\treturn this;\n\t}\n\n\t// @method removeLayer(layer: Layer): this\n\t// Removes the given layer from the group.\n\t// @alternative\n\t// @method removeLayer(id: Number): this\n\t// Removes the layer with the given internal ID from the group.\n\tremoveLayer(layer) {\n\t\tconst id = layer in this._layers ? layer : this.getLayerId(layer);\n\n\t\tif (this._map && this._layers[id]) {\n\t\t\tthis._map.removeLayer(this._layers[id]);\n\t\t}\n\n\t\tdelete this._layers[id];\n\n\t\treturn this;\n\t}\n\n\t// @method hasLayer(layer: Layer): Boolean\n\t// Returns `true` if the given layer is currently added to the group.\n\t// @alternative\n\t// @method hasLayer(id: Number): Boolean\n\t// Returns `true` if the given internal ID is currently added to the group.\n\thasLayer(layer) {\n\t\tconst layerId = typeof layer === 'number' ? layer : this.getLayerId(layer);\n\t\treturn layerId in this._layers;\n\t}\n\n\t// @method clearLayers(): this\n\t// Removes all the layers from the group.\n\tclearLayers() {\n\t\treturn this.eachLayer(this.removeLayer, this);\n\t}\n\n\tonAdd(map) {\n\t\tthis.eachLayer(map.addLayer, map);\n\t}\n\n\tonRemove(map) {\n\t\tthis.eachLayer(map.removeLayer, map);\n\t}\n\n\t// @method eachLayer(fn: Function, context?: Object): this\n\t// Iterates over the layers of the group, optionally specifying context of the iterator function.\n\t// ```js\n\t// group.eachLayer(layer => layer.bindPopup('Hello'));\n\t// ```\n\teachLayer(method, context) {\n\t\tfor (const layer of Object.values(this._layers)) {\n\t\t\tmethod.call(context, layer);\n\t\t}\n\t\treturn this;\n\t}\n\n\t// @method getLayer(id: Number): Layer\n\t// Returns the layer with the given internal ID.\n\tgetLayer(id) {\n\t\treturn this._layers[id];\n\t}\n\n\t// @method getLayers(): Layer[]\n\t// Returns an array of all the layers added to the group.\n\tgetLayers() {\n\t\tconst layers = [];\n\t\tthis.eachLayer(layers.push, layers);\n\t\treturn layers;\n\t}\n\n\t// @method setZIndex(zIndex: Number): this\n\t// Calls `setZIndex` on every layer contained in this group, passing the z-index.\n\tsetZIndex(zIndex) {\n\t\treturn this.eachLayer(l => l.setZIndex?.(zIndex));\n\t}\n\n\t// @method getLayerId(layer: Layer): Number\n\t// Returns the internal ID for a layer\n\tgetLayerId(layer) {\n\t\treturn Util.stamp(layer);\n\t}\n}\n"],"mappings":";;;AAuBA,IAAa,aAAb,MAAa,mBAAmB,MAAM;CAErC,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAE7B,KAAK,UAAU,CAAC;EAEhB,KAAK,MAAM,SAAS,UAAU,CAAC,GAC9B,KAAK,SAAS,KAAK;EAGpB,KAAK,cAAc,UAAU;CAC9B;CAIA,SAAS,OAAO;EACf,MAAM,KAAK,KAAK,WAAW,KAAK;EAEhC,KAAK,QAAQ,MAAM;EAEnB,KAAK,MAAM,SAAS,KAAK;EAEzB,OAAO;CACR;CAOA,YAAY,OAAO;EAClB,MAAM,KAAK,SAAS,KAAK,UAAU,QAAQ,KAAK,WAAW,KAAK;EAEhE,IAAI,KAAK,QAAQ,KAAK,QAAQ,KAC7B,KAAK,KAAK,YAAY,KAAK,QAAQ,GAAG;EAGvC,OAAO,KAAK,QAAQ;EAEpB,OAAO;CACR;CAOA,SAAS,OAAO;EAEf,QADgB,OAAO,UAAU,WAAW,QAAQ,KAAK,WAAW,KAAK,MACvD,KAAK;CACxB;CAIA,cAAc;EACb,OAAO,KAAK,UAAU,KAAK,aAAa,IAAI;CAC7C;CAEA,MAAM,KAAK;EACV,KAAK,UAAU,IAAI,UAAU,GAAG;CACjC;CAEA,SAAS,KAAK;EACb,KAAK,UAAU,IAAI,aAAa,GAAG;CACpC;CAOA,UAAU,QAAQ,SAAS;EAC1B,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,OAAO,GAC7C,OAAO,KAAK,SAAS,KAAK;EAE3B,OAAO;CACR;CAIA,SAAS,IAAI;EACZ,OAAO,KAAK,QAAQ;CACrB;CAIA,YAAY;EACX,MAAM,SAAS,CAAC;EAChB,KAAK,UAAU,OAAO,MAAM,MAAM;EAClC,OAAO;CACR;CAIA,UAAU,QAAQ;EACjB,OAAO,KAAK,WAAU,MAAK,EAAE,YAAY,MAAM,CAAC;CACjD;CAIA,WAAW,OAAO;EACjB,OAAOA,MAAW,KAAK;CACxB;AACD"}
@@ -0,0 +1,224 @@
1
+ import { Point } from "../geometry/Point.js";
2
+ import Browser_default from "../core/Browser.js";
3
+ import { disableClickPropagation, disableScrollPropagation, on, stop, stopPropagation } from "../dom/DomEvent.js";
4
+ import { create, getPosition, setPosition } from "../dom/DomUtil.js";
5
+ import { I18n } from "../core/I18n.js";
6
+ import { Layer } from "./Layer.js";
7
+ import { FeatureGroup } from "./FeatureGroup.js";
8
+ import { Path } from "./vector/Path.js";
9
+ import { DivOverlay } from "./DivOverlay.js";
10
+ //#region src/layer/Popup.js
11
+ var Popup = class Popup extends DivOverlay {
12
+ static {
13
+ this.setDefaultOptions({
14
+ pane: "popupPane",
15
+ offset: [0, 7],
16
+ maxWidth: 300,
17
+ minWidth: 50,
18
+ maxHeight: null,
19
+ autoPan: !Browser_default.reducedMotion,
20
+ autoPanPaddingTopLeft: null,
21
+ autoPanPaddingBottomRight: null,
22
+ autoPanPadding: [5, 5],
23
+ keepInView: false,
24
+ closeButton: true,
25
+ autoClose: true,
26
+ closeOnEscapeKey: true,
27
+ className: "",
28
+ trackResize: true
29
+ });
30
+ }
31
+ constructor(...args) {
32
+ super(...args);
33
+ this.callInitHooks(Popup);
34
+ }
35
+ openOn(map) {
36
+ map = arguments.length ? map : this._source._map;
37
+ if (!map.hasLayer(this) && map._popup && map._popup.options.autoClose) map.removeLayer(map._popup);
38
+ map._popup = this;
39
+ return super.openOn(map);
40
+ }
41
+ onAdd(map) {
42
+ super.onAdd(map);
43
+ map.fire("popupopen", { popup: this });
44
+ if (this._source) {
45
+ this._source.fire("popupopen", { popup: this }, true);
46
+ if (!(this._source instanceof Path)) this._source.on("preclick", stopPropagation);
47
+ }
48
+ }
49
+ onRemove(map) {
50
+ super.onRemove(map);
51
+ map.fire("popupclose", { popup: this });
52
+ if (this._source) {
53
+ this._source.fire("popupclose", { popup: this }, true);
54
+ if (!(this._source instanceof Path)) this._source.off("preclick", stopPropagation);
55
+ }
56
+ }
57
+ getEvents() {
58
+ const events = super.getEvents();
59
+ if (this.options.closeOnClick ?? this._map.options.closePopupOnClick) events.preclick = this.close;
60
+ if (this.options.keepInView) events.moveend = this._adjustPan;
61
+ return events;
62
+ }
63
+ _initLayout() {
64
+ const prefix = "maplair-popup", container = this._container = create("div", `${prefix} ${this.options.className || ""} maplair-zoom-animated`);
65
+ const wrapper = this._wrapper = create("div", `${prefix}-content-wrapper`, container);
66
+ this._contentNode = create("div", `${prefix}-content`, wrapper);
67
+ disableClickPropagation(container);
68
+ disableScrollPropagation(this._contentNode);
69
+ on(container, "contextmenu", stopPropagation);
70
+ this._tipContainer = create("div", `${prefix}-tip-container`, container);
71
+ this._tip = create("div", `${prefix}-tip`, this._tipContainer);
72
+ if (this.options.closeButton) {
73
+ const closeButton = this._closeButton = create("a", `${prefix}-close-button`, container);
74
+ closeButton.setAttribute("role", "button");
75
+ closeButton.setAttribute("aria-label", I18n.translate("Close popup"));
76
+ closeButton.href = "#close";
77
+ closeButton.innerHTML = "<span aria-hidden=\"true\">&#215;</span>";
78
+ on(closeButton, "click", (ev) => {
79
+ ev.preventDefault();
80
+ this.close();
81
+ });
82
+ }
83
+ if (this.options.trackResize) {
84
+ this._resizeObserver = new ResizeObserver(((entries) => {
85
+ if (!this._map) return;
86
+ this._containerWidth = entries[0]?.contentRect?.width;
87
+ this._containerHeight = entries[0]?.contentRect?.height;
88
+ this._updateLayout();
89
+ this._updatePosition();
90
+ this._adjustPan();
91
+ }));
92
+ this._resizeObserver.observe(this._contentNode);
93
+ }
94
+ }
95
+ _updateLayout() {
96
+ const container = this._contentNode, style = container.style;
97
+ style.maxWidth = `${this.options.maxWidth}px`;
98
+ style.minWidth = `${this.options.minWidth}px`;
99
+ const maxHeight = this.options.maxHeight, scrolledClass = "maplair-popup-scrolled";
100
+ if (maxHeight && (this._containerHeight ?? container.offsetHeight) > maxHeight) {
101
+ style.height = `${maxHeight}px`;
102
+ container.classList.add(scrolledClass);
103
+ } else container.classList.remove(scrolledClass);
104
+ this._containerWidth = this._container.offsetWidth;
105
+ this._containerHeight = this._container.offsetHeight;
106
+ this._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;
107
+ }
108
+ _animateZoom(e) {
109
+ const pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center), anchor = this._getAnchor();
110
+ setPosition(this._container, pos.add(anchor));
111
+ }
112
+ _adjustPan() {
113
+ if (!this.options.autoPan) return;
114
+ this._map._panAnim?.stop();
115
+ if (this._autopanning) {
116
+ this._autopanning = false;
117
+ return;
118
+ }
119
+ const map = this._map, marginBottom = this._containerMarginBottom ?? (parseInt(getComputedStyle(this._container).marginBottom, 10) || 0), containerHeight = this._containerHeight + marginBottom, containerWidth = this._containerWidth, layerPos = new Point(this._containerLeft, -containerHeight - this._containerBottom);
120
+ layerPos._add(getPosition(this._container));
121
+ const containerPos = map.layerPointToContainerPoint(layerPos), padding = new Point(this.options.autoPanPadding), paddingTL = new Point(this.options.autoPanPaddingTopLeft ?? padding), paddingBR = new Point(this.options.autoPanPaddingBottomRight ?? padding), size = map.getSize();
122
+ let dx = 0, dy = 0;
123
+ if (containerPos.x + containerWidth + paddingBR.x > size.x) dx = containerPos.x + containerWidth - size.x + paddingBR.x;
124
+ if (containerPos.x - dx - paddingTL.x < 0) dx = containerPos.x - paddingTL.x;
125
+ if (containerPos.y + containerHeight + paddingBR.y > size.y) dy = containerPos.y + containerHeight - size.y + paddingBR.y;
126
+ if (containerPos.y - dy - paddingTL.y < 0) dy = containerPos.y - paddingTL.y;
127
+ if (dx || dy) {
128
+ if (this.options.keepInView) this._autopanning = true;
129
+ map.fire("autopanstart").panBy([dx, dy]);
130
+ }
131
+ }
132
+ _getAnchor() {
133
+ return new Point(this._source?._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);
134
+ }
135
+ static register(MaplairMap) {
136
+ MaplairMap.mergeOptions({ closePopupOnClick: true });
137
+ MaplairMap.include({
138
+ openPopup(popup, latlng, options) {
139
+ this._initOverlay(Popup, popup, latlng, options).openOn(this);
140
+ return this;
141
+ },
142
+ closePopup(popup) {
143
+ popup = arguments.length ? popup : this._popup;
144
+ popup?.close();
145
+ return this;
146
+ }
147
+ });
148
+ Layer.include({
149
+ bindPopup(content, options) {
150
+ this._popup = this._initOverlay(Popup, this._popup, content, options);
151
+ if (!this._popupHandlersAdded) {
152
+ this.on({
153
+ click: this._openPopup,
154
+ keypress: this._onKeyPress,
155
+ remove: this.closePopup,
156
+ move: this._movePopup
157
+ });
158
+ this._popupHandlersAdded = true;
159
+ }
160
+ return this;
161
+ },
162
+ unbindPopup() {
163
+ if (this._popup) {
164
+ this.off({
165
+ click: this._openPopup,
166
+ keypress: this._onKeyPress,
167
+ remove: this.closePopup,
168
+ move: this._movePopup
169
+ });
170
+ this._popupHandlersAdded = false;
171
+ this._popup = null;
172
+ }
173
+ return this;
174
+ },
175
+ openPopup(latlng) {
176
+ if (this._popup) {
177
+ if (!(this instanceof FeatureGroup)) this._popup._source = this;
178
+ if (this._popup._prepareOpen(latlng || this._latlng)) this._popup.openOn(this._map);
179
+ }
180
+ return this;
181
+ },
182
+ closePopup() {
183
+ this._popup?.close();
184
+ return this;
185
+ },
186
+ togglePopup() {
187
+ this._popup?.toggle(this);
188
+ return this;
189
+ },
190
+ isPopupOpen() {
191
+ return this._popup?.isOpen() ?? false;
192
+ },
193
+ setPopupContent(content) {
194
+ this._popup?.setContent(content);
195
+ return this;
196
+ },
197
+ getPopup() {
198
+ return this._popup;
199
+ },
200
+ _openPopup(e) {
201
+ if (!this._popup || !this._map) return;
202
+ stop(e);
203
+ const target = e.propagatedFrom ?? e.target;
204
+ if (this._popup._source === target && !(target instanceof Path)) {
205
+ if (this._map.hasLayer(this._popup)) this.closePopup();
206
+ else this.openPopup(e.latlng);
207
+ return;
208
+ }
209
+ this._popup._source = target;
210
+ this.openPopup(e.latlng);
211
+ },
212
+ _movePopup(e) {
213
+ this._popup.setLatLng(e.latlng);
214
+ },
215
+ _onKeyPress(e) {
216
+ if (e.originalEvent.code === "Enter") this._openPopup(e);
217
+ }
218
+ });
219
+ }
220
+ };
221
+ //#endregion
222
+ export { Popup };
223
+
224
+ //# sourceMappingURL=Popup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.js","names":["Browser","DomEvent.stopPropagation","DomUtil.create","DomUtil.getPosition"],"sources":["../../../src/layer/Popup.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport Browser from '../core/Browser.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport {Path} from './vector/Path.js';\nimport {FeatureGroup} from './FeatureGroup.js';\nimport {I18n} from '../core/I18n.js';\n\n/*\n * @class Popup\n * @inherits DivOverlay\n * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to\n * open popups while making sure that only one popup is open at one time\n * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want.\n *\n * @example\n *\n * If you want to just bind a popup to marker click and then open it, it's really easy:\n *\n * ```js\n * marker.bindPopup(popupContent).openPopup();\n * ```\n * Path overlays like polylines also have a `bindPopup` method.\n *\n * A popup can be also standalone:\n *\n * ```js\n * const popup = new Popup()\n * \t.setLatLng(latlng)\n * \t.setContent('<p>Hello world!<br />This is a nice popup.</p>')\n * \t.openOn(map);\n * ```\n * or\n * ```js\n * const popup = new Popup(latlng, {content: '<p>Hello world!<br />This is a nice popup.</p>'})\n * \t.openOn(map);\n * ```\n *\n * **Security note.** Popup string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindPopup(el);\n * ```\n */\n\n// @namespace Popup\n// @constructor Popup(options?: Popup options, source?: Layer)\n// Instantiates a `Popup` object given an optional `options` object that describes its appearance and location and an optional `source` object that is used to tag the popup with a reference to the Layer to which it refers.\n// @alternative\n// @constructor Popup(latlng: LatLng, options?: Popup options)\n// Instantiates a `Popup` object given `latlng` where the popup will open and an optional `options` object that describes its appearance and location.\nexport class Popup extends DivOverlay {\n\n\tstatic {\n\t\t// @section\n\t\t// @aka Popup options\n\t\tthis.setDefaultOptions({\n\t\t\t// @option pane: String = 'popupPane'\n\t\t\t// `Map pane` where the popup will be added.\n\t\t\tpane: 'popupPane',\n\n\t\t\t// @option offset: Point = Point(0, 7)\n\t\t\t// The offset of the popup position.\n\t\t\toffset: [0, 7],\n\n\t\t\t// @option maxWidth: Number = 300\n\t\t\t// Max width of the popup, in pixels.\n\t\t\tmaxWidth: 300,\n\n\t\t\t// @option minWidth: Number = 50\n\t\t\t// Min width of the popup, in pixels.\n\t\t\tminWidth: 50,\n\n\t\t\t// @option maxHeight: Number = null\n\t\t\t// If set, creates a scrollable container of the given height\n\t\t\t// inside a popup if its content exceeds it.\n\t\t\t// The scrollable container can be styled using the\n\t\t\t// `maplair-popup-scrolled` CSS class selector.\n\t\t\tmaxHeight: null,\n\n\t\t\t// @option autoPan: Boolean = true\n\t\t\t// Set it to `false` if you don't want the map to do panning animation\n\t\t\t// to fit the opened popup.\n\t\t\tautoPan: !Browser.reducedMotion,\n\n\t\t\t// @option autoPanPaddingTopLeft: Point = null\n\t\t\t// The margin between the popup and the top left corner of the map\n\t\t\t// view after autopanning was performed.\n\t\t\tautoPanPaddingTopLeft: null,\n\n\t\t\t// @option autoPanPaddingBottomRight: Point = null\n\t\t\t// The margin between the popup and the bottom right corner of the map\n\t\t\t// view after autopanning was performed.\n\t\t\tautoPanPaddingBottomRight: null,\n\n\t\t\t// @option autoPanPadding: Point = Point(5, 5)\n\t\t\t// Equivalent of setting both top left and bottom right autopan padding to the same value.\n\t\t\tautoPanPadding: [5, 5],\n\n\t\t\t// @option keepInView: Boolean = false\n\t\t\t// Set it to `true` if you want to prevent users from panning the popup\n\t\t\t// off of the screen while it is open.\n\t\t\tkeepInView: false,\n\n\t\t\t// @option closeButton: Boolean = true\n\t\t\t// Controls the presence of a close button in the popup.\n\t\t\tcloseButton: true,\n\n\t\t\t// @option autoClose: Boolean = true\n\t\t\t// Set it to `false` if you want to override the default behavior of\n\t\t\t// the popup closing when another popup is opened.\n\t\t\tautoClose: true,\n\n\t\t\t// @option closeOnEscapeKey: Boolean = true\n\t\t\t// Set it to `false` if you want to override the default behavior of\n\t\t\t// the ESC key for closing of the popup.\n\t\t\tcloseOnEscapeKey: true,\n\n\t\t\t// @option closeOnClick: Boolean = *\n\t\t\t// Set it if you want to override the default behavior of the popup closing when user clicks\n\t\t\t// on the map. Defaults to the map's [`closePopupOnClick`](#map-closepopuponclick) option.\n\n\t\t\t// @option className: String = ''\n\t\t\t// A custom CSS class name to assign to the popup.\n\t\t\tclassName: '',\n\n\t\t\t// @option trackResize: Boolean = true\n\t\t\t// Whether the popup shall react to changes in the size of its contents\n\t\t\t// (e.g. when an image inside the popup loads) and reposition itself.\n\t\t\ttrackResize: true,\n\t\t});\n\t}\n\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Popup);\n\t}\n\n\t// @namespace Popup\n\t// @method openOn(map: MaplairMap): this\n\t// Alternative to `map.openPopup(popup)`.\n\t// Adds the popup to the map and closes the previous one.\n\topenOn(map) {\n\t\tmap = arguments.length ? map : this._source._map; // experimental, not the part of public api\n\n\t\tif (!map.hasLayer(this) && map._popup && map._popup.options.autoClose) {\n\t\t\tmap.removeLayer(map._popup);\n\t\t}\n\t\tmap._popup = this;\n\n\t\treturn super.openOn(map);\n\t}\n\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\n\t\t// @namespace MaplairMap\n\t\t// @section Popup events\n\t\t// @event popupopen: PopupEvent\n\t\t// Fired when a popup is opened in the map\n\t\tmap.fire('popupopen', {popup: this});\n\n\t\tif (this._source) {\n\t\t\t// @namespace Layer\n\t\t\t// @section Popup events\n\t\t\t// @event popupopen: PopupEvent\n\t\t\t// Fired when a popup bound to this layer is opened\n\t\t\tthis._source.fire('popupopen', {popup: this}, true);\n\t\t\t// For non-path layers, we toggle the popup when clicking\n\t\t\t// again the layer, so prevent the map to reopen it.\n\t\t\tif (!(this._source instanceof Path)) {\n\t\t\t\tthis._source.on('preclick', DomEvent.stopPropagation);\n\t\t\t}\n\t\t}\n\t}\n\n\tonRemove(map) {\n\t\tsuper.onRemove(map);\n\n\t\t// @namespace MaplairMap\n\t\t// @section Popup events\n\t\t// @event popupclose: PopupEvent\n\t\t// Fired when a popup in the map is closed\n\t\tmap.fire('popupclose', {popup: this});\n\n\t\tif (this._source) {\n\t\t\t// @namespace Layer\n\t\t\t// @section Popup events\n\t\t\t// @event popupclose: PopupEvent\n\t\t\t// Fired when a popup bound to this layer is closed\n\t\t\tthis._source.fire('popupclose', {popup: this}, true);\n\t\t\tif (!(this._source instanceof Path)) {\n\t\t\t\tthis._source.off('preclick', DomEvent.stopPropagation);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (this.options.closeOnClick ?? this._map.options.closePopupOnClick) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\tif (this.options.keepInView) {\n\t\t\tevents.moveend = this._adjustPan;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-popup',\n\t\tcontainer = this._container = DomUtil.create('div', `${prefix} ${this.options.className || ''} maplair-zoom-animated`);\n\n\t\tconst wrapper = this._wrapper = DomUtil.create('div', `${prefix}-content-wrapper`, container);\n\t\tthis._contentNode = DomUtil.create('div', `${prefix}-content`, wrapper);\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(this._contentNode);\n\t\tDomEvent.on(container, 'contextmenu', DomEvent.stopPropagation);\n\n\t\tthis._tipContainer = DomUtil.create('div', `${prefix}-tip-container`, container);\n\t\tthis._tip = DomUtil.create('div', `${prefix}-tip`, this._tipContainer);\n\n\t\tif (this.options.closeButton) {\n\t\t\tconst closeButton = this._closeButton = DomUtil.create('a', `${prefix}-close-button`, container);\n\t\t\tcloseButton.setAttribute('role', 'button'); // overrides the implicit role=link of <a> elements #7399\n\t\t\tcloseButton.setAttribute('aria-label', I18n.translate('Close popup'));\n\n\t\t\tcloseButton.href = '#close';\n\t\t\tcloseButton.innerHTML = '<span aria-hidden=\"true\">&#215;</span>';\n\n\t\t\tDomEvent.on(closeButton, 'click', (ev) => {\n\t\t\t\tev.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.trackResize) {\n\t\t\tthis._resizeObserver = new ResizeObserver(((entries) => {\n\t\t\t\tif (!this._map) { return; }\n\t\t\t\tthis._containerWidth = entries[0]?.contentRect?.width;\n\t\t\t\tthis._containerHeight = entries[0]?.contentRect?.height;\n\n\t\t\t\tthis._updateLayout();\n\t\t\t\tthis._updatePosition();\n\t\t\t\tthis._adjustPan();\n\t\t\t}));\n\n\t\t\tthis._resizeObserver.observe(this._contentNode);\n\t\t}\n\t}\n\n\t_updateLayout() {\n\t\tconst container = this._contentNode,\n\t\tstyle = container.style;\n\n\t\tstyle.maxWidth = `${this.options.maxWidth}px`;\n\t\tstyle.minWidth = `${this.options.minWidth}px`;\n\n\t\tconst maxHeight = this.options.maxHeight,\n\t\tscrolledClass = 'maplair-popup-scrolled';\n\n\t\t// only measure the height (forcing a layout) if needed\n\t\tif (maxHeight && (this._containerHeight ?? container.offsetHeight) > maxHeight) {\n\t\t\tstyle.height = `${maxHeight}px`;\n\t\t\tcontainer.classList.add(scrolledClass);\n\t\t} else {\n\t\t\tcontainer.classList.remove(scrolledClass);\n\t\t}\n\n\t\tthis._containerWidth = this._container.offsetWidth;\n\t\tthis._containerHeight = this._container.offsetHeight;\n\t\t// read along with the size, so that _adjustPan doesn't force another style\n\t\t// recalculation and layout after the popup has been positioned\n\t\tthis._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),\n\t\tanchor = this._getAnchor();\n\t\tDomUtil.setPosition(this._container, pos.add(anchor));\n\t}\n\n\t_adjustPan() {\n\t\tif (!this.options.autoPan) { return; }\n\t\tthis._map._panAnim?.stop();\n\n\t\t// We can endlessly recurse if keepInView is set and the view resets.\n\t\t// Let's guard against that by exiting early if we're responding to our own autopan.\n\t\tif (this._autopanning) {\n\t\t\tthis._autopanning = false;\n\t\t\treturn;\n\t\t}\n\n\t\tconst map = this._map,\n\t\tmarginBottom = this._containerMarginBottom ?? (parseInt(getComputedStyle(this._container).marginBottom, 10) || 0),\n\t\tcontainerHeight = this._containerHeight + marginBottom,\n\t\tcontainerWidth = this._containerWidth,\n\t\tlayerPos = new Point(this._containerLeft, -containerHeight - this._containerBottom);\n\n\t\tlayerPos._add(DomUtil.getPosition(this._container));\n\n\t\tconst containerPos = map.layerPointToContainerPoint(layerPos),\n\t\tpadding = new Point(this.options.autoPanPadding),\n\t\tpaddingTL = new Point(this.options.autoPanPaddingTopLeft ?? padding),\n\t\tpaddingBR = new Point(this.options.autoPanPaddingBottomRight ?? padding),\n\t\tsize = map.getSize();\n\t\tlet dx = 0,\n\t\tdy = 0;\n\n\t\tif (containerPos.x + containerWidth + paddingBR.x > size.x) { // right\n\t\t\tdx = containerPos.x + containerWidth - size.x + paddingBR.x;\n\t\t}\n\t\tif (containerPos.x - dx - paddingTL.x < 0) { // left\n\t\t\tdx = containerPos.x - paddingTL.x;\n\t\t}\n\t\tif (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom\n\t\t\tdy = containerPos.y + containerHeight - size.y + paddingBR.y;\n\t\t}\n\t\tif (containerPos.y - dy - paddingTL.y < 0) { // top\n\t\t\tdy = containerPos.y - paddingTL.y;\n\t\t}\n\n\t\t// @namespace MaplairMap\n\t\t// @section Popup events\n\t\t// @event autopanstart: Event\n\t\t// Fired when the map starts autopanning when opening a popup.\n\t\tif (dx || dy) {\n\t\t\t// Track that we're autopanning, as this function will be re-ran on moveend\n\t\t\tif (this.options.keepInView) {\n\t\t\t\tthis._autopanning = true;\n\t\t\t}\n\n\t\t\tmap\n\t\t\t\t.fire('autopanstart')\n\t\t\t\t.panBy([dx, dy]);\n\t\t}\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the popup on the source layer?\n\t\treturn new Point(this._source?._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);\n\t}\n\n\t// Registers this default feature on the map class, called by `MaplairMap` itself.\n\tstatic register(MaplairMap) {\n\t\t/* @namespace MaplairMap\n\t\t * @section Interaction Options\n\t\t * @option closePopupOnClick: Boolean = true\n\t\t * Set it to `false` if you don't want popups to close when user clicks the map.\n\t\t */\n\t\tMaplairMap.mergeOptions({\n\t\t\tclosePopupOnClick: true\n\t\t});\n\n\t\t// @namespace MaplairMap\n\t\t// @section Methods for Layers and Controls\n\t\tMaplairMap.include({\n\t\t\t// @method openPopup(popup: Popup): this\n\t\t\t// Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).\n\t\t\t// @alternative\n\t\t\t// @method openPopup(content: String|HTMLElement, latlng: LatLng, options?: Popup options): this\n\t\t\t// Creates a popup with the specified content and options and opens it in the given point on a map.\n\t\t\t// String content is rendered as HTML; sanitize untrusted input or pass an `HTMLElement` with safe `textContent` instead.\n\t\t\topenPopup(popup, latlng, options) {\n\t\t\t\tthis._initOverlay(Popup, popup, latlng, options)\n\t\t\t\t\t.openOn(this);\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method closePopup(popup?: Popup): this\n\t\t\t// Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one).\n\t\t\tclosePopup(popup) {\n\t\t\t\tpopup = arguments.length ? popup : this._popup;\n\t\t\t\tpopup?.close();\n\t\t\t\treturn this;\n\t\t\t}\n\t\t});\n\n\t\t/*\n\t\t * @namespace Layer\n\t\t * @section Popup methods example\n\t\t *\n\t\t * All layers share a set of methods convenient for binding popups to it.\n\t\t *\n\t\t * ```js\n\t\t * const layer = new Polygon(latlngs).bindPopup('Hi There!').addTo(map);\n\t\t * layer.openPopup();\n\t\t * layer.closePopup();\n\t\t * ```\n\t\t *\n\t\t * Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened.\n\t\t */\n\n\t\t// @section Popup methods\n\t\tLayer.include({\n\n\t\t\t// @method bindPopup(content: String|HTMLElement|Function|Popup, options?: Popup options): this\n\t\t\t// Binds a popup to the layer with the passed `content` and sets up the\n\t\t\t// necessary event listeners. A `String` argument is rendered as HTML; if it\n\t\t\t// may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an\n\t\t\t// `HTMLElement` with safe `textContent` instead. If a `Function` is passed\n\t\t\t// it will receive the layer as the first argument and should return a\n\t\t\t// `String` or `HTMLElement`.\n\t\t\tbindPopup(content, options) {\n\t\t\t\tthis._popup = this._initOverlay(Popup, this._popup, content, options);\n\t\t\t\tif (!this._popupHandlersAdded) {\n\t\t\t\t\tthis.on({\n\t\t\t\t\t\tclick: this._openPopup,\n\t\t\t\t\t\tkeypress: this._onKeyPress,\n\t\t\t\t\t\tremove: this.closePopup,\n\t\t\t\t\t\tmove: this._movePopup\n\t\t\t\t\t});\n\t\t\t\t\tthis._popupHandlersAdded = true;\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method unbindPopup(): this\n\t\t\t// Removes the popup previously bound with `bindPopup`.\n\t\t\tunbindPopup() {\n\t\t\t\tif (this._popup) {\n\t\t\t\t\tthis.off({\n\t\t\t\t\t\tclick: this._openPopup,\n\t\t\t\t\t\tkeypress: this._onKeyPress,\n\t\t\t\t\t\tremove: this.closePopup,\n\t\t\t\t\t\tmove: this._movePopup\n\t\t\t\t\t});\n\t\t\t\t\tthis._popupHandlersAdded = false;\n\t\t\t\t\tthis._popup = null;\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method openPopup(latlng?: LatLng): this\n\t\t\t// Opens the bound popup at the specified `latlng` or at the default popup anchor if no `latlng` is passed.\n\t\t\topenPopup(latlng) {\n\t\t\t\tif (this._popup) {\n\t\t\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\t\t\tthis._popup._source = this;\n\t\t\t\t\t}\n\t\t\t\t\tif (this._popup._prepareOpen(latlng || this._latlng)) {\n\t\t\t\t\t\t// open the popup on the map\n\t\t\t\t\t\tthis._popup.openOn(this._map);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method closePopup(): this\n\t\t\t// Closes the popup bound to this layer if it is open.\n\t\t\tclosePopup() {\n\t\t\t\tthis._popup?.close();\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method togglePopup(): this\n\t\t\t// Opens or closes the popup bound to this layer depending on its current state.\n\t\t\ttogglePopup() {\n\t\t\t\tthis._popup?.toggle(this);\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method isPopupOpen(): boolean\n\t\t\t// Returns `true` if the popup bound to this layer is currently open.\n\t\t\tisPopupOpen() {\n\t\t\t\treturn this._popup?.isOpen() ?? false;\n\t\t\t},\n\n\t\t\t// @method setPopupContent(content: String|HTMLElement|Popup): this\n\t\t\t// Sets the content of the popup bound to this layer.\n\t\t\t// String content is rendered as HTML; sanitize untrusted input or pass an `HTMLElement` with safe `textContent` instead.\n\t\t\tsetPopupContent(content) {\n\t\t\t\tthis._popup?.setContent(content);\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// @method getPopup(): Popup\n\t\t\t// Returns the popup bound to this layer.\n\t\t\tgetPopup() {\n\t\t\t\treturn this._popup;\n\t\t\t},\n\n\t\t\t_openPopup(e) {\n\t\t\t\tif (!this._popup || !this._map) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// prevent map click\n\t\t\t\tDomEvent.stop(e);\n\n\t\t\t\tconst target = e.propagatedFrom ?? e.target;\n\t\t\t\tif (this._popup._source === target && !(target instanceof Path)) {\n\t\t\t\t\t// treat it like a marker and figure out\n\t\t\t\t\t// if we should toggle it open/closed\n\t\t\t\t\tif (this._map.hasLayer(this._popup)) {\n\t\t\t\t\t\tthis.closePopup();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.openPopup(e.latlng);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis._popup._source = target;\n\t\t\t\tthis.openPopup(e.latlng);\n\t\t\t},\n\n\t\t\t_movePopup(e) {\n\t\t\t\tthis._popup.setLatLng(e.latlng);\n\t\t\t},\n\n\t\t\t_onKeyPress(e) {\n\t\t\t\tif (e.originalEvent.code === 'Enter') {\n\t\t\t\t\tthis._openPopup(e);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;AA0DA,IAAa,QAAb,MAAa,cAAc,WAAW;CAErC;EAGC,KAAK,kBAAkB;GAGtB,MAAM;GAIN,QAAQ,CAAC,GAAG,CAAC;GAIb,UAAU;GAIV,UAAU;GAOV,WAAW;GAKX,SAAS,CAACA,gBAAQ;GAKlB,uBAAuB;GAKvB,2BAA2B;GAI3B,gBAAgB,CAAC,GAAG,CAAC;GAKrB,YAAY;GAIZ,aAAa;GAKb,WAAW;GAKX,kBAAkB;GAQlB,WAAW;GAKX,aAAa;EACd,CAAC;CACF;CAEA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,KAAK;CACzB;CAMA,OAAO,KAAK;EACX,MAAM,UAAU,SAAS,MAAM,KAAK,QAAQ;EAE5C,IAAI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K,QAAQ,OAAO,IAAI;IACxB,OAAO;GACR;GAIA,cAAc;IACb,OAAO,KAAK,QAAQ,OAAO,KAAK;GACjC;GAKA,gBAAgB,SAAS;IACxB,KAAK,QAAQ,WAAW,OAAO;IAC/B,OAAO;GACR;GAIA,WAAW;IACV,OAAO,KAAK;GACb;GAEA,WAAW,GAAG;IACb,IAAI,CAAC,KAAK,UAAU,CAAC,KAAK,MACzB;IAGD,KAAc,CAAC;IAEf,MAAM,SAAS,EAAE,kBAAkB,EAAE;IACrC,IAAI,KAAK,OAAO,YAAY,UAAU,EAAE,kBAAkB,OAAO;KAGhE,IAAI,KAAK,KAAK,SAAS,KAAK,MAAM,GACjC,KAAK,WAAW;UAEhB,KAAK,UAAU,EAAE,MAAM;KAExB;IACD;IACA,KAAK,OAAO,UAAU;IACtB,KAAK,UAAU,EAAE,MAAM;GACxB;GAEA,WAAW,GAAG;IACb,KAAK,OAAO,UAAU,EAAE,MAAM;GAC/B;GAEA,YAAY,GAAG;IACd,IAAI,EAAE,cAAc,SAAS,SAC5B,KAAK,WAAW,CAAC;GAEnB;EACD,CAAC;CACF;AACD"}
@@ -0,0 +1,21 @@
1
+ import { falseFn, splitWords } from "../core/Util.js";
2
+ import { ImageOverlay } from "./ImageOverlay.js";
3
+ //#region src/layer/SVGOverlay.js
4
+ var SVGOverlay = class SVGOverlay extends ImageOverlay {
5
+ constructor(...args) {
6
+ super(...args);
7
+ this.callInitHooks(SVGOverlay);
8
+ }
9
+ _initImage() {
10
+ const el = this._image = this._url;
11
+ el.classList.add("maplair-image-layer");
12
+ if (this._zoomAnimated) el.classList.add("maplair-zoom-animated");
13
+ if (this.options.className) el.classList.add(...splitWords(this.options.className));
14
+ el.onselectstart = falseFn;
15
+ el.onpointermove = falseFn;
16
+ }
17
+ };
18
+ //#endregion
19
+ export { SVGOverlay };
20
+
21
+ //# sourceMappingURL=SVGOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SVGOverlay.js","names":["Util.splitWords","Util.falseFn"],"sources":["../../../src/layer/SVGOverlay.js"],"sourcesContent":["import {ImageOverlay} from './ImageOverlay.js';\nimport * as Util from '../core/Util.js';\n\n/*\n * @class SVGOverlay\n * @inherits ImageOverlay\n *\n * Used to load, display and provide DOM access to an SVG file over specific bounds of the map. Extends `ImageOverlay`.\n *\n * An SVG overlay uses the [`<svg>`](https://developer.mozilla.org/docs/Web/SVG/Element/svg) element.\n *\n * @example\n *\n * ```js\n * const svgElement = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n * svgElement.setAttribute('xmlns', \"http://www.w3.org/2000/svg\");\n * svgElement.setAttribute('viewBox', \"0 0 200 200\");\n * svgElement.innerHTML = '<rect width=\"200\" height=\"200\"/><rect x=\"75\" y=\"23\" width=\"50\" height=\"50\" style=\"fill:red\"/><rect x=\"75\" y=\"123\" width=\"50\" height=\"50\" style=\"fill:#0013ff\"/>';\n * const svgElementBounds = [ [ 32, -130 ], [ 13, -100 ] ];\n * new SVGOverlay(svgElement, svgElementBounds).addTo(map);\n * ```\n */\n\n// @constructor SVGOverlay(svg: String|SVGElement, bounds: LatLngBounds, options?: SVGOverlay options)\n// Instantiates an image overlay object given an SVG element and the geographical bounds it is tied to.\n// A viewBox attribute is required on the SVG element to zoom in and out properly.\nexport class SVGOverlay extends ImageOverlay {\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(SVGOverlay);\n\t}\n\n\t_initImage() {\n\t\tconst el = this._image = this._url;\n\n\t\tel.classList.add('maplair-image-layer');\n\t\tif (this._zoomAnimated) { el.classList.add('maplair-zoom-animated'); }\n\t\tif (this.options.className) { el.classList.add(...Util.splitWords(this.options.className)); }\n\n\t\tel.onselectstart = Util.falseFn;\n\t\tel.onpointermove = Util.falseFn;\n\t}\n\n\t// @method getElement(): SVGElement\n\t// Returns the instance of [`SVGElement`](https://developer.mozilla.org/docs/Web/API/SVGElement)\n\t// used by this overlay.\n}\n"],"mappings":";;;AA0BA,IAAa,aAAb,MAAa,mBAAmB,aAAa;CAC5C,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,UAAU;CAC9B;CAEA,aAAa;EACZ,MAAM,KAAK,KAAK,SAAS,KAAK;EAE9B,GAAG,UAAU,IAAI,qBAAqB;EACtC,IAAI,KAAK,eAAiB,GAAG,UAAU,IAAI,uBAAuB;EAClE,IAAI,KAAK,QAAQ,WAAa,GAAG,UAAU,IAAI,GAAGA,WAAgB,KAAK,QAAQ,SAAS,CAAC;EAEzF,GAAG,gBAAgBC;EACnB,GAAG,gBAAgBA;CACpB;AAKD"}