maplair 4.0.0 → 4.1.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 (270) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/dist/esm/Maplair.js +14 -14
  3. package/dist/esm/control/AttributionControl.js +24 -14
  4. package/dist/esm/control/AttributionControl.js.map +1 -1
  5. package/dist/esm/control/ButtonControl.js +9 -11
  6. package/dist/esm/control/ButtonControl.js.map +1 -1
  7. package/dist/esm/control/ContextMenu.js +1 -3
  8. package/dist/esm/control/ContextMenu.js.map +1 -1
  9. package/dist/esm/control/Control.js +9 -16
  10. package/dist/esm/control/Control.js.map +1 -1
  11. package/dist/esm/control/FullscreenControl.js +5 -7
  12. package/dist/esm/control/FullscreenControl.js.map +1 -1
  13. package/dist/esm/control/LayersControl.js +144 -35
  14. package/dist/esm/control/LayersControl.js.map +1 -1
  15. package/dist/esm/control/LegendControl.js +7 -9
  16. package/dist/esm/control/LegendControl.js.map +1 -1
  17. package/dist/esm/control/MiniMapControl.js +14 -16
  18. package/dist/esm/control/MiniMapControl.js.map +1 -1
  19. package/dist/esm/control/RotateControl.js +1 -3
  20. package/dist/esm/control/RotateControl.js.map +1 -1
  21. package/dist/esm/control/ScaleControl.js +7 -9
  22. package/dist/esm/control/ScaleControl.js.map +1 -1
  23. package/dist/esm/control/SearchControl.js +99 -17
  24. package/dist/esm/control/SearchControl.js.map +1 -1
  25. package/dist/esm/control/SideBySideControl.js +1 -3
  26. package/dist/esm/control/SideBySideControl.js.map +1 -1
  27. package/dist/esm/control/TextControl.js +5 -7
  28. package/dist/esm/control/TextControl.js.map +1 -1
  29. package/dist/esm/control/TimeControl.js +408 -0
  30. package/dist/esm/control/TimeControl.js.map +1 -0
  31. package/dist/esm/control/ZoomControl.js +5 -7
  32. package/dist/esm/control/ZoomControl.js.map +1 -1
  33. package/dist/esm/core/Class.js +28 -37
  34. package/dist/esm/core/Class.js.map +1 -1
  35. package/dist/esm/core/Events.js +21 -8
  36. package/dist/esm/core/Events.js.map +1 -1
  37. package/dist/esm/core/Handler.js +13 -11
  38. package/dist/esm/core/Handler.js.map +1 -1
  39. package/dist/esm/core/Util.js +13 -1
  40. package/dist/esm/core/Util.js.map +1 -1
  41. package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
  42. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  43. package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
  44. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  45. package/dist/esm/dom/DomEvent.js +8 -42
  46. package/dist/esm/dom/DomEvent.js.map +1 -1
  47. package/dist/esm/dom/DomUtil.js +14 -68
  48. package/dist/esm/dom/DomUtil.js.map +1 -1
  49. package/dist/esm/dom/Draggable.js +17 -18
  50. package/dist/esm/dom/Draggable.js.map +1 -1
  51. package/dist/esm/dom/PosAnimation.js +3 -25
  52. package/dist/esm/dom/PosAnimation.js.map +1 -1
  53. package/dist/esm/geo/LatLng.js +15 -5
  54. package/dist/esm/geo/LatLng.js.map +1 -1
  55. package/dist/esm/geo/crs/EPSG3395.js +1 -1
  56. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  57. package/dist/esm/geo/crs/EPSG3857.js +1 -1
  58. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  59. package/dist/esm/geo/crs/EPSG4326.js +1 -1
  60. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  61. package/dist/esm/geo/crs/EarthCRS.js +2 -2
  62. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  63. package/dist/esm/geo/crs/SimpleCRS.js +1 -1
  64. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  65. package/dist/esm/geo/projection/Projection.LonLat.js +1 -1
  66. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  67. package/dist/esm/geo/projection/Projection.Mercator.js +1 -1
  68. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  69. package/dist/esm/geo/projection/Projection.SphericalMercator.js +1 -1
  70. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  71. package/dist/esm/geometry/LineUtil.js +36 -30
  72. package/dist/esm/geometry/LineUtil.js.map +1 -1
  73. package/dist/esm/geometry/PolyUtil.js +8 -27
  74. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  75. package/dist/esm/layer/BlanketOverlay.js +6 -8
  76. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  77. package/dist/esm/layer/DivOverlay.js +15 -20
  78. package/dist/esm/layer/DivOverlay.js.map +1 -1
  79. package/dist/esm/layer/GeoJSON.js +9 -145
  80. package/dist/esm/layer/GeoJSON.js.map +1 -1
  81. package/dist/esm/layer/GeoJSONUtil.js +75 -0
  82. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  83. package/dist/esm/layer/HeatLayer.js +15 -17
  84. package/dist/esm/layer/HeatLayer.js.map +1 -1
  85. package/dist/esm/layer/ImageOverlay.js +20 -26
  86. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  87. package/dist/esm/layer/Layer.js +8 -10
  88. package/dist/esm/layer/Layer.js.map +1 -1
  89. package/dist/esm/layer/LayerGroup.js +51 -0
  90. package/dist/esm/layer/LayerGroup.js.map +1 -1
  91. package/dist/esm/layer/Popup.js +26 -42
  92. package/dist/esm/layer/Popup.js.map +1 -1
  93. package/dist/esm/layer/SVGOverlay.js +2 -5
  94. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  95. package/dist/esm/layer/Tooltip.js +15 -17
  96. package/dist/esm/layer/Tooltip.js.map +1 -1
  97. package/dist/esm/layer/VideoOverlay.js +12 -15
  98. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  99. package/dist/esm/layer/marker/DefaultIcon.js +15 -48
  100. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  101. package/dist/esm/layer/marker/DivIcon.js +7 -9
  102. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  103. package/dist/esm/layer/marker/Icon.js +7 -10
  104. package/dist/esm/layer/marker/Icon.js.map +1 -1
  105. package/dist/esm/layer/marker/Marker.Drag.js +1 -1
  106. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  107. package/dist/esm/layer/marker/Marker.Move.js +1 -2
  108. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  109. package/dist/esm/layer/marker/Marker.js +61 -33
  110. package/dist/esm/layer/marker/Marker.js.map +1 -1
  111. package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
  112. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  113. package/dist/esm/layer/marker/SvgIcon.js +6 -8
  114. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  115. package/dist/esm/layer/tile/GridLayer.js +85 -97
  116. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  117. package/dist/esm/layer/tile/TileLayer.js +28 -36
  118. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  119. package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
  120. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  121. package/dist/esm/layer/vector/Canvas.js +1 -3
  122. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  123. package/dist/esm/layer/vector/Circle.js +2 -2
  124. package/dist/esm/layer/vector/Circle.js.map +1 -1
  125. package/dist/esm/layer/vector/CircleMarker.js +17 -7
  126. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  127. package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
  128. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  129. package/dist/esm/layer/vector/Path.js +27 -20
  130. package/dist/esm/layer/vector/Path.js.map +1 -1
  131. package/dist/esm/layer/vector/Polygon.js +20 -4
  132. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  133. package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
  134. package/dist/esm/layer/vector/Polyline.js +23 -7
  135. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  136. package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
  137. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  138. package/dist/esm/layer/vector/SVG.js +5 -5
  139. package/dist/esm/layer/vector/SVG.js.map +1 -1
  140. package/dist/esm/map/Map.Rotation.js +10 -6
  141. package/dist/esm/map/Map.Rotation.js.map +1 -1
  142. package/dist/esm/map/Map.js +116 -110
  143. package/dist/esm/map/Map.js.map +1 -1
  144. package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
  145. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  146. package/dist/esm/map/handler/DisplaceHandler.js +6 -8
  147. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  148. package/dist/esm/map/handler/DragHandler.js +19 -19
  149. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  150. package/dist/esm/map/handler/KeyboardHandler.js +35 -35
  151. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  152. package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
  153. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  154. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
  155. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  156. package/dist/esm/map/handler/TapHoldHandler.js +12 -5
  157. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  158. package/dist/esm/package.js +1 -1
  159. package/dist/maplair-global-src.js +8009 -7369
  160. package/dist/maplair-global-src.js.map +1 -1
  161. package/dist/maplair-global.js +2 -2
  162. package/dist/maplair-global.js.map +1 -1
  163. package/dist/maplair-src.js +10040 -9381
  164. package/dist/maplair-src.js.map +1 -1
  165. package/dist/maplair.css +148 -98
  166. package/dist/maplair.js +2 -2
  167. package/dist/maplair.js.map +1 -1
  168. package/i18n/cs.json +6 -0
  169. package/i18n/de.json +6 -0
  170. package/i18n/en.json +6 -0
  171. package/i18n/es.json +6 -0
  172. package/i18n/fr.json +6 -0
  173. package/i18n/hu.json +6 -0
  174. package/i18n/it.json +6 -0
  175. package/i18n/rm.json +6 -0
  176. package/i18n/sk.json +6 -0
  177. package/i18n/sl.json +6 -0
  178. package/package.json +9 -11
  179. package/src/control/AttributionControl.js +25 -18
  180. package/src/control/ButtonControl.js +9 -11
  181. package/src/control/ContextMenu.js +3 -5
  182. package/src/control/Control.js +9 -19
  183. package/src/control/FullscreenControl.js +5 -7
  184. package/src/control/LayersControl.js +159 -36
  185. package/src/control/LegendControl.js +7 -9
  186. package/src/control/MiniMapControl.js +9 -11
  187. package/src/control/RotateControl.js +3 -5
  188. package/src/control/ScaleControl.js +7 -9
  189. package/src/control/SearchControl.js +102 -19
  190. package/src/control/SideBySideControl.js +3 -5
  191. package/src/control/TextControl.js +5 -7
  192. package/src/control/TimeControl.js +471 -0
  193. package/src/control/ZoomControl.js +5 -7
  194. package/src/control/index.js +1 -0
  195. package/src/core/Class.js +35 -34
  196. package/src/core/Events.js +22 -3
  197. package/src/core/Handler.js +14 -12
  198. package/src/core/Util.js +19 -1
  199. package/src/core/index.js +0 -1
  200. package/src/dom/DomEvent.DoubleTap.js +18 -10
  201. package/src/dom/DomEvent.PointerEvents.js +3 -26
  202. package/src/dom/DomEvent.js +8 -66
  203. package/src/dom/DomUtil.js +22 -78
  204. package/src/dom/Draggable.js +27 -22
  205. package/src/dom/PosAnimation.js +3 -25
  206. package/src/dom/index.js +0 -1
  207. package/src/geo/LatLng.js +20 -3
  208. package/src/geo/crs/EPSG3395.js +1 -1
  209. package/src/geo/crs/EPSG3857.js +1 -1
  210. package/src/geo/crs/EPSG4326.js +1 -1
  211. package/src/geo/crs/EarthCRS.js +2 -8
  212. package/src/geo/crs/SimpleCRS.js +1 -1
  213. package/src/geo/projection/Projection.LonLat.js +1 -1
  214. package/src/geo/projection/Projection.Mercator.js +1 -1
  215. package/src/geo/projection/Projection.SphericalMercator.js +1 -1
  216. package/src/geometry/LineUtil.js +47 -48
  217. package/src/geometry/PolyUtil.js +14 -43
  218. package/src/layer/BlanketOverlay.js +6 -10
  219. package/src/layer/DivOverlay.js +15 -26
  220. package/src/layer/GeoJSON.js +7 -205
  221. package/src/layer/GeoJSONUtil.js +85 -0
  222. package/src/layer/HeatLayer.js +9 -11
  223. package/src/layer/ImageOverlay.js +19 -30
  224. package/src/layer/Layer.js +8 -10
  225. package/src/layer/LayerGroup.js +71 -0
  226. package/src/layer/Popup.js +28 -43
  227. package/src/layer/SVGOverlay.js +1 -5
  228. package/src/layer/Tooltip.js +15 -19
  229. package/src/layer/VideoOverlay.js +12 -15
  230. package/src/layer/marker/DefaultIcon.js +15 -61
  231. package/src/layer/marker/DivIcon.js +9 -11
  232. package/src/layer/marker/Icon.js +7 -10
  233. package/src/layer/marker/Marker.Drag.js +1 -1
  234. package/src/layer/marker/Marker.Move.js +1 -2
  235. package/src/layer/marker/Marker.js +81 -39
  236. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  237. package/src/layer/marker/SvgIcon.js +7 -9
  238. package/src/layer/marker/index.js +1 -0
  239. package/src/layer/tile/GridLayer.js +103 -133
  240. package/src/layer/tile/TileLayer.js +35 -43
  241. package/src/layer/tile/WMSTileLayer.js +26 -24
  242. package/src/layer/vector/Canvas.js +3 -5
  243. package/src/layer/vector/Circle.js +5 -2
  244. package/src/layer/vector/CircleMarker.js +17 -6
  245. package/src/layer/vector/Path.DashAnimation.js +1 -2
  246. package/src/layer/vector/Path.js +30 -21
  247. package/src/layer/vector/Polygon.js +28 -5
  248. package/src/layer/vector/Polyline.js +25 -6
  249. package/src/layer/vector/Renderer.getRenderer.js +17 -17
  250. package/src/layer/vector/SVG.js +5 -5
  251. package/src/map/Map.Rotation.js +12 -4
  252. package/src/map/Map.js +142 -133
  253. package/src/map/handler/BoxZoomHandler.js +9 -8
  254. package/src/map/handler/DisplaceHandler.js +6 -8
  255. package/src/map/handler/DragHandler.js +25 -28
  256. package/src/map/handler/KeyboardHandler.js +42 -48
  257. package/src/map/handler/PinchZoomHandler.js +16 -5
  258. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  259. package/src/map/handler/TapHoldHandler.js +15 -4
  260. package/src/map/index.js +1 -1
  261. package/src/maplair.css +148 -98
  262. package/dist/esm/core/Browser.js +0 -100
  263. package/dist/esm/core/Browser.js.map +0 -1
  264. package/dist/images/layers.svg +0 -1
  265. package/dist/images/marker-icon.svg +0 -1
  266. package/dist/images/marker-shadow.svg +0 -1
  267. package/src/core/Browser.js +0 -110
  268. package/src/images/layers.svg +0 -1
  269. package/src/images/marker-icon.svg +0 -1
  270. package/src/images/marker-shadow.svg +0 -1
@@ -1,7 +1,6 @@
1
1
  import {DivOverlay} from './DivOverlay.js';
2
2
  import * as DomEvent from '../dom/DomEvent.js';
3
3
  import * as DomUtil from '../dom/DomUtil.js';
4
- import Browser from '../core/Browser.js';
5
4
  import {Point} from '../geometry/Point.js';
6
5
  import {Layer} from './Layer.js';
7
6
  import {Path} from './vector/Path.js';
@@ -24,9 +23,8 @@ import {I18n} from '../core/I18n.js';
24
23
  * @property {number|null} [maxHeight=null] If set, creates a scrollable container of
25
24
  * the given height inside a popup if its content exceeds it. The scrollable container
26
25
  * can be styled using the `maplair-popup-scrolled` CSS class selector.
27
- * @property {boolean} [autoPan] Set it to `false` if you don't want the map to do
28
- * panning animation to fit the opened popup. Defaults to `true`, unless the user
29
- * prefers reduced motion (`Browser.reducedMotion`).
26
+ * @property {boolean} [autoPan=true] Set it to `false` if you don't want the map to do
27
+ * panning animation to fit the opened popup.
30
28
  * @property {PointExpression|null} [autoPanPaddingTopLeft=null] The margin between the
31
29
  * popup and the top left corner of the map view after autopanning was performed.
32
30
  * @property {PointExpression|null} [autoPanPaddingBottomRight=null] The margin between
@@ -138,15 +136,11 @@ const layerPopupMethods = {
138
136
  bindPopup(content, options) {
139
137
  // eslint-disable-next-line no-use-before-define -- defined below, used when called
140
138
  this._popup = this._initOverlay(Popup, this._popup, content, options);
141
- if (!this._popupHandlersAdded) {
142
- this.on({
143
- click: this._openPopup,
144
- keypress: this._onKeyPress,
145
- remove: this.closePopup,
146
- move: this._movePopup
147
- });
148
- this._popupHandlersAdded = true;
149
- }
139
+ this.on({
140
+ click: this._openPopup,
141
+ remove: this.closePopup,
142
+ move: this._movePopup
143
+ });
150
144
 
151
145
  return this;
152
146
  },
@@ -160,11 +154,9 @@ const layerPopupMethods = {
160
154
  if (this._popup) {
161
155
  this.off({
162
156
  click: this._openPopup,
163
- keypress: this._onKeyPress,
164
157
  remove: this.closePopup,
165
158
  move: this._movePopup
166
159
  });
167
- this._popupHandlersAdded = false;
168
160
  this._popup = null;
169
161
  }
170
162
  return this;
@@ -265,14 +257,6 @@ const layerPopupMethods = {
265
257
 
266
258
  _movePopup(e) {
267
259
  this._popup.setLatLng(e.latlng);
268
- },
269
-
270
- _onKeyPress(e) {
271
- if (e.originalEvent.code === 'Enter') {
272
- this._popup._openedByKeyboard = true;
273
- this._openPopup(e);
274
- this._popup._openedByKeyboard = false;
275
- }
276
260
  }
277
261
  };
278
262
  /** @typedef {typeof layerPopupMethods} LayerPopupMethods */
@@ -317,25 +301,23 @@ const layerPopupMethods = {
317
301
  */
318
302
  export class Popup extends DivOverlay {
319
303
 
320
- static {
321
- this.setDefaultOptions({
322
- pane: 'popupPane',
323
- offset: [0, 7],
324
- maxWidth: 300,
325
- minWidth: 50,
326
- maxHeight: null,
327
- autoPan: !Browser.reducedMotion,
328
- autoPanPaddingTopLeft: null,
329
- autoPanPaddingBottomRight: null,
330
- autoPanPadding: [5, 5],
331
- keepInView: false,
332
- closeButton: true,
333
- autoClose: true,
334
- closeOnEscapeKey: true,
335
- className: '',
336
- trackResize: true,
337
- });
338
- }
304
+ static defaultOptions = {
305
+ pane: 'popupPane',
306
+ offset: [0, 7],
307
+ maxWidth: 300,
308
+ minWidth: 50,
309
+ maxHeight: null,
310
+ autoPan: true,
311
+ autoPanPaddingTopLeft: null,
312
+ autoPanPaddingBottomRight: null,
313
+ autoPanPadding: [5, 5],
314
+ keepInView: false,
315
+ closeButton: true,
316
+ autoClose: true,
317
+ closeOnEscapeKey: true,
318
+ className: '',
319
+ trackResize: true,
320
+ };
339
321
 
340
322
  /**
341
323
  * Instantiates a `Popup` object given an optional `options` object that describes
@@ -388,7 +370,7 @@ export class Popup extends DivOverlay {
388
370
 
389
371
  super.onAdd(map);
390
372
 
391
- if (this._openedByKeyboard) {
373
+ if (this._source?._clickedByKeyboard) {
392
374
  // Move the focus into the popup, so that its content is read and reachable
393
375
  if (!this._closeButton) {
394
376
  this._container.tabIndex = -1;
@@ -531,6 +513,9 @@ export class Popup extends DivOverlay {
531
513
  if (!this.options.autoPan) { return; }
532
514
  this._map._panAnim?.stop();
533
515
 
516
+ // Stopping the pan fires `moveend`, whose listeners may have removed this popup.
517
+ if (!this._map) { return; }
518
+
534
519
  // We can endlessly recurse if keepInView is set and the view resets.
535
520
  // Let's guard against that by exiting early if we're responding to our own autopan.
536
521
  if (this._autopanning) {
@@ -44,11 +44,7 @@ export class SVGOverlay extends ImageOverlay {
44
44
  _initImage() {
45
45
  const el = this._image = this._url;
46
46
 
47
- el.classList.add('maplair-image-layer');
48
- if (this._zoomAnimated) { el.classList.add('maplair-zoom-animated'); }
47
+ el.classList.add('maplair-image-layer', 'maplair-zoom-animated');
49
48
  if (this.options.className) { el.classList.add(...Util.splitWords(this.options.className)); }
50
-
51
- el.onselectstart = Util.falseFn;
52
- el.onpointermove = Util.falseFn;
53
49
  }
54
50
  }
@@ -204,15 +204,13 @@ const layerTooltipMethods = {
204
204
  },
205
205
 
206
206
  /**
207
- * Closes the tooltip bound to this layer if it is open. Returns the bound tooltip
208
- * (not the layer), or `undefined` without one.
207
+ * Closes the tooltip bound to this layer if it is open.
209
208
  * @group Tooltip methods
210
- * @returns {Tooltip|undefined}
209
+ * @returns {this}
211
210
  */
212
211
  closeTooltip() {
213
- if (this._tooltip) {
214
- return this._tooltip.close();
215
- }
212
+ this._tooltip?.close();
213
+ return this;
216
214
  },
217
215
 
218
216
  /**
@@ -231,7 +229,7 @@ const layerTooltipMethods = {
231
229
  * @returns {boolean}
232
230
  */
233
231
  isTooltipOpen() {
234
- return this._tooltip.isOpen();
232
+ return this._tooltip?.isOpen() ?? false;
235
233
  },
236
234
 
237
235
  /**
@@ -374,16 +372,14 @@ const layerTooltipMethods = {
374
372
  */
375
373
  export class Tooltip extends DivOverlay {
376
374
 
377
- static {
378
- this.setDefaultOptions({
379
- pane: 'tooltipPane',
380
- offset: [0, 0],
381
- direction: 'auto',
382
- permanent: false,
383
- sticky: false,
384
- opacity: 0.9
385
- });
386
- }
375
+ static defaultOptions = {
376
+ pane: 'tooltipPane',
377
+ offset: [0, 0],
378
+ direction: 'auto',
379
+ permanent: false,
380
+ sticky: false,
381
+ opacity: 0.9
382
+ };
387
383
 
388
384
  /**
389
385
  * Instantiates a `Tooltip` object given an optional `options` object that describes
@@ -457,7 +453,7 @@ export class Tooltip extends DivOverlay {
457
453
 
458
454
  _initLayout() {
459
455
  const prefix = 'maplair-tooltip',
460
- className = `${prefix} ${this.options.className || ''} maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;
456
+ className = `${prefix} ${this.options.className || ''} maplair-zoom-animated`;
461
457
 
462
458
  this._contentNode = this._container = DomUtil.create('div', className);
463
459
 
@@ -597,7 +593,7 @@ export class Tooltip extends DivOverlay {
597
593
  this.options.opacity = opacity;
598
594
 
599
595
  if (this._container) {
600
- this._container.style.opacity = opacity;
596
+ this._container.style.opacity = `${opacity}`;
601
597
  }
602
598
  }
603
599
 
@@ -45,16 +45,14 @@ import * as Util from '../core/Util.js';
45
45
  */
46
46
  export class VideoOverlay extends ImageOverlay {
47
47
 
48
- static {
49
- this.setDefaultOptions({
50
- autoplay: true,
51
- controls: false,
52
- loop: true,
53
- keepAspectRatio: true,
54
- muted: false,
55
- playsInline: true
56
- });
57
- }
48
+ static defaultOptions = {
49
+ autoplay: true,
50
+ controls: false,
51
+ loop: true,
52
+ keepAspectRatio: true,
53
+ muted: false,
54
+ playsInline: true
55
+ };
58
56
 
59
57
  /**
60
58
  * Instantiates a video overlay object given the URL of the video (or array of
@@ -73,11 +71,10 @@ export class VideoOverlay extends ImageOverlay {
73
71
  }
74
72
 
75
73
  _initImage() {
76
- const wasElementSupplied = this._url.tagName === 'VIDEO';
74
+ const wasElementSupplied = this._url instanceof HTMLVideoElement;
77
75
  const vid = this._image = wasElementSupplied ? this._url : DomUtil.create('video');
78
76
 
79
- vid.classList.add('maplair-image-layer');
80
- if (this._zoomAnimated) { vid.classList.add('maplair-zoom-animated'); }
77
+ vid.classList.add('maplair-image-layer', 'maplair-zoom-animated');
81
78
  if (this.options.className) { vid.classList.add(...Util.splitWords(this.options.className)); }
82
79
 
83
80
  DomEvent.on(vid, 'pointerdown', (e) => {
@@ -91,14 +88,14 @@ export class VideoOverlay extends ImageOverlay {
91
88
 
92
89
  if (wasElementSupplied) {
93
90
  const sourceElements = vid.getElementsByTagName('source');
94
- const sources = sourceElements.map(e => e.src);
91
+ const sources = Array.from(sourceElements, e => e.src);
95
92
  this._url = (sourceElements.length > 0) ? sources : [vid.src];
96
93
  return;
97
94
  }
98
95
 
99
96
  if (!Array.isArray(this._url)) { this._url = [this._url]; }
100
97
 
101
- if (!this.options.keepAspectRatio && Object.hasOwn(vid.style, 'objectFit')) {
98
+ if (!this.options.keepAspectRatio) {
102
99
  vid.style['objectFit'] = 'fill';
103
100
  }
104
101
  vid.autoplay = !!this.options.autoplay;
@@ -1,53 +1,42 @@
1
1
  import {Icon} from './Icon.js';
2
- import * as DomUtil from '../../dom/DomUtil.js';
3
2
  /** @import {IconOptions} from './Icon.js' */
4
3
  /** @import {PointExpression} from '../../geometry/Point.js' */
5
4
 
6
- const URL_RE = /^url\((['"])?(.+)\1\)$/;
7
- const MARKER_ICON_RE = /^(.*)marker-icon\.svg$/;
8
-
9
5
  /**
10
6
  * Options of `DefaultIcon`.
11
7
  * @typedef {object} DefaultIconOptions
12
- * @property {string} [iconUrl='marker-icon.svg']
13
- * @property {string} [iconRetinaUrl='marker-icon.svg']
14
- * @property {string} [shadowUrl='marker-shadow.svg']
8
+ * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
9
+ * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
15
10
  * @property {PointExpression|number} [iconSize=[25, 41]]
16
11
  * @property {PointExpression} [iconAnchor=[12, 41]]
17
12
  * @property {PointExpression} [popupAnchor=[1, -34]]
18
13
  * @property {PointExpression} [tooltipAnchor=[16, -28]]
19
14
  * @property {PointExpression|number} [shadowSize=[41, 41]]
20
- * @property {string} [imagePath] `DefaultIcon` will try to auto-detect the location of
21
- * the blue icon images. If you are placing these images in a non-standard way, set this
22
- * option to point to the right path.
23
15
  * @extends IconOptions
24
16
  */
25
17
 
26
18
  /**
27
19
  * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when
28
- * no icon is specified. Points to the blue marker image distributed with Maplair
29
- * releases.
20
+ * no icon is specified. The maple leaf marker and its shadow are inlined as SVG data
21
+ * URIs, so they work with any bundler and need no image files.
30
22
  *
31
23
  * In order to customize the default icon, just change the properties of
32
- * `DefaultIcon.prototype.options` (which is a set of `Icon options`).
24
+ * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
33
25
  *
34
26
  * If you want to _completely_ replace the default icon, override the
35
- * `Marker.prototype.options.icon` with your own icon instead.
27
+ * `Marker.defaultOptions.icon` with your own icon instead.
36
28
  */
37
29
  export class DefaultIcon extends Icon {
38
30
 
39
- static {
40
- this.setDefaultOptions({
41
- iconUrl: 'marker-icon.svg',
42
- iconRetinaUrl: 'marker-icon.svg',
43
- shadowUrl: 'marker-shadow.svg',
44
- iconSize: [25, 41],
45
- iconAnchor: [12, 41],
46
- popupAnchor: [1, -34],
47
- tooltipAnchor: [16, -28],
48
- shadowSize: [41, 41]
49
- });
50
- }
31
+ static defaultOptions = {
32
+ iconUrl: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="%23C2331B"/><stop offset="1" stop-color="%23E2603F"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="%238F2D20"/><stop offset="1" stop-color="%23B23A27"/></linearGradient></defs><path fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/><path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>',
33
+ shadowUrl: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 817.2 820"><radialGradient id="a" cx="526.6" cy="486.836" r="478.154" fx="275.876" fy="893.983" gradientUnits="userSpaceOnUse"><stop offset="0" style="stop-color:%235c5c5c;stop-opacity:.9477"/><stop offset=".112" style="stop-color:%23474747;stop-opacity:.7805"/><stop offset=".34" style="stop-color:%23202020;stop-opacity:.4413"/><stop offset=".523" style="stop-color:%23090909;stop-opacity:.1692"/><stop offset=".637" style="stop-color:%23000;stop-opacity:0"/></radialGradient><path d="M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z" style="fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)"/></svg>',
34
+ iconSize: [25, 41],
35
+ iconAnchor: [12, 41],
36
+ popupAnchor: [1, -34],
37
+ tooltipAnchor: [16, -28],
38
+ shadowSize: [41, 41]
39
+ };
51
40
 
52
41
  /**
53
42
  * Creates the default icon, optionally with changed options.
@@ -57,39 +46,4 @@ export class DefaultIcon extends Icon {
57
46
  super(...args);
58
47
  this.callInitHooks(DefaultIcon);
59
48
  }
60
-
61
- _getIconUrl(name) {
62
- // only detect once
63
- if (!DefaultIcon.imagePath) {
64
- DefaultIcon.imagePath = this._detectIconPath();
65
- }
66
-
67
- const url = super._getIconUrl(name);
68
- if (!url) {
69
- return null;
70
- }
71
-
72
- // see the `imagePath` option
73
- return (this.options.imagePath ?? DefaultIcon.imagePath) + url;
74
- }
75
-
76
- _stripUrl(path) { // separate function to use in tests
77
- const strip = function (str, re, idx) {
78
- const match = re.exec(str);
79
- return match && match[idx];
80
- };
81
- path = strip(path, URL_RE, 2);
82
- return path && strip(path, MARKER_ICON_RE, 1);
83
- }
84
-
85
- _detectIconPath() {
86
- const el = DomUtil.create('div', 'maplair-default-icon-path', document.body);
87
- const path = this._stripUrl(getComputedStyle(el).backgroundImage);
88
-
89
- document.body.removeChild(el);
90
- if (path) { return path; }
91
- const link = document.querySelector('link[href$="maplair.css"]');
92
- if (!link) { return ''; }
93
- return link.href.substring(0, link.href.length - 'maplair.css'.length - 1);
94
- }
95
49
  }
@@ -34,18 +34,16 @@ import {Point} from '../../geometry/Point.js';
34
34
  */
35
35
  export class DivIcon extends Icon {
36
36
 
37
- static {
38
- this.setDefaultOptions({
39
- iconSize: [12, 12], // also can be set through CSS
37
+ static defaultOptions = {
38
+ iconSize: [12, 12], // also can be set through CSS
40
39
 
41
- // iconAnchor: (Point),
42
- // popupAnchor: (Point),
40
+ // iconAnchor: (Point),
41
+ // popupAnchor: (Point),
43
42
 
44
- html: false,
45
- bgPos: null,
46
- className: 'maplair-div-icon'
47
- });
48
- }
43
+ html: false,
44
+ bgPos: null,
45
+ className: 'maplair-div-icon'
46
+ };
49
47
 
50
48
  /**
51
49
  * Creates a `DivIcon` instance with the given options.
@@ -63,7 +61,7 @@ export class DivIcon extends Icon {
63
61
  * @returns {HTMLElement}
64
62
  */
65
63
  createIcon(oldIcon) {
66
- const div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),
64
+ const div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement('div'),
67
65
  options = this.options;
68
66
 
69
67
  if (options.html instanceof Element) {
@@ -1,7 +1,6 @@
1
1
  import {Class} from '../../core/Class.js';
2
2
  import {setOptions} from '../../core/Util.js';
3
3
  import {Point} from '../../geometry/Point.js';
4
- import Browser from '../../core/Browser.js';
5
4
 
6
5
  /** @import {PointExpression} from '../../geometry/Point.js' */
7
6
 
@@ -63,13 +62,11 @@ import Browser from '../../core/Browser.js';
63
62
  */
64
63
  export class Icon extends Class {
65
64
 
66
- static {
67
- this.setDefaultOptions({
68
- popupAnchor: [0, 0],
69
- tooltipAnchor: [0, 0],
70
- crossOrigin: false
71
- });
72
- }
65
+ static defaultOptions = {
66
+ popupAnchor: [0, 0],
67
+ tooltipAnchor: [0, 0],
68
+ crossOrigin: false
69
+ };
73
70
 
74
71
  /**
75
72
  * Creates an icon instance with the given options.
@@ -111,7 +108,7 @@ export class Icon extends Class {
111
108
  return null;
112
109
  }
113
110
 
114
- const img = this._createImg(src, oldIcon && oldIcon.tagName === 'IMG' ? oldIcon : null);
111
+ const img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);
115
112
  this._setIconStyles(img, name);
116
113
 
117
114
  if (this.options.crossOrigin || this.options.crossOrigin === '') {
@@ -154,6 +151,6 @@ export class Icon extends Class {
154
151
  }
155
152
 
156
153
  _getIconUrl(name) {
157
- return Browser.retina && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
154
+ return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
158
155
  }
159
156
  }
@@ -38,7 +38,7 @@ export class MarkerDrag extends Handler {
38
38
  const icon = this._marker._icon;
39
39
 
40
40
  if (!this._draggable) {
41
- this._draggable = new Draggable(icon, icon, true);
41
+ this._draggable = new Draggable(icon);
42
42
  }
43
43
 
44
44
  this._draggable.on({
@@ -1,7 +1,6 @@
1
1
  import {Marker} from './Marker.js';
2
2
  import {LatLng} from '../../geo/LatLng.js';
3
3
  import {Point} from '../../geometry/Point.js';
4
- import Browser from '../../core/Browser.js';
5
4
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
6
5
  /** @import {MaplairMap} from '../../map/Map.js' */
7
6
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -73,7 +72,7 @@ const markerMoveMethods = {
73
72
 
74
73
  const frame = () => {
75
74
  // the distance moved, at a constant speed
76
- let distance = duration && !Browser.reducedMotion ? Math.min(1, (performance.now() - start) / duration) * total : total,
75
+ let distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total,
77
76
  i = 0;
78
77
  const moved = distance;
79
78
  while (i < lengths.length - 1 && distance > lengths[i]) {