maplair 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/esm/Maplair.js +5 -4
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +1 -2
  6. package/dist/esm/control/ButtonControl.js +1 -2
  7. package/dist/esm/control/ContextMenu.js +1 -2
  8. package/dist/esm/control/Control.js +1 -2
  9. package/dist/esm/control/FullscreenControl.js +1 -2
  10. package/dist/esm/control/LayersControl.js +27 -31
  11. package/dist/esm/control/LayersControl.js.map +1 -1
  12. package/dist/esm/control/LegendControl.js +1 -2
  13. package/dist/esm/control/MiniMapControl.js +1 -2
  14. package/dist/esm/control/RotateControl.js +1 -2
  15. package/dist/esm/control/ScaleControl.js +1 -2
  16. package/dist/esm/control/SearchControl.js +1 -2
  17. package/dist/esm/control/SideBySideControl.js +1 -2
  18. package/dist/esm/control/TextControl.js +1 -2
  19. package/dist/esm/control/TimeControl.js +1 -2
  20. package/dist/esm/control/ZoomControl.js +18 -29
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Class.js +2 -9
  23. package/dist/esm/core/Class.js.map +1 -1
  24. package/dist/esm/core/Events.js +1 -2
  25. package/dist/esm/core/Handler.js +10 -3
  26. package/dist/esm/core/Handler.js.map +1 -1
  27. package/dist/esm/core/I18n.js +1 -2
  28. package/dist/esm/core/Util.js +2 -3
  29. package/dist/esm/core/Util.js.map +1 -1
  30. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  32. package/dist/esm/dom/DomEvent.js +10 -18
  33. package/dist/esm/dom/DomEvent.js.map +1 -1
  34. package/dist/esm/dom/DomUtil.js +1 -2
  35. package/dist/esm/dom/Draggable.js +4 -3
  36. package/dist/esm/dom/Draggable.js.map +1 -1
  37. package/dist/esm/dom/PosAnimation.js +1 -2
  38. package/dist/esm/geo/LatLng.js +1 -2
  39. package/dist/esm/geo/LatLngBounds.js +9 -15
  40. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  41. package/dist/esm/geo/crs/CRS.js +1 -2
  42. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  43. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  44. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  45. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  46. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  47. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  48. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  49. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  50. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  51. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  52. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  53. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  54. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  55. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  56. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  57. package/dist/esm/geometry/Bounds.js +10 -14
  58. package/dist/esm/geometry/Bounds.js.map +1 -1
  59. package/dist/esm/geometry/LineUtil.js +2 -3
  60. package/dist/esm/geometry/LineUtil.js.map +1 -1
  61. package/dist/esm/geometry/Point.js +1 -2
  62. package/dist/esm/geometry/PolyUtil.js +17 -25
  63. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  64. package/dist/esm/geometry/Transformation.js +1 -2
  65. package/dist/esm/layer/BlanketOverlay.js +1 -2
  66. package/dist/esm/layer/Classification.js +1 -2
  67. package/dist/esm/layer/DivOverlay.js +2 -3
  68. package/dist/esm/layer/DivOverlay.js.map +1 -1
  69. package/dist/esm/layer/FeatureGroup.js +5 -4
  70. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  71. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  72. package/dist/esm/layer/GeoJSON.js +8 -10
  73. package/dist/esm/layer/GeoJSON.js.map +1 -1
  74. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  75. package/dist/esm/layer/HeatLayer.js +2 -3
  76. package/dist/esm/layer/HeatLayer.js.map +1 -1
  77. package/dist/esm/layer/ImageOverlay.js +2 -3
  78. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  79. package/dist/esm/layer/Layer.js +1 -2
  80. package/dist/esm/layer/LayerGroup.js +2 -3
  81. package/dist/esm/layer/LayerGroup.js.map +1 -1
  82. package/dist/esm/layer/Popup.js +9 -16
  83. package/dist/esm/layer/Popup.js.map +1 -1
  84. package/dist/esm/layer/SVGOverlay.js +1 -2
  85. package/dist/esm/layer/Tooltip.js +16 -17
  86. package/dist/esm/layer/Tooltip.js.map +1 -1
  87. package/dist/esm/layer/VideoOverlay.js +1 -2
  88. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  89. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  90. package/dist/esm/layer/marker/DivIcon.js +1 -2
  91. package/dist/esm/layer/marker/Icon.js +2 -2
  92. package/dist/esm/layer/marker/Icon.js.map +1 -1
  93. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  94. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  95. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  96. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  97. package/dist/esm/layer/marker/Marker.js +54 -14
  98. package/dist/esm/layer/marker/Marker.js.map +1 -1
  99. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  100. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  101. package/dist/esm/layer/tile/GridLayer.js +4 -4
  102. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  103. package/dist/esm/layer/tile/TileLayer.js +8 -8
  104. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  105. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  106. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  107. package/dist/esm/layer/vector/Canvas.js +7 -14
  108. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  109. package/dist/esm/layer/vector/Circle.js +4 -3
  110. package/dist/esm/layer/vector/Circle.js.map +1 -1
  111. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  112. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  113. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  114. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  115. package/dist/esm/layer/vector/Path.js +1 -2
  116. package/dist/esm/layer/vector/Polygon.js +2 -3
  117. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  118. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  119. package/dist/esm/layer/vector/Polyline.js +2 -3
  120. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  121. package/dist/esm/layer/vector/Rectangle.js +1 -2
  122. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  124. package/dist/esm/layer/vector/Renderer.js +1 -2
  125. package/dist/esm/layer/vector/SVG.js +7 -4
  126. package/dist/esm/layer/vector/SVG.js.map +1 -1
  127. package/dist/esm/map/Hash.js +1 -2
  128. package/dist/esm/map/Map.Rotation.js +31 -16
  129. package/dist/esm/map/Map.Rotation.js.map +1 -1
  130. package/dist/esm/map/Map.js +10 -17
  131. package/dist/esm/map/Map.js.map +1 -1
  132. package/dist/esm/map/MapSync.js +1 -2
  133. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  134. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  135. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  136. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  137. package/dist/esm/map/handler/DragHandler.js +1 -2
  138. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  139. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  140. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  141. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  144. package/dist/esm/package.js +2 -3
  145. package/dist/maplair-global-src.js +487 -613
  146. package/dist/maplair-global-src.js.map +1 -1
  147. package/dist/maplair-global.js +2 -2
  148. package/dist/maplair-global.js.map +1 -1
  149. package/dist/maplair-src.js +483 -609
  150. package/dist/maplair-src.js.map +1 -1
  151. package/dist/maplair.css +1 -1263
  152. package/dist/maplair.js +2 -2
  153. package/dist/maplair.js.map +1 -1
  154. package/package.json +3 -8
  155. package/src/Maplair.all.js +0 -1
  156. package/src/control/LayersControl.js +39 -52
  157. package/src/control/ZoomControl.js +17 -31
  158. package/src/core/Class.js +5 -14
  159. package/src/core/Handler.js +11 -1
  160. package/src/core/Util.js +1 -1
  161. package/src/dom/DomEvent.js +9 -19
  162. package/src/dom/Draggable.js +5 -1
  163. package/src/geo/LatLngBounds.js +8 -15
  164. package/src/geo/crs/EPSG3395.js +3 -3
  165. package/src/geo/crs/EPSG3857.js +3 -3
  166. package/src/geo/crs/EPSG4326.js +2 -2
  167. package/src/geo/crs/SimpleCRS.js +2 -2
  168. package/src/geo/index.js +1 -2
  169. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  170. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  171. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  172. package/src/geo/projection/index.js +5 -5
  173. package/src/geometry/Bounds.js +12 -17
  174. package/src/geometry/LineUtil.js +1 -1
  175. package/src/geometry/PolyUtil.js +23 -31
  176. package/src/layer/DivOverlay.js +1 -1
  177. package/src/layer/FeatureGroup.js +8 -2
  178. package/src/layer/GeoJSON.js +10 -13
  179. package/src/layer/HeatLayer.js +1 -1
  180. package/src/layer/ImageOverlay.js +2 -2
  181. package/src/layer/LayerGroup.js +1 -1
  182. package/src/layer/Popup.js +9 -19
  183. package/src/layer/Tooltip.js +19 -17
  184. package/src/layer/marker/DefaultIcon.js +33 -5
  185. package/src/layer/marker/Icon.js +2 -0
  186. package/src/layer/marker/Marker.Drag.js +53 -5
  187. package/src/layer/marker/Marker.Move.js +3 -4
  188. package/src/layer/marker/Marker.js +64 -13
  189. package/src/layer/tile/GridLayer.js +5 -2
  190. package/src/layer/tile/TileLayer.js +9 -6
  191. package/src/layer/tile/WMSTileLayer.js +5 -2
  192. package/src/layer/vector/Canvas.js +10 -14
  193. package/src/layer/vector/Circle.js +4 -1
  194. package/src/layer/vector/CircleMarker.js +2 -1
  195. package/src/layer/vector/Polygon.js +1 -1
  196. package/src/layer/vector/Polyline.js +1 -1
  197. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  198. package/src/layer/vector/SVG.js +12 -2
  199. package/src/map/Map.Rotation.js +28 -4
  200. package/src/map/Map.js +17 -21
  201. package/src/map/handler/BoxZoomHandler.js +21 -42
  202. package/src/map/handler/KeyboardHandler.js +34 -53
  203. package/src/maplair.css +5 -0
  204. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  205. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  206. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  207. package/dist/esm/geo/projection/index.js +0 -14
  208. package/dist/esm/geo/projection/index.js.map +0 -1
  209. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  210. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  211. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -1 +1 @@
1
- {"version":3,"file":"TileLayer.js","names":["Util.setOptions","Util.template"],"sources":["../../../../src/layer/tile/TileLayer.js"],"sourcesContent":["import {GridLayer} from './GridLayer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {I18n} from '../../core/I18n.js';\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */\n/** @import {TileEvent} from '../../core/Events.js' */\n\nconst osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];\nconst hostRe = /^(https?:)?\\/\\/([^/?#:]*)/i;\nconst httpRe = /^http:/i;\n\nfunction isOSMUrl(url) {\n\tconst host = hostRe.exec(url)?.[2] ?? '';\n\treturn osmHosts.some(osmHost => host === osmHost || host.endsWith(`.${osmHost}`));\n}\n\n// OSM tiles are upgraded to HTTPS so that the referrer policy works\nconst upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : url);\n\n/**\n * Options of `TileLayer`.\n * @typedef {object} TileLayerOptions\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxZoom=18] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {string|string[]} [subdomains='abc'] Subdomains of the tile service. Can be\n * passed in the form of one string (where each letter is a subdomain name) or an array\n * of strings.\n * @property {string} [errorTileUrl=''] URL to the tile image to show in place of the\n * tile that failed to load.\n * @property {number} [zoomOffset=0] The zoom number used in tile URLs will be offset\n * with this value.\n * @property {boolean} [tms=false] If `true`, inverses Y axis numbering for tiles (turn\n * this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).\n * @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile\n * URLs will be reversed (`maxZoom - zoom` instead of `zoom`).\n * @property {boolean} [detectRetina=false] If `true` and user is on a retina display, it\n * will request four tiles of half the specified size and a bigger zoom level in place\n * of one to utilize the high resolution.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the tiles. If a String is provided, all tiles will have their crossOrigin\n * attribute set to the String provided. This is needed if you want to access tile pixel\n * data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n * @property {ReferrerPolicy} [referrerPolicy='strict-origin-when-cross-origin'] Sets the\n * tiles' `referrerPolicy` attribute set to the String provided. See\n * [`HTMLImageElement.referrerPolicy`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy)\n * for possible values.\n *\n * Tile providers might require you to use a specific referrer policy (e.g. to verify\n * API tokens or prevent abuse). Specifically, if you are using tiles from\n * `tile.openstreetmap.org` or `tile.osm.org`, you\n * [should not change this value](https://operations.osmfoundation.org/policies/tiles/).\n * @property {RequestInit|null} [fetchOptions=null] If set, the tiles are loaded with\n * [`fetch()`](https://developer.mozilla.org/docs/Web/API/Window/fetch) using these\n * options (see [`RequestInit`](https://developer.mozilla.org/docs/Web/API/RequestInit)),\n * e.g. `{headers: {Authorization: 'Bearer …'}}` for tile servers requiring custom HTTP\n * headers. Requests of tiles that are no longer needed (e.g. after panning or zooming\n * away) are aborted. Cross-origin tile servers have to allow such requests with\n * [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) headers.\n * @extends GridLayerOptions\n */\n\n/**\n * Used to load and display tile layers on the map. Note that most tile servers require\n * attribution, which you can set under `Layer`. Extends `GridLayer`.\n *\n * ### URL template\n *\n * A string of the following form:\n *\n * ```\n * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'\n * ```\n *\n * `{s}` means one of the available subdomains (used sequentially to help with browser\n * parallel requests per domain limitation; subdomain values are specified in options;\n * `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` —\n * tile coordinates. `{r}` can be used to add \"@2x\" to the URL to load retina tiles.\n *\n * You can use custom keys in the template, which will be [evaluated](#util-template)\n * from TileLayer options, like this:\n *\n * ```\n * new TileLayer('https://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});\n * ```\n *\n * Layers extending `TileLayer` might reimplement the [`getTileUrl()`](#tilelayer-gettileurl)\n * method.\n *\n * @example\n * ```js\n * new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>'}).addTo(map);\n * ```\n *\n * @fires tileabort {TileEvent} Fired when a tile was loading but is now not wanted.\n */\nexport class TileLayer extends GridLayer {\n\n\tstatic defaultOptions = {\n\t\tminZoom: 0,\n\t\tmaxZoom: 18,\n\t\tsubdomains: 'abc',\n\t\terrorTileUrl: '',\n\t\tzoomOffset: 0,\n\t\ttms: false,\n\t\tzoomReverse: false,\n\t\tdetectRetina: false,\n\t\tcrossOrigin: false,\n\t\treferrerPolicy: 'strict-origin-when-cross-origin',\n\t\tfetchOptions: null\n\n\t};\n\n\t/**\n\t * Instantiates a tile layer object given a [URL template](#tilelayer) and optionally an\n\t * options object.\n\t * @param {string} url The URL template.\n\t * @param {TileLayerOptions & Record<string, unknown>} [options] The options, and the values\n\t * of custom keys of the URL template.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(options);\n\n\t\toptions = Util.setOptions(this, options);\n\n\t\t// Set required OpenStreetMap attribution if it hasn't been specified\n\t\tif (isOSMUrl(url) && options.attribution === null) {\n\t\t\toptions.attribution = `&copy; <a href=\"https://www.openstreetmap.org/copyright\">${I18n.translate('OpenStreetMap contributors')}</a>`;\n\t\t}\n\t\tthis._url = upgradeOSMUrl(url);\n\n\t\tconst {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom} = this.options;\n\t\tthis._nonRetinaOptions = {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom};\n\t\tthis._applyRetina();\n\n\t\tif (typeof this.options.subdomains === 'string') {\n\t\t\tthis.options.subdomains = this.options.subdomains.split('');\n\t\t}\n\n\t\tthis.callInitHooks(TileLayer);\n\t}\n\n\t// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels.\n\t_applyRetina() {\n\t\tObject.assign(this.options, this._nonRetinaOptions);\n\t\tthis._retina = window.devicePixelRatio > 1;\n\n\t\tif (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {\n\n\t\t\tthis.options.tileSize = Math.floor(this.options.tileSize / 2);\n\n\t\t\tif (!this.options.zoomReverse) {\n\t\t\t\tthis.options.zoomOffset++;\n\t\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);\n\t\t\t\t// do not request tiles beyond the native zoom levels\n\t\t\t\tif (this.options.maxNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);\n\t\t\t\t}\n\t\t\t\tif (this.options.minNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.options.zoomOffset--;\n\t\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);\n\t\t\t}\n\n\t\t\tthis.options.minZoom = Math.max(0, this.options.minZoom);\n\t\t} else if (!this.options.zoomReverse) {\n\t\t\t// make sure maxZoom is gte minZoom\n\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);\n\t\t} else {\n\t\t\t// make sure minZoom is lte maxZoom\n\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\t\tevents.pixelratiochange = this._onPixelRatioChange;\n\t\treturn events;\n\t}\n\n\t// Loads the tiles for the new resolution, see the map's `pixelratiochange` event.\n\t_onPixelRatioChange() {\n\t\tif ((window.devicePixelRatio > 1) === this._retina) { return; }\n\t\tconst map = this._map;\n\t\tthis._applyRetina();\n\t\tif (this.options.detectRetina) {\n\t\t\tmap._removeZoomLimit(this);\n\t\t\tmap._addZoomLimit(this);\n\t\t\tthis._invalidateAll();\n\t\t\tthis._resetView();\n\t\t} else if (this._url.includes('{r}')) {\n\t\t\tthis.redraw();\n\t\t}\n\t}\n\n\t/**\n\t * Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).\n\t * If the URL does not change, the layer will not be redrawn unless\n\t * the noRedraw parameter is set to false.\n\t * The current tiles stay visible until the new tiles have loaded, to avoid flickering.\n\t * @param {string} url\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetUrl(url, noRedraw) {\n\t\turl = upgradeOSMUrl(url);\n\n\t\tif (this._url === url && noRedraw === undefined) {\n\t\t\tnoRedraw = true;\n\t\t}\n\n\t\tthis._url = url;\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)\n\t * to return an `<img>` HTML element with the appropriate image URL given `coords`. The\n\t * `done` callback is called when the tile has been loaded.\n\t * @param {Point} coords\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLImageElement}\n\t */\n\tcreateTile(coords, done) {\n\t\tconst tile = document.createElement('img');\n\n\t\tDomEvent.on(tile, 'load', this._tileOnLoad.bind(this, done, tile));\n\t\tDomEvent.on(tile, 'error', this._tileOnError.bind(this, done, tile));\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\ttile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\t// for this new option we follow the documented behavior\n\t\t// more closely by only setting the property when string\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\ttile.referrerPolicy = this.options.referrerPolicy;\n\t\t}\n\n\t\t// The alt attribute is set to the empty string,\n\t\t// allowing screen readers to ignore the decorative image tiles.\n\t\t// https://www.w3.org/WAI/tutorials/images/decorative/\n\t\t// https://www.w3.org/TR/html-aria/#el-img-empty-alt\n\t\ttile.alt = '';\n\n\t\tconst url = this.getTileUrl(coords);\n\t\tif (this.options.fetchOptions) {\n\t\t\tthis._fetchTile(tile, url, done);\n\t\t} else {\n\t\t\ttile.src = url;\n\t\t}\n\n\t\treturn tile;\n\t}\n\n\t// Loads the tile image with `fetch()`, see the `fetchOptions` option.\n\t_fetchTile(tile, url, done) {\n\t\tconst controller = new AbortController(),\n\t\toptions = {signal: controller.signal, ...this.options.fetchOptions};\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\toptions.referrerPolicy ??= this.options.referrerPolicy;\n\t\t}\n\n\t\tthis._tileFetches ??= new Map();\n\t\tthis._tileFetches.set(tile, controller);\n\n\t\tfetch(url, options)\n\t\t\t.then((response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Failed to load the tile ${url}: HTTP ${response.status}`);\n\t\t\t\t}\n\t\t\t\treturn response.blob();\n\t\t\t})\n\t\t\t.then((blob) => {\n\t\t\t\t// revoked in `_tileOnLoad()`\n\t\t\t\ttile.src = URL.createObjectURL(blob);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\tthis._tileOnError(done, tile, error);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => this._tileFetches.delete(tile));\n\t}\n\n\t// Aborts the request of a tile loaded with `fetch()`, returns whether there was one.\n\t_abortTileFetch(tile) {\n\t\tconst controller = this._tileFetches?.get(tile);\n\t\tif (!controller) { return false; }\n\t\tcontroller.abort();\n\t\tthis._tileFetches.delete(tile);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL for a tile given its coordinates.\n\t * Classes extending `TileLayer` can override this function to provide custom tile URL\n\t * naming schemes.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\t\tconst data = Object.create(this.options);\n\t\tObject.assign(data, {\n\t\t\tr: window.devicePixelRatio > 1 ? '@2x' : '',\n\t\t\ts: this._getSubdomain(coords),\n\t\t\tx: coords.x,\n\t\t\ty: coords.y,\n\t\t\tz: this._getZoomForUrl()\n\t\t});\n\t\tif (this._map && !this._map.options.crs.infinite) {\n\t\t\tconst invertedY = this._globalTileRange.max.y - coords.y;\n\t\t\tif (this.options.tms) {\n\t\t\t\tdata['y'] = invertedY;\n\t\t\t}\n\t\t\tdata['-y'] = invertedY;\n\t\t}\n\n\t\treturn Util.template(this._url, data);\n\t}\n\n\t_tileOnLoad(done, tile) {\n\t\tif (tile.src.startsWith('blob:')) {\n\t\t\t// the image keeps its data, see `_fetchTile()`\n\t\t\tURL.revokeObjectURL(tile.src);\n\t\t}\n\t\tdone(null, tile);\n\t}\n\n\t_tileOnError(done, tile, e) {\n\t\tconst errorUrl = this.options.errorTileUrl;\n\t\tif (errorUrl && tile.getAttribute('src') !== errorUrl) {\n\t\t\ttile.src = errorUrl;\n\t\t}\n\t\tdone(e, tile);\n\t}\n\n\t_getZoomForUrl() {\n\t\tlet zoom = this._tileZoom;\n\t\tconst maxZoom = this.options.maxZoom,\n\t\tzoomReverse = this.options.zoomReverse,\n\t\tzoomOffset = this.options.zoomOffset;\n\n\t\tif (zoomReverse) {\n\t\t\tzoom = maxZoom - zoom;\n\t\t}\n\n\t\treturn zoom + zoomOffset;\n\t}\n\n\t_getSubdomain(tilePoint) {\n\t\tconst index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;\n\t\treturn this.options.subdomains[index];\n\t}\n\n\t// stops loading all tiles in the background layer\n\t_abortLoading() {\n\t\tlet i, tile;\n\t\tfor (i of Object.keys(this._tiles)) {\n\t\t\tif (this._tiles[i].coords.z !== this._tileZoom) {\n\t\t\t\ttile = this._tiles[i].el;\n\n\t\t\t\tif (this._abortTileFetch(tile) || !tile.complete) {\n\t\t\t\t\ttile.setAttribute('src', '');\n\t\t\t\t\tconst coords = this._tiles[i].coords;\n\t\t\t\t\ttile.remove();\n\t\t\t\t\tdelete this._tiles[i];\n\t\t\t\t\tthis.fire('tileabort', {\n\t\t\t\t\t\ttile,\n\t\t\t\t\t\tcoords\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\t// Cancels any pending http requests associated with the tile\n\t\tthis._abortTileFetch(tile.el);\n\t\ttile.el.setAttribute('src', '');\n\n\t\treturn super._removeTile(key);\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (!this._map || (tile && tile.getAttribute('src') === '')) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn super._tileReady(coords, err, tile);\n\t}\n\n\t_clampZoom(zoom) {\n\t\treturn Math.round(super._clampZoom(zoom));\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,WAAW,CAAC,0BAA0B,cAAc;AAC1D,MAAM,SAAS;AACf,MAAM,SAAS;AAEf,SAAS,SAAS,KAAK;CACtB,MAAM,OAAO,OAAO,KAAK,GAAG,CAAC,GAAG,MAAM;CACtC,OAAO,SAAS,MAAK,YAAW,SAAS,WAAW,KAAK,SAAS,IAAI,SAAS,CAAC;AACjF;AAGA,MAAM,iBAAgB,QAAQ,SAAS,GAAG,IAAI,IAAI,QAAQ,QAAQ,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkF9E,IAAa,YAAb,MAAa,kBAAkB,UAAU;CAExC,OAAO,iBAAiB;EACvB,SAAS;EACT,SAAS;EACT,YAAY;EACZ,cAAc;EACd,YAAY;EACZ,KAAK;EACL,aAAa;EACb,cAAc;EACd,aAAa;EACb,gBAAgB;EAChB,cAAc;CAEf;;;;;;;;CASA,YAAY,KAAK,SAAS;EACzB,MAAM,OAAO;EAEb,UAAUA,WAAgB,MAAM,OAAO;EAGvC,IA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G,aAAa,OAAO,EAAE;EAE9B,OAAO,MAAM,YAAY,GAAG;CAC7B;CAEA,WAAW,QAAQ,KAAK,MAAM;EAC7B,IAAI,CAAC,KAAK,QAAS,QAAQ,KAAK,aAAa,KAAK,MAAM,IACvD;EAGD,OAAO,MAAM,WAAW,QAAQ,KAAK,IAAI;CAC1C;CAEA,WAAW,MAAM;EAChB,OAAO,KAAK,MAAM,MAAM,WAAW,IAAI,CAAC;CACzC;AACD"}
1
+ {"version":3,"file":"TileLayer.js","names":["Util.setOptions","Util.template"],"sources":["../../../../src/layer/tile/TileLayer.js"],"sourcesContent":["import {GridLayer} from './GridLayer.js';\nimport * as Util from '../../core/Util.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {I18n} from '../../core/I18n.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */\n/** @import {TileEvent} from '../../core/Events.js' */\n\nconst osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];\nconst hostRe = /^(https?:)?\\/\\/([^/?#:]*)/i;\nconst httpRe = /^http:/i;\n\nfunction isOSMUrl(url) {\n\tconst host = hostRe.exec(url)?.[2] ?? '';\n\treturn osmHosts.some(osmHost => host === osmHost || host.endsWith(`.${osmHost}`));\n}\n\n// OSM tiles are upgraded to HTTPS so that the referrer policy works\nconst upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : url);\n\n/**\n * Options of `TileLayer`.\n * @typedef {object} TileLayerOptions\n * @property {number} [minZoom=0] The minimum zoom level down to which this layer will be\n * displayed (inclusive).\n * @property {number} [maxZoom=18] The maximum zoom level up to which this layer will be\n * displayed (inclusive).\n * @property {string|string[]} [subdomains='abc'] Subdomains of the tile service. Can be\n * passed in the form of one string (where each letter is a subdomain name) or an array\n * of strings.\n * @property {string} [errorTileUrl=''] URL to the tile image to show in place of the\n * tile that failed to load.\n * @property {number} [zoomOffset=0] The zoom number used in tile URLs will be offset\n * with this value.\n * @property {boolean} [tms=false] If `true`, inverses Y axis numbering for tiles (turn\n * this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).\n * @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile\n * URLs will be reversed (`maxZoom - zoom` instead of `zoom`).\n * @property {boolean} [detectRetina=false] If `true` and user is on a retina display, it\n * will request four tiles of half the specified size and a bigger zoom level in place\n * of one to utilize the high resolution.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the tiles. If a String is provided, all tiles will have their crossOrigin\n * attribute set to the String provided. This is needed if you want to access tile pixel\n * data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n * @property {ReferrerPolicy} [referrerPolicy='strict-origin-when-cross-origin'] Sets the\n * tiles' `referrerPolicy` attribute set to the String provided. See\n * [`HTMLImageElement.referrerPolicy`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy)\n * for possible values.\n *\n * Tile providers might require you to use a specific referrer policy (e.g. to verify\n * API tokens or prevent abuse). Specifically, if you are using tiles from\n * `tile.openstreetmap.org` or `tile.osm.org`, you\n * [should not change this value](https://operations.osmfoundation.org/policies/tiles/).\n * @property {RequestInit|null} [fetchOptions=null] If set, the tiles are loaded with\n * [`fetch()`](https://developer.mozilla.org/docs/Web/API/Window/fetch) using these\n * options (see [`RequestInit`](https://developer.mozilla.org/docs/Web/API/RequestInit)),\n * e.g. `{headers: {Authorization: 'Bearer …'}}` for tile servers requiring custom HTTP\n * headers. Requests of tiles that are no longer needed (e.g. after panning or zooming\n * away) are aborted. Cross-origin tile servers have to allow such requests with\n * [CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS) headers.\n * @extends GridLayerOptions\n */\n\n/**\n * Used to load and display tile layers on the map. Note that most tile servers require\n * attribution, which you can set under `Layer`. Extends `GridLayer`.\n *\n * ### URL template\n *\n * A string of the following form:\n *\n * ```\n * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'\n * ```\n *\n * `{s}` means one of the available subdomains (used sequentially to help with browser\n * parallel requests per domain limitation; subdomain values are specified in options;\n * `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` —\n * tile coordinates. `{r}` can be used to add \"@2x\" to the URL to load retina tiles.\n *\n * You can use custom keys in the template, which will be [evaluated](#util-template)\n * from TileLayer options, like this:\n *\n * ```\n * new TileLayer('https://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});\n * ```\n *\n * Layers extending `TileLayer` might reimplement the [`getTileUrl()`](#tilelayer-gettileurl)\n * method.\n *\n * @example\n * ```js\n * new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>'}).addTo(map);\n * ```\n *\n * @fires tileabort {TileEvent} Fired when a tile was loading but is now not wanted.\n */\nexport class TileLayer extends GridLayer {\n\n\tstatic defaultOptions = {\n\t\tminZoom: 0,\n\t\tmaxZoom: 18,\n\t\tsubdomains: 'abc',\n\t\terrorTileUrl: '',\n\t\tzoomOffset: 0,\n\t\ttms: false,\n\t\tzoomReverse: false,\n\t\tdetectRetina: false,\n\t\tcrossOrigin: false,\n\t\treferrerPolicy: 'strict-origin-when-cross-origin',\n\t\tfetchOptions: null\n\n\t};\n\n\t/**\n\t * Instantiates a tile layer object given a [URL template](#tilelayer) and optionally an\n\t * options object.\n\t * @param {string} url The URL template.\n\t * @param {TileLayerOptions & Record<string, unknown>} [options] The options, and the values\n\t * of custom keys of the URL template.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(options);\n\n\t\toptions = Util.setOptions(this, options);\n\n\t\t// Set required OpenStreetMap attribution if it hasn't been specified\n\t\tif (isOSMUrl(url) && options.attribution === null) {\n\t\t\toptions.attribution = `&copy; <a href=\"https://www.openstreetmap.org/copyright\">${I18n.translate('OpenStreetMap contributors')}</a>`;\n\t\t}\n\t\tthis._url = upgradeOSMUrl(url);\n\n\t\tconst {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom} = this.options;\n\t\tthis._nonRetinaOptions = {tileSize, zoomOffset, minZoom, maxZoom, minNativeZoom, maxNativeZoom};\n\t\tthis._applyRetina();\n\n\t\tif (typeof this.options.subdomains === 'string') {\n\t\t\tthis.options.subdomains = this.options.subdomains.split('');\n\t\t}\n\n\t\tthis.callInitHooks(TileLayer);\n\t}\n\n\t// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels.\n\t_applyRetina() {\n\t\tObject.assign(this.options, this._nonRetinaOptions);\n\t\tthis._retina = window.devicePixelRatio > 1;\n\n\t\tif (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {\n\n\t\t\tconst tileSize = this.options.tileSize;\n\t\t\tthis.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);\n\n\t\t\tif (!this.options.zoomReverse) {\n\t\t\t\tthis.options.zoomOffset++;\n\t\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);\n\t\t\t\t// do not request tiles beyond the native zoom levels\n\t\t\t\tif (this.options.maxNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);\n\t\t\t\t}\n\t\t\t\tif (this.options.minNativeZoom !== undefined) {\n\t\t\t\t\tthis.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.options.zoomOffset--;\n\t\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);\n\t\t\t}\n\n\t\t\tthis.options.minZoom = Math.max(0, this.options.minZoom);\n\t\t} else if (!this.options.zoomReverse) {\n\t\t\t// make sure maxZoom is gte minZoom\n\t\t\tthis.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);\n\t\t} else {\n\t\t\t// make sure minZoom is lte maxZoom\n\t\t\tthis.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\t\tevents.pixelratiochange = this._onPixelRatioChange;\n\t\treturn events;\n\t}\n\n\t// Loads the tiles for the new resolution, see the map's `pixelratiochange` event.\n\t_onPixelRatioChange() {\n\t\tif ((window.devicePixelRatio > 1) === this._retina) { return; }\n\t\tconst map = this._map;\n\t\tthis._applyRetina();\n\t\tif (this.options.detectRetina) {\n\t\t\tmap._removeZoomLimit(this);\n\t\t\tmap._addZoomLimit(this);\n\t\t\tthis._invalidateAll();\n\t\t\tthis._resetView();\n\t\t} else if (this._url.includes('{r}')) {\n\t\t\tthis.redraw();\n\t\t}\n\t}\n\n\t/**\n\t * Updates the layer's URL template and redraws it (unless `noRedraw` is set to `true`).\n\t * If the URL does not change, the layer will not be redrawn unless\n\t * the noRedraw parameter is set to false.\n\t * The current tiles stay visible until the new tiles have loaded, to avoid flickering.\n\t * @param {string} url\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetUrl(url, noRedraw) {\n\t\turl = upgradeOSMUrl(url);\n\n\t\tif (this._url === url && noRedraw === undefined) {\n\t\t\tnoRedraw = true;\n\t\t}\n\n\t\tthis._url = url;\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)\n\t * to return an `<img>` HTML element with the appropriate image URL given `coords`. The\n\t * `done` callback is called when the tile has been loaded.\n\t * @param {Point} coords\n\t * @param {TileDoneCallback} [done]\n\t * @returns {HTMLImageElement}\n\t */\n\tcreateTile(coords, done) {\n\t\tconst tile = document.createElement('img');\n\n\t\tDomEvent.on(tile, 'load', this._tileOnLoad.bind(this, done, tile));\n\t\tDomEvent.on(tile, 'error', this._tileOnError.bind(this, done, tile));\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\ttile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\t// for this new option we follow the documented behavior\n\t\t// more closely by only setting the property when string\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\ttile.referrerPolicy = this.options.referrerPolicy;\n\t\t}\n\n\t\t// The alt attribute is set to the empty string,\n\t\t// allowing screen readers to ignore the decorative image tiles.\n\t\t// https://www.w3.org/WAI/tutorials/images/decorative/\n\t\t// https://www.w3.org/TR/html-aria/#el-img-empty-alt\n\t\ttile.alt = '';\n\n\t\tconst url = this.getTileUrl(coords);\n\t\tif (this.options.fetchOptions) {\n\t\t\tthis._fetchTile(tile, url, done);\n\t\t} else {\n\t\t\ttile.src = url;\n\t\t}\n\n\t\treturn tile;\n\t}\n\n\t// Loads the tile image with `fetch()`, see the `fetchOptions` option.\n\t_fetchTile(tile, url, done) {\n\t\tconst controller = new AbortController(),\n\t\toptions = {signal: controller.signal, ...this.options.fetchOptions};\n\t\tif (typeof this.options.referrerPolicy === 'string') {\n\t\t\toptions.referrerPolicy ??= this.options.referrerPolicy;\n\t\t}\n\n\t\tthis._tileFetches ??= new Map();\n\t\tthis._tileFetches.set(tile, controller);\n\n\t\tfetch(url, options)\n\t\t\t.then((response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Failed to load the tile ${url}: HTTP ${response.status}`);\n\t\t\t\t}\n\t\t\t\treturn response.blob();\n\t\t\t})\n\t\t\t.then((blob) => {\n\t\t\t\t// revoked in `_tileOnLoad()`\n\t\t\t\ttile.src = URL.createObjectURL(blob);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\tthis._tileOnError(done, tile, error);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => this._tileFetches.delete(tile));\n\t}\n\n\t// Aborts the request of a tile loaded with `fetch()`, returns whether there was one.\n\t_abortTileFetch(tile) {\n\t\tconst controller = this._tileFetches?.get(tile);\n\t\tif (!controller) { return false; }\n\t\tcontroller.abort();\n\t\tthis._tileFetches.delete(tile);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL for a tile given its coordinates.\n\t * Classes extending `TileLayer` can override this function to provide custom tile URL\n\t * naming schemes.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\t\tconst data = Object.create(this.options);\n\t\tObject.assign(data, {\n\t\t\tr: window.devicePixelRatio > 1 ? '@2x' : '',\n\t\t\ts: this._getSubdomain(coords),\n\t\t\tx: coords.x,\n\t\t\ty: coords.y,\n\t\t\tz: this._getZoomForUrl()\n\t\t});\n\t\tif (this._map && !this._map.options.crs.infinite) {\n\t\t\tconst invertedY = this._globalTileRange.max.y - coords.y;\n\t\t\tif (this.options.tms) {\n\t\t\t\tdata['y'] = invertedY;\n\t\t\t}\n\t\t\tdata['-y'] = invertedY;\n\t\t}\n\n\t\treturn Util.template(this._url, data);\n\t}\n\n\t_tileOnLoad(done, tile) {\n\t\tif (tile.src.startsWith('blob:')) {\n\t\t\t// the image keeps its data, see `_fetchTile()`\n\t\t\tURL.revokeObjectURL(tile.src);\n\t\t}\n\t\tdone(null, tile);\n\t}\n\n\t_tileOnError(done, tile, e) {\n\t\tconst errorUrl = this.options.errorTileUrl,\n\t\tsrc = tile.getAttribute('src');\n\t\t// removed tiles get an empty src to cancel their request, which fires error too\n\t\tif (errorUrl && src !== errorUrl && (src || tile.isConnected)) {\n\t\t\ttile.src = errorUrl;\n\t\t}\n\t\tdone(e, tile);\n\t}\n\n\t_getZoomForUrl() {\n\t\tlet zoom = this._tileZoom;\n\t\tconst maxZoom = this.options.maxZoom,\n\t\tzoomReverse = this.options.zoomReverse,\n\t\tzoomOffset = this.options.zoomOffset;\n\n\t\tif (zoomReverse) {\n\t\t\tzoom = maxZoom - zoom;\n\t\t}\n\n\t\treturn zoom + zoomOffset;\n\t}\n\n\t_getSubdomain(tilePoint) {\n\t\tconst {subdomains} = this.options;\n\t\treturn subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];\n\t}\n\n\t// stops loading all tiles in the background layer\n\t_abortLoading() {\n\t\tlet i, tile;\n\t\tfor (i of Object.keys(this._tiles)) {\n\t\t\tif (this._tiles[i].coords.z !== this._tileZoom) {\n\t\t\t\ttile = this._tiles[i].el;\n\n\t\t\t\tif (this._abortTileFetch(tile) || !tile.complete) {\n\t\t\t\t\ttile.setAttribute('src', '');\n\t\t\t\t\tconst coords = this._tiles[i].coords;\n\t\t\t\t\ttile.remove();\n\t\t\t\t\tdelete this._tiles[i];\n\t\t\t\t\tthis.fire('tileabort', {\n\t\t\t\t\t\ttile,\n\t\t\t\t\t\tcoords\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t_removeTile(key) {\n\t\tconst tile = this._tiles[key];\n\t\tif (!tile) { return; }\n\n\t\t// Cancels any pending http requests associated with the tile\n\t\tthis._abortTileFetch(tile.el);\n\t\ttile.el.setAttribute('src', '');\n\n\t\treturn super._removeTile(key);\n\t}\n\n\t_tileReady(coords, err, tile) {\n\t\tif (!this._map || (tile && tile.getAttribute('src') === '')) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn super._tileReady(coords, err, tile);\n\t}\n\n\t_clampZoom(zoom) {\n\t\treturn Math.round(super._clampZoom(zoom));\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,WAAW,CAAC,0BAA0B,cAAc;AAC1D,MAAM,SAAS;AACf,MAAM,SAAS;AAEf,SAAS,SAAS,KAAK;CACtB,MAAM,OAAO,OAAO,KAAK,GAAG,CAAC,GAAG,MAAM;CACtC,OAAO,SAAS,MAAK,YAAW,SAAS,WAAW,KAAK,SAAS,IAAI,SAAS,CAAC;AACjF;AAGA,M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AAI,WAAW;CACtE;CAGA,gBAAgB;EACf,IAAI,GAAG;EACP,KAAK,KAAK,OAAO,KAAK,KAAK,MAAM,GAChC,IAAI,KAAK,OAAO,EAAE,CAAC,OAAO,MAAM,KAAK,WAAW;GAC/C,OAAO,KAAK,OAAO,EAAE,CAAC;GAEtB,IAAI,KAAK,gBAAgB,IAAI,KAAK,CAAC,KAAK,UAAU;IACjD,KAAK,aAAa,OAAO,EAAE;IAC3B,MAAM,SAAS,KAAK,OAAO,EAAE,CAAC;IAC9B,KAAK,OAAO;IACZ,OAAO,KAAK,OAAO;IACnB,KAAK,KAAK,aAAa;KACtB;KACA;IACD,CAAC;GACF;EACD;CAEF;CAEA,YAAY,KAAK;EAChB,MAAM,OAAO,KAAK,OAAO;EACzB,IAAI,CAAC,MAAQ;EAGb,KAAK,gBAAgB,KAAK,EAAE;EAC5B,KAAK,GAAG,aAAa,OAAO,EAAE;EAE9B,OAAO,MAAM,YAAY,GAAG;CAC7B;CAEA,WAAW,QAAQ,KAAK,MAAM;EAC7B,IAAI,CAAC,KAAK,QAAS,QAAQ,KAAK,aAAa,KAAK,MAAM,IACvD;EAGD,OAAO,MAAM,WAAW,QAAQ,KAAK,IAAI;CAC1C;CAEA,WAAW,MAAM;EAChB,OAAO,KAAK,MAAM,MAAM,WAAW,IAAI,CAAC;CACzC;AACD"}
@@ -1,7 +1,7 @@
1
1
  import { Bounds } from "../../geometry/Bounds.js";
2
2
  import { EPSG4326 } from "../../geo/crs/EPSG4326.js";
3
3
  import { TileLayer } from "./TileLayer.js";
4
- //#region src/layer/tile/WMSTileLayer.js
4
+ // src/layer/tile/WMSTileLayer.js
5
5
  /** @import {CRS} from '../../geo/crs/CRS.js' */
6
6
  /** @import {Point} from '../../geometry/Point.js' */
7
7
  /** @import {MaplairMap} from '../../map/Map.js' */
@@ -98,8 +98,9 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
98
98
  _updateCrs() {
99
99
  this._crs = this.options.crs ?? this._map.options.crs;
100
100
  this._wmsVersion = parseFloat(this.wmsParams.version);
101
- const projectionKey = this._wmsVersion >= 1.3 ? "crs" : "srs";
102
- this.wmsParams[projectionKey] = this._crs.code;
101
+ delete this.wmsParams.srs;
102
+ delete this.wmsParams.crs;
103
+ this.wmsParams[this._wmsVersion >= 1.3 ? "crs" : "srs"] = this._crs.code;
103
104
  }
104
105
  /**
105
106
  * Returns the map events the layer listens to, see `Layer`.
@@ -168,6 +169,7 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
168
169
  */
169
170
  setParams(params, noRedraw) {
170
171
  Object.assign(this.wmsParams, params);
172
+ if (this._map) this._updateCrs();
171
173
  if (!noRedraw) {
172
174
  this._keepCurrentTiles();
173
175
  this.redraw();
@@ -175,7 +177,6 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
175
177
  return this;
176
178
  }
177
179
  };
178
- //#endregion
179
180
  export { WMSTileLayer };
180
181
 
181
182
  //# sourceMappingURL=WMSTileLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WMSTileLayer.js","names":[],"sources":["../../../../src/layer/tile/WMSTileLayer.js"],"sourcesContent":["import {TileLayer} from './TileLayer.js';\nimport {EPSG4326} from '../../geo/crs/EPSG4326.js';\nimport {Bounds} from '../../geometry/Bounds.js';\n/** @import {CRS} from '../../geo/crs/CRS.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {TileLayerOptions} from './TileLayer.js' */\n\n/**\n * Options of `WMSTileLayer`. If any custom options not documented here are used, they\n * will be sent to the WMS server as extra parameters in each request URL. This can be\n * useful for\n * [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\n * @typedef {object} WMSTileLayerOptions\n * @property {string} [layers=''] **(required)** Comma-separated list of WMS layers to\n * show.\n * @property {string} [styles=''] Comma-separated list of WMS styles.\n * @property {string} [format='image/jpeg'] WMS image format (use `'image/png'` for\n * layers with transparency).\n * @property {boolean} [transparent=false] If `true`, the WMS service will return images\n * with transparency.\n * @property {string} [version='1.1.1'] Version of the WMS service to use.\n * @property {CRS|null} [crs=null] Coordinate Reference System to use for the WMS\n * requests, defaults to map CRS. Don't change this if you're not sure what it means.\n * @property {boolean} [uppercase=false] If `true`, WMS request parameter keys will be\n * uppercase.\n * @extends TileLayerOptions\n */\n\n/**\n * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile\n * layers on the map. Extends `TileLayer`.\n *\n * @example\n * ```js\n * const nexrad = new WMSTileLayer(\"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi\", {\n * \tlayers: 'nexrad-n0r-900913',\n * \tformat: 'image/png',\n * \ttransparent: true,\n * \tattribution: \"Weather data © 2012 IEM Nexrad\"\n * });\n * ```\n */\nexport class WMSTileLayer extends TileLayer {\n\n\t/**\n\t * The default WMS parameters, which the options override, see `WMSTileLayerOptions`.\n\t * @type {Record<string, any>}\n\t */\n\tstatic defaultWmsParams = {\n\t\tservice: 'WMS',\n\t\trequest: 'GetMap',\n\t\tlayers: '',\n\t\tstyles: '',\n\t\tformat: 'image/jpeg',\n\t\ttransparent: false,\n\t\tversion: '1.1.1'\n\t};\n\n\tstatic defaultOptions = {\n\t\tcrs: null,\n\t\tuppercase: false\n\t};\n\n\t/**\n\t * Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS\n\t * parameters/options object.\n\t * @param {string} url The base URL of the WMS service.\n\t * @param {WMSTileLayerOptions & Record<string, unknown>} options The options and WMS\n\t * parameters.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(url, options);\n\n\t\tconst wmsParams = {...WMSTileLayer.defaultWmsParams};\n\n\t\t// Options that are unknown in the prototype chain are considered WMS params.\n\t\tfor (const [key, value] of Object.entries(options)) {\n\t\t\tif (!(key in WMSTileLayer.defaultOptions)) {\n\t\t\t\twmsParams[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * The parameters of the WMS requests, see `setParams()`.\n\t\t * @type {Record<string, any>}\n\t\t */\n\t\tthis.wmsParams = wmsParams;\n\t\tthis._updateWmsSize();\n\n\t\tthis.callInitHooks(WMSTileLayer);\n\t}\n\n\t// The size of the requested images: the tile size, doubled on retina displays with `detectRetina`.\n\t_updateWmsSize() {\n\t\tconst realRetina = this.options.detectRetina && window.devicePixelRatio > 1 ? 2 : 1;\n\t\tconst tileSize = this.getTileSize();\n\n\t\tthis.wmsParams.width = tileSize.x * realRetina;\n\t\tthis.wmsParams.height = tileSize.y * realRetina;\n\t}\n\n\t_applyRetina() {\n\t\tsuper._applyRetina();\n\t\tif (this.wmsParams) {\n\t\t\tthis._updateWmsSize();\n\t\t}\n\t}\n\n\t/**\n\t * Uses the CRS of the map (unless the `crs` option is set) and loads the tiles.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._updateCrs();\n\t\tsuper.onAdd(map);\n\t}\n\n\t_updateCrs() {\n\t\tthis._crs = this.options.crs ?? this._map.options.crs;\n\t\tthis._wmsVersion = parseFloat(this.wmsParams.version);\n\n\t\tconst projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';\n\t\tthis.wmsParams[projectionKey] = this._crs.code;\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\t\tevents.crschange = this._updateCrs;\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL of the `GetMap` request for a tile given its\n\t * coordinates.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\n\t\tconst tileBounds = this._tileCoordsToNwSe(coords),\n\t\tcrs = this._crs,\n\t\tbounds = new Bounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),\n\t\tmin = bounds.min,\n\t\tmax = bounds.max,\n\t\tbbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?\n\t\t\t[min.y, min.x, max.y, max.x] :\n\t\t\t[min.x, min.y, max.x, max.y]).join(',');\n\t\tconst url = new URL(super.getTileUrl(coords), document.baseURI);\n\t\tfor (const [k, v] of Object.entries({...this.wmsParams, bbox})) {\n\t\t\turl.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Returns the URL of the legend image (a `GetLegendGraphic` request) of the first\n\t * of the `layers` (with its style, if any), with the version, format and `uppercase`\n\t * option of the layer. `params` change or add parameters, e.g. `{layer: 'roads',\n\t * width: 20, height: 20}` or vendor parameters like `legend_options`.\n\t * @param {Record<string, any>} [params]\n\t * @returns {string}\n\t */\n\tgetLegendUrl(params) {\n\t\tconst {version, format, layers, styles} = this.wmsParams,\n\t\turl = new URL(this._url, document.baseURI);\n\t\tfor (const [k, v] of Object.entries({\n\t\t\tservice: 'WMS',\n\t\t\trequest: 'GetLegendGraphic',\n\t\t\tversion,\n\t\t\tformat,\n\t\t\tlayer: layers.split(',')[0],\n\t\t\tstyle: styles?.split(',')[0] || undefined,\n\t\t\t// required by the WMS 1.3 profile of SLD\n\t\t\tsld_version: parseFloat(version) >= 1.3 ? '1.1.0' : undefined,\n\t\t\t...params\n\t\t})) {\n\t\t\tif (v !== undefined) {\n\t\t\t\turl.searchParams.set(this.options.uppercase ? k.toUpperCase() : k, v);\n\t\t\t}\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Merges an object with the new parameters and re-requests tiles on the current screen\n\t * (unless `noRedraw` was set to true). The current tiles stay visible until the new\n\t * tiles have loaded, to avoid flickering.\n\t * @param {Record<string, any>} params\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetParams(params, noRedraw) {\n\n\t\tObject.assign(this.wmsParams, params);\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;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
+ {"version":3,"file":"WMSTileLayer.js","names":[],"sources":["../../../../src/layer/tile/WMSTileLayer.js"],"sourcesContent":["import {TileLayer} from './TileLayer.js';\nimport {EPSG4326} from '../../geo/crs/EPSG4326.js';\nimport {Bounds} from '../../geometry/Bounds.js';\n/** @import {CRS} from '../../geo/crs/CRS.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {TileLayerOptions} from './TileLayer.js' */\n\n/**\n * Options of `WMSTileLayer`. If any custom options not documented here are used, they\n * will be sent to the WMS server as extra parameters in each request URL. This can be\n * useful for\n * [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\n * @typedef {object} WMSTileLayerOptions\n * @property {string} [layers=''] **(required)** Comma-separated list of WMS layers to\n * show.\n * @property {string} [styles=''] Comma-separated list of WMS styles.\n * @property {string} [format='image/jpeg'] WMS image format (use `'image/png'` for\n * layers with transparency).\n * @property {boolean} [transparent=false] If `true`, the WMS service will return images\n * with transparency.\n * @property {string} [version='1.1.1'] Version of the WMS service to use.\n * @property {CRS|null} [crs=null] Coordinate Reference System to use for the WMS\n * requests, defaults to map CRS. Don't change this if you're not sure what it means.\n * @property {boolean} [uppercase=false] If `true`, WMS request parameter keys will be\n * uppercase.\n * @extends TileLayerOptions\n */\n\n/**\n * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile\n * layers on the map. Extends `TileLayer`.\n *\n * @example\n * ```js\n * const nexrad = new WMSTileLayer(\"http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi\", {\n * \tlayers: 'nexrad-n0r-900913',\n * \tformat: 'image/png',\n * \ttransparent: true,\n * \tattribution: \"Weather data © 2012 IEM Nexrad\"\n * });\n * ```\n */\nexport class WMSTileLayer extends TileLayer {\n\n\t/**\n\t * The default WMS parameters, which the options override, see `WMSTileLayerOptions`.\n\t * @type {Record<string, any>}\n\t */\n\tstatic defaultWmsParams = {\n\t\tservice: 'WMS',\n\t\trequest: 'GetMap',\n\t\tlayers: '',\n\t\tstyles: '',\n\t\tformat: 'image/jpeg',\n\t\ttransparent: false,\n\t\tversion: '1.1.1'\n\t};\n\n\tstatic defaultOptions = {\n\t\tcrs: null,\n\t\tuppercase: false\n\t};\n\n\t/**\n\t * Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS\n\t * parameters/options object.\n\t * @param {string} url The base URL of the WMS service.\n\t * @param {WMSTileLayerOptions & Record<string, unknown>} options The options and WMS\n\t * parameters.\n\t */\n\tconstructor(url, options) {\n\t\tsuper(url, options);\n\n\t\tconst wmsParams = {...WMSTileLayer.defaultWmsParams};\n\n\t\t// Options that are unknown in the prototype chain are considered WMS params.\n\t\tfor (const [key, value] of Object.entries(options)) {\n\t\t\tif (!(key in WMSTileLayer.defaultOptions)) {\n\t\t\t\twmsParams[key] = value;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * The parameters of the WMS requests, see `setParams()`.\n\t\t * @type {Record<string, any>}\n\t\t */\n\t\tthis.wmsParams = wmsParams;\n\t\tthis._updateWmsSize();\n\n\t\tthis.callInitHooks(WMSTileLayer);\n\t}\n\n\t// The size of the requested images: the tile size, doubled on retina displays with `detectRetina`.\n\t_updateWmsSize() {\n\t\tconst realRetina = this.options.detectRetina && window.devicePixelRatio > 1 ? 2 : 1;\n\t\tconst tileSize = this.getTileSize();\n\n\t\tthis.wmsParams.width = tileSize.x * realRetina;\n\t\tthis.wmsParams.height = tileSize.y * realRetina;\n\t}\n\n\t_applyRetina() {\n\t\tsuper._applyRetina();\n\t\tif (this.wmsParams) {\n\t\t\tthis._updateWmsSize();\n\t\t}\n\t}\n\n\t/**\n\t * Uses the CRS of the map (unless the `crs` option is set) and loads the tiles.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._updateCrs();\n\t\tsuper.onAdd(map);\n\t}\n\n\t_updateCrs() {\n\t\tthis._crs = this.options.crs ?? this._map.options.crs;\n\t\tthis._wmsVersion = parseFloat(this.wmsParams.version);\n\n\t\tdelete this.wmsParams.srs;\n\t\tdelete this.wmsParams.crs;\n\t\tthis.wmsParams[this._wmsVersion >= 1.3 ? 'crs' : 'srs'] = this._crs.code;\n\t}\n\n\t/**\n\t * Returns the map events the layer listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\t\tevents.crschange = this._updateCrs;\n\t\treturn events;\n\t}\n\n\t/**\n\t * Called only internally, returns the URL of the `GetMap` request for a tile given its\n\t * coordinates.\n\t * @group Extension methods\n\t * @param {Point} coords\n\t * @returns {string}\n\t */\n\tgetTileUrl(coords) {\n\n\t\tconst tileBounds = this._tileCoordsToNwSe(coords),\n\t\tcrs = this._crs,\n\t\tbounds = new Bounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),\n\t\tmin = bounds.min,\n\t\tmax = bounds.max,\n\t\tbbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?\n\t\t\t[min.y, min.x, max.y, max.x] :\n\t\t\t[min.x, min.y, max.x, max.y]).join(',');\n\t\tconst url = new URL(super.getTileUrl(coords), document.baseURI);\n\t\tfor (const [k, v] of Object.entries({...this.wmsParams, bbox})) {\n\t\t\turl.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Returns the URL of the legend image (a `GetLegendGraphic` request) of the first\n\t * of the `layers` (with its style, if any), with the version, format and `uppercase`\n\t * option of the layer. `params` change or add parameters, e.g. `{layer: 'roads',\n\t * width: 20, height: 20}` or vendor parameters like `legend_options`.\n\t * @param {Record<string, any>} [params]\n\t * @returns {string}\n\t */\n\tgetLegendUrl(params) {\n\t\tconst {version, format, layers, styles} = this.wmsParams,\n\t\turl = new URL(this._url, document.baseURI);\n\t\tfor (const [k, v] of Object.entries({\n\t\t\tservice: 'WMS',\n\t\t\trequest: 'GetLegendGraphic',\n\t\t\tversion,\n\t\t\tformat,\n\t\t\tlayer: layers.split(',')[0],\n\t\t\tstyle: styles?.split(',')[0] || undefined,\n\t\t\t// required by the WMS 1.3 profile of SLD\n\t\t\tsld_version: parseFloat(version) >= 1.3 ? '1.1.0' : undefined,\n\t\t\t...params\n\t\t})) {\n\t\t\tif (v !== undefined) {\n\t\t\t\turl.searchParams.set(this.options.uppercase ? k.toUpperCase() : k, v);\n\t\t\t}\n\t\t}\n\t\treturn url.toString();\n\t}\n\n\t/**\n\t * Merges an object with the new parameters and re-requests tiles on the current screen\n\t * (unless `noRedraw` was set to true). The current tiles stay visible until the new\n\t * tiles have loaded, to avoid flickering.\n\t * @param {Record<string, any>} params\n\t * @param {boolean} [noRedraw]\n\t * @returns {this}\n\t */\n\tsetParams(params, noRedraw) {\n\n\t\tObject.assign(this.wmsParams, params);\n\n\t\tif (this._map) { this._updateCrs(); }\n\n\t\tif (!noRedraw) {\n\t\t\tthis._keepCurrentTiles();\n\t\t\tthis.redraw();\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,eAAb,MAAa,qBAAqB,UAAU;;;;;CAM3C,OAAO,mBAAmB;EACzB,SAAS;EACT,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,aAAa;EACb,SAAS;CACV;CAEA,OAAO,iBAAiB;EACvB,KAAK;EACL,WAAW;CACZ;;;;;;;;CASA,YAAY,KAAK,SAAS;EACzB,MAAM,KAAK,OAAO;EAElB,MAAM,YAAY,EAAC,GAAG,aAAa,iBAAgB;EAGnD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,EAAE,OAAO,aAAa,iBACzB,UAAU,OAAO;;;;;EAQnB,KAAK,YAAY;EACjB,KAAK,eAAe;EAEpB,KAAK,cAAc,YAAY;CAChC;CAGA,iBAAiB;EAChB,MAAM,aAAa,KAAK,QAAQ,gBAAg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,IAAI,SAAS;CACrB;;;;;;;;;CAUA,aAAa,QAAQ;EACpB,MAAM,EAAC,SAAS,QAAQ,QAAQ,WAAU,KAAK,WAC/C,MAAM,IAAI,IAAI,KAAK,MAAM,SAAS,OAAO;EACzC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ;GACnC,SAAS;GACT,SAAS;GACT;GACA;GACA,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;GACzB,OAAO,QAAQ,MAAM,GAAG,CAAC,CAAC,MAAM,KAAA;GAEhC,aAAa,WAAW,OAAO,KAAK,MAAM,UAAU,KAAA;GACpD,GAAG;EACJ,CAAC,GACA,IAAI,MAAM,KAAA,GACT,IAAI,aAAa,IAAI,KAAK,QAAQ,YAAY,EAAE,YAAY,IAAI,GAAG,CAAC;EAGtE,OAAO,IAAI,SAAS;CACrB;;;;;;;;;CAUA,UAAU,QAAQ,UAAU;EAE3B,OAAO,OAAO,KAAK,WAAW,MAAM;EAEpC,IAAI,KAAK,MAAQ,KAAK,WAAW;EAEjC,IAAI,CAAC,UAAU;GACd,KAAK,kBAAkB;GACvB,KAAK,OAAO;EACb;EAEA,OAAO;CACR;AACD"}
@@ -2,7 +2,7 @@ import { stamp } from "../../core/Util.js";
2
2
  import { on } from "../../dom/DomEvent.js";
3
3
  import { Bounds } from "../../geometry/Bounds.js";
4
4
  import { Renderer } from "./Renderer.js";
5
- //#region src/layer/vector/Canvas.js
5
+ // src/layer/vector/Canvas.js
6
6
  /** @import {MaplairMap} from '../../map/Map.js' */
7
7
  /** @import {EventListener} from '../../core/Events.js' */
8
8
  /** @import {RendererOptions} from './Renderer.js' */
@@ -159,10 +159,8 @@ var Canvas = class Canvas extends Renderer {
159
159
  this._requestRedraw(layer);
160
160
  }
161
161
  _updateDashArray(layer) {
162
- if (typeof layer.options.dashArray === "string") {
163
- const parts = layer.options.dashArray.split(DASH_SEPARATOR_RE);
164
- layer.options._dashArray = parts.map((n) => Number(n)).filter((n) => !isNaN(n));
165
- } else layer.options._dashArray = layer.options.dashArray;
162
+ if (typeof layer.options.dashArray === "string") layer._dashArray = layer.options.dashArray.split(DASH_SEPARATOR_RE).map((n) => Number(n)).filter((n) => !isNaN(n));
163
+ else layer._dashArray = layer.options.dashArray;
166
164
  }
167
165
  _requestRedraw(layer) {
168
166
  if (!this._map) return;
@@ -233,14 +231,10 @@ var Canvas = class Canvas extends Renderer {
233
231
  }
234
232
  _updateCircle(layer) {
235
233
  if (!this._drawing || layer._empty()) return;
236
- const p = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), s = (Math.max(Math.round(layer._pxRadiusY), 1) || r) / r;
237
- if (s !== 1) {
238
- ctx.save();
239
- ctx.scale(1, s);
240
- }
234
+ const { x, y } = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), ry = Math.max(Math.round(layer._pxRadiusY), 1) || r;
241
235
  ctx.beginPath();
242
- ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);
243
- if (s !== 1) ctx.restore();
236
+ if (ry === r) ctx.arc(x, y, r, 0, Math.PI * 2);
237
+ else ctx.ellipse(x, y, r, ry, 0, 0, Math.PI * 2);
244
238
  this._fillStroke(ctx, layer);
245
239
  }
246
240
  _fillStroke(ctx, layer) {
@@ -252,7 +246,7 @@ var Canvas = class Canvas extends Renderer {
252
246
  }
253
247
  if (options.stroke && options.weight !== 0) {
254
248
  ctx.lineDashOffset = Number(options.dashOffset ?? 0);
255
- ctx.setLineDash(options._dashArray ?? []);
249
+ ctx.setLineDash(layer._dashArray ?? []);
256
250
  ctx.globalAlpha = options.opacity;
257
251
  ctx.lineWidth = options.weight;
258
252
  ctx.strokeStyle = options.color;
@@ -342,7 +336,6 @@ var Canvas = class Canvas extends Renderer {
342
336
  this._requestRedraw(layer);
343
337
  }
344
338
  };
345
- //#endregion
346
339
  export { Canvas };
347
340
 
348
341
  //# sourceMappingURL=Canvas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.js","names":["Util.stamp"],"sources":["../../../../src/layer/vector/Canvas.js"],"sourcesContent":["import {Renderer} from './Renderer.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport * as Util from '../../core/Util.js';\nimport {Bounds} from '../../geometry/Bounds.js';\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {EventListener} from '../../core/Events.js' */\n/** @import {RendererOptions} from './Renderer.js' */\n\nconst DASH_SEPARATOR_RE = /[, ]+/;\n\n/**\n * Options of `Canvas`.\n * @typedef {object} CanvasOptions\n * @property {number} [tolerance=0] How much to extend the click tolerance around a\n * path/object on the map.\n * @extends RendererOptions\n */\n\n/**\n * Allows vector layers to be displayed with [`<canvas>`](https://developer.mozilla.org/docs/Web/API/Canvas_API).\n * Inherits `Renderer`.\n *\n * @example\n * Use Canvas by default for all paths in the map:\n *\n * ```js\n * const map = new MaplairMap('map', {\n * \trenderer: new Canvas()\n * });\n * ```\n *\n * Use a Canvas renderer with extra padding for specific vector geometries:\n *\n * ```js\n * const map = new MaplairMap('map');\n * const myRenderer = new Canvas({ padding: 0.5 });\n * const line = new Polyline( coordinates, { renderer: myRenderer } );\n * const circle = new Circle( center, { renderer: myRenderer, radius: 100 } );\n * ```\n */\nexport class Canvas extends Renderer {\n\n\tstatic defaultOptions = {\n\t\ttolerance: 0\n\t};\n\n\t/**\n\t * Creates a Canvas renderer with the given options.\n\t * @overload\n\t * @param {CanvasOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Canvas);\n\t}\n\n\t/**\n\t * Returns the map events the renderer listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\t\tevents.viewprereset = this._onViewPreReset;\n\t\tevents.pixelratiochange = this._onPixelRatioChange;\n\t\treturn events;\n\t}\n\n\t// Redraws with the resolution of the new `devicePixelRatio`.\n\t_onPixelRatioChange() {\n\t\tthis._resizeContainer();\n\t\tthis._update();\n\t}\n\n\t_onViewPreReset() {\n\t\t// Set a flag so that a viewprereset+moveend+viewreset only updates&redraws once\n\t\tthis._postponeUpdatePaths = true;\n\t}\n\n\t/**\n\t * Adds the canvas to the map and draws the paths.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\n\t\t// Redraw vectors since canvas is cleared upon removal,\n\t\t// in case of removing the renderer itself from the map.\n\t\tthis._draw();\n\t}\n\n\t/**\n\t * Removes the canvas from the map.\n\t */\n\tonRemove() {\n\t\tsuper.onRemove();\n\n\t\tclearTimeout(this._pointerHoverThrottleTimeout);\n\t}\n\n\t_initContainer() {\n\t\tconst container = this._container = document.createElement('canvas');\n\n\t\tDomEvent.on(container, 'pointermove', this._onPointerMove, this);\n\t\tDomEvent.on(container, 'click dblclick pointerdown pointerup contextmenu', this._onClick, this);\n\t\tDomEvent.on(container, 'pointerout', this._handlePointerOut, this);\n\t\tcontainer['_maplair_disable_events'] = true;\n\n\t\tthis._ctx = container.getContext('2d');\n\t}\n\n\t_destroyContainer() {\n\t\tcancelAnimationFrame(this._redrawRequest);\n\t\tthis._redrawRequest = null;\n\t\tdelete this._ctx;\n\t\tsuper._destroyContainer();\n\t}\n\n\t_resizeContainer() {\n\t\tconst size = super._resizeContainer();\n\t\tconst m = this._ctxScale = window.devicePixelRatio;\n\n\t\t// set canvas size (also clearing it); use double size on retina\n\t\tthis._container.width = m * size.x;\n\t\tthis._container.height = m * size.y;\n\t}\n\n\t_updatePaths() {\n\t\tif (this._postponeUpdatePaths) { return; }\n\n\t\tthis._redrawBounds = null;\n\t\tfor (const layer of Object.values(this._layers)) {\n\t\t\tlayer._update();\n\t\t}\n\t\tthis._redraw();\n\t}\n\n\t_update() {\n\t\tif (this._map._animatingZoom && this._bounds) { return; }\n\n\t\tconst b = this._bounds,\n\t\ts = this._ctxScale;\n\n\t\t// translate so we use the same path coordinates after canvas element moves\n\t\tthis._ctx.setTransform(\n\t\t\ts, 0, 0, s,\n\t\t\t-b.min.x * s,\n\t\t\t-b.min.y * s);\n\n\t\t// Tell paths to redraw themselves\n\t\tthis.fire('update');\n\t}\n\n\t_reset() {\n\t\tsuper._reset();\n\n\t\tif (this._postponeUpdatePaths) {\n\t\t\tthis._postponeUpdatePaths = false;\n\t\t\tthis._updatePaths();\n\t\t}\n\t}\n\n\t_initPath(layer) {\n\t\tthis._updateDashArray(layer);\n\t\tthis._layers[Util.stamp(layer)] = layer;\n\n\t\tconst order = layer._order = {\n\t\t\tlayer,\n\t\t\tprev: this._drawLast,\n\t\t\tnext: null\n\t\t};\n\t\tif (this._drawLast) { this._drawLast.next = order; }\n\t\tthis._drawLast = order;\n\t\tthis._drawFirst ??= this._drawLast;\n\t}\n\n\t_addPath(layer) {\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_removePath(layer) {\n\t\tconst order = layer._order;\n\t\tconst next = order.next;\n\t\tconst prev = order.prev;\n\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else {\n\t\t\tthis._drawLast = prev;\n\t\t}\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else {\n\t\t\tthis._drawFirst = next;\n\t\t}\n\n\t\tdelete layer._order;\n\n\t\tdelete this._layers[Util.stamp(layer)];\n\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_updatePath(layer) {\n\t\t// Redraw the union of the layer's old pixel\n\t\t// bounds and the new pixel bounds.\n\t\tthis._extendRedrawBounds(layer);\n\t\tlayer._project();\n\t\tlayer._update();\n\t\t// The redraw will extend the redraw bounds\n\t\t// with the new pixel bounds.\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_updateStyle(layer) {\n\t\tthis._updateDashArray(layer);\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_updateDashArray(layer) {\n\t\tif (typeof layer.options.dashArray === 'string') {\n\t\t\tconst parts = layer.options.dashArray.split(DASH_SEPARATOR_RE);\n\t\t\t// Ignore dash array containing invalid lengths\n\t\t\tlayer.options._dashArray = parts.map(n => Number(n)).filter(n => !isNaN(n));\n\t\t} else {\n\t\t\tlayer.options._dashArray = layer.options.dashArray;\n\t\t}\n\t}\n\n\t_requestRedraw(layer) {\n\t\tif (!this._map) { return; }\n\n\t\tthis._extendRedrawBounds(layer);\n\t\tthis._redrawRequest ??= requestAnimationFrame(this._redraw.bind(this));\n\t}\n\n\t_extendRedrawBounds(layer) {\n\t\tif (layer._pxBounds) {\n\t\t\tconst padding = (layer.options.weight ?? 0) + 1;\n\t\t\tthis._redrawBounds ??= new Bounds();\n\t\t\tthis._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]));\n\t\t\tthis._redrawBounds.extend(layer._pxBounds.max.add([padding, padding]));\n\t\t}\n\t}\n\n\t_redraw() {\n\t\t// also when redrawing directly, see `_updatePaths()`\n\t\tcancelAnimationFrame(this._redrawRequest);\n\t\tthis._redrawRequest = null;\n\n\t\tif (this._redrawBounds) {\n\t\t\tthis._redrawBounds.min._floor();\n\t\t\tthis._redrawBounds.max._ceil();\n\t\t}\n\n\t\tthis._clear(); // clear layers in redraw bounds\n\t\tthis._draw(); // draw layers\n\n\t\tthis._redrawBounds = null;\n\t}\n\n\t_clear() {\n\t\tconst bounds = this._redrawBounds;\n\t\tif (bounds) {\n\t\t\tconst size = bounds.getSize();\n\t\t\tthis._ctx.clearRect(bounds.min.x, bounds.min.y, size.x, size.y);\n\t\t} else {\n\t\t\tthis._ctx.save();\n\t\t\tthis._ctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\t\tthis._ctx.clearRect(0, 0, this._container.width, this._container.height);\n\t\t\tthis._ctx.restore();\n\t\t}\n\t}\n\n\t_draw() {\n\t\tlet layer;\n\t\tconst bounds = this._redrawBounds;\n\t\tthis._ctx.save();\n\t\tif (bounds) {\n\t\t\tconst size = bounds.getSize();\n\t\t\tthis._ctx.beginPath();\n\t\t\tthis._ctx.rect(bounds.min.x, bounds.min.y, size.x, size.y);\n\t\t\tthis._ctx.clip();\n\t\t}\n\n\t\tthis._drawing = true;\n\n\t\tfor (let order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (!bounds || (layer._pxBounds && layer._pxBounds.intersects(bounds))) {\n\t\t\t\tlayer._updatePath();\n\t\t\t}\n\t\t}\n\n\t\tthis._drawing = false;\n\n\t\tthis._ctx.restore(); // Restore state before clipping.\n\t}\n\n\t_updatePoly(layer, closed) {\n\t\tif (!this._drawing) { return; }\n\n\t\tconst parts = layer._parts,\n\t\tctx = this._ctx;\n\n\t\tif (!parts.length) { return; }\n\n\t\tctx.beginPath();\n\n\t\tparts.forEach((p0) => {\n\t\t\tp0.forEach((p, j) => {\n\t\t\t\tctx[j ? 'lineTo' : 'moveTo'](p.x, p.y);\n\t\t\t});\n\t\t\tif (closed) {\n\t\t\t\tctx.closePath();\n\t\t\t}\n\t\t});\n\n\t\tthis._fillStroke(ctx, layer);\n\n\t\t// TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature\n\t}\n\n\t_updateCircle(layer) {\n\n\t\tif (!this._drawing || layer._empty()) { return; }\n\n\t\tconst p = layer._point,\n\t\tctx = this._ctx,\n\t\tr = Math.max(Math.round(layer._pxRadius), 1),\n\t\ts = (Math.max(Math.round(layer._pxRadiusY), 1) || r) / r;\n\n\t\tif (s !== 1) {\n\t\t\tctx.save();\n\t\t\tctx.scale(1, s);\n\t\t}\n\n\t\tctx.beginPath();\n\t\tctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);\n\n\t\tif (s !== 1) {\n\t\t\tctx.restore();\n\t\t}\n\n\t\tthis._fillStroke(ctx, layer);\n\t}\n\n\t_fillStroke(ctx, layer) {\n\t\tconst options = layer.options;\n\n\t\tif (options.fill) {\n\t\t\tctx.globalAlpha = options.fillOpacity;\n\t\t\tctx.fillStyle = options.fillColor ?? options.color;\n\t\t\tctx.fill(options.fillRule || 'evenodd');\n\t\t}\n\n\t\tif (options.stroke && options.weight !== 0) {\n\t\t\tctx.lineDashOffset = Number(options.dashOffset ?? 0);\n\t\t\tctx.setLineDash(options._dashArray ?? []);\n\t\t\tctx.globalAlpha = options.opacity;\n\t\t\tctx.lineWidth = options.weight;\n\t\t\tctx.strokeStyle = options.color;\n\t\t\tctx.lineCap = options.lineCap;\n\t\t\tctx.lineJoin = options.lineJoin;\n\t\t\tctx.stroke();\n\t\t}\n\t}\n\n\t// The hit detection checks the `interactive` option of the layers,\n\t// the hovered layer is left on the next pointer move.\n\t_updateInteractive() {}\n\n\t// Canvas obviously doesn't have pointer events for individual drawn objects,\n\t// so we emulate that by calculating what's under the pointer on pointermove/click manually\n\n\t_onClick(e) {\n\t\tconst point = this._map.pointerEventToLayerPoint(e);\n\t\tlet layer, clickedLayer;\n\n\t\tfor (let order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (layer.options.interactive && layer._containsPoint(point)) {\n\t\t\t\tif (!(e.type === 'click' || e.type === 'preclick') || !this._map._draggableMoved(layer)) {\n\t\t\t\t\tclickedLayer = layer;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._fireEvent(clickedLayer ? [clickedLayer] : false, e);\n\t}\n\n\t_onPointerMove(e) {\n\t\tif (!this._map || this._map.dragging.moving() || this._map._animatingZoom) { return; }\n\n\t\tconst point = this._map.pointerEventToLayerPoint(e);\n\t\tthis._handlePointerHover(e, point);\n\t}\n\n\n\t_handlePointerOut(e) {\n\t\tconst layer = this._hoveredLayer;\n\t\tif (layer) {\n\t\t\t// if we're leaving the layer, fire pointerout\n\t\t\tthis._container.classList.remove('maplair-interactive');\n\t\t\tthis._fireEvent([layer], e, 'pointerout');\n\t\t\tthis._hoveredLayer = null;\n\t\t\tthis._pointerHoverThrottled = false;\n\t\t}\n\t}\n\n\t_handlePointerHover(e, point) {\n\t\tif (this._pointerHoverThrottled) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet layer, candidateHoveredLayer;\n\n\t\tfor (let order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (layer.options.interactive && layer._containsPoint(point)) {\n\t\t\t\tcandidateHoveredLayer = layer;\n\t\t\t}\n\t\t}\n\n\t\tif (candidateHoveredLayer !== this._hoveredLayer) {\n\t\t\tthis._handlePointerOut(e);\n\n\t\t\tif (candidateHoveredLayer) {\n\t\t\t\tthis._container.classList.add('maplair-interactive'); // change cursor\n\t\t\t\tthis._fireEvent([candidateHoveredLayer], e, 'pointerover');\n\t\t\t\tthis._hoveredLayer = candidateHoveredLayer;\n\t\t\t}\n\t\t}\n\n\t\tthis._fireEvent(this._hoveredLayer ? [this._hoveredLayer] : false, e);\n\n\t\tthis._pointerHoverThrottled = true;\n\t\tthis._pointerHoverThrottleTimeout = setTimeout((() => {\n\t\t\tthis._pointerHoverThrottled = false;\n\t\t}), 32);\n\t}\n\n\t_fireEvent(layers, e, type) {\n\t\tthis._map._fireDOMEvent(e, type || e.type, layers);\n\t}\n\n\t_bringToFront(layer) {\n\t\tconst order = layer._order;\n\n\t\tif (!order) { return; }\n\n\t\tconst next = order.next;\n\t\tconst prev = order.prev;\n\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else {\n\t\t\t// Already last\n\t\t\treturn;\n\t\t}\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else if (next) {\n\t\t\t// Update first entry unless this is the\n\t\t\t// single entry\n\t\t\tthis._drawFirst = next;\n\t\t}\n\n\t\torder.prev = this._drawLast;\n\t\tthis._drawLast.next = order;\n\n\t\torder.next = null;\n\t\tthis._drawLast = order;\n\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_bringToBack(layer) {\n\t\tconst order = layer._order;\n\n\t\tif (!order) { return; }\n\n\t\tconst next = order.next;\n\t\tconst prev = order.prev;\n\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else {\n\t\t\t// Already first\n\t\t\treturn;\n\t\t}\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else if (prev) {\n\t\t\t// Update last entry unless this is the\n\t\t\t// single entry\n\t\t\tthis._drawLast = prev;\n\t\t}\n\n\t\torder.prev = null;\n\n\t\torder.next = this._drawFirst;\n\t\tthis._drawFirst.prev = order;\n\t\tthis._drawFirst = order;\n\n\t\tthis._requestRedraw(layer);\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgC1B,IAAa,SAAb,MAAa,eAAe,SAAS;CAEpC,OAAO,iBAAiB,EACvB,WAAW,EACZ;;;;;;;;;CAUA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,MAAM;CAC1B;;;;;CAMA,YAAY;EACX,MAAM,SAAS,MAAM,UAAU;EAC/B,OAAO,eAAe,KAAK;EAC3B,OAAO,mBAAmB,KAAK;EAC/B,OAAO;CACR;CAGA,sBAAsB;EACrB,KAAK,iBAAiB;EACtB,KAAK,QAAQ;CACd;CAEA,kBAAkB;EAEjB,KAAK,uBAAuB;CAC7B;;;;;CAMA,MAAM,KAAK;EACV,MAAM,MAAM,GAAG;EAIf,KAAK,MAAM;CACZ;;;;CAKA,WAAW;EACV,MAAM,SAAS;EAEf,aAAa,KAAK,4BAA4B;CAC/C;CAEA,iBAAiB;EAChB,MAAM,YAAY,KAAK,aAAa,SAAS,cAAc,QAAQ;EAEnE,GAAY,WAAW,eAAe,KAAK,gBAAgB,IAAI;EAC/D,GAAY,WAAW,oDAAoD,KAAK,UAAU,IAAI;EAC9F,GAAY,WAAW,cAAc,KAAK,mBAAmB,IAAI;EACjE,UAAU,6BAA6B;EAEvC,KAAK,OAAO,UAAU,WAAW,IAAI;CACtC;CAEA,oBAAoB;EACnB,qBAAqB,KAAK,cAAc;EACxC,KAAK,iBAAiB;EACtB,OAAO,KAAK;EACZ,MAAM,kBAAkB;CACzB;CAEA,mBAAmB;EAClB,MAAM,OAAO,MAAM,iBAAiB;EACpC,MAAM,IAAI,KAAK,YAAY,OAAO;EAGlC,KAAK,WAAW,QA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AAU,OAAO;EAEtB,MAAM,OAAO;EACb,KAAK,YAAY;EAEjB,KAAK,eAAe,KAAK;CAC1B;CAEA,aAAa,OAAO;EACnB,MAAM,QAAQ,MAAM;EAEpB,IAAI,CAAC,OAAS;EAEd,MAAM,OAAO,MAAM;EACnB,MAAM,OAAO,MAAM;EAEnB,IAAI,MACH,KAAK,OAAO;OAGZ;EAED,IAAI,MACH,KAAK,OAAO;OACN,IAAI,MAGV,KAAK,YAAY;EAGlB,MAAM,OAAO;EAEb,MAAM,OAAO,KAAK;EAClB,KAAK,WAAW,OAAO;EACvB,KAAK,aAAa;EAElB,KAAK,eAAe,KAAK;CAC1B;AACD"}
1
+ {"version":3,"file":"Canvas.js","names":["Util.stamp"],"sources":["../../../../src/layer/vector/Canvas.js"],"sourcesContent":["import {Renderer} from './Renderer.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport * as Util from '../../core/Util.js';\nimport {Bounds} from '../../geometry/Bounds.js';\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {EventListener} from '../../core/Events.js' */\n/** @import {RendererOptions} from './Renderer.js' */\n\nconst DASH_SEPARATOR_RE = /[, ]+/;\n\n/**\n * Options of `Canvas`.\n * @typedef {object} CanvasOptions\n * @property {number} [tolerance=0] How much to extend the click tolerance around a\n * path/object on the map.\n * @extends RendererOptions\n */\n\n/**\n * Allows vector layers to be displayed with [`<canvas>`](https://developer.mozilla.org/docs/Web/API/Canvas_API).\n * Inherits `Renderer`.\n *\n * @example\n * Use Canvas by default for all paths in the map:\n *\n * ```js\n * const map = new MaplairMap('map', {\n * \trenderer: new Canvas()\n * });\n * ```\n *\n * Use a Canvas renderer with extra padding for specific vector geometries:\n *\n * ```js\n * const map = new MaplairMap('map');\n * const myRenderer = new Canvas({ padding: 0.5 });\n * const line = new Polyline( coordinates, { renderer: myRenderer } );\n * const circle = new Circle( center, { renderer: myRenderer, radius: 100 } );\n * ```\n */\nexport class Canvas extends Renderer {\n\n\tstatic defaultOptions = {\n\t\ttolerance: 0\n\t};\n\n\t/**\n\t * Creates a Canvas renderer with the given options.\n\t * @overload\n\t * @param {CanvasOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Canvas);\n\t}\n\n\t/**\n\t * Returns the map events the renderer listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\t\tevents.viewprereset = this._onViewPreReset;\n\t\tevents.pixelratiochange = this._onPixelRatioChange;\n\t\treturn events;\n\t}\n\n\t// Redraws with the resolution of the new `devicePixelRatio`.\n\t_onPixelRatioChange() {\n\t\tthis._resizeContainer();\n\t\tthis._update();\n\t}\n\n\t_onViewPreReset() {\n\t\t// Set a flag so that a viewprereset+moveend+viewreset only updates&redraws once\n\t\tthis._postponeUpdatePaths = true;\n\t}\n\n\t/**\n\t * Adds the canvas to the map and draws the paths.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\n\t\t// Redraw vectors since canvas is cleared upon removal,\n\t\t// in case of removing the renderer itself from the map.\n\t\tthis._draw();\n\t}\n\n\t/**\n\t * Removes the canvas from the map.\n\t */\n\tonRemove() {\n\t\tsuper.onRemove();\n\n\t\tclearTimeout(this._pointerHoverThrottleTimeout);\n\t}\n\n\t_initContainer() {\n\t\tconst container = this._container = document.createElement('canvas');\n\n\t\tDomEvent.on(container, 'pointermove', this._onPointerMove, this);\n\t\tDomEvent.on(container, 'click dblclick pointerdown pointerup contextmenu', this._onClick, this);\n\t\tDomEvent.on(container, 'pointerout', this._handlePointerOut, this);\n\t\tcontainer['_maplair_disable_events'] = true;\n\n\t\tthis._ctx = container.getContext('2d');\n\t}\n\n\t_destroyContainer() {\n\t\tcancelAnimationFrame(this._redrawRequest);\n\t\tthis._redrawRequest = null;\n\t\tdelete this._ctx;\n\t\tsuper._destroyContainer();\n\t}\n\n\t_resizeContainer() {\n\t\tconst size = super._resizeContainer();\n\t\tconst m = this._ctxScale = window.devicePixelRatio;\n\n\t\t// set canvas size (also clearing it); use double size on retina\n\t\tthis._container.width = m * size.x;\n\t\tthis._container.height = m * size.y;\n\t}\n\n\t_updatePaths() {\n\t\tif (this._postponeUpdatePaths) { return; }\n\n\t\tthis._redrawBounds = null;\n\t\tfor (const layer of Object.values(this._layers)) {\n\t\t\tlayer._update();\n\t\t}\n\t\tthis._redraw();\n\t}\n\n\t_update() {\n\t\tif (this._map._animatingZoom && this._bounds) { return; }\n\n\t\tconst b = this._bounds,\n\t\ts = this._ctxScale;\n\n\t\t// translate so we use the same path coordinates after canvas element moves\n\t\tthis._ctx.setTransform(\n\t\t\ts, 0, 0, s,\n\t\t\t-b.min.x * s,\n\t\t\t-b.min.y * s);\n\n\t\t// Tell paths to redraw themselves\n\t\tthis.fire('update');\n\t}\n\n\t_reset() {\n\t\tsuper._reset();\n\n\t\tif (this._postponeUpdatePaths) {\n\t\t\tthis._postponeUpdatePaths = false;\n\t\t\tthis._updatePaths();\n\t\t}\n\t}\n\n\t_initPath(layer) {\n\t\tthis._updateDashArray(layer);\n\t\tthis._layers[Util.stamp(layer)] = layer;\n\n\t\tconst order = layer._order = {\n\t\t\tlayer,\n\t\t\tprev: this._drawLast,\n\t\t\tnext: null\n\t\t};\n\t\tif (this._drawLast) { this._drawLast.next = order; }\n\t\tthis._drawLast = order;\n\t\tthis._drawFirst ??= this._drawLast;\n\t}\n\n\t_addPath(layer) {\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_removePath(layer) {\n\t\tconst order = layer._order;\n\t\tconst next = order.next;\n\t\tconst prev = order.prev;\n\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else {\n\t\t\tthis._drawLast = prev;\n\t\t}\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else {\n\t\t\tthis._drawFirst = next;\n\t\t}\n\n\t\tdelete layer._order;\n\n\t\tdelete this._layers[Util.stamp(layer)];\n\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_updatePath(layer) {\n\t\t// Redraw the union of the layer's old pixel\n\t\t// bounds and the new pixel bounds.\n\t\tthis._extendRedrawBounds(layer);\n\t\tlayer._project();\n\t\tlayer._update();\n\t\t// The redraw will extend the redraw bounds\n\t\t// with the new pixel bounds.\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_updateStyle(layer) {\n\t\tthis._updateDashArray(layer);\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_updateDashArray(layer) {\n\t\tif (typeof layer.options.dashArray === 'string') {\n\t\t\tconst parts = layer.options.dashArray.split(DASH_SEPARATOR_RE);\n\t\t\t// Ignore dash array containing invalid lengths\n\t\t\tlayer._dashArray = parts.map(n => Number(n)).filter(n => !isNaN(n));\n\t\t} else {\n\t\t\tlayer._dashArray = layer.options.dashArray;\n\t\t}\n\t}\n\n\t_requestRedraw(layer) {\n\t\tif (!this._map) { return; }\n\n\t\tthis._extendRedrawBounds(layer);\n\t\tthis._redrawRequest ??= requestAnimationFrame(this._redraw.bind(this));\n\t}\n\n\t_extendRedrawBounds(layer) {\n\t\tif (layer._pxBounds) {\n\t\t\tconst padding = (layer.options.weight ?? 0) + 1;\n\t\t\tthis._redrawBounds ??= new Bounds();\n\t\t\tthis._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]));\n\t\t\tthis._redrawBounds.extend(layer._pxBounds.max.add([padding, padding]));\n\t\t}\n\t}\n\n\t_redraw() {\n\t\t// also when redrawing directly, see `_updatePaths()`\n\t\tcancelAnimationFrame(this._redrawRequest);\n\t\tthis._redrawRequest = null;\n\n\t\tif (this._redrawBounds) {\n\t\t\tthis._redrawBounds.min._floor();\n\t\t\tthis._redrawBounds.max._ceil();\n\t\t}\n\n\t\tthis._clear(); // clear layers in redraw bounds\n\t\tthis._draw(); // draw layers\n\n\t\tthis._redrawBounds = null;\n\t}\n\n\t_clear() {\n\t\tconst bounds = this._redrawBounds;\n\t\tif (bounds) {\n\t\t\tconst size = bounds.getSize();\n\t\t\tthis._ctx.clearRect(bounds.min.x, bounds.min.y, size.x, size.y);\n\t\t} else {\n\t\t\tthis._ctx.save();\n\t\t\tthis._ctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\t\tthis._ctx.clearRect(0, 0, this._container.width, this._container.height);\n\t\t\tthis._ctx.restore();\n\t\t}\n\t}\n\n\t_draw() {\n\t\tlet layer;\n\t\tconst bounds = this._redrawBounds;\n\t\tthis._ctx.save();\n\t\tif (bounds) {\n\t\t\tconst size = bounds.getSize();\n\t\t\tthis._ctx.beginPath();\n\t\t\tthis._ctx.rect(bounds.min.x, bounds.min.y, size.x, size.y);\n\t\t\tthis._ctx.clip();\n\t\t}\n\n\t\tthis._drawing = true;\n\n\t\tfor (let order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (!bounds || (layer._pxBounds && layer._pxBounds.intersects(bounds))) {\n\t\t\t\tlayer._updatePath();\n\t\t\t}\n\t\t}\n\n\t\tthis._drawing = false;\n\n\t\tthis._ctx.restore(); // Restore state before clipping.\n\t}\n\n\t_updatePoly(layer, closed) {\n\t\tif (!this._drawing) { return; }\n\n\t\tconst parts = layer._parts,\n\t\tctx = this._ctx;\n\n\t\tif (!parts.length) { return; }\n\n\t\tctx.beginPath();\n\n\t\tparts.forEach((p0) => {\n\t\t\tp0.forEach((p, j) => {\n\t\t\t\tctx[j ? 'lineTo' : 'moveTo'](p.x, p.y);\n\t\t\t});\n\t\t\tif (closed) {\n\t\t\t\tctx.closePath();\n\t\t\t}\n\t\t});\n\n\t\tthis._fillStroke(ctx, layer);\n\n\t\t// TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature\n\t}\n\n\t_updateCircle(layer) {\n\n\t\tif (!this._drawing || layer._empty()) { return; }\n\n\t\tconst {x, y} = layer._point,\n\t\tctx = this._ctx,\n\t\tr = Math.max(Math.round(layer._pxRadius), 1),\n\t\try = Math.max(Math.round(layer._pxRadiusY), 1) || r;\n\n\t\tctx.beginPath();\n\t\t// arc is faster for circles in Chrome and Firefox, ellipse for everything else\n\t\tif (ry === r) {\n\t\t\tctx.arc(x, y, r, 0, Math.PI * 2);\n\t\t} else {\n\t\t\tctx.ellipse(x, y, r, ry, 0, 0, Math.PI * 2);\n\t\t}\n\n\t\tthis._fillStroke(ctx, layer);\n\t}\n\n\t_fillStroke(ctx, layer) {\n\t\tconst options = layer.options;\n\n\t\tif (options.fill) {\n\t\t\tctx.globalAlpha = options.fillOpacity;\n\t\t\tctx.fillStyle = options.fillColor ?? options.color;\n\t\t\tctx.fill(options.fillRule || 'evenodd');\n\t\t}\n\n\t\tif (options.stroke && options.weight !== 0) {\n\t\t\tctx.lineDashOffset = Number(options.dashOffset ?? 0);\n\t\t\tctx.setLineDash(layer._dashArray ?? []);\n\t\t\tctx.globalAlpha = options.opacity;\n\t\t\tctx.lineWidth = options.weight;\n\t\t\tctx.strokeStyle = options.color;\n\t\t\tctx.lineCap = options.lineCap;\n\t\t\tctx.lineJoin = options.lineJoin;\n\t\t\tctx.stroke();\n\t\t}\n\t}\n\n\t// The hit detection checks the `interactive` option of the layers,\n\t// the hovered layer is left on the next pointer move.\n\t_updateInteractive() {}\n\n\t// Canvas obviously doesn't have pointer events for individual drawn objects,\n\t// so we emulate that by calculating what's under the pointer on pointermove/click manually\n\n\t_onClick(e) {\n\t\tconst point = this._map.pointerEventToLayerPoint(e);\n\t\tlet layer, clickedLayer;\n\n\t\tfor (let order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (layer.options.interactive && layer._containsPoint(point)) {\n\t\t\t\tif (!(e.type === 'click' || e.type === 'preclick') || !this._map._draggableMoved(layer)) {\n\t\t\t\t\tclickedLayer = layer;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis._fireEvent(clickedLayer ? [clickedLayer] : false, e);\n\t}\n\n\t_onPointerMove(e) {\n\t\tif (!this._map || this._map.dragging.moving() || this._map._animatingZoom) { return; }\n\n\t\tconst point = this._map.pointerEventToLayerPoint(e);\n\t\tthis._handlePointerHover(e, point);\n\t}\n\n\n\t_handlePointerOut(e) {\n\t\tconst layer = this._hoveredLayer;\n\t\tif (layer) {\n\t\t\t// if we're leaving the layer, fire pointerout\n\t\t\tthis._container.classList.remove('maplair-interactive');\n\t\t\tthis._fireEvent([layer], e, 'pointerout');\n\t\t\tthis._hoveredLayer = null;\n\t\t\tthis._pointerHoverThrottled = false;\n\t\t}\n\t}\n\n\t_handlePointerHover(e, point) {\n\t\tif (this._pointerHoverThrottled) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet layer, candidateHoveredLayer;\n\n\t\tfor (let order = this._drawFirst; order; order = order.next) {\n\t\t\tlayer = order.layer;\n\t\t\tif (layer.options.interactive && layer._containsPoint(point)) {\n\t\t\t\tcandidateHoveredLayer = layer;\n\t\t\t}\n\t\t}\n\n\t\tif (candidateHoveredLayer !== this._hoveredLayer) {\n\t\t\tthis._handlePointerOut(e);\n\n\t\t\tif (candidateHoveredLayer) {\n\t\t\t\tthis._container.classList.add('maplair-interactive'); // change cursor\n\t\t\t\tthis._fireEvent([candidateHoveredLayer], e, 'pointerover');\n\t\t\t\tthis._hoveredLayer = candidateHoveredLayer;\n\t\t\t}\n\t\t}\n\n\t\tthis._fireEvent(this._hoveredLayer ? [this._hoveredLayer] : false, e);\n\n\t\tthis._pointerHoverThrottled = true;\n\t\tthis._pointerHoverThrottleTimeout = setTimeout((() => {\n\t\t\tthis._pointerHoverThrottled = false;\n\t\t}), 32);\n\t}\n\n\t_fireEvent(layers, e, type) {\n\t\tthis._map._fireDOMEvent(e, type || e.type, layers);\n\t}\n\n\t_bringToFront(layer) {\n\t\tconst order = layer._order;\n\n\t\tif (!order) { return; }\n\n\t\tconst next = order.next;\n\t\tconst prev = order.prev;\n\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else {\n\t\t\t// Already last\n\t\t\treturn;\n\t\t}\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else if (next) {\n\t\t\t// Update first entry unless this is the\n\t\t\t// single entry\n\t\t\tthis._drawFirst = next;\n\t\t}\n\n\t\torder.prev = this._drawLast;\n\t\tthis._drawLast.next = order;\n\n\t\torder.next = null;\n\t\tthis._drawLast = order;\n\n\t\tthis._requestRedraw(layer);\n\t}\n\n\t_bringToBack(layer) {\n\t\tconst order = layer._order;\n\n\t\tif (!order) { return; }\n\n\t\tconst next = order.next;\n\t\tconst prev = order.prev;\n\n\t\tif (prev) {\n\t\t\tprev.next = next;\n\t\t} else {\n\t\t\t// Already first\n\t\t\treturn;\n\t\t}\n\t\tif (next) {\n\t\t\tnext.prev = prev;\n\t\t} else if (prev) {\n\t\t\t// Update last entry unless this is the\n\t\t\t// single entry\n\t\t\tthis._drawLast = prev;\n\t\t}\n\n\t\torder.prev = null;\n\n\t\torder.next = this._drawFirst;\n\t\tthis._drawFirst.prev = order;\n\t\tthis._drawFirst = order;\n\n\t\tthis._requestRedraw(layer);\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgC1B,IAAa,SAAb,MAAa,eAAe,SAAS;CAEpC,OAAO,iBAAiB,EACvB,WAAW,EACZ;;;;;;;;;CAUA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,MAAM;CAC1B;;;;;CAMA,YAAY;EACX,MAAM,SAAS,MAAM,UAAU;EAC/B,OAAO,eAAe,KAAK;EAC3B,OAAO,mBAAmB,KAAK;EAC/B,OAAO;CACR;CAGA,sBAAsB;EACrB,KAAK,iBAAiB;EACtB,KAAK,QAAQ;CACd;CAEA,kBAAkB;EAEjB,KAAK,uBAAuB;CAC7B;;;;;CAMA,MAAM,KAAK;EACV,MAAM,MAAM,GAAG;EAIf,KAAK,MAAM;CACZ;;;;CAKA,WAAW;EACV,MAAM,SAAS;EAEf,aAAa,KAAK,4BAA4B;CAC/C;CAEA,iBAAiB;EAChB,MAAM,YAA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AC/B,IAAI,EAAE;CACP;CAEA,WAAW,QAAQ,GAAG,MAAM;EAC3B,KAAK,KAAK,cAAc,GAAG,QAAQ,EAAE,MAAM,MAAM;CAClD;CAEA,cAAc,OAAO;EACpB,MAAM,QAAQ,MAAM;EAEpB,IAAI,CAAC,OAAS;EAEd,MAAM,OAAO,MAAM;EACnB,MAAM,OAAO,MAAM;EAEnB,IAAI,MACH,KAAK,OAAO;OAGZ;EAED,IAAI,MACH,KAAK,OAAO;OACN,IAAI,MAGV,KAAK,aAAa;EAGnB,MAAM,OAAO,KAAK;EAClB,KAAK,UAAU,OAAO;EAEtB,MAAM,OAAO;EACb,KAAK,YAAY;EAEjB,KAAK,eAAe,KAAK;CAC1B;CAEA,aAAa,OAAO;EACnB,MAAM,QAAQ,MAAM;EAEpB,IAAI,CAAC,OAAS;EAEd,MAAM,OAAO,MAAM;EACnB,MAAM,OAAO,MAAM;EAEnB,IAAI,MACH,KAAK,OAAO;OAGZ;EAED,IAAI,MACH,KAAK,OAAO;OACN,IAAI,MAGV,KAAK,YAAY;EAGlB,MAAM,OAAO;EAEb,MAAM,OAAO,KAAK;EAClB,KAAK,WAAW,OAAO;EACvB,KAAK,aAAa;EAElB,KAAK,eAAe,KAAK;CAC1B;AACD"}
@@ -1,7 +1,7 @@
1
1
  import { LatLngBounds } from "../../geo/LatLngBounds.js";
2
2
  import { CircleMarker } from "./CircleMarker.js";
3
3
  import { EarthCRS } from "../../geo/crs/EarthCRS.js";
4
- //#region src/layer/vector/Circle.js
4
+ // src/layer/vector/Circle.js
5
5
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
6
6
  /** @import {CircleMarkerOptions} from './CircleMarker.js' */
7
7
  /**
@@ -35,10 +35,12 @@ var Circle = class Circle extends CircleMarker {
35
35
  this.callInitHooks(Circle);
36
36
  }
37
37
  /**
38
- * Returns the `LatLngBounds` of the path.
38
+ * Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're
39
+ * approximated on a sphere.
39
40
  * @returns {LatLngBounds}
40
41
  */
41
42
  getBounds() {
43
+ if (!this._map) return this._latlng.toBounds(this._radius * 2);
42
44
  const half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];
43
45
  return new LatLngBounds(this._map.layerPointToLatLng(this._point.subtract(half)), this._map.layerPointToLatLng(this._point.add(half)));
44
46
  }
@@ -59,7 +61,6 @@ var Circle = class Circle extends CircleMarker {
59
61
  this._updateBounds();
60
62
  }
61
63
  };
62
- //#endregion
63
64
  export { Circle };
64
65
 
65
66
  //# sourceMappingURL=Circle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Circle.js","names":[],"sources":["../../../../src/layer/vector/Circle.js"],"sourcesContent":["import {CircleMarker} from './CircleMarker.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\nimport {EarthCRS} from '../../geo/crs/EarthCRS.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {CircleMarkerOptions} from './CircleMarker.js' */\n\n\n/**\n * Options of `Circle`.\n * @typedef {object} CircleOptions\n * @property {number} [radius] Radius of the circle, in meters.\n * @extends CircleMarkerOptions\n */\n\n/**\n * A class for drawing circle overlays on a map with radius specified in meters.\n * Extends `CircleMarker`, its `setRadius()` and `getRadius()` use meters.\n *\n * It's an approximation and starts to diverge from a real circle closer to poles\n * (due to projection distortion).\n *\n * @example\n * ```js\n * new Circle([50.5, 30.5], {radius: 200}).addTo(map);\n * ```\n */\nexport class Circle extends CircleMarker {\n\n\t/**\n\t * Instantiates a circle object given a geographical point, and an options object\n\t * which contains the circle radius.\n\t * @param {LatLngExpression} latlng\n\t * @param {CircleOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper(latlng, options);\n\n\t\tif (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }\n\n\t\tthis.callInitHooks(Circle);\n\t}\n\n\t/**\n\t * Returns the `LatLngBounds` of the path.\n\t * @returns {LatLngBounds}\n\t */\n\tgetBounds() {\n\t\tconst half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];\n\n\t\treturn new LatLngBounds(\n\t\t\tthis._map.layerPointToLatLng(this._point.subtract(half)),\n\t\t\tthis._map.layerPointToLatLng(this._point.add(half)));\n\t}\n\n\t_project() {\n\n\t\tconst lng = this._latlng.lng,\n\t\tlat = this._latlng.lat,\n\t\tmap = this._map,\n\t\tcrs = map.options.crs;\n\n\t\tif (crs.distance === EarthCRS.distance) {\n\t\t\tconst d = Math.PI / 180,\n\t\t\tlatR = (this._radius / EarthCRS.R) / d,\n\t\t\ttop = map.project([lat + latR, lng]),\n\t\t\tbottom = map.project([lat - latR, lng]),\n\t\t\tp = top.add(bottom).divideBy(2),\n\t\t\tlat2 = map.unproject(p).lat;\n\t\t\t// Longitude span from the haversine form of the spherical law of cosines. The plain acos() form\n\t\t\t// loses precision for radii of about a metre and less, where cos(latR) is too close to 1 (#6120).\n\t\t\tlet lngR = 2 * Math.asin(Math.sqrt(\n\t\t\t\t(Math.sin(latR * d / 2) ** 2 - Math.sin((lat2 - lat) * d / 2) ** 2) /\n\t\t\t\t(Math.cos(lat * d) * Math.cos(lat2 * d)))) / d;\n\n\t\t\tif (isNaN(lngR) || lngR === 0) {\n\t\t\t\tlngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425\n\t\t\t}\n\n\t\t\tthis._point = p.subtract(map.getPixelOrigin());\n\t\t\tthis._pxRadius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR]).x;\n\t\t\tthis._pxRadiusY = p.y - top.y;\n\n\t\t} else {\n\t\t\tconst latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));\n\n\t\t\tthis._point = map.latLngToLayerPoint(this._latlng);\n\t\t\tthis._pxRadius = Math.abs(this._point.x - map.latLngToLayerPoint(latlng2).x);\n\t\t}\n\n\t\tthis._updateBounds();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,SAAb,MAAa,eAAe,aAAa;;;;;;;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MAAM,IAAI,CAAC,CAAC,CAAC;GACzE,KAAK,aAAa,EAAE,IAAI,IAAI;EAE7B,OAAO;GACN,MAAM,UAAU,IAAI,UAAU,IAAI,QAAQ,KAAK,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;GAEnF,KAAK,SAAS,IAAI,mBAAmB,KAAK,OAAO;GACjD,KAAK,YAAY,KAAK,IAAI,KAAK,OAAO,IAAI,IAAI,mBAAmB,OAAO,CAAC,CAAC,CAAC;EAC5E;EAEA,KAAK,cAAc;CACpB;AACD"}
1
+ {"version":3,"file":"Circle.js","names":[],"sources":["../../../../src/layer/vector/Circle.js"],"sourcesContent":["import {CircleMarker} from './CircleMarker.js';\nimport {LatLngBounds} from '../../geo/LatLngBounds.js';\nimport {EarthCRS} from '../../geo/crs/EarthCRS.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {CircleMarkerOptions} from './CircleMarker.js' */\n\n\n/**\n * Options of `Circle`.\n * @typedef {object} CircleOptions\n * @property {number} [radius] Radius of the circle, in meters.\n * @extends CircleMarkerOptions\n */\n\n/**\n * A class for drawing circle overlays on a map with radius specified in meters.\n * Extends `CircleMarker`, its `setRadius()` and `getRadius()` use meters.\n *\n * It's an approximation and starts to diverge from a real circle closer to poles\n * (due to projection distortion).\n *\n * @example\n * ```js\n * new Circle([50.5, 30.5], {radius: 200}).addTo(map);\n * ```\n */\nexport class Circle extends CircleMarker {\n\n\t/**\n\t * Instantiates a circle object given a geographical point, and an options object\n\t * which contains the circle radius.\n\t * @param {LatLngExpression} latlng\n\t * @param {CircleOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper(latlng, options);\n\n\t\tif (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }\n\n\t\tthis.callInitHooks(Circle);\n\t}\n\n\t/**\n\t * Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're\n\t * approximated on a sphere.\n\t * @returns {LatLngBounds}\n\t */\n\tgetBounds() {\n\t\tif (!this._map) { return this._latlng.toBounds(this._radius * 2); }\n\n\t\tconst half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];\n\n\t\treturn new LatLngBounds(\n\t\t\tthis._map.layerPointToLatLng(this._point.subtract(half)),\n\t\t\tthis._map.layerPointToLatLng(this._point.add(half)));\n\t}\n\n\t_project() {\n\n\t\tconst lng = this._latlng.lng,\n\t\tlat = this._latlng.lat,\n\t\tmap = this._map,\n\t\tcrs = map.options.crs;\n\n\t\tif (crs.distance === EarthCRS.distance) {\n\t\t\tconst d = Math.PI / 180,\n\t\t\tlatR = (this._radius / EarthCRS.R) / d,\n\t\t\ttop = map.project([lat + latR, lng]),\n\t\t\tbottom = map.project([lat - latR, lng]),\n\t\t\tp = top.add(bottom).divideBy(2),\n\t\t\tlat2 = map.unproject(p).lat;\n\t\t\t// Longitude span from the haversine form of the spherical law of cosines. The plain acos() form\n\t\t\t// loses precision for radii of about a metre and less, where cos(latR) is too close to 1 (#6120).\n\t\t\tlet lngR = 2 * Math.asin(Math.sqrt(\n\t\t\t\t(Math.sin(latR * d / 2) ** 2 - Math.sin((lat2 - lat) * d / 2) ** 2) /\n\t\t\t\t(Math.cos(lat * d) * Math.cos(lat2 * d)))) / d;\n\n\t\t\tif (isNaN(lngR) || lngR === 0) {\n\t\t\t\tlngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425\n\t\t\t}\n\n\t\t\tthis._point = p.subtract(map.getPixelOrigin());\n\t\t\tthis._pxRadius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR]).x;\n\t\t\tthis._pxRadiusY = p.y - top.y;\n\n\t\t} else {\n\t\t\tconst latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));\n\n\t\t\tthis._point = map.latLngToLayerPoint(this._latlng);\n\t\t\tthis._pxRadius = Math.abs(this._point.x - map.latLngToLayerPoint(latlng2).x);\n\t\t}\n\n\t\tthis._updateBounds();\n\t}\n}\n"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AI,KAAK,KAAK,MAAM,GAAG;GAG3C,KAAK,SAAS,EAAE,SAAS,IAAI,eAAe,CAAC;GAC7C,KAAK,YAAY,MAAM,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,QAAQ,CAAC,MAAM,MAAM,IAAI,CAAC,CAAC,CAAC;GACzE,KAAK,aAAa,EAAE,IAAI,IAAI;EAE7B,OAAO;GACN,MAAM,UAAU,IAAI,UAAU,IAAI,QAAQ,KAAK,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;GAEnF,KAAK,SAAS,IAAI,mBAAmB,KAAK,OAAO;GACjD,KAAK,YAAY,KAAK,IAAI,KAAK,OAAO,IAAI,IAAI,mBAAmB,OAAO,CAAC,CAAC,CAAC;EAC5E;EAEA,KAAK,cAAc;CACpB;AACD"}
@@ -3,7 +3,7 @@ import { Bounds } from "../../geometry/Bounds.js";
3
3
  import { Path } from "./Path.js";
4
4
  import { LatLng } from "../../geo/LatLng.js";
5
5
  import { pointToGeoJSON } from "../GeoJSONUtil.js";
6
- //#region src/layer/vector/CircleMarker.js
6
+ // src/layer/vector/CircleMarker.js
7
7
  /** @import {Feature} from 'geojson' */
8
8
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
9
9
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -95,7 +95,7 @@ var CircleMarker = class CircleMarker extends Path {
95
95
  return this;
96
96
  }
97
97
  _project() {
98
- this._point = this._map.latLngToLayerPoint(this._latlng);
98
+ this._point = this._map.latLngToLayerPoint(this._latlng)._round();
99
99
  this._pxRadius = this._radius;
100
100
  this._updateBounds();
101
101
  }
@@ -126,7 +126,6 @@ var CircleMarker = class CircleMarker extends Path {
126
126
  return pointToGeoJSON(this, precision);
127
127
  }
128
128
  };
129
- //#endregion
130
129
  export { CircleMarker };
131
130
 
132
131
  //# sourceMappingURL=CircleMarker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CircleMarker.js","names":[],"sources":["../../../../src/layer/vector/CircleMarker.js"],"sourcesContent":["import {Path} from './Path.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {pointToGeoJSON} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {PathOptions} from './Path.js' */\n\n\n/**\n * Options of `CircleMarker`.\n * @typedef {object} CircleMarkerOptions\n * @property {boolean} [fill=true] Whether to fill the circle with color.\n * @property {number} [radius=10] Radius of the circle marker, in CSS pixels.\n * @extends PathOptions\n */\n\n/**\n * The event object of `move` of circle markers.\n * @typedef {object} CircleMarkerMoveEvent\n * @property {LatLng} oldLatLng The previous position of the circle marker.\n * @property {LatLng} latlng The new position of the circle marker.\n * @extends MaplairEvent\n */\n\n/**\n * A circle of a fixed size with radius specified in CSS pixels. Extends `Path`.\n *\n * @fires move {CircleMarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#circlemarker-setlatlng). Old and new coordinates are included in\n * event arguments as `oldLatLng`, `latlng`.\n */\nexport class CircleMarker extends Path {\n\n\tstatic defaultOptions = {\n\t\tfill: true,\n\t\tradius: 10\n\t};\n\n\t/**\n\t * Instantiates a circle marker object given a geographical point, and an optional\n\t * options object.\n\t * @param {LatLngExpression} latlng\n\t * @param {CircleMarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\t\tthis._radius = this.options.radius;\n\n\t\tthis.callInitHooks(CircleMarker);\n\t}\n\n\t/**\n\t * Sets the position of a circle marker to a new location.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tthis.redraw();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Returns the current geographical position of the circle marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Sets the radius of a circle marker. Units are in CSS pixels.\n\t * @param {number} radius\n\t * @returns {this}\n\t */\n\tsetRadius(radius) {\n\t\tthis.options.radius = this._radius = radius;\n\t\treturn this.redraw();\n\t}\n\n\t/**\n\t * Returns the current radius of the circle. Units are in CSS pixels.\n\t * @returns {number}\n\t */\n\tgetRadius() {\n\t\treturn this._radius;\n\t}\n\n\t/**\n\t * Changes the appearance of the circle marker, also its `radius`.\n\t * @param {CircleMarkerOptions} options\n\t * @returns {this}\n\t */\n\tsetStyle(options) {\n\t\tsuper.setStyle(options);\n\t\tif (options?.radius !== undefined) {\n\t\t\tthis.setRadius(options.radius);\n\t\t}\n\t\treturn this;\n\t}\n\n\t_project() {\n\t\tthis._point = this._map.latLngToLayerPoint(this._latlng);\n\t\tthis._pxRadius = this._radius;\n\t\tthis._updateBounds();\n\t}\n\n\t_updateBounds() {\n\t\tconst r = this._pxRadius,\n\t\tr2 = this._pxRadiusY ?? r,\n\t\tw = this._clickTolerance(),\n\t\tp = [r + w, r2 + w];\n\t\tthis._pxBounds = new Bounds(this._point.subtract(p), this._point.add(p));\n\t}\n\n\t_update() {\n\t\tif (this._map) {\n\t\t\tthis._updatePath();\n\t\t}\n\t}\n\n\t_updatePath() {\n\t\tthis._renderer._updateCircle(this);\n\t}\n\n\t_empty() {\n\t\treturn this._pxRadius && !this._renderer._bounds.intersects(this._pxBounds);\n\t}\n\n\t// Needed by the `Canvas` renderer for interactivity\n\t_containsPoint(p) {\n\t\treturn p.distanceTo(this._point) <= this._pxRadius + this._clickTolerance();\n\t}\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the circle marker (as a GeoJSON `Point` Feature).\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\treturn pointToGeoJSON(this, precision);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,eAAb,MAAa,qBAAqB,KAAK;CAEtC,OAAO,iBAAiB;EACvB,MAAM;EACN,QAAQ;CACT;;;;;;;CAQA,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,UAAU,IAAI,OAAO,MAAM;EAChC,KAAK,UAAU,KAAK,QAAQ;EAE5B,KAAK,cAAc,YAAY;CAChC;;;;;;CAOA,UAAU,QAAQ;EACjB,MAAM,YAAY,KAAK;EACvB,KAAK,UAAU,IAAI,OAAO,MAAM;EAChC,KAAK,OAAO;EAEZ,OAAO,KAAK,KAAK,QAAQ;GAAC;GAAW,QAAQ,KAAK;EAAO,CAAC;CAC3D;;;;;CAMA,YAAY;EACX,OAAO,KAAK;CACb;;;;;;CAOA,UAAU,QAAQ;EACjB,KAAK,QAAQ,SAAS,KAAK,UAAU;EACrC,OAAO,KAAK,OAAO;CACpB;;;;;CAMA,YAAY;EACX,OAAO,KAAK;CACb;;;;;;CAOA,SAAS,SAAS;EACjB,MAAM,SAAS,OAAO;EACtB,IAAI,SAAS,WAAW,KAAA,GACvB,KAAK,UAAU,QAAQ,MAAM;EAE9B,OAAO;CACR;CAEA,WAAW;EACV,KAAK,SAAS,KAAK,KAAK,mBAAmB,KAAK,OAAO;EACvD,KAAK,YAAY,KAAK;EACtB,KAAK,cAAc;CACpB;CAEA,gBAAgB;EACf,MAAM,IAAI,KAAK,WACf,KAAK,KAAK,cAAc,GACxB,IAAI,KAAK,gBAAgB,GACzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;EAClB,KAAK,YAAY,IAAI,OAAO,KAAK,OAAO,SAAS,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC;CACxE;CAEA,UAAU;EACT,IAAI,KAAK,MACR,KAAK,YAAY;CAEnB;CAEA,cAAc;EACb,KAAK,UAAU,cAAc,IAAI;CAClC;CAEA,SAAS;EACR,OAAO,KAAK,aAAa,CAAC,KAAK,UAAU,QAAQ,WAAW,KAAK,SAAS;CAC3E;CAGA,eAAe,GAAG;EACjB,OAAO,EAAE,WAAW,KAAK,MAAM,KAAK,KAAK,YAAY,KAAK,gBAAgB;CAC3E;;;;;;;;CASA,UAAU,WAAW;EACpB,OAAO,eAAe,MAAM,SAAS;CACtC;AACD"}
1
+ {"version":3,"file":"CircleMarker.js","names":[],"sources":["../../../../src/layer/vector/CircleMarker.js"],"sourcesContent":["import {Path} from './Path.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {pointToGeoJSON} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {PathOptions} from './Path.js' */\n\n\n/**\n * Options of `CircleMarker`.\n * @typedef {object} CircleMarkerOptions\n * @property {boolean} [fill=true] Whether to fill the circle with color.\n * @property {number} [radius=10] Radius of the circle marker, in CSS pixels.\n * @extends PathOptions\n */\n\n/**\n * The event object of `move` of circle markers.\n * @typedef {object} CircleMarkerMoveEvent\n * @property {LatLng} oldLatLng The previous position of the circle marker.\n * @property {LatLng} latlng The new position of the circle marker.\n * @extends MaplairEvent\n */\n\n/**\n * A circle of a fixed size with radius specified in CSS pixels. Extends `Path`.\n *\n * @fires move {CircleMarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#circlemarker-setlatlng). Old and new coordinates are included in\n * event arguments as `oldLatLng`, `latlng`.\n */\nexport class CircleMarker extends Path {\n\n\tstatic defaultOptions = {\n\t\tfill: true,\n\t\tradius: 10\n\t};\n\n\t/**\n\t * Instantiates a circle marker object given a geographical point, and an optional\n\t * options object.\n\t * @param {LatLngExpression} latlng\n\t * @param {CircleMarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\t\tthis._radius = this.options.radius;\n\n\t\tthis.callInitHooks(CircleMarker);\n\t}\n\n\t/**\n\t * Sets the position of a circle marker to a new location.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tthis.redraw();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Returns the current geographical position of the circle marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Sets the radius of a circle marker. Units are in CSS pixels.\n\t * @param {number} radius\n\t * @returns {this}\n\t */\n\tsetRadius(radius) {\n\t\tthis.options.radius = this._radius = radius;\n\t\treturn this.redraw();\n\t}\n\n\t/**\n\t * Returns the current radius of the circle. Units are in CSS pixels.\n\t * @returns {number}\n\t */\n\tgetRadius() {\n\t\treturn this._radius;\n\t}\n\n\t/**\n\t * Changes the appearance of the circle marker, also its `radius`.\n\t * @param {CircleMarkerOptions} options\n\t * @returns {this}\n\t */\n\tsetStyle(options) {\n\t\tsuper.setStyle(options);\n\t\tif (options?.radius !== undefined) {\n\t\t\tthis.setRadius(options.radius);\n\t\t}\n\t\treturn this;\n\t}\n\n\t_project() {\n\t\t// snapped to whole pixels: subpixel precision is invisible on markers but slows down rendering many of them\n\t\tthis._point = this._map.latLngToLayerPoint(this._latlng)._round();\n\t\tthis._pxRadius = this._radius;\n\t\tthis._updateBounds();\n\t}\n\n\t_updateBounds() {\n\t\tconst r = this._pxRadius,\n\t\tr2 = this._pxRadiusY ?? r,\n\t\tw = this._clickTolerance(),\n\t\tp = [r + w, r2 + w];\n\t\tthis._pxBounds = new Bounds(this._point.subtract(p), this._point.add(p));\n\t}\n\n\t_update() {\n\t\tif (this._map) {\n\t\t\tthis._updatePath();\n\t\t}\n\t}\n\n\t_updatePath() {\n\t\tthis._renderer._updateCircle(this);\n\t}\n\n\t_empty() {\n\t\treturn this._pxRadius && !this._renderer._bounds.intersects(this._pxBounds);\n\t}\n\n\t// Needed by the `Canvas` renderer for interactivity\n\t_containsPoint(p) {\n\t\treturn p.distanceTo(this._point) <= this._pxRadius + this._clickTolerance();\n\t}\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the circle marker (as a GeoJSON `Point` Feature).\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\treturn pointToGeoJSON(this, precision);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,eAAb,MAAa,qBAAqB,KAAK;CAEtC,OAAO,iBAAiB;EACvB,MAAM;EACN,QAAQ;CACT;;;;;;;CAQA,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,UAAU,IAAI,OAAO,MAAM;EAChC,KAAK,UAAU,KAAK,QAAQ;EAE5B,KAAK,cAAc,YAAY;CAChC;;;;;;CAOA,UAAU,QAAQ;EACjB,MAAM,YAAY,KAAK;EACvB,KAAK,UAAU,IAAI,OAAO,MAAM;EAChC,KAAK,OAAO;EAEZ,OAAO,KAAK,KAAK,QAAQ;GAAC;GAAW,QAAQ,KAAK;EAAO,CAAC;CAC3D;;;;;CAMA,YAAY;EACX,OAAO,KAAK;CACb;;;;;;CAOA,UAAU,QAAQ;EACjB,KAAK,QAAQ,SAAS,KAAK,UAAU;EACrC,OAAO,KAAK,OAAO;CACpB;;;;;CAMA,YAAY;EACX,OAAO,KAAK;CACb;;;;;;CAOA,SAAS,SAAS;EACjB,MAAM,SAAS,OAAO;EACtB,IAAI,SAAS,WAAW,KAAA,GACvB,KAAK,UAAU,QAAQ,MAAM;EAE9B,OAAO;CACR;CAEA,WAAW;EAEV,KAAK,SAAS,KAAK,KAAK,mBAAmB,KAAK,OAAO,CAAC,CAAC,OAAO;EAChE,KAAK,YAAY,KAAK;EACtB,KAAK,cAAc;CACpB;CAEA,gBAAgB;EACf,MAAM,IAAI,KAAK,WACf,KAAK,KAAK,cAAc,GACxB,IAAI,KAAK,gBAAgB,GACzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;EAClB,KAAK,YAAY,IAAI,OAAO,KAAK,OAAO,SAAS,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC;CACxE;CAEA,UAAU;EACT,IAAI,KAAK,MACR,KAAK,YAAY;CAEnB;CAEA,cAAc;EACb,KAAK,UAAU,cAAc,IAAI;CAClC;CAEA,SAAS;EACR,OAAO,KAAK,aAAa,CAAC,KAAK,UAAU,QAAQ,WAAW,KAAK,SAAS;CAC3E;CAGA,eAAe,GAAG;EACjB,OAAO,EAAE,WAAW,KAAK,MAAM,KAAK,KAAK,YAAY,KAAK,gBAAgB;CAC3E;;;;;;;;CASA,UAAU,WAAW;EACpB,OAAO,eAAe,MAAM,SAAS;CACtC;AACD"}
@@ -2,7 +2,7 @@ import { setOptions, stamp } from "../../core/Util.js";
2
2
  import { SVG } from "./SVG.js";
3
3
  import { Path } from "./Path.js";
4
4
  import { Canvas } from "./Canvas.js";
5
- //#region src/layer/vector/Path.DashAnimation.js
5
+ // src/layer/vector/Path.DashAnimation.js
6
6
  const DASH_SEPARATOR_RE = /[ ,]+/;
7
7
  const { _updateStyle: updateSvgStyle } = SVG.prototype, { _fillStroke: fillStroke, _destroyContainer: destroyCanvasContainer } = Canvas.prototype;
8
8
  /**
@@ -72,6 +72,5 @@ Canvas.include({
72
72
  return performance.now() / 1e3 * speed % length;
73
73
  }
74
74
  });
75
- //#endregion
76
75
 
77
76
  //# sourceMappingURL=Path.DashAnimation.js.map
@@ -1,6 +1,6 @@
1
1
  import { Path } from "./Path.js";
2
2
  import { CircleMarker } from "./CircleMarker.js";
3
- //#region src/layer/vector/Path.ZoomStyles.js
3
+ // src/layer/vector/Path.ZoomStyles.js
4
4
  /**
5
5
  * A zoom-dependent style value, of the `weight` option of paths and the `radius` of
6
6
  * circle markers: either a function of the zoom or an object of zoom stops
@@ -72,6 +72,5 @@ CircleMarker.include({ setRadius(radius) {
72
72
  Path.addInitHook(function() {
73
73
  this._takeZoomStyles(this.options);
74
74
  });
75
- //#endregion
76
75
 
77
76
  //# sourceMappingURL=Path.ZoomStyles.js.map
@@ -1,7 +1,7 @@
1
1
  import { setOptions } from "../../core/Util.js";
2
2
  import { Layer } from "../Layer.js";
3
3
  import { SVG } from "./SVG.js";
4
- //#region src/layer/vector/Path.js
4
+ // src/layer/vector/Path.js
5
5
  /** @import {InteractiveLayerOptions} from '../Layer.js' */
6
6
  /** @import {MaplairMap} from '../../map/Map.js' */
7
7
  /** @import {Renderer} from './Renderer.js' */
@@ -143,7 +143,6 @@ var Path = class extends Layer {
143
143
  return (this.options.stroke ? this.options.weight / 2 : 0) + (this._renderer.options.tolerance || 0);
144
144
  }
145
145
  };
146
- //#endregion
147
146
  export { Path };
148
147
 
149
148
  //# sourceMappingURL=Path.js.map
@@ -5,7 +5,7 @@ import { isFlat } from "../../geometry/LineUtil.js";
5
5
  import { getFeature, latLngsToCoords } from "../GeoJSONUtil.js";
6
6
  import { Polyline } from "./Polyline.js";
7
7
  import { clipPolygon, polygonCenter } from "../../geometry/PolyUtil.js";
8
- //#region src/layer/vector/Polygon.js
8
+ // src/layer/vector/Polygon.js
9
9
  /** @import {Feature} from 'geojson' */
10
10
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
11
11
  /** @import {PolylineOptions} from './Polyline.js' */
@@ -110,7 +110,7 @@ var Polygon = class Polygon extends Polyline {
110
110
  return;
111
111
  }
112
112
  for (const ring of this._rings) {
113
- const clipped = clipPolygon(ring, bounds, true);
113
+ const clipped = clipPolygon(ring, bounds);
114
114
  if (clipped.length) this._parts.push(clipped);
115
115
  }
116
116
  }
@@ -147,7 +147,6 @@ var Polygon = class Polygon extends Polyline {
147
147
  });
148
148
  }
149
149
  };
150
- //#endregion
151
150
  export { Polygon };
152
151
 
153
152
  //# sourceMappingURL=Polygon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Polygon.js","names":["PolyUtil.polygonCenter","LineUtil.isFlat","PolyUtil.clipPolygon"],"sources":["../../../../src/layer/vector/Polygon.js"],"sourcesContent":["import {Polyline} from './Polyline.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport * as LineUtil from '../../geometry/LineUtil.js';\nimport {Point} from '../../geometry/Point.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport * as PolyUtil from '../../geometry/PolyUtil.js';\nimport {latLngsToCoords, getFeature} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PolylineOptions} from './Polyline.js' */\n\n/**\n * Options of `Polygon`.\n * @typedef {object} PolygonOptions\n * @property {boolean} [fill=true] Whether to fill the polygon with color.\n * @extends PolylineOptions\n */\n\n/**\n * A class for drawing polygon overlays on a map. Extends `Polyline`.\n *\n * Note that points you pass when creating a polygon shouldn't have an additional last\n * point equal to the first one — it's better to filter out such points.\n *\n * @example\n * ```js\n * // create a red polygon from an array of LatLng points\n * const latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];\n *\n * const polygon = new Polygon(latlngs, {color: 'red'}).addTo(map);\n *\n * // zoom the map to the polygon\n * map.fitBounds(polygon.getBounds());\n * ```\n *\n * You can also pass an array of arrays of latlngs, with the first array representing\n * the outer shape and the other arrays representing holes in the outer shape:\n *\n * ```js\n * const latlngs = [\n * [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring\n * [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole\n * ];\n * ```\n *\n * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.\n *\n * ```js\n * const latlngs = [\n * [ // first polygon\n * [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring\n * [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole\n * ],\n * [ // second polygon\n * [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]\n * ]\n * ];\n * ```\n */\nexport class Polygon extends Polyline {\n\n\tstatic defaultOptions = {\n\t\tfill: true\n\t};\n\n\t/**\n\t * Instantiates a polygon object given an array of geographical points (or arrays\n\t * of them for holes and multi-polygons) and optionally an options object.\n\t * @overload\n\t * @param {LatLngExpression[]|LatLngExpression[][]|LatLngExpression[][][]} latlngs\n\t * @param {PolygonOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Polygon);\n\t}\n\n\t/**\n\t * Returns `true` if the Polygon has no LatLngs.\n\t * @returns {boolean}\n\t */\n\tisEmpty() {\n\t\treturn !this._latlngs.length || !this._latlngs[0].length;\n\t}\n\n\t/**\n\t * Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the Polygon.\n\t * @returns {LatLng}\n\t */\n\tgetCenter() {\n\t\t// throws error when not yet added to map as this center calculation requires projected coordinates\n\t\tif (!this._map) {\n\t\t\tthrow new Error('Must add layer to map before using getCenter()');\n\t\t}\n\t\treturn PolyUtil.polygonCenter(this._defaultShape(), this._map.options.crs);\n\t}\n\n\t_convertLatLngs(latlngs) {\n\t\tconst result = super._convertLatLngs(latlngs),\n\t\tlen = result.length;\n\n\t\t// remove last point if it equals first one\n\t\tif (len >= 2 && result[0] instanceof LatLng && result[0].equals(result[len - 1])) {\n\t\t\tresult.pop();\n\t\t}\n\t\treturn result;\n\t}\n\n\t_setLatLngs(latlngs) {\n\t\tsuper._setLatLngs(latlngs);\n\t\tif (LineUtil.isFlat(this._latlngs)) {\n\t\t\tthis._latlngs = [this._latlngs];\n\t\t}\n\t}\n\n\t_defaultShape() {\n\t\treturn LineUtil.isFlat(this._latlngs[0]) ? this._latlngs[0] : this._latlngs[0][0];\n\t}\n\n\t_clipPoints() {\n\t\t// polygons need a different clipping algorithm so we redefine that\n\n\t\tlet bounds = this._renderer._bounds;\n\t\tconst w = this.options.weight,\n\t\tp = new Point(w, w);\n\n\t\t// increase clip padding by stroke width to avoid stroke on clip edges\n\t\tbounds = new Bounds(bounds.min.subtract(p), bounds.max.add(p));\n\n\t\tthis._parts = [];\n\t\tif (!this._pxBounds || !this._pxBounds.intersects(bounds)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.options.noClip) {\n\t\t\tthis._parts = this._rings;\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const ring of this._rings) {\n\t\t\tconst clipped = PolyUtil.clipPolygon(ring, bounds, true);\n\t\t\tif (clipped.length) {\n\t\t\t\tthis._parts.push(clipped);\n\t\t\t}\n\t\t}\n\t}\n\n\t_updatePath() {\n\t\tthis._renderer._updatePoly(this, true);\n\t}\n\n\t// Needed by the `Canvas` renderer for interactivity\n\t_containsPoint(p) {\n\t\tlet inside = false,\n\t\tpart, p1, p2, i, j, k, len, len2;\n\n\t\tif (!this._pxBounds || !this._pxBounds.contains(p)) { return false; }\n\n\t\t// ray casting algorithm for detecting if point is in polygon\n\t\tfor (i = 0, len = this._parts.length; i < len; i++) {\n\t\t\tpart = this._parts[i];\n\n\t\t\tfor (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {\n\t\t\t\tp1 = part[j];\n\t\t\t\tp2 = part[k];\n\n\t\t\t\tif (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n\t\t\t\t\tinside = !inside;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// also check if it's on polygon stroke\n\t\treturn inside || super._containsPoint(p, true);\n\t}\n\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature).\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\tconst holes = !LineUtil.isFlat(this._latlngs),\n\t\tmulti = holes && !LineUtil.isFlat(this._latlngs[0]);\n\n\t\tlet coords = latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true, precision);\n\n\t\tif (!holes) {\n\t\t\tcoords = [coords];\n\t\t}\n\n\t\treturn getFeature(this, {\n\t\t\ttype: `${multi ? 'Multi' : ''}Polygon`,\n\t\t\tcoordinates: coords\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,IAAa,UAAb,MAAa,gBAAgB,SAAS;CAErC,OAAO,iBAAiB,EACvB,MAAM,KACP;;;;;;;;;;;CAYA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;CAMA,UAAU;EACT,OAAO,CAAC,KAAK,SAAS,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;CACnD;;;;;CAMA,YAAY;EAEX,IAAI,CAAC,KAAK,MACT,MAAM,IAAI,MAAM,gDAAgD;EAEjE,OAAOA,cAAuB,KAAK,cAAc,GAAG,KAAK,KAAK,QAAQ,GAAG;CAC1E;CAEA,gBAAgB,SAAS;EACxB,MAAM,SAAS,MAAM,gBAAgB,OAAO,GAC5C,MAAM,OAAO;EAGb,IAAI,OAAO,KAAK,OAAO,cAAc,UAAU,OAAO,EAAE,CAAC,OAAO,OAAO,MAAM,EAAE,GAC9E,OAAO,IAAI;EAEZ,OAAO;CACR;CAEA,YAAY,SAAS;EACpB,MAAM,YAAY,O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M,GAAG,IAAI,GAAG,KAAK,GAAG,GAC/F,SAAS,CAAC;GAEZ;EACD;EAGA,OAAO,UAAU,MAAM,eAAe,GAAG,IAAI;CAC9C;;;;;;;;CAUA,UAAU,WAAW;EACpB,MAAM,QAAQ,CAACD,OAAgB,KAAK,QAAQ,GAC5C,QAAQ,SAAS,CAACA,OAAgB,KAAK,SAAS,EAAE;EAElD,IAAI,SAAS,gBAAgB,KAAK,UAAU,QAAQ,IAAI,QAAQ,IAAI,GAAG,MAAM,SAAS;EAEtF,IAAI,CAAC,OACJ,SAAS,CAAC,MAAM;EAGjB,OAAO,WAAW,MAAM;GACvB,MAAM,GAAG,QAAQ,UAAU,GAAG;GAC9B,aAAa;EACd,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"Polygon.js","names":["PolyUtil.polygonCenter","LineUtil.isFlat","PolyUtil.clipPolygon"],"sources":["../../../../src/layer/vector/Polygon.js"],"sourcesContent":["import {Polyline} from './Polyline.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport * as LineUtil from '../../geometry/LineUtil.js';\nimport {Point} from '../../geometry/Point.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport * as PolyUtil from '../../geometry/PolyUtil.js';\nimport {latLngsToCoords, getFeature} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PolylineOptions} from './Polyline.js' */\n\n/**\n * Options of `Polygon`.\n * @typedef {object} PolygonOptions\n * @property {boolean} [fill=true] Whether to fill the polygon with color.\n * @extends PolylineOptions\n */\n\n/**\n * A class for drawing polygon overlays on a map. Extends `Polyline`.\n *\n * Note that points you pass when creating a polygon shouldn't have an additional last\n * point equal to the first one — it's better to filter out such points.\n *\n * @example\n * ```js\n * // create a red polygon from an array of LatLng points\n * const latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];\n *\n * const polygon = new Polygon(latlngs, {color: 'red'}).addTo(map);\n *\n * // zoom the map to the polygon\n * map.fitBounds(polygon.getBounds());\n * ```\n *\n * You can also pass an array of arrays of latlngs, with the first array representing\n * the outer shape and the other arrays representing holes in the outer shape:\n *\n * ```js\n * const latlngs = [\n * [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring\n * [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole\n * ];\n * ```\n *\n * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.\n *\n * ```js\n * const latlngs = [\n * [ // first polygon\n * [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring\n * [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole\n * ],\n * [ // second polygon\n * [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]\n * ]\n * ];\n * ```\n */\nexport class Polygon extends Polyline {\n\n\tstatic defaultOptions = {\n\t\tfill: true\n\t};\n\n\t/**\n\t * Instantiates a polygon object given an array of geographical points (or arrays\n\t * of them for holes and multi-polygons) and optionally an options object.\n\t * @overload\n\t * @param {LatLngExpression[]|LatLngExpression[][]|LatLngExpression[][][]} latlngs\n\t * @param {PolygonOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Polygon);\n\t}\n\n\t/**\n\t * Returns `true` if the Polygon has no LatLngs.\n\t * @returns {boolean}\n\t */\n\tisEmpty() {\n\t\treturn !this._latlngs.length || !this._latlngs[0].length;\n\t}\n\n\t/**\n\t * Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the Polygon.\n\t * @returns {LatLng}\n\t */\n\tgetCenter() {\n\t\t// throws error when not yet added to map as this center calculation requires projected coordinates\n\t\tif (!this._map) {\n\t\t\tthrow new Error('Must add layer to map before using getCenter()');\n\t\t}\n\t\treturn PolyUtil.polygonCenter(this._defaultShape(), this._map.options.crs);\n\t}\n\n\t_convertLatLngs(latlngs) {\n\t\tconst result = super._convertLatLngs(latlngs),\n\t\tlen = result.length;\n\n\t\t// remove last point if it equals first one\n\t\tif (len >= 2 && result[0] instanceof LatLng && result[0].equals(result[len - 1])) {\n\t\t\tresult.pop();\n\t\t}\n\t\treturn result;\n\t}\n\n\t_setLatLngs(latlngs) {\n\t\tsuper._setLatLngs(latlngs);\n\t\tif (LineUtil.isFlat(this._latlngs)) {\n\t\t\tthis._latlngs = [this._latlngs];\n\t\t}\n\t}\n\n\t_defaultShape() {\n\t\treturn LineUtil.isFlat(this._latlngs[0]) ? this._latlngs[0] : this._latlngs[0][0];\n\t}\n\n\t_clipPoints() {\n\t\t// polygons need a different clipping algorithm so we redefine that\n\n\t\tlet bounds = this._renderer._bounds;\n\t\tconst w = this.options.weight,\n\t\tp = new Point(w, w);\n\n\t\t// increase clip padding by stroke width to avoid stroke on clip edges\n\t\tbounds = new Bounds(bounds.min.subtract(p), bounds.max.add(p));\n\n\t\tthis._parts = [];\n\t\tif (!this._pxBounds || !this._pxBounds.intersects(bounds)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.options.noClip) {\n\t\t\tthis._parts = this._rings;\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const ring of this._rings) {\n\t\t\tconst clipped = PolyUtil.clipPolygon(ring, bounds);\n\t\t\tif (clipped.length) {\n\t\t\t\tthis._parts.push(clipped);\n\t\t\t}\n\t\t}\n\t}\n\n\t_updatePath() {\n\t\tthis._renderer._updatePoly(this, true);\n\t}\n\n\t// Needed by the `Canvas` renderer for interactivity\n\t_containsPoint(p) {\n\t\tlet inside = false,\n\t\tpart, p1, p2, i, j, k, len, len2;\n\n\t\tif (!this._pxBounds || !this._pxBounds.contains(p)) { return false; }\n\n\t\t// ray casting algorithm for detecting if point is in polygon\n\t\tfor (i = 0, len = this._parts.length; i < len; i++) {\n\t\t\tpart = this._parts[i];\n\n\t\t\tfor (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {\n\t\t\t\tp1 = part[j];\n\t\t\t\tp2 = part[k];\n\n\t\t\t\tif (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {\n\t\t\t\t\tinside = !inside;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// also check if it's on polygon stroke\n\t\treturn inside || super._containsPoint(p, true);\n\t}\n\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature).\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\tconst holes = !LineUtil.isFlat(this._latlngs),\n\t\tmulti = holes && !LineUtil.isFlat(this._latlngs[0]);\n\n\t\tlet coords = latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true, precision);\n\n\t\tif (!holes) {\n\t\t\tcoords = [coords];\n\t\t}\n\n\t\treturn getFeature(this, {\n\t\t\ttype: `${multi ? 'Multi' : ''}Polygon`,\n\t\t\tcoordinates: coords\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,IAAa,UAAb,MAAa,gBAAgB,SAAS;CAErC,OAAO,iBAAiB,EACvB,MAAM,KACP;;;;;;;;;;;CAYA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;CAMA,UAAU;EACT,OAAO,CAAC,KAAK,SAAS,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;CACnD;;;;;CAMA,YAAY;EAEX,IAAI,CAAC,KAAK,MACT,MAAM,IAAI,MAAM,gDAAgD;EAEjE,OAAOA,cAAuB,KAAK,cAAc,GAAG,KAAK,KAAK,QAAQ,GAAG;CAC1E;CAEA,gBAAg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,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,IAAI,MAAM,IAAI,KAAK;IAChE,KAAK,KAAK;IACV,KAAK,KAAK;IAEV,IAAM,GAAG,IAAI,EAAE,MAAQ,GAAG,IAAI,EAAE,KAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,GAC/F,SAAS,CAAC;GAEZ;EACD;EAGA,OAAO,UAAU,MAAM,eAAe,GAAG,IAAI;CAC9C;;;;;;;;CAUA,UAAU,WAAW;EACpB,MAAM,QAAQ,CAACD,OAAgB,KAAK,QAAQ,GAC5C,QAAQ,SAAS,CAACA,OAAgB,KAAK,SAAS,EAAE;EAElD,IAAI,SAAS,gBAAgB,KAAK,UAAU,QAAQ,IAAI,QAAQ,IAAI,GAAG,MAAM,SAAS;EAEtF,IAAI,CAAC,OACJ,SAAS,CAAC,MAAM;EAGjB,OAAO,WAAW,MAAM;GACvB,MAAM,GAAG,QAAQ,UAAU,GAAG;GAC9B,aAAa;EACd,CAAC;CACF;AACD"}
@@ -4,7 +4,7 @@ import { SVG } from "./SVG.js";
4
4
  import { Path } from "./Path.js";
5
5
  import { Polyline } from "./Polyline.js";
6
6
  import { Canvas } from "./Canvas.js";
7
- //#region src/layer/vector/Polyline.Decorations.js
7
+ // src/layer/vector/Polyline.Decorations.js
8
8
  /**
9
9
  * Options of `Path` for arrowheads and text along lines (for `Polyline`s and
10
10
  * `Polygon`s). They are an optional feature: import this module to add the
@@ -239,6 +239,5 @@ Canvas.include({
239
239
  }
240
240
  }
241
241
  });
242
- //#endregion
243
242
 
244
243
  //# sourceMappingURL=Polyline.Decorations.js.map