maplair 4.0.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.
- package/CHANGELOG.md +178 -0
- package/dist/esm/Maplair.js +18 -17
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +25 -16
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +10 -13
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +2 -5
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +10 -18
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +6 -9
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +170 -65
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +8 -11
- package/dist/esm/control/LegendControl.js.map +1 -1
- package/dist/esm/control/MiniMapControl.js +15 -18
- package/dist/esm/control/MiniMapControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +2 -5
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +8 -11
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +100 -19
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +2 -5
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/TextControl.js +6 -9
- package/dist/esm/control/TextControl.js.map +1 -1
- package/dist/esm/control/TimeControl.js +407 -0
- package/dist/esm/control/TimeControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +23 -36
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +28 -44
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +22 -10
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +23 -14
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +15 -4
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +26 -24
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +3 -18
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +18 -60
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +15 -70
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +21 -21
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +4 -27
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +16 -7
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +5 -6
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +5 -6
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +4 -5
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +3 -4
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +4 -5
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +5 -6
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +5 -6
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +37 -32
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +24 -51
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +7 -10
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +16 -22
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +17 -155
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +74 -0
- package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
- package/dist/esm/layer/HeatLayer.js +17 -20
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +22 -29
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +9 -12
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +53 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +35 -58
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +3 -7
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -34
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +13 -17
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +38 -49
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +8 -11
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +9 -12
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +44 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +5 -8
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +115 -47
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +301 -0
- package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
- package/dist/esm/layer/marker/SvgIcon.js +7 -10
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +89 -101
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +36 -44
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +33 -27
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +8 -17
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +6 -5
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +19 -10
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +3 -5
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +28 -22
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +22 -7
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +3 -4
- package/dist/esm/layer/vector/Polyline.js +25 -10
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +17 -17
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +12 -9
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +41 -22
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +125 -126
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +25 -47
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +7 -10
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +20 -21
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +48 -68
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +13 -5
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +4 -6
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +13 -7
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +6495 -5981
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +6206 -5673
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1213
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/i18n/cs.json +6 -0
- package/i18n/de.json +6 -0
- package/i18n/en.json +6 -0
- package/i18n/es.json +6 -0
- package/i18n/fr.json +6 -0
- package/i18n/hu.json +6 -0
- package/i18n/it.json +6 -0
- package/i18n/rm.json +6 -0
- package/i18n/sk.json +6 -0
- package/i18n/sl.json +6 -0
- package/package.json +11 -18
- package/src/Maplair.all.js +0 -1
- package/src/control/AttributionControl.js +25 -18
- package/src/control/ButtonControl.js +9 -11
- package/src/control/ContextMenu.js +3 -5
- package/src/control/Control.js +9 -19
- package/src/control/FullscreenControl.js +5 -7
- package/src/control/LayersControl.js +196 -86
- package/src/control/LegendControl.js +7 -9
- package/src/control/MiniMapControl.js +9 -11
- package/src/control/RotateControl.js +3 -5
- package/src/control/ScaleControl.js +7 -9
- package/src/control/SearchControl.js +102 -19
- package/src/control/SideBySideControl.js +3 -5
- package/src/control/TextControl.js +5 -7
- package/src/control/TimeControl.js +471 -0
- package/src/control/ZoomControl.js +22 -38
- package/src/control/index.js +1 -0
- package/src/core/Class.js +37 -45
- package/src/core/Events.js +22 -3
- package/src/core/Handler.js +25 -13
- package/src/core/Util.js +20 -2
- package/src/core/index.js +0 -1
- package/src/dom/DomEvent.DoubleTap.js +18 -10
- package/src/dom/DomEvent.PointerEvents.js +3 -26
- package/src/dom/DomEvent.js +17 -85
- package/src/dom/DomUtil.js +22 -78
- package/src/dom/Draggable.js +32 -23
- package/src/dom/PosAnimation.js +3 -25
- package/src/dom/index.js +0 -1
- package/src/geo/LatLng.js +20 -3
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +4 -4
- package/src/geo/crs/EPSG3857.js +4 -4
- package/src/geo/crs/EPSG4326.js +3 -3
- package/src/geo/crs/EarthCRS.js +2 -8
- package/src/geo/crs/SimpleCRS.js +3 -3
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +2 -2
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +2 -2
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +2 -2
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +48 -49
- package/src/geometry/PolyUtil.js +39 -76
- package/src/layer/BlanketOverlay.js +6 -10
- package/src/layer/DivOverlay.js +16 -27
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +17 -218
- package/src/layer/GeoJSONUtil.js +85 -0
- package/src/layer/HeatLayer.js +10 -12
- package/src/layer/ImageOverlay.js +21 -32
- package/src/layer/Layer.js +8 -10
- package/src/layer/LayerGroup.js +72 -1
- package/src/layer/Popup.js +37 -62
- package/src/layer/SVGOverlay.js +1 -5
- package/src/layer/Tooltip.js +34 -36
- package/src/layer/VideoOverlay.js +12 -15
- package/src/layer/marker/DefaultIcon.js +40 -58
- package/src/layer/marker/DivIcon.js +9 -11
- package/src/layer/marker/Icon.js +9 -10
- package/src/layer/marker/Marker.Drag.js +54 -6
- package/src/layer/marker/Marker.Move.js +4 -6
- package/src/layer/marker/Marker.js +145 -52
- package/src/layer/marker/MarkerClusterGroup.js +370 -0
- package/src/layer/marker/SvgIcon.js +7 -9
- package/src/layer/marker/index.js +1 -0
- package/src/layer/tile/GridLayer.js +108 -135
- package/src/layer/tile/TileLayer.js +44 -49
- package/src/layer/tile/WMSTileLayer.js +31 -26
- package/src/layer/vector/Canvas.js +13 -19
- package/src/layer/vector/Circle.js +9 -3
- package/src/layer/vector/CircleMarker.js +19 -7
- package/src/layer/vector/Path.DashAnimation.js +1 -2
- package/src/layer/vector/Path.js +30 -21
- package/src/layer/vector/Polygon.js +29 -6
- package/src/layer/vector/Polyline.js +26 -7
- package/src/layer/vector/Renderer.getRenderer.js +20 -19
- package/src/layer/vector/SVG.js +17 -7
- package/src/map/Map.Rotation.js +40 -8
- package/src/map/Map.js +158 -153
- package/src/map/handler/BoxZoomHandler.js +30 -50
- package/src/map/handler/DisplaceHandler.js +6 -8
- package/src/map/handler/DragHandler.js +25 -28
- package/src/map/handler/KeyboardHandler.js +65 -90
- package/src/map/handler/PinchZoomHandler.js +16 -5
- package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
- package/src/map/handler/TapHoldHandler.js +15 -4
- package/src/map/index.js +1 -1
- package/src/maplair.css +153 -98
- package/dist/esm/core/Browser.js +0 -100
- package/dist/esm/core/Browser.js.map +0 -1
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/dist/images/layers.svg +0 -1
- package/dist/images/marker-icon.svg +0 -1
- package/dist/images/marker-shadow.svg +0 -1
- package/src/core/Browser.js +0 -110
- package/src/images/layers.svg +0 -1
- package/src/images/marker-icon.svg +0 -1
- package/src/images/marker-shadow.svg +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["DomEvent.off","DomEvent.on","DomUtil.create","Util.stamp"],"sources":["../../../src/layer/Tooltip.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\nimport {FeatureGroup} from './FeatureGroup.js';\n\nconst directions = ['top', 'bottom', 'center', 'right', 'left'];\n\n// The size of the tooltip tip (see `.maplair-tooltip-top` etc. in maplair.css) and\n// the minimum distance of an `auto` tooltip to the edge of the map.\nconst tipSize = 6,\nautoPadding = 4;\n\n// The shift moving a box from `start` with `size` into the range `[min, max]`.\nfunction shiftInto(start, size, min, max) {\n\treturn Math.max(0, min - start) - Math.max(0, start + size - max);\n}\n\n// Keeps the shifted tip off the rounded corners of the tooltip.\nfunction clampTip(tipShift, size) {\n\tconst max = Math.max(0, size / 2 - 2 * tipSize);\n\treturn Math.round(Math.min(max, Math.max(-max, tipShift)));\n}\n\n/** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */\n/** @import {LatLngExpression} from '../geo/LatLng.js' */\n/** @import {PointExpression} from '../geometry/Point.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {EventListener, TooltipEvent} from '../core/Events.js' */\n\n/**\n * Options of `Tooltip`.\n * @typedef {object} TooltipOptions\n * @property {string} [pane='tooltipPane'] `Map pane` where the tooltip will be added.\n * @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position.\n * @property {'right'|'left'|'top'|'bottom'|'center'|'auto'} [direction='auto']\n * Direction where to open the tooltip. Possible values are: `right`, `left`, `top`,\n * `bottom`, `center`, `auto`. `auto` chooses the direction with enough space when\n * opening the tooltip: preferably the side towards the center of the map (`right` or\n * `left`), otherwise the opposite side, `top` or `bottom`. The tooltip is shifted\n * along that side to stay within the map (within the viewport if `overflow` is set),\n * its tip still pointing at the source.\n * @property {boolean} [permanent=false] Whether to open the tooltip permanently or only\n * on pointerover.\n * @property {boolean} [sticky=false] If true, the tooltip will follow the pointer\n * instead of being fixed at the feature center.\n * @property {number} [opacity=0.9] Tooltip container opacity.\n * @extends DivOverlayOptions\n */\n\n/**\n * Methods of `MaplairMap` for tooltips.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#tooltipopen {TooltipEvent} Fired when a tooltip is opened in the map.\n * @fires MaplairMap#tooltipclose {TooltipEvent} Fired when a tooltip in the map is closed.\n */\nconst mapTooltipMethods = {\n\t/**\n\t * Opens the specified tooltip.\n\t *\n\t * Alternatively, creates a tooltip with the specified content and options and\n\t * opens it. String content is rendered as HTML; sanitize untrusted input or pass\n\t * an `HTMLElement` with safe `textContent` instead.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip|DivOverlayContent} tooltip The tooltip, or the content of a new\n\t * tooltip.\n\t * @param {LatLngExpression} [latlng]\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\topenTooltip(tooltip, latlng, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._initOverlay(Tooltip, tooltip, latlng, options)\n\t\t\t.openOn(this);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip given as parameter.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip} tooltip\n\t * @returns {this}\n\t */\n\tcloseTooltip(tooltip) {\n\t\ttooltip.close();\n\t\treturn this;\n\t}\n};\n/** @typedef {typeof mapTooltipMethods} MapTooltipMethods */\n\n/**\n * Methods of `Layer` for tooltips. All layers share a set of methods convenient for\n * binding tooltips to it.\n *\n * ```js\n * const layer = new Polygon(latlngs).bindTooltip('Hi There!').addTo(map);\n * layer.openTooltip();\n * layer.closeTooltip();\n * ```\n *\n * @lends Layer.prototype\n * @fires Layer#tooltipopen {TooltipEvent} Fired when a tooltip bound to this layer is\n * opened.\n * @fires Layer#tooltipclose {TooltipEvent} Fired when a tooltip bound to this layer is\n * closed.\n */\nconst layerTooltipMethods = {\n\t/**\n\t * Binds a tooltip to the layer with the passed `content` and sets up the\n\t * necessary event listeners. A `String` argument is rendered as HTML; if it\n\t * may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an\n\t * `HTMLElement` with safe `textContent` instead. If a `Function` is passed\n\t * it will receive the layer as the first argument and should return a\n\t * `String` or `HTMLElement`.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent|Tooltip} content\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\tbindTooltip(content, options) {\n\n\t\tif (this._tooltip && this.isTooltipOpen()) {\n\t\t\tthis.unbindTooltip();\n\t\t}\n\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._tooltip = this._initOverlay(Tooltip, this._tooltip, content, options);\n\t\tthis._initTooltipInteractions();\n\n\t\tif (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) {\n\t\t\tthis.openTooltip();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the tooltip previously bound with `bindTooltip`.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tunbindTooltip() {\n\t\tif (this._tooltip) {\n\t\t\tthis._initTooltipInteractions(true);\n\t\t\tthis.closeTooltip();\n\t\t\tthis._tooltip = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t_initTooltipInteractions(remove) {\n\t\tif (!remove && this._tooltipHandlersAdded) { return; }\n\t\tconst onOff = remove ? 'off' : 'on',\n\t\tevents = {\n\t\t\tremove: this.closeTooltip,\n\t\t\tmove: this._moveTooltip\n\t\t};\n\t\tif (!this._tooltip.options.permanent) {\n\t\t\tevents.pointerover = this._openTooltip;\n\t\t\tevents.pointerout = this.closeTooltip;\n\t\t\tevents.click = this._openTooltip;\n\t\t\tif (this._map) {\n\t\t\t\tthis._addFocusListeners(remove);\n\t\t\t} else {\n\t\t\t\tevents.add = () => this._addFocusListeners(remove);\n\t\t\t}\n\t\t} else {\n\t\t\tevents.add = this._openTooltip;\n\t\t}\n\t\tif (this._tooltip.options.sticky) {\n\t\t\tevents.pointermove = this._moveTooltip;\n\t\t}\n\t\tthis[onOff](events);\n\t\tthis._tooltipHandlersAdded = !remove;\n\t},\n\n\t/**\n\t * Opens the bound tooltip at the specified `latlng` or at the default tooltip\n\t * anchor if no `latlng` is passed.\n\t * @group Tooltip methods\n\t * @param {LatLngExpression} [latlng]\n\t * @returns {this}\n\t */\n\topenTooltip(latlng) {\n\t\tif (this._tooltip) {\n\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\tthis._tooltip._source = this;\n\t\t\t}\n\t\t\tif (this._tooltip._prepareOpen(latlng)) {\n\t\t\t\t// open the tooltip on the map\n\t\t\t\tthis._tooltip.openOn(this._map);\n\n\t\t\t\tif (this.getElement) {\n\t\t\t\t\tthis._setAriaDescribedByOnLayer(this);\n\t\t\t\t} else if (this.eachLayer) {\n\t\t\t\t\tthis.eachLayer(this._setAriaDescribedByOnLayer, this);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip bound to this layer if it is open. Returns the bound tooltip\n\t * (not the layer), or `undefined` without one.\n\t * @group Tooltip methods\n\t * @returns {Tooltip|undefined}\n\t */\n\tcloseTooltip() {\n\t\tif (this._tooltip) {\n\t\t\treturn this._tooltip.close();\n\t\t}\n\t},\n\n\t/**\n\t * Opens or closes the tooltip bound to this layer depending on its current state.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\ttoggleTooltip() {\n\t\tthis._tooltip?.toggle(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the tooltip bound to this layer is currently open.\n\t * @group Tooltip methods\n\t * @returns {boolean}\n\t */\n\tisTooltipOpen() {\n\t\treturn this._tooltip.isOpen();\n\t},\n\n\t/**\n\t * Sets the content of the tooltip bound to this layer. String content is rendered\n\t * as HTML; sanitize untrusted input or pass an `HTMLElement` with safe\n\t * `textContent` instead.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent} content\n\t * @returns {this}\n\t */\n\tsetTooltipContent(content) {\n\t\tthis._tooltip?.setContent(content);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns the tooltip bound to this layer.\n\t * @group Tooltip methods\n\t * @returns {Tooltip|undefined}\n\t */\n\tgetTooltip() {\n\t\treturn this._tooltip;\n\t},\n\n\t_addFocusListeners(remove) {\n\t\tif (this.getElement) {\n\t\t\tthis._addFocusListenersOnLayer(this, remove);\n\t\t} else if (this.eachLayer) {\n\t\t\tthis.eachLayer(layer => this._addFocusListenersOnLayer(layer, remove), this);\n\t\t}\n\t},\n\n\t_addFocusListenersOnLayer(layer, remove) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tif (el) {\n\t\t\tconst toggle = remove ? DomEvent.off : DomEvent.on;\n\t\t\tif (!remove) {\n\t\t\t\t// Remove focus listener, if already existing\n\t\t\t\tel._maplair_focus_handler && DomEvent.off(el, 'focus', el._maplair_focus_handler, this);\n\n\t\t\t\tel._maplair_focus_handler = () => {\n\t\t\t\t\tif (this._tooltip) {\n\t\t\t\t\t\tthis._tooltip._source = layer;\n\t\t\t\t\t\tthis.openTooltip();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tel._maplair_focus_handler && toggle(el, 'focus', el._maplair_focus_handler, this);\n\t\t\ttoggle(el, 'blur', this.closeTooltip, this);\n\n\t\t\tif (remove) {\n\t\t\t\tdelete el._maplair_focus_handler;\n\t\t\t}\n\t\t}\n\t},\n\n\t_setAriaDescribedByOnLayer(layer) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tel?.setAttribute?.('aria-describedby', this._tooltip._container.id);\n\t},\n\n\t_openTooltip(e) {\n\t\tif (!this._tooltip || !this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the map is moving, we will show the tooltip after it's done.\n\t\tif (this._map.dragging?.moving()) {\n\t\t\tif (e.type === 'add' && !this._moveEndOpensTooltip) {\n\t\t\t\tthis._moveEndOpensTooltip = true;\n\t\t\t\tthis._map.once('moveend', () => {\n\t\t\t\t\tthis._moveEndOpensTooltip = false;\n\t\t\t\t\tthis._openTooltip(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis._tooltip._source = e.propagatedFrom ?? e.target;\n\n\t\tthis.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);\n\t},\n\n\t_moveTooltip(e) {\n\t\tlet latlng = e.latlng, containerPoint, layerPoint;\n\t\tif (this._tooltip.options.sticky && e.originalEvent) {\n\t\t\tcontainerPoint = this._map.pointerEventToContainerPoint(e.originalEvent);\n\t\t\tlayerPoint = this._map.containerPointToLayerPoint(containerPoint);\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\t\t}\n\t\tthis._tooltip.setLatLng(latlng);\n\t}\n};\n/** @typedef {typeof layerTooltipMethods} LayerTooltipMethods */\n\n/**\n * Used to display small texts on top of map layers.\n *\n * @example\n * If you want to just bind a tooltip to marker:\n *\n * ```js\n * marker.bindTooltip(\"my tooltip text\").openTooltip();\n * ```\n * Path overlays like polylines also have a `bindTooltip` method.\n *\n * A tooltip can be also standalone:\n *\n * ```js\n * const tooltip = new Tooltip()\n * \t.setLatLng(latlng)\n * \t.setContent('Hello world!<br />This is a nice tooltip.')\n * \t.addTo(map);\n * ```\n * or\n * ```js\n * const tooltip = new Tooltip(latlng, {content: 'Hello world!<br />This is a nice tooltip.'})\n * \t.addTo(map);\n * ```\n *\n * **Security note.** Tooltip string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindTooltip(el);\n * ```\n *\n * Note about tooltip offset. Maplair takes two options in consideration\n * for computing tooltip offsetting:\n * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip.\n * Add a positive x offset to move the tooltip to the right, and a positive y offset to\n * move it to the bottom. Negatives will move to the left and top.\n * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You\n * should adapt this value if you use a custom icon.\n */\nexport class Tooltip extends DivOverlay {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tpane: 'tooltipPane',\n\t\t\toffset: [0, 0],\n\t\t\tdirection: 'auto',\n\t\t\tpermanent: false,\n\t\t\tsticky: false,\n\t\t\topacity: 0.9\n\t\t});\n\t}\n\n\t/**\n\t * Instantiates a `Tooltip` object given an optional `options` object that describes\n\t * its appearance and location and an optional `source` object that is used to tag\n\t * the tooltip with a reference to the Layer to which it refers.\n\t * @overload\n\t * @param {TooltipOptions} [options]\n\t * @param {Layer} [source]\n\t */\n\t/**\n\t * Instantiates a `Tooltip` object given `latlng` where the tooltip will open and an\n\t * optional `options` object that describes its appearance and location.\n\t * @overload\n\t * @param {LatLngExpression} latlng\n\t * @param {TooltipOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Tooltip);\n\t}\n\n\t/**\n\t * Adds the tooltip to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\t\tthis.setOpacity(this.options.opacity);\n\n\t\tmap.fire('tooltipopen', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.addEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipopen', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the tooltip from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tsuper.onRemove(map);\n\n\t\tmap.fire('tooltipclose', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.removeEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipclose', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the tooltip listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (!this.options.permanent) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-tooltip',\n\t\tclassName = `${prefix} ${this.options.className || ''} maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;\n\n\t\tthis._contentNode = this._container = DomUtil.create('div', className);\n\n\t\tthis._container.setAttribute('role', 'tooltip');\n\t\tthis._container.setAttribute('id', `maplair-tooltip-${Util.stamp(this)}`);\n\t}\n\n\t_updateLayout() {}\n\n\t_adjustPan() {}\n\n\t/**\n\t * Updates the tooltip content, layout and position.\n\t * @returns {void}\n\t */\n\tupdate() {\n\t\t// The automatic direction is chosen once per opening and content, so that\n\t\t// the tooltip does not flip sides while the map or the pointer moves.\n\t\tthis._autoDirection = undefined;\n\t\tsuper.update();\n\t}\n\n\t_setPosition(pos) {\n\t\tlet direction = this.options.direction,\n\t\tshift = new Point(0, 0);\n\t\tconst container = this._container,\n\t\ttooltipWidth = container.offsetWidth,\n\t\ttooltipHeight = container.offsetHeight,\n\t\toffset = new Point(this.options.offset),\n\t\tanchor = this._getAnchor();\n\n\t\tif (!directions.includes(direction)) {\n\t\t\t({direction, shift} = this._getAutoPlacement(pos, offset, anchor, tooltipWidth, tooltipHeight));\n\t\t\tif (direction === 'left') {\n\t\t\t\t// mirror the offset and anchor, which are meant for the right side\n\t\t\t\toffset.x = -offset.x;\n\t\t\t\tanchor.x = -anchor.x;\n\t\t\t}\n\t\t}\n\n\t\tlet subX = tooltipWidth / 2,\n\t\tsubY = tooltipHeight / 2;\n\t\tif (direction === 'top') {\n\t\t\tsubY = tooltipHeight;\n\t\t} else if (direction === 'bottom') {\n\t\t\tsubY = 0;\n\t\t} else if (direction === 'right') {\n\t\t\tsubX = 0;\n\t\t} else if (direction === 'left') {\n\t\t\tsubX = tooltipWidth;\n\t\t}\n\n\t\tpos = pos.subtract(new Point(subX, subY, true)).add(offset).add(anchor).add(shift);\n\n\t\tcontainer.classList.remove(\n\t\t\t'maplair-tooltip-right',\n\t\t\t'maplair-tooltip-left',\n\t\t\t'maplair-tooltip-top',\n\t\t\t'maplair-tooltip-bottom'\n\t\t);\n\t\tcontainer.classList.add(`maplair-tooltip-${direction}`);\n\n\t\t// Let the tip point at the source despite the shift\n\t\tconst tipShift = direction === 'top' || direction === 'bottom' ?\n\t\t\tclampTip(-shift.x, tooltipWidth) :\n\t\t\tclampTip(-shift.y, tooltipHeight);\n\t\tif (tipShift) {\n\t\t\tcontainer.style.setProperty('--maplair-tooltip-tip-shift', `${tipShift}px`);\n\t\t} else {\n\t\t\tcontainer.style.removeProperty('--maplair-tooltip-tip-shift');\n\t\t}\n\n\t\tthis._setContainerPosition(pos);\n\t}\n\n\t// Chooses the direction of an `auto` tooltip by the available space:\n\t// preferably the side towards the center, otherwise the opposite side,\n\t// above or below. The tooltip is shifted along that side to stay in view.\n\t_getAutoPlacement(pos, offset, anchor, width, height) {\n\t\tconst area = this._getAutoArea(),\n\t\tpoint = this._map.layerPointToContainerPoint(pos),\n\t\tx = point.x + offset.x + anchor.x,\n\t\ty = point.y + offset.y + anchor.y,\n\t\t// the space for each direction, see `direction` for the mirrored left side\n\t\tspace = {\n\t\t\tright: area.max.x - x - width - tipSize,\n\t\t\tleft: point.x - offset.x - anchor.x - area.min.x - width - tipSize,\n\t\t\ttop: y - area.min.y - height - tipSize,\n\t\t\tbottom: area.max.y - y - height - tipSize\n\t\t};\n\n\t\tif (!this._autoDirection) {\n\t\t\tconst sides = point.x < (area.min.x + area.max.x) / 2 ? ['right', 'left'] : ['left', 'right'],\n\t\t\tfallback = space.right >= space.left ? 'right' : 'left';\n\t\t\tthis._autoDirection = [...sides, 'top', 'bottom'].find(d => space[d] >= 0 &&\n\t\t\t\t// above or below, the tooltip has to fit horizontally\n\t\t\t\t(d === 'right' || d === 'left' || width <= area.max.x - area.min.x)) ?? fallback;\n\t\t}\n\n\t\tconst direction = this._autoDirection,\n\t\tshift = direction === 'top' || direction === 'bottom' ?\n\t\t\tnew Point(shiftInto(x - width / 2, width, area.min.x, area.max.x), 0) :\n\t\t\tnew Point(0, shiftInto(y - height / 2, height, area.min.y, area.max.y));\n\n\t\treturn {direction, shift};\n\t}\n\n\t// The area in container points an `auto` tooltip should stay within:\n\t// the map, or the viewport for an overflowing tooltip.\n\t_getAutoArea() {\n\t\tconst map = this._map;\n\t\tlet min = new Point(0, 0),\n\t\tmax = map.getSize();\n\t\tif (this.options.overflow) {\n\t\t\tconst mapContainer = map._container,\n\t\t\trect = mapContainer.getBoundingClientRect(),\n\t\t\torigin = new Point(rect.left + mapContainer.clientLeft, rect.top + mapContainer.clientTop),\n\t\t\tviewport = document.documentElement;\n\t\t\tmin = min.subtract(origin);\n\t\t\tmax = new Point(viewport.clientWidth, viewport.clientHeight).subtract(origin);\n\t\t}\n\t\tconst padding = new Point(autoPadding, autoPadding);\n\t\treturn {min: min.add(padding), max: max.subtract(padding)};\n\t}\n\n\t_updatePosition() {\n\t\tconst pos = this._map.latLngToLayerPoint(this._latlng);\n\t\tthis._setPosition(pos);\n\t}\n\n\t/**\n\t * Sets the opacity of the tooltip.\n\t * @param {number} opacity\n\t * @returns {void}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\n\t\tif (this._container) {\n\t\t\tthis._container.style.opacity = opacity;\n\t\t}\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);\n\t\tthis._setPosition(pos);\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the tooltip on the source layer?\n\t\treturn new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.include(mapTooltipMethods);\n\n\t\tLayer.include(layerTooltipMethods);\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,aAAa;CAAC;CAAO;CAAU;CAAU;CAAS;AAAM;AAI9D,MAAM,UAAU;AAChB,MAAA,cAAc;AAGd,SAAS,UAAU,OAAO,MAAM,KAAK,KAAK;CACzC,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK,IAAI,KAAK,IAAI,GA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AAC;CAC1D;CAEA,kBAAkB;EACjB,MAAM,MAAM,KAAK,KAAK,mBAAmB,KAAK,OAAO;EACrD,KAAK,aAAa,GAAG;CACtB;;;;;;CAOA,WAAW,SAAS;EACnB,KAAK,QAAQ,UAAU;EAEvB,IAAI,KAAK,YACR,KAAK,WAAW,MAAM,UAAU;CAElC;CAEA,aAAa,GAAG;EACf,MAAM,MAAM,KAAK,KAAK,uBAAuB,KAAK,SAAS,EAAE,MAAM,EAAE,MAAM;EAC3E,KAAK,aAAa,GAAG;CACtB;CAEA,aAAa;EAEZ,OAAO,IAAI,MAAM,KAAK,SAAS,qBAAqB,CAAC,KAAK,QAAQ,SAAS,KAAK,QAAQ,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;CACrH;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;EAEpC,MAAM,QAAQ,mBAAmB;CAClC;AACD"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["DomEvent.off","DomEvent.on","DomUtil.create","Util.stamp"],"sources":["../../../src/layer/Tooltip.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\nimport {FeatureGroup} from './FeatureGroup.js';\n\nconst directions = ['top', 'bottom', 'center', 'right', 'left'];\n\n// The size of the tooltip tip (see `.maplair-tooltip-top` etc. in maplair.css) and\n// the minimum distance of an `auto` tooltip to the edge of the map.\nconst tipSize = 6,\nautoPadding = 4;\n\n// The shift moving a box from `start` with `size` into the range `[min, max]`.\nfunction shiftInto(start, size, min, max) {\n\treturn Math.max(0, min - start) - Math.max(0, start + size - max);\n}\n\n// Keeps the shifted tip off the rounded corners of the tooltip.\nfunction clampTip(tipShift, size) {\n\tconst max = Math.max(0, size / 2 - 2 * tipSize);\n\treturn Math.round(Math.min(max, Math.max(-max, tipShift)));\n}\n\n/** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */\n/** @import {LatLngExpression} from '../geo/LatLng.js' */\n/** @import {PointExpression} from '../geometry/Point.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {EventListener, TooltipEvent} from '../core/Events.js' */\n\n/**\n * Options of `Tooltip`.\n * @typedef {object} TooltipOptions\n * @property {string} [pane='tooltipPane'] `Map pane` where the tooltip will be added.\n * @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position.\n * @property {'right'|'left'|'top'|'bottom'|'center'|'auto'} [direction='auto']\n * Direction where to open the tooltip. Possible values are: `right`, `left`, `top`,\n * `bottom`, `center`, `auto`. `auto` chooses the direction with enough space when\n * opening the tooltip: preferably the side towards the center of the map (`right` or\n * `left`), otherwise the opposite side, `top` or `bottom`. The tooltip is shifted\n * along that side to stay within the map (within the viewport if `overflow` is set),\n * its tip still pointing at the source.\n * @property {boolean} [permanent=false] Whether to open the tooltip permanently or only\n * on pointerover.\n * @property {boolean} [sticky=false] If true, the tooltip will follow the pointer\n * instead of being fixed at the feature center.\n * @property {number} [opacity=0.9] Tooltip container opacity.\n * @extends DivOverlayOptions\n */\n\n/**\n * Methods of `MaplairMap` for tooltips.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#tooltipopen {TooltipEvent} Fired when a tooltip is opened in the map.\n * @fires MaplairMap#tooltipclose {TooltipEvent} Fired when a tooltip in the map is closed.\n */\nconst mapTooltipMethods = {\n\t/**\n\t * Opens the specified tooltip.\n\t *\n\t * Alternatively, creates a tooltip with the specified content and options and\n\t * opens it. String content is rendered as HTML; sanitize untrusted input or pass\n\t * an `HTMLElement` with safe `textContent` instead.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip|DivOverlayContent} tooltip The tooltip, or the content of a new\n\t * tooltip.\n\t * @param {LatLngExpression} [latlng]\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\topenTooltip(tooltip, latlng, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._initOverlay(Tooltip, tooltip, latlng, options)\n\t\t\t.openOn(this);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip given as parameter.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip} tooltip\n\t * @returns {this}\n\t */\n\tcloseTooltip(tooltip) {\n\t\ttooltip.close();\n\t\treturn this;\n\t}\n};\n/** @typedef {typeof mapTooltipMethods} MapTooltipMethods */\n\n/**\n * Methods of `Layer` for tooltips. All layers share a set of methods convenient for\n * binding tooltips to it.\n *\n * ```js\n * const layer = new Polygon(latlngs).bindTooltip('Hi There!').addTo(map);\n * layer.openTooltip();\n * layer.closeTooltip();\n * ```\n *\n * @lends Layer.prototype\n * @fires Layer#tooltipopen {TooltipEvent} Fired when a tooltip bound to this layer is\n * opened.\n * @fires Layer#tooltipclose {TooltipEvent} Fired when a tooltip bound to this layer is\n * closed.\n */\nconst layerTooltipMethods = {\n\t/**\n\t * Binds a tooltip to the layer with the passed `content` and sets up the\n\t * necessary event listeners. A `String` argument is rendered as HTML; if it\n\t * may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an\n\t * `HTMLElement` with safe `textContent` instead. If a `Function` is passed\n\t * it will receive the layer as the first argument and should return a\n\t * `String` or `HTMLElement`.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent|Tooltip} content\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\tbindTooltip(content, options) {\n\t\t// an open tooltip is replaced, a closed one reused\n\t\tconst old = this.isTooltipOpen() ? null : this._tooltip;\n\n\t\t// the handlers depend on the old options, so they go before the new ones are applied\n\t\tif (this._tooltip) {\n\t\t\tthis.unbindTooltip();\n\t\t}\n\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._tooltip = this._initOverlay(Tooltip, old, content, options);\n\t\tthis._initTooltipInteractions();\n\n\t\tif (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) {\n\t\t\tthis.openTooltip();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the tooltip previously bound with `bindTooltip`.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tunbindTooltip() {\n\t\tif (this._tooltip) {\n\t\t\tthis._initTooltipInteractions(true);\n\t\t\tthis.closeTooltip();\n\t\t\tthis._tooltip = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t_initTooltipInteractions(remove) {\n\t\tconst {permanent, sticky} = this._tooltip.options,\n\t\tevents = {\n\t\t\tremove: this.closeTooltip,\n\t\t\tmove: this._moveTooltip\n\t\t};\n\t\tif (permanent) {\n\t\t\tevents.add = this._openTooltip;\n\t\t} else {\n\t\t\tevents.pointerover = this._openTooltip;\n\t\t\tevents.pointerout = this.closeTooltip;\n\t\t\tevents.click = this._openTooltip;\n\t\t\t// layer elements can be recreated on every add\n\t\t\tevents.add = this._toggleFocusListeners;\n\t\t\tif (this._map) {\n\t\t\t\tthis._toggleFocusListeners(!remove);\n\t\t\t}\n\t\t}\n\t\tif (sticky) {\n\t\t\tevents.pointermove = this._moveTooltip;\n\t\t}\n\t\tthis[remove ? 'off' : 'on'](events);\n\t},\n\n\t/**\n\t * Opens the bound tooltip at the specified `latlng` or at the default tooltip\n\t * anchor if no `latlng` is passed.\n\t * @group Tooltip methods\n\t * @param {LatLngExpression} [latlng]\n\t * @returns {this}\n\t */\n\topenTooltip(latlng) {\n\t\tif (this._tooltip) {\n\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\tthis._tooltip._source = this;\n\t\t\t}\n\t\t\tif (this._tooltip._prepareOpen(latlng)) {\n\t\t\t\t// open the tooltip on the map\n\t\t\t\tthis._tooltip.openOn(this._map);\n\n\t\t\t\tif (this.getElement) {\n\t\t\t\t\tthis._setAriaDescribedByOnLayer(this);\n\t\t\t\t} else if (this.eachLayer) {\n\t\t\t\t\tthis.eachLayer(this._setAriaDescribedByOnLayer, this);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip bound to this layer if it is open.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tcloseTooltip() {\n\t\tthis._tooltip?.close();\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens or closes the tooltip bound to this layer depending on its current state.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\ttoggleTooltip() {\n\t\tthis._tooltip?.toggle(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the tooltip bound to this layer is currently open.\n\t * @group Tooltip methods\n\t * @returns {boolean}\n\t */\n\tisTooltipOpen() {\n\t\treturn this._tooltip?.isOpen() ?? false;\n\t},\n\n\t/**\n\t * Sets the content of the tooltip bound to this layer. String content is rendered\n\t * as HTML; sanitize untrusted input or pass an `HTMLElement` with safe\n\t * `textContent` instead.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent} content\n\t * @returns {this}\n\t */\n\tsetTooltipContent(content) {\n\t\tthis._tooltip?.setContent(content);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns the tooltip bound to this layer.\n\t * @group Tooltip methods\n\t * @returns {Tooltip|undefined}\n\t */\n\tgetTooltip() {\n\t\treturn this._tooltip;\n\t},\n\n\t// also the `add` listener, so any truthy argument adds\n\t_toggleFocusListeners(add) {\n\t\tif (this.getElement) {\n\t\t\tthis._addFocusListenersOnLayer(this, !add);\n\t\t} else if (this.eachLayer) {\n\t\t\tthis.eachLayer(layer => this._addFocusListenersOnLayer(layer, !add), this);\n\t\t}\n\t},\n\n\t_addFocusListenersOnLayer(layer, remove) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tif (el) {\n\t\t\tconst toggle = remove ? DomEvent.off : DomEvent.on;\n\t\t\tif (!remove) {\n\t\t\t\t// Remove focus listener, if already existing\n\t\t\t\tel._maplair_focus_handler && DomEvent.off(el, 'focus', el._maplair_focus_handler, this);\n\n\t\t\t\tel._maplair_focus_handler = () => {\n\t\t\t\t\tif (this._tooltip) {\n\t\t\t\t\t\tthis._tooltip._source = layer;\n\t\t\t\t\t\tthis.openTooltip();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tel._maplair_focus_handler && toggle(el, 'focus', el._maplair_focus_handler, this);\n\t\t\ttoggle(el, 'blur', this.closeTooltip, this);\n\n\t\t\tif (remove) {\n\t\t\t\tdelete el._maplair_focus_handler;\n\t\t\t}\n\t\t}\n\t},\n\n\t_setAriaDescribedByOnLayer(layer) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tel?.setAttribute?.('aria-describedby', this._tooltip._container.id);\n\t},\n\n\t_openTooltip(e) {\n\t\tif (!this._tooltip || !this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the map is moving, we will show the tooltip after it's done.\n\t\tif (this._map.dragging?.moving()) {\n\t\t\tif (e.type === 'add' && !this._moveEndOpensTooltip) {\n\t\t\t\tthis._moveEndOpensTooltip = true;\n\t\t\t\tthis._map.once('moveend', () => {\n\t\t\t\t\tthis._moveEndOpensTooltip = false;\n\t\t\t\t\tthis._openTooltip(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis._tooltip._source = e.propagatedFrom ?? e.target;\n\n\t\tthis.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);\n\t},\n\n\t_moveTooltip(e) {\n\t\tlet latlng = e.latlng, containerPoint, layerPoint;\n\t\tif (this._tooltip.options.sticky && e.originalEvent) {\n\t\t\tcontainerPoint = this._map.pointerEventToContainerPoint(e.originalEvent);\n\t\t\tlayerPoint = this._map.containerPointToLayerPoint(containerPoint);\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\t\t}\n\t\tthis._tooltip.setLatLng(latlng);\n\t}\n};\n/** @typedef {typeof layerTooltipMethods} LayerTooltipMethods */\n\n/**\n * Used to display small texts on top of map layers.\n *\n * @example\n * If you want to just bind a tooltip to marker:\n *\n * ```js\n * marker.bindTooltip(\"my tooltip text\").openTooltip();\n * ```\n * Path overlays like polylines also have a `bindTooltip` method.\n *\n * A tooltip can be also standalone:\n *\n * ```js\n * const tooltip = new Tooltip()\n * \t.setLatLng(latlng)\n * \t.setContent('Hello world!<br />This is a nice tooltip.')\n * \t.addTo(map);\n * ```\n * or\n * ```js\n * const tooltip = new Tooltip(latlng, {content: 'Hello world!<br />This is a nice tooltip.'})\n * \t.addTo(map);\n * ```\n *\n * **Security note.** Tooltip string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindTooltip(el);\n * ```\n *\n * Note about tooltip offset. Maplair takes two options in consideration\n * for computing tooltip offsetting:\n * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip.\n * Add a positive x offset to move the tooltip to the right, and a positive y offset to\n * move it to the bottom. Negatives will move to the left and top.\n * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You\n * should adapt this value if you use a custom icon.\n */\nexport class Tooltip extends DivOverlay {\n\n\tstatic defaultOptions = {\n\t\tpane: 'tooltipPane',\n\t\toffset: [0, 0],\n\t\tdirection: 'auto',\n\t\tpermanent: false,\n\t\tsticky: false,\n\t\topacity: 0.9\n\t};\n\n\t/**\n\t * Instantiates a `Tooltip` object given an optional `options` object that describes\n\t * its appearance and location and an optional `source` object that is used to tag\n\t * the tooltip with a reference to the Layer to which it refers.\n\t * @overload\n\t * @param {TooltipOptions} [options]\n\t * @param {Layer} [source]\n\t */\n\t/**\n\t * Instantiates a `Tooltip` object given `latlng` where the tooltip will open and an\n\t * optional `options` object that describes its appearance and location.\n\t * @overload\n\t * @param {LatLngExpression} latlng\n\t * @param {TooltipOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Tooltip);\n\t}\n\n\t/**\n\t * Adds the tooltip to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\t\tthis.setOpacity(this.options.opacity);\n\n\t\tmap.fire('tooltipopen', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.addEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipopen', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the tooltip from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tsuper.onRemove(map);\n\n\t\tmap.fire('tooltipclose', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.removeEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipclose', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the tooltip listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (!this.options.permanent) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-tooltip',\n\t\tclassName = `${prefix} ${this.options.className || ''} maplair-zoom-animated`;\n\n\t\tthis._contentNode = this._container = DomUtil.create('div', className);\n\n\t\tthis._container.setAttribute('role', 'tooltip');\n\t\tthis._container.setAttribute('id', `maplair-tooltip-${Util.stamp(this)}`);\n\t}\n\n\t_updateLayout() {}\n\n\t_adjustPan() {}\n\n\t/**\n\t * Updates the tooltip content, layout and position.\n\t * @returns {void}\n\t */\n\tupdate() {\n\t\t// The automatic direction is chosen once per opening and content, so that\n\t\t// the tooltip does not flip sides while the map or the pointer moves.\n\t\tthis._autoDirection = undefined;\n\t\tsuper.update();\n\t}\n\n\t_setPosition(pos) {\n\t\tlet direction = this.options.direction,\n\t\tshift = new Point(0, 0);\n\t\tconst container = this._container,\n\t\ttooltipWidth = container.offsetWidth,\n\t\ttooltipHeight = container.offsetHeight,\n\t\toffset = new Point(this.options.offset),\n\t\tanchor = this._getAnchor();\n\n\t\tif (!directions.includes(direction)) {\n\t\t\t({direction, shift} = this._getAutoPlacement(pos, offset, anchor, tooltipWidth, tooltipHeight));\n\t\t\tif (direction === 'left') {\n\t\t\t\t// mirror the offset and anchor, which are meant for the right side\n\t\t\t\toffset.x = -offset.x;\n\t\t\t\tanchor.x = -anchor.x;\n\t\t\t}\n\t\t}\n\n\t\tlet subX = tooltipWidth / 2,\n\t\tsubY = tooltipHeight / 2;\n\t\tif (direction === 'top') {\n\t\t\tsubY = tooltipHeight;\n\t\t} else if (direction === 'bottom') {\n\t\t\tsubY = 0;\n\t\t} else if (direction === 'right') {\n\t\t\tsubX = 0;\n\t\t} else if (direction === 'left') {\n\t\t\tsubX = tooltipWidth;\n\t\t}\n\n\t\tpos = pos.subtract(new Point(subX, subY, true)).add(offset).add(anchor).add(shift);\n\n\t\tcontainer.classList.remove(\n\t\t\t'maplair-tooltip-right',\n\t\t\t'maplair-tooltip-left',\n\t\t\t'maplair-tooltip-top',\n\t\t\t'maplair-tooltip-bottom'\n\t\t);\n\t\tcontainer.classList.add(`maplair-tooltip-${direction}`);\n\n\t\t// Let the tip point at the source despite the shift\n\t\tconst tipShift = direction === 'top' || direction === 'bottom' ?\n\t\t\tclampTip(-shift.x, tooltipWidth) :\n\t\t\tclampTip(-shift.y, tooltipHeight);\n\t\tif (tipShift) {\n\t\t\tcontainer.style.setProperty('--maplair-tooltip-tip-shift', `${tipShift}px`);\n\t\t} else {\n\t\t\tcontainer.style.removeProperty('--maplair-tooltip-tip-shift');\n\t\t}\n\n\t\tthis._setContainerPosition(pos);\n\t}\n\n\t// Chooses the direction of an `auto` tooltip by the available space:\n\t// preferably the side towards the center, otherwise the opposite side,\n\t// above or below. The tooltip is shifted along that side to stay in view.\n\t_getAutoPlacement(pos, offset, anchor, width, height) {\n\t\tconst area = this._getAutoArea(),\n\t\tpoint = this._map.layerPointToContainerPoint(pos),\n\t\tx = point.x + offset.x + anchor.x,\n\t\ty = point.y + offset.y + anchor.y,\n\t\t// the space for each direction, see `direction` for the mirrored left side\n\t\tspace = {\n\t\t\tright: area.max.x - x - width - tipSize,\n\t\t\tleft: point.x - offset.x - anchor.x - area.min.x - width - tipSize,\n\t\t\ttop: y - area.min.y - height - tipSize,\n\t\t\tbottom: area.max.y - y - height - tipSize\n\t\t};\n\n\t\tif (!this._autoDirection) {\n\t\t\tconst sides = point.x < (area.min.x + area.max.x) / 2 ? ['right', 'left'] : ['left', 'right'],\n\t\t\tfallback = space.right >= space.left ? 'right' : 'left';\n\t\t\tthis._autoDirection = [...sides, 'top', 'bottom'].find(d => space[d] >= 0 &&\n\t\t\t\t// above or below, the tooltip has to fit horizontally\n\t\t\t\t(d === 'right' || d === 'left' || width <= area.max.x - area.min.x)) ?? fallback;\n\t\t}\n\n\t\tconst direction = this._autoDirection,\n\t\tshift = direction === 'top' || direction === 'bottom' ?\n\t\t\tnew Point(shiftInto(x - width / 2, width, area.min.x, area.max.x), 0) :\n\t\t\tnew Point(0, shiftInto(y - height / 2, height, area.min.y, area.max.y));\n\n\t\treturn {direction, shift};\n\t}\n\n\t// The area in container points an `auto` tooltip should stay within:\n\t// the map, or the viewport for an overflowing tooltip.\n\t_getAutoArea() {\n\t\tconst map = this._map;\n\t\tlet min = new Point(0, 0),\n\t\tmax = map.getSize();\n\t\tif (this.options.overflow) {\n\t\t\tconst mapContainer = map._container,\n\t\t\trect = mapContainer.getBoundingClientRect(),\n\t\t\torigin = new Point(rect.left + mapContainer.clientLeft, rect.top + mapContainer.clientTop),\n\t\t\tviewport = document.documentElement;\n\t\t\tmin = min.subtract(origin);\n\t\t\tmax = new Point(viewport.clientWidth, viewport.clientHeight).subtract(origin);\n\t\t}\n\t\tconst padding = new Point(autoPadding, autoPadding);\n\t\treturn {min: min.add(padding), max: max.subtract(padding)};\n\t}\n\n\t_updatePosition() {\n\t\tconst pos = this._map.latLngToLayerPoint(this._latlng)._round();\n\t\tthis._setPosition(pos);\n\t}\n\n\t/**\n\t * Sets the opacity of the tooltip.\n\t * @param {number} opacity\n\t * @returns {void}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\n\t\tif (this._container) {\n\t\t\tthis._container.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);\n\t\tthis._setPosition(pos);\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the tooltip on the source layer?\n\t\treturn new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.include(mapTooltipMethods);\n\n\t\tLayer.include(layerTooltipMethods);\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,aAAa;CAAC;CAAO;CAAU;CAAU;CAAS;AAAM;AAI9D,MAAM,UAAU;AAChB,MAAA,cAAc;AAGd,SAAS,UAAU,OAAO,MAAM,KAAK,KAAK;CACzC,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK,IAAI,KAAK,IAAI,GAAG,QAAQ,OAAO,GAAG;AACjE;AAGA,SAAS,SAAS,UAAU,MAAM;CACjC,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO,IAAI,EAAW;CAC9C,OAAO,KAAK,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC;AAC1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,oBAAoB;;;;;;;;;;;;;;CAczB,YAAY,SAAS,QAAQ,SAAS;EAErC,KAAK,aAAa,SAAS,SAAS,QAAQ,OAAO,CAAC,CAClD,OAAO,IAAI;EAEb,OAAO;CACR;;;;;;;CAQA,aAA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B,WAAW,QAAQ,iBAAiB;EAEpC,MAAM,QAAQ,mBAAmB;CAClC;AACD"}
|
|
@@ -2,7 +2,7 @@ import { splitWords } from "../core/Util.js";
|
|
|
2
2
|
import { on, stopPropagation } from "../dom/DomEvent.js";
|
|
3
3
|
import { create } from "../dom/DomUtil.js";
|
|
4
4
|
import { ImageOverlay } from "./ImageOverlay.js";
|
|
5
|
-
|
|
5
|
+
// src/layer/VideoOverlay.js
|
|
6
6
|
/** @import {ImageOverlayOptions} from './ImageOverlay.js' */
|
|
7
7
|
/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
|
|
8
8
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
@@ -42,16 +42,14 @@ import { ImageOverlay } from "./ImageOverlay.js";
|
|
|
42
42
|
* @fires load {MaplairEvent} Fired when the video has finished loading the first frame.
|
|
43
43
|
*/
|
|
44
44
|
var VideoOverlay = class VideoOverlay extends ImageOverlay {
|
|
45
|
-
static {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
}
|
|
45
|
+
static defaultOptions = {
|
|
46
|
+
autoplay: true,
|
|
47
|
+
controls: false,
|
|
48
|
+
loop: true,
|
|
49
|
+
keepAspectRatio: true,
|
|
50
|
+
muted: false,
|
|
51
|
+
playsInline: true
|
|
52
|
+
};
|
|
55
53
|
/**
|
|
56
54
|
* Instantiates a video overlay object given the URL of the video (or array of
|
|
57
55
|
* URLs, or even a video element) and the geographical bounds it is tied to.
|
|
@@ -68,10 +66,9 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
|
|
|
68
66
|
this.callInitHooks(VideoOverlay);
|
|
69
67
|
}
|
|
70
68
|
_initImage() {
|
|
71
|
-
const wasElementSupplied = this._url
|
|
69
|
+
const wasElementSupplied = this._url instanceof HTMLVideoElement;
|
|
72
70
|
const vid = this._image = wasElementSupplied ? this._url : create("video");
|
|
73
|
-
vid.classList.add("maplair-image-layer");
|
|
74
|
-
if (this._zoomAnimated) vid.classList.add("maplair-zoom-animated");
|
|
71
|
+
vid.classList.add("maplair-image-layer", "maplair-zoom-animated");
|
|
75
72
|
if (this.options.className) vid.classList.add(...splitWords(this.options.className));
|
|
76
73
|
on(vid, "pointerdown", (e) => {
|
|
77
74
|
if (vid.controls) stopPropagation(e);
|
|
@@ -79,12 +76,12 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
|
|
|
79
76
|
vid.onloadeddata = this.fire.bind(this, "load");
|
|
80
77
|
if (wasElementSupplied) {
|
|
81
78
|
const sourceElements = vid.getElementsByTagName("source");
|
|
82
|
-
const sources =
|
|
79
|
+
const sources = Array.from(sourceElements, (e) => e.src);
|
|
83
80
|
this._url = sourceElements.length > 0 ? sources : [vid.src];
|
|
84
81
|
return;
|
|
85
82
|
}
|
|
86
83
|
if (!Array.isArray(this._url)) this._url = [this._url];
|
|
87
|
-
if (!this.options.keepAspectRatio
|
|
84
|
+
if (!this.options.keepAspectRatio) vid.style["objectFit"] = "fill";
|
|
88
85
|
vid.autoplay = !!this.options.autoplay;
|
|
89
86
|
vid.controls = !!this.options.controls;
|
|
90
87
|
vid.loop = !!this.options.loop;
|
|
@@ -97,7 +94,6 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
|
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
96
|
};
|
|
100
|
-
//#endregion
|
|
101
97
|
export { VideoOverlay };
|
|
102
98
|
|
|
103
99
|
//# sourceMappingURL=VideoOverlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoOverlay.js","names":["DomUtil.create","Util.splitWords"],"sources":["../../../src/layer/VideoOverlay.js"],"sourcesContent":["import {ImageOverlay} from './ImageOverlay.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\n\n/** @import {ImageOverlayOptions} from './ImageOverlay.js' */\n/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\n/**\n * Options of `VideoOverlay`.\n * @typedef {object} VideoOverlayOptions\n * @property {boolean} [autoplay=true] Whether the video starts playing automatically\n * when loaded. On some browsers autoplay will only work with `muted: true`.\n * @property {boolean} [controls=false] Whether the browser will offer controls to\n * allow the user to control video playback, including volume, seeking, and\n * pause/resume playback.\n * @property {boolean} [loop=true] Whether the video will loop back to the beginning\n * when played.\n * @property {boolean} [keepAspectRatio=true] Whether the video will save aspect ratio\n * after the projection.\n * @property {boolean} [muted=false] Whether the video starts on mute when loaded.\n * @property {boolean} [playsInline=true] Mobile browsers will play the video right\n * where it is instead of open it up in fullscreen mode.\n * @extends ImageOverlayOptions\n */\n\n/**\n * Used to load and display a video player over specific bounds of the map. Extends\n * `ImageOverlay`.\n *\n * A video overlay uses the [`<video>`](https://developer.mozilla.org/docs/Web/HTML/Element/video)\n * HTML element; `getElement()` returns the instance of\n * [`HTMLVideoElement`](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement)\n * used by this overlay.\n *\n * @example\n * ```js\n * const videoUrl = 'https://www.mapbox.com/bites/00188/patricia_nasa.webm',\n * \tvideoBounds = [[ 32, -130], [ 13, -100]];\n * new VideoOverlay(videoUrl, videoBounds ).addTo(map);\n * ```\n *\n * @fires load {MaplairEvent} Fired when the video has finished loading the first frame.\n */\nexport class VideoOverlay extends ImageOverlay {\n\n\tstatic {\n\t\
|
|
1
|
+
{"version":3,"file":"VideoOverlay.js","names":["DomUtil.create","Util.splitWords"],"sources":["../../../src/layer/VideoOverlay.js"],"sourcesContent":["import {ImageOverlay} from './ImageOverlay.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\n\n/** @import {ImageOverlayOptions} from './ImageOverlay.js' */\n/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\n/**\n * Options of `VideoOverlay`.\n * @typedef {object} VideoOverlayOptions\n * @property {boolean} [autoplay=true] Whether the video starts playing automatically\n * when loaded. On some browsers autoplay will only work with `muted: true`.\n * @property {boolean} [controls=false] Whether the browser will offer controls to\n * allow the user to control video playback, including volume, seeking, and\n * pause/resume playback.\n * @property {boolean} [loop=true] Whether the video will loop back to the beginning\n * when played.\n * @property {boolean} [keepAspectRatio=true] Whether the video will save aspect ratio\n * after the projection.\n * @property {boolean} [muted=false] Whether the video starts on mute when loaded.\n * @property {boolean} [playsInline=true] Mobile browsers will play the video right\n * where it is instead of open it up in fullscreen mode.\n * @extends ImageOverlayOptions\n */\n\n/**\n * Used to load and display a video player over specific bounds of the map. Extends\n * `ImageOverlay`.\n *\n * A video overlay uses the [`<video>`](https://developer.mozilla.org/docs/Web/HTML/Element/video)\n * HTML element; `getElement()` returns the instance of\n * [`HTMLVideoElement`](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement)\n * used by this overlay.\n *\n * @example\n * ```js\n * const videoUrl = 'https://www.mapbox.com/bites/00188/patricia_nasa.webm',\n * \tvideoBounds = [[ 32, -130], [ 13, -100]];\n * new VideoOverlay(videoUrl, videoBounds ).addTo(map);\n * ```\n *\n * @fires load {MaplairEvent} Fired when the video has finished loading the first frame.\n */\nexport class VideoOverlay extends ImageOverlay {\n\n\tstatic defaultOptions = {\n\t\tautoplay: true,\n\t\tcontrols: false,\n\t\tloop: true,\n\t\tkeepAspectRatio: true,\n\t\tmuted: false,\n\t\tplaysInline: true\n\t};\n\n\t/**\n\t * Instantiates a video overlay object given the URL of the video (or array of\n\t * URLs, or even a video element) and the geographical bounds it is tied to.\n\t * @overload\n\t * @param {string|string[]|HTMLVideoElement} video\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {VideoOverlayOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(VideoOverlay);\n\t}\n\n\t_initImage() {\n\t\tconst wasElementSupplied = this._url instanceof HTMLVideoElement;\n\t\tconst vid = this._image = wasElementSupplied ? this._url : DomUtil.create('video');\n\n\t\tvid.classList.add('maplair-image-layer', 'maplair-zoom-animated');\n\t\tif (this.options.className) { vid.classList.add(...Util.splitWords(this.options.className)); }\n\n\t\tDomEvent.on(vid, 'pointerdown', (e) => {\n\t\t\tif (vid.controls) {\n\t\t\t\t// Prevent the map from moving when the video or the seekbar is moved\n\t\t\t\tDomEvent.stopPropagation(e);\n\t\t\t}\n\t\t});\n\n\t\tvid.onloadeddata = this.fire.bind(this, 'load');\n\n\t\tif (wasElementSupplied) {\n\t\t\tconst sourceElements = vid.getElementsByTagName('source');\n\t\t\tconst sources = Array.from(sourceElements, e => e.src);\n\t\t\tthis._url = (sourceElements.length > 0) ? sources : [vid.src];\n\t\t\treturn;\n\t\t}\n\n\t\tif (!Array.isArray(this._url)) { this._url = [this._url]; }\n\n\t\tif (!this.options.keepAspectRatio) {\n\t\t\tvid.style['objectFit'] = 'fill';\n\t\t}\n\t\tvid.autoplay = !!this.options.autoplay;\n\t\tvid.controls = !!this.options.controls;\n\t\tvid.loop = !!this.options.loop;\n\t\tvid.muted = !!this.options.muted;\n\t\tvid.playsInline = !!this.options.playsInline;\n\t\tfor (const url of this._url) {\n\t\t\tconst source = DomUtil.create('source');\n\t\t\tsource.src = url;\n\t\t\tvid.appendChild(source);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,eAAb,MAAa,qBAAqB,aAAa;CAE9C,OAAO,iBAAiB;EACvB,UAAU;EACV,UAAU;EACV,MAAM;EACN,iBAAiB;EACjB,OAAO;EACP,aAAa;CACd;;;;;;;;;;;;CAaA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,YAAY;CAChC;CAEA,aAAa;EACZ,MAAM,qBAAqB,KAAK,gBAAgB;EAChD,MAAM,MAAM,KAAK,SAAS,qBAAqB,KAAK,OAAOA,OAAe,OAAO;EAEjF,IAAI,UAAU,IAAI,uBAAuB,uBAAuB;EAChE,IAAI,KAAK,QAAQ,WAAa,IAAI,UAAU,IAAI,GAAGC,WAAgB,KAAK,QAAQ,SAAS,CAAC;EAE1F,GAAY,KAAK,gBAAgB,MAAM;GACtC,IAAI,IAAI,UAEP,gBAAyB,CAAC;EAE5B,CAAC;EAED,IAAI,eAAe,KAAK,KAAK,KAAK,MAAM,MAAM;EAE9C,IAAI,oBAAoB;GACvB,MAAM,iBAAiB,IAAI,qBAAqB,QAAQ;GACxD,MAAM,UAAU,MAAM,KAAK,iBAAgB,MAAK,EAAE,GAAG;GACrD,KAAK,OAAQ,eAAe,SAAS,IAAK,UAAU,CAAC,IAAI,GAAG;GAC5D;EACD;EAEA,IAAI,CAAC,MAAM,QAAQ,KAAK,IAAI,GAAK,KAAK,OAAO,CAAC,KAAK,IAAI;EAEvD,IAAI,CAAC,KAAK,QAAQ,iBACjB,IAAI,MAAM,eAAe;EAE1B,IAAI,WAAW,CAAC,CAAC,KAAK,QAAQ;EAC9B,IAAI,WAAW,CAAC,CAAC,KAAK,QAAQ;EAC9B,IAAI,OAAO,CAAC,CAAC,KAAK,QAAQ;EAC1B,IAAI,QAAQ,CAAC,CAAC,KAAK,QAAQ;EAC3B,IAAI,cAAc,CAAC,CAAC,KAAK,QAAQ;EACjC,KAAK,MAAM,OAAO,KAAK,MAAM;GAC5B,MAAM,SAASD,OAAe,QAAQ;GACtC,OAAO,MAAM;GACb,IAAI,YAAY,MAAM;EACvB;CACD;AACD"}
|
|
@@ -1,50 +1,53 @@
|
|
|
1
|
-
import { create } from "../../dom/DomUtil.js";
|
|
2
1
|
import { Icon } from "./Icon.js";
|
|
3
|
-
|
|
2
|
+
// src/layer/marker/DefaultIcon.js
|
|
4
3
|
/** @import {IconOptions} from './Icon.js' */
|
|
5
4
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} fill
|
|
7
|
+
* @param {string} fillTop
|
|
8
|
+
* @param {number} fillTopOpacity
|
|
9
|
+
* @param {string} stroke
|
|
10
|
+
* @param {string} strokeTop
|
|
11
|
+
* @param {string} [outline]
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
const marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = "") => `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="${fill}"/><stop offset="1" stop-color="${fillTop}" stop-opacity="${fillTopOpacity}"/></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="${stroke}"/><stop offset="1" stop-color="${strokeTop}"/></linearGradient></defs><g fill="%23FFF"><path id="p" 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)"/></g><use href="%23p" fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10"/>${outline}<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>`;
|
|
8
15
|
/**
|
|
9
16
|
* Options of `DefaultIcon`.
|
|
10
17
|
* @typedef {object} DefaultIconOptions
|
|
11
|
-
* @property {string} [iconUrl
|
|
12
|
-
* @property {string} [
|
|
13
|
-
*
|
|
18
|
+
* @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
|
|
19
|
+
* @property {string|null} [color=null] Paints the pin in the given CSS color instead of
|
|
20
|
+
* the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.
|
|
21
|
+
* @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
|
|
14
22
|
* @property {PointExpression|number} [iconSize=[25, 41]]
|
|
15
23
|
* @property {PointExpression} [iconAnchor=[12, 41]]
|
|
16
24
|
* @property {PointExpression} [popupAnchor=[1, -34]]
|
|
17
25
|
* @property {PointExpression} [tooltipAnchor=[16, -28]]
|
|
18
26
|
* @property {PointExpression|number} [shadowSize=[41, 41]]
|
|
19
|
-
* @property {string} [imagePath] `DefaultIcon` will try to auto-detect the location of
|
|
20
|
-
* the blue icon images. If you are placing these images in a non-standard way, set this
|
|
21
|
-
* option to point to the right path.
|
|
22
27
|
* @extends IconOptions
|
|
23
28
|
*/
|
|
24
29
|
/**
|
|
25
|
-
* A
|
|
26
|
-
*
|
|
27
|
-
*
|
|
30
|
+
* A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is
|
|
31
|
+
* specified, optionally in another `color`. The maple leaf marker and its shadow are
|
|
32
|
+
* inlined as SVG data URIs, so they work with any bundler and need no image files.
|
|
28
33
|
*
|
|
29
34
|
* In order to customize the default icon, just change the properties of
|
|
30
|
-
* `DefaultIcon.
|
|
35
|
+
* `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
|
|
31
36
|
*
|
|
32
37
|
* If you want to _completely_ replace the default icon, override the
|
|
33
|
-
* `Marker.
|
|
38
|
+
* `Marker.defaultOptions.icon` with your own icon instead.
|
|
34
39
|
*/
|
|
35
40
|
var DefaultIcon = class DefaultIcon extends Icon {
|
|
36
|
-
static {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
}
|
|
41
|
+
static defaultOptions = {
|
|
42
|
+
iconUrl: /* @__PURE__ */ marker("%23C2331B", "%23E2603F", 1, "%238F2D20", "%23B23A27"),
|
|
43
|
+
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>",
|
|
44
|
+
iconSize: [25, 41],
|
|
45
|
+
iconAnchor: [12, 41],
|
|
46
|
+
popupAnchor: [1, -34],
|
|
47
|
+
tooltipAnchor: [16, -28],
|
|
48
|
+
shadowSize: [41, 41],
|
|
49
|
+
color: null
|
|
50
|
+
};
|
|
48
51
|
/**
|
|
49
52
|
* Creates the default icon, optionally with changed options.
|
|
50
53
|
* @param {[options?: DefaultIconOptions]} args The options.
|
|
@@ -53,31 +56,17 @@ var DefaultIcon = class DefaultIcon extends Icon {
|
|
|
53
56
|
super(...args);
|
|
54
57
|
this.callInitHooks(DefaultIcon);
|
|
55
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* @param {'icon'|'shadow'} name
|
|
61
|
+
* @returns {string|undefined}
|
|
62
|
+
*/
|
|
56
63
|
_getIconUrl(name) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
}
|
|
62
|
-
_stripUrl(path) {
|
|
63
|
-
const strip = function(str, re, idx) {
|
|
64
|
-
const match = re.exec(str);
|
|
65
|
-
return match && match[idx];
|
|
66
|
-
};
|
|
67
|
-
path = strip(path, URL_RE, 2);
|
|
68
|
-
return path && strip(path, MARKER_ICON_RE, 1);
|
|
69
|
-
}
|
|
70
|
-
_detectIconPath() {
|
|
71
|
-
const el = create("div", "maplair-default-icon-path", document.body);
|
|
72
|
-
const path = this._stripUrl(getComputedStyle(el).backgroundImage);
|
|
73
|
-
document.body.removeChild(el);
|
|
74
|
-
if (path) return path;
|
|
75
|
-
const link = document.querySelector("link[href$=\"maplair.css\"]");
|
|
76
|
-
if (!link) return "";
|
|
77
|
-
return link.href.substring(0, link.href.length - 11 - 1);
|
|
64
|
+
const { color } = this.options;
|
|
65
|
+
if (!color || name !== "icon") return super._getIconUrl(name);
|
|
66
|
+
const c = encodeURIComponent(color);
|
|
67
|
+
return marker(c, c, .75, c, c, "<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>");
|
|
78
68
|
}
|
|
79
69
|
};
|
|
80
|
-
//#endregion
|
|
81
70
|
export { DefaultIcon };
|
|
82
71
|
|
|
83
72
|
//# sourceMappingURL=DefaultIcon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultIcon.js","names":[
|
|
1
|
+
{"version":3,"file":"DefaultIcon.js","names":[],"sources":["../../../../src/layer/marker/DefaultIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n// The maple leaf marker. The pin is drawn white under its fill, which fades to it at the top with a `fillTopOpacity`\n// below 1, so that a single color gets a highlight like the default one; the outline keeps light colors visible,\n// but would double the antialiased edges of the default pin.\n/**\n * @param {string} fill\n * @param {string} fillTop\n * @param {number} fillTopOpacity\n * @param {string} stroke\n * @param {string} strokeTop\n * @param {string} [outline]\n * @returns {string}\n */\nconst marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = '') => `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=\"${fill}\"/><stop offset=\"1\" stop-color=\"${fillTop}\" stop-opacity=\"${fillTopOpacity}\"/></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=\"${stroke}\"/><stop offset=\"1\" stop-color=\"${strokeTop}\"/></linearGradient></defs><g fill=\"%23FFF\"><path id=\"p\" 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)\"/></g><use href=\"%23p\" fill=\"url(%23a)\" stroke=\"url(%23b)\" stroke-width=\"1.1\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\"/>${outline}<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>`;\n\n/**\n * Options of `DefaultIcon`.\n * @typedef {object} DefaultIconOptions\n * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.\n * @property {string|null} [color=null] Paints the pin in the given CSS color instead of\n * the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.\n * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.\n * @property {PointExpression|number} [iconSize=[25, 41]]\n * @property {PointExpression} [iconAnchor=[12, 41]]\n * @property {PointExpression} [popupAnchor=[1, -34]]\n * @property {PointExpression} [tooltipAnchor=[16, -28]]\n * @property {PointExpression|number} [shadowSize=[41, 41]]\n * @extends IconOptions\n */\n\n/**\n * A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is\n * specified, optionally in another `color`. The maple leaf marker and its shadow are\n * inlined as SVG data URIs, so they work with any bundler and need no image files.\n *\n * In order to customize the default icon, just change the properties of\n * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).\n *\n * If you want to _completely_ replace the default icon, override the\n * `Marker.defaultOptions.icon` with your own icon instead.\n */\nexport class DefaultIcon extends Icon {\n\n\tstatic defaultOptions = {\n\t\ticonUrl: /* @__PURE__ */ marker('%23C2331B', '%23E2603F', 1, '%238F2D20', '%23B23A27'),\n\t\tshadowUrl: '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>',\n\t\ticonSize: [25, 41],\n\t\ticonAnchor: [12, 41],\n\t\tpopupAnchor: [1, -34],\n\t\ttooltipAnchor: [16, -28],\n\t\tshadowSize: [41, 41],\n\t\tcolor: null\n\t};\n\n\t/**\n\t * Creates the default icon, optionally with changed options.\n\t * @param {[options?: DefaultIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(DefaultIcon);\n\t}\n\n\t/**\n\t * @param {'icon'|'shadow'} name\n\t * @returns {string|undefined}\n\t */\n\t_getIconUrl(name) {\n\t\tconst {color} = this.options;\n\t\tif (!color || name !== 'icon') { return super._getIconUrl(name); }\n\t\tconst c = encodeURIComponent(color);\n\t\treturn marker(c, c, 0.75, c, c, '<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,UAAU,MAAM,SAAS,gBAAgB,QAAQ,WAAW,UAAU,OAAO,2VAA2V,KAAK,kCAAkC,QAAQ,kBAAkB,eAAe,iMAAiM,OAAO,kCAAkC,UAAU,oxBAAoxB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B9gD,IAAa,cAAb,MAAa,oBAAoB,KAAK;CAErC,OAAO,iBAAiB;EACvB,SAAyB,uBAAO,aAAa,aAAa,GAAG,aAAa,WAAW;EACrF,WAAW;EACX,UAAU,CAAC,IAAI,EAAE;EACjB,YAAY,CAAC,IAAI,EAAE;EACnB,aAAa,CAAC,GAAG,GAAG;EACpB,eAAe,CAAC,IAAI,GAAG;EACvB,YAAY,CAAC,IAAI,EAAE;EACnB,OAAO;CACR;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,WAAW;CAC/B;;;;;CAMA,YAAY,MAAM;EACjB,MAAM,EAAC,UAAS,KAAK;EACrB,IAAI,CAAC,SAAS,SAAS,QAAU,OAAO,MAAM,YAAY,IAAI;EAC9D,MAAM,IAAI,mBAAmB,KAAK;EAClC,OAAO,OAAO,GAAG,GAAG,KAAM,GAAG,GAAG,4EAAoE;CACrG;AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Point } from "../../geometry/Point.js";
|
|
2
2
|
import { Icon } from "./Icon.js";
|
|
3
|
-
|
|
3
|
+
// src/layer/marker/DivIcon.js
|
|
4
4
|
/** @import {IconOptions} from './Icon.js' */
|
|
5
5
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
6
6
|
/**
|
|
@@ -32,14 +32,12 @@ import { Icon } from "./Icon.js";
|
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
34
|
var DivIcon = class DivIcon extends Icon {
|
|
35
|
-
static {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
}
|
|
35
|
+
static defaultOptions = {
|
|
36
|
+
iconSize: [12, 12],
|
|
37
|
+
html: false,
|
|
38
|
+
bgPos: null,
|
|
39
|
+
className: "maplair-div-icon"
|
|
40
|
+
};
|
|
43
41
|
/**
|
|
44
42
|
* Creates a `DivIcon` instance with the given options.
|
|
45
43
|
* @param {[options?: DivIconOptions]} args The options.
|
|
@@ -55,7 +53,7 @@ var DivIcon = class DivIcon extends Icon {
|
|
|
55
53
|
* @returns {HTMLElement}
|
|
56
54
|
*/
|
|
57
55
|
createIcon(oldIcon) {
|
|
58
|
-
const div = oldIcon
|
|
56
|
+
const div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement("div"), options = this.options;
|
|
59
57
|
if (options.html instanceof Element) {
|
|
60
58
|
div.replaceChildren();
|
|
61
59
|
div.appendChild(options.html);
|
|
@@ -75,7 +73,6 @@ var DivIcon = class DivIcon extends Icon {
|
|
|
75
73
|
return null;
|
|
76
74
|
}
|
|
77
75
|
};
|
|
78
|
-
//#endregion
|
|
79
76
|
export { DivIcon };
|
|
80
77
|
|
|
81
78
|
//# sourceMappingURL=DivIcon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DivIcon.js","names":[],"sources":["../../../../src/layer/marker/DivIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `DivIcon`.\n * @typedef {object} DivIconOptions\n * @property {PointExpression|number} [iconSize=[12, 12]] Size of the icon in pixels,\n * also can be set through CSS.\n * @property {string|HTMLElement|false} [html=false] Custom HTML code to put inside the\n * div element, empty by default. Alternatively, an instance of `HTMLElement`.\n * @property {PointExpression|null} [bgPos=null] Optional relative position of the\n * background, in pixels.\n * @property {string} [className='maplair-div-icon']\n * @extends IconOptions\n */\n\n/**\n * Represents a lightweight icon for markers that uses a simple `<div>`\n * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and\n * shadow options.\n *\n * By default, it has a 'maplair-div-icon' CSS class and is styled as a little white\n * square with a shadow.\n *\n * @example\n * ```js\n * const myIcon = new DivIcon({className: 'my-div-icon'});\n * // you can set .my-div-icon styles in CSS\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class DivIcon extends Icon {\n\n\tstatic {\n\t\
|
|
1
|
+
{"version":3,"file":"DivIcon.js","names":[],"sources":["../../../../src/layer/marker/DivIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `DivIcon`.\n * @typedef {object} DivIconOptions\n * @property {PointExpression|number} [iconSize=[12, 12]] Size of the icon in pixels,\n * also can be set through CSS.\n * @property {string|HTMLElement|false} [html=false] Custom HTML code to put inside the\n * div element, empty by default. Alternatively, an instance of `HTMLElement`.\n * @property {PointExpression|null} [bgPos=null] Optional relative position of the\n * background, in pixels.\n * @property {string} [className='maplair-div-icon']\n * @extends IconOptions\n */\n\n/**\n * Represents a lightweight icon for markers that uses a simple `<div>`\n * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and\n * shadow options.\n *\n * By default, it has a 'maplair-div-icon' CSS class and is styled as a little white\n * square with a shadow.\n *\n * @example\n * ```js\n * const myIcon = new DivIcon({className: 'my-div-icon'});\n * // you can set .my-div-icon styles in CSS\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class DivIcon extends Icon {\n\n\tstatic defaultOptions = {\n\t\ticonSize: [12, 12], // also can be set through CSS\n\n\t\t// iconAnchor: (Point),\n\t\t// popupAnchor: (Point),\n\n\t\thtml: false,\n\t\tbgPos: null,\n\t\tclassName: 'maplair-div-icon'\n\t};\n\n\t/**\n\t * Creates a `DivIcon` instance with the given options.\n\t * @param {[options?: DivIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(DivIcon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<div>` element\n\t * styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\tconst div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement('div'),\n\t\toptions = this.options;\n\n\t\tif (options.html instanceof Element) {\n\t\t\tdiv.replaceChildren();\n\t\t\tdiv.appendChild(options.html);\n\t\t} else {\n\t\t\tdiv.innerHTML = options.html !== false ? options.html : '';\n\t\t}\n\n\t\tif (options.bgPos) {\n\t\t\tconst bgPos = Point.from(options.bgPos);\n\t\t\tdiv.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;\n\t\t}\n\t\tthis._setIconStyles(div, 'icon');\n\n\t\treturn div;\n\t}\n\n\t/**\n\t * Returns `null`, a `DivIcon` has no shadow.\n\t * @returns {null}\n\t */\n\tcreateShadow() {\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,UAAb,MAAa,gBAAgB,KAAK;CAEjC,OAAO,iBAAiB;EACvB,UAAU,CAAC,IAAI,EAAE;EAKjB,MAAM;EACN,OAAO;EACP,WAAW;CACZ;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;;;CAQA,WAAW,SAAS;EACnB,MAAM,MAAM,mBAAmB,iBAAiB,UAAU,SAAS,cAAc,KAAK,GACtF,UAAU,KAAK;EAEf,IAAI,QAAQ,gBAAgB,SAAS;GACpC,IAAI,gBAAgB;GACpB,IAAI,YAAY,QAAQ,IAAI;EAC7B,OACC,IAAI,YAAY,QAAQ,SAAS,QAAQ,QAAQ,OAAO;EAGzD,IAAI,QAAQ,OAAO;GAClB,MAAM,QAAQ,MAAM,KAAK,QAAQ,KAAK;GACtC,IAAI,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;EAC1D;EACA,KAAK,eAAe,KAAK,MAAM;EAE/B,OAAO;CACR;;;;;CAMA,eAAe;EACd,OAAO;CACR;AACD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { setOptions } from "../../core/Util.js";
|
|
2
2
|
import { Class } from "../../core/Class.js";
|
|
3
3
|
import { Point } from "../../geometry/Point.js";
|
|
4
|
-
|
|
5
|
-
//#region src/layer/marker/Icon.js
|
|
4
|
+
// src/layer/marker/Icon.js
|
|
6
5
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
7
6
|
/**
|
|
8
7
|
* Options of `Icon`.
|
|
@@ -60,13 +59,11 @@ import Browser_default from "../../core/Browser.js";
|
|
|
60
59
|
* ```
|
|
61
60
|
*/
|
|
62
61
|
var Icon = class Icon extends Class {
|
|
63
|
-
static {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
}
|
|
62
|
+
static defaultOptions = {
|
|
63
|
+
popupAnchor: [0, 0],
|
|
64
|
+
tooltipAnchor: [0, 0],
|
|
65
|
+
crossOrigin: false
|
|
66
|
+
};
|
|
70
67
|
/**
|
|
71
68
|
* Creates an icon instance with the given options.
|
|
72
69
|
* @param {IconOptions} [options]
|
|
@@ -99,7 +96,7 @@ var Icon = class Icon extends Class {
|
|
|
99
96
|
if (name === "icon") throw new Error("iconUrl not set in Icon options (see the docs).");
|
|
100
97
|
return null;
|
|
101
98
|
}
|
|
102
|
-
const img = this._createImg(src, oldIcon
|
|
99
|
+
const img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);
|
|
103
100
|
this._setIconStyles(img, name);
|
|
104
101
|
if (this.options.crossOrigin || this.options.crossOrigin === "") img.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
|
|
105
102
|
return img;
|
|
@@ -116,6 +113,7 @@ var Icon = class Icon extends Class {
|
|
|
116
113
|
img.style.marginLeft = `${-anchor.x}px`;
|
|
117
114
|
img.style.marginTop = `${-anchor.y}px`;
|
|
118
115
|
}
|
|
116
|
+
img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
|
|
119
117
|
if (size) {
|
|
120
118
|
img.style.width = `${size.x}px`;
|
|
121
119
|
img.style.height = `${size.y}px`;
|
|
@@ -127,10 +125,9 @@ var Icon = class Icon extends Class {
|
|
|
127
125
|
return el;
|
|
128
126
|
}
|
|
129
127
|
_getIconUrl(name) {
|
|
130
|
-
return
|
|
128
|
+
return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
|
|
131
129
|
}
|
|
132
130
|
};
|
|
133
|
-
//#endregion
|
|
134
131
|
export { Icon };
|
|
135
132
|
|
|
136
133
|
//# sourceMappingURL=Icon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","names":[
|
|
1
|
+
{"version":3,"file":"Icon.js","names":[],"sources":["../../../../src/layer/marker/Icon.js"],"sourcesContent":["import {Class} from '../../core/Class.js';\nimport {setOptions} from '../../core/Util.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `Icon`.\n * @typedef {object} IconOptions\n * @property {string} [iconUrl] **(required)** The URL to the icon image (absolute or\n * relative to your script path).\n * @property {string} [iconRetinaUrl] The URL to a retina sized version of the icon\n * image (absolute or relative to your script path). Used for Retina screen devices.\n * @property {PointExpression|number} [iconSize] Size of the icon image in pixels (a\n * number for square icons).\n * @property {PointExpression} [iconAnchor] The coordinates of the \"tip\" of the icon\n * (relative to its top left corner). The icon will be aligned so that this point is at\n * the marker's geographical location. Centered by default if size is specified, also\n * can be set in CSS with negative margins.\n * @property {PointExpression} [popupAnchor=[0, 0]] The coordinates of the point from\n * which popups will \"open\", relative to the icon anchor.\n * @property {PointExpression} [tooltipAnchor=[0, 0]] The coordinates of the point from\n * which tooltips will \"open\", relative to the icon anchor.\n * @property {string} [shadowUrl] The URL to the icon shadow image. If not specified, no\n * shadow image will be created.\n * @property {string} [shadowRetinaUrl] The URL to a retina sized version of the shadow\n * image. Used for Retina screen devices.\n * @property {PointExpression|number} [shadowSize] Size of the shadow image in pixels.\n * @property {PointExpression} [shadowAnchor] The coordinates of the \"tip\" of the shadow\n * (relative to its top left corner) (the same as iconAnchor if not specified).\n * @property {string} [className] A custom class name to assign to both icon and shadow\n * images. Empty by default.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the icon images. If a String is provided, all images will have their\n * crossOrigin attribute set to the String provided. This is needed if you want to\n * access image pixel data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n */\n\n/**\n * Represents an icon to provide when creating a marker.\n *\n * `DefaultIcon` extends `Icon` and is the blue icon Maplair uses for markers by default.\n *\n * @example\n * ```js\n * const myIcon = new Icon({\n * iconUrl: 'my-icon.png',\n * iconRetinaUrl: 'my-icon@2x.png',\n * iconSize: [38, 95],\n * iconAnchor: [22, 94],\n * popupAnchor: [-3, -76],\n * shadowUrl: 'my-icon-shadow.png',\n * shadowRetinaUrl: 'my-icon-shadow@2x.png',\n * shadowSize: [68, 95],\n * shadowAnchor: [22, 94]\n * });\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class Icon extends Class {\n\n\tstatic defaultOptions = {\n\t\tpopupAnchor: [0, 0],\n\t\ttooltipAnchor: [0, 0],\n\t\tcrossOrigin: false\n\t};\n\n\t/**\n\t * Creates an icon instance with the given options.\n\t * @param {IconOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tsetOptions(this, options);\n\n\t\tthis.callInitHooks(Icon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<img>` HTML element\n\t * styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\treturn this._createIcon('icon', oldIcon);\n\t}\n\n\t/**\n\t * As `createIcon`, but for the shadow beneath it. Returns `null` without a shadow.\n\t * @param {HTMLElement} [oldIcon] The current element of the shadow, to be reused if possible.\n\t * @returns {HTMLElement|null}\n\t */\n\tcreateShadow(oldIcon) {\n\t\treturn this._createIcon('shadow', oldIcon);\n\t}\n\n\t_createIcon(name, oldIcon) {\n\t\tconst src = this._getIconUrl(name);\n\n\t\tif (!src) {\n\t\t\tif (name === 'icon') {\n\t\t\t\tthrow new Error('iconUrl not set in Icon options (see the docs).');\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tconst img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);\n\t\tthis._setIconStyles(img, name);\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\timg.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\treturn img;\n\t}\n\n\t_setIconStyles(img, name) {\n\t\tconst options = this.options;\n\t\tlet sizeOption = options[`${name}Size`];\n\n\t\tif (typeof sizeOption === 'number') {\n\t\t\tsizeOption = [sizeOption, sizeOption];\n\t\t}\n\n\t\tconst size = Point.validate(sizeOption) && Point.from(sizeOption);\n\n\t\tconst anchorPosition = name === 'shadow' && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true);\n\t\tconst anchor = Point.validate(anchorPosition) && Point.from(anchorPosition);\n\n\t\timg.className = `maplair-marker-${name} ${options.className || ''}`;\n\n\t\tif (anchor) {\n\t\t\timg.style.marginLeft = `${-anchor.x}px`;\n\t\t\timg.style.marginTop = `${-anchor.y}px`;\n\t\t}\n\t\t// the origin of the marker rotation: the anchor, which is the top left corner without one\n\t\timg.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : '0 0';\n\n\t\tif (size) {\n\t\t\timg.style.width = `${size.x}px`;\n\t\t\timg.style.height = `${size.y}px`;\n\t\t}\n\t}\n\n\t_createImg(src, el) {\n\t\tel ??= document.createElement('img');\n\t\tel.src = src;\n\t\treturn el;\n\t}\n\n\t_getIconUrl(name) {\n\t\treturn window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAa,OAAb,MAAa,aAAa,MAAM;CAE/B,OAAO,iBAAiB;EACvB,aAAa,CAAC,GAAG,CAAC;EAClB,eAAe,CAAC,GAAG,CAAC;EACpB,aAAa;CACd;;;;;CAMA,YAAY,SAAS;EAC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