maplair 4.1.0 → 4.3.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 +77 -0
- package/dist/esm/Maplair.js +5 -4
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +1 -2
- package/dist/esm/control/ButtonControl.js +1 -2
- package/dist/esm/control/ContextMenu.js +1 -2
- package/dist/esm/control/Control.js +1 -2
- package/dist/esm/control/FullscreenControl.js +1 -2
- package/dist/esm/control/LayersControl.js +27 -31
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +1 -2
- package/dist/esm/control/MiniMapControl.js +1 -2
- package/dist/esm/control/RotateControl.js +1 -2
- package/dist/esm/control/ScaleControl.js +1 -2
- package/dist/esm/control/SearchControl.js +1 -2
- package/dist/esm/control/SideBySideControl.js +1 -2
- package/dist/esm/control/TextControl.js +1 -2
- package/dist/esm/control/TimeControl.js +1 -2
- package/dist/esm/control/ZoomControl.js +18 -29
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +2 -9
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +2 -2
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +10 -3
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +2 -3
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
- package/dist/esm/dom/DomEvent.js +10 -18
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +1 -2
- package/dist/esm/dom/Draggable.js +4 -3
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +1 -2
- package/dist/esm/geo/LatLng.js +1 -2
- 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 +4 -5
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +4 -5
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +3 -4
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +1 -2
- package/dist/esm/geo/crs/SimpleCRS.js +3 -4
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
- 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 +2 -3
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +17 -25
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +1 -2
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +2 -3
- 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 +8 -10
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +1 -2
- package/dist/esm/layer/HeatLayer.js +2 -3
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +2 -3
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -2
- package/dist/esm/layer/LayerGroup.js +2 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +9 -16
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +1 -2
- package/dist/esm/layer/Tooltip.js +16 -17
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +1 -2
- package/dist/esm/layer/marker/DefaultIcon.js +29 -7
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +1 -2
- package/dist/esm/layer/marker/Icon.js +2 -2
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +43 -4
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +4 -6
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +54 -14
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
- package/dist/esm/layer/marker/SvgIcon.js +1 -2
- package/dist/esm/layer/tile/GridLayer.js +4 -4
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +8 -8
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +7 -14
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +5 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +2 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +1 -2
- package/dist/esm/layer/vector/Polygon.js +2 -3
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
- package/dist/esm/layer/vector/Polyline.js +2 -3
- 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 +4 -5
- 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 +7 -4
- 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 +31 -16
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +10 -17
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +1 -2
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +1 -2
- package/dist/esm/map/handler/KeyboardHandler.js +23 -43
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +1 -2
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +489 -613
- 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 +485 -609
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1263
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +4 -8
- package/src/Maplair.all.js +0 -1
- package/src/control/LayersControl.js +39 -52
- package/src/control/ZoomControl.js +17 -31
- package/src/core/Class.js +5 -14
- package/src/core/Events.js +2 -0
- package/src/core/Handler.js +11 -1
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.js +9 -19
- package/src/dom/Draggable.js +5 -1
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +3 -3
- package/src/geo/crs/EPSG3857.js +3 -3
- package/src/geo/crs/EPSG4326.js +2 -2
- package/src/geo/crs/SimpleCRS.js +2 -2
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +1 -1
- package/src/geometry/PolyUtil.js +23 -31
- package/src/layer/DivOverlay.js +1 -1
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +10 -13
- package/src/layer/HeatLayer.js +1 -1
- package/src/layer/ImageOverlay.js +2 -2
- package/src/layer/LayerGroup.js +1 -1
- package/src/layer/Popup.js +9 -19
- package/src/layer/Tooltip.js +19 -17
- package/src/layer/marker/DefaultIcon.js +33 -5
- package/src/layer/marker/Icon.js +2 -0
- package/src/layer/marker/Marker.Drag.js +53 -5
- package/src/layer/marker/Marker.Move.js +3 -4
- package/src/layer/marker/Marker.js +64 -13
- package/src/layer/tile/GridLayer.js +5 -2
- package/src/layer/tile/TileLayer.js +9 -6
- package/src/layer/tile/WMSTileLayer.js +5 -2
- package/src/layer/vector/Canvas.js +10 -14
- package/src/layer/vector/Circle.js +7 -1
- package/src/layer/vector/CircleMarker.js +2 -1
- package/src/layer/vector/Polygon.js +1 -1
- package/src/layer/vector/Polyline.js +1 -1
- package/src/layer/vector/Renderer.getRenderer.js +4 -3
- package/src/layer/vector/SVG.js +12 -2
- package/src/map/Map.Rotation.js +28 -4
- package/src/map/Map.js +17 -21
- package/src/map/handler/BoxZoomHandler.js +21 -42
- package/src/map/handler/KeyboardHandler.js +34 -53
- package/src/maplair.css +5 -0
- 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/src/layer/marker/Marker.Rotation.js +0 -103
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popup.js","names":["DomEvent.stopPropagation","DomUtil.create"],"sources":["../../../src/layer/Popup.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport {Path} from './vector/Path.js';\nimport {FeatureGroup} from './FeatureGroup.js';\nimport {I18n} from '../core/I18n.js';\n\n/** @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, MaplairEvent, PopupEvent} from '../core/Events.js' */\n\n/**\n * Options of `Popup`.\n * @typedef {object} PopupOptions\n * @property {string} [pane='popupPane'] `Map pane` where the popup will be added.\n * @property {PointExpression} [offset=[0, 7]] The offset of the popup position.\n * @property {number} [maxWidth=300] Max width of the popup, in pixels.\n * @property {number} [minWidth=50] Min width of the popup, in pixels.\n * @property {number|null} [maxHeight=null] If set, creates a scrollable container of\n * the given height inside a popup if its content exceeds it. The scrollable container\n * can be styled using the `maplair-popup-scrolled` CSS class selector.\n * @property {boolean} [autoPan=true] Set it to `false` if you don't want the map to do\n * panning animation to fit the opened popup.\n * @property {PointExpression|null} [autoPanPaddingTopLeft=null] The margin between the\n * popup and the top left corner of the map view after autopanning was performed.\n * @property {PointExpression|null} [autoPanPaddingBottomRight=null] The margin between\n * the popup and the bottom right corner of the map view after autopanning was\n * performed.\n * @property {PointExpression} [autoPanPadding=[5, 5]] Equivalent of setting both top\n * left and bottom right autopan padding to the same value.\n * @property {boolean} [keepInView=false] Set it to `true` if you want to prevent users\n * from panning the popup off of the screen while it is open.\n * @property {boolean} [closeButton=true] Controls the presence of a close button in\n * the popup.\n * @property {boolean} [autoClose=true] Set it to `false` if you want to override the\n * default behavior of the popup closing when another popup is opened.\n * @property {boolean} [closeOnEscapeKey=true] Set it to `false` if you want to\n * override the default behavior of the ESC key for closing of the popup.\n * @property {boolean} [closeOnClick] Set it if you want to override the default\n * behavior of the popup closing when user clicks on the map. Defaults to the map's\n * [`closePopupOnClick`](#map-closepopuponclick) option.\n * @property {string} [className=''] A custom CSS class name to assign to the popup.\n * @property {boolean} [trackResize=true] Whether the popup shall react to changes in\n * the size of its contents (e.g. when an image inside the popup loads) and reposition\n * itself.\n * @extends DivOverlayOptions\n */\n\n/**\n * Map options of `Popup`.\n * @typedef {object} PopupMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [closePopupOnClick=true] Set it to `false` if you don't want\n * popups to close when user clicks the map.\n */\n\n/**\n * Methods of `MaplairMap` for popups.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#popupopen {PopupEvent} Fired when a popup is opened in the map.\n * @fires MaplairMap#popupclose {PopupEvent} Fired when a popup in the map is closed.\n * @fires MaplairMap#autopanstart {MaplairEvent} Fired when the map starts autopanning\n * when opening a popup.\n */\nconst mapPopupMethods = {\n\t/**\n\t * Opens the specified popup while closing the previously opened (to make sure only\n\t * one is opened at one time for usability).\n\t *\n\t * Alternatively, creates a popup with the specified content and options and opens\n\t * it in the given point on a map. String content is rendered as HTML; sanitize\n\t * untrusted input or pass an `HTMLElement` with safe `textContent` instead.\n\t * @group Methods for layers and controls\n\t * @param {Popup|DivOverlayContent} popup The popup, or the content of a new popup.\n\t * @param {LatLngExpression} [latlng]\n\t * @param {PopupOptions} [options]\n\t * @returns {this}\n\t */\n\topenPopup(popup, latlng, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._initOverlay(Popup, popup, latlng, options)\n\t\t\t.openOn(this);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the popup previously opened with [openPopup](#map-openpopup) (or the\n\t * given one).\n\t * @group Methods for layers and controls\n\t * @param {Popup} [popup]\n\t * @returns {this}\n\t */\n\tclosePopup(popup) {\n\t\tpopup = arguments.length ? popup : this._popup;\n\t\tpopup?.close();\n\t\treturn this;\n\t}\n};\n/** @typedef {typeof mapPopupMethods} MapPopupMethods */\n\n/**\n * Methods of `Layer` for popups. All layers share a set of methods convenient for\n * binding popups to it.\n *\n * ```js\n * const layer = new Polygon(latlngs).bindPopup('Hi There!').addTo(map);\n * layer.openPopup();\n * layer.closePopup();\n * ```\n *\n * Popups will also be automatically opened when the layer is clicked on and closed\n * when the layer is removed from the map or another popup is opened.\n *\n * @lends Layer.prototype\n * @fires Layer#popupopen {PopupEvent} Fired when a popup bound to this layer is opened.\n * @fires Layer#popupclose {PopupEvent} Fired when a popup bound to this layer is closed.\n */\nconst layerPopupMethods = {\n\t/**\n\t * Binds a popup 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 Popup methods\n\t * @param {DivOverlayContent|Popup} content\n\t * @param {PopupOptions} [options]\n\t * @returns {this}\n\t */\n\tbindPopup(content, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._popup = this._initOverlay(Popup, this._popup, content, options);\n\t\tthis.on({\n\t\t\tclick: this._openPopup,\n\t\t\tremove: this.closePopup,\n\t\t\tmove: this._movePopup\n\t\t});\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the popup previously bound with `bindPopup`.\n\t * @group Popup methods\n\t * @returns {this}\n\t */\n\tunbindPopup() {\n\t\tif (this._popup) {\n\t\t\tthis.off({\n\t\t\t\tclick: this._openPopup,\n\t\t\t\tremove: this.closePopup,\n\t\t\t\tmove: this._movePopup\n\t\t\t});\n\t\t\tthis._popup = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens the bound popup at the specified `latlng` or at the default popup anchor\n\t * if no `latlng` is passed.\n\t * @group Popup methods\n\t * @param {LatLngExpression} [latlng]\n\t * @returns {this}\n\t */\n\topenPopup(latlng) {\n\t\tif (this._popup) {\n\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\tthis._popup._source = this;\n\t\t\t}\n\t\t\tif (this._popup._prepareOpen(latlng || this._latlng)) {\n\t\t\t\t// open the popup on the map\n\t\t\t\tthis._popup.openOn(this._map);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the popup bound to this layer if it is open.\n\t * @group Popup methods\n\t * @returns {this}\n\t */\n\tclosePopup() {\n\t\tthis._popup?.close();\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens or closes the popup bound to this layer depending on its current state.\n\t * @group Popup methods\n\t * @returns {this}\n\t */\n\ttogglePopup() {\n\t\tthis._popup?.toggle(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the popup bound to this layer is currently open.\n\t * @group Popup methods\n\t * @returns {boolean}\n\t */\n\tisPopupOpen() {\n\t\treturn this._popup?.isOpen() ?? false;\n\t},\n\n\t/**\n\t * Sets the content of the popup 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 Popup methods\n\t * @param {DivOverlayContent} content\n\t * @returns {this}\n\t */\n\tsetPopupContent(content) {\n\t\tthis._popup?.setContent(content);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns the popup bound to this layer.\n\t * @group Popup methods\n\t * @returns {Popup|undefined}\n\t */\n\tgetPopup() {\n\t\treturn this._popup;\n\t},\n\n\t_openPopup(e) {\n\t\tif (!this._popup || !this._map) {\n\t\t\treturn;\n\t\t}\n\t\t// prevent map click\n\t\tDomEvent.stop(e);\n\n\t\tconst target = e.propagatedFrom ?? e.target;\n\t\tif (this._popup._source === target && !(target instanceof Path)) {\n\t\t\t// treat it like a marker and figure out\n\t\t\t// if we should toggle it open/closed\n\t\t\tif (this._map.hasLayer(this._popup)) {\n\t\t\t\tthis.closePopup();\n\t\t\t} else {\n\t\t\t\tthis.openPopup(e.latlng);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis._popup._source = target;\n\t\tthis.openPopup(e.latlng);\n\t},\n\n\t_movePopup(e) {\n\t\tthis._popup.setLatLng(e.latlng);\n\t}\n};\n/** @typedef {typeof layerPopupMethods} LayerPopupMethods */\n\n/**\n * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to\n * open popups while making sure that only one popup is open at one time\n * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want.\n *\n * @example\n * If you want to just bind a popup to marker click and then open it, it's really easy:\n *\n * ```js\n * marker.bindPopup(popupContent).openPopup();\n * ```\n * Path overlays like polylines also have a `bindPopup` method.\n *\n * A popup can be also standalone:\n *\n * ```js\n * const popup = new Popup()\n * \t.setLatLng(latlng)\n * \t.setContent('<p>Hello world!<br />This is a nice popup.</p>')\n * \t.openOn(map);\n * ```\n * or\n * ```js\n * const popup = new Popup(latlng, {content: '<p>Hello world!<br />This is a nice popup.</p>'})\n * \t.openOn(map);\n * ```\n *\n * **Security note.** Popup string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindPopup(el);\n * ```\n */\nexport class Popup extends DivOverlay {\n\n\tstatic defaultOptions = {\n\t\tpane: 'popupPane',\n\t\toffset: [0, 7],\n\t\tmaxWidth: 300,\n\t\tminWidth: 50,\n\t\tmaxHeight: null,\n\t\tautoPan: true,\n\t\tautoPanPaddingTopLeft: null,\n\t\tautoPanPaddingBottomRight: null,\n\t\tautoPanPadding: [5, 5],\n\t\tkeepInView: false,\n\t\tcloseButton: true,\n\t\tautoClose: true,\n\t\tcloseOnEscapeKey: true,\n\t\tclassName: '',\n\t\ttrackResize: true,\n\t};\n\n\t/**\n\t * Instantiates a `Popup` 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 popup with a reference to the Layer to which it refers.\n\t * @overload\n\t * @param {PopupOptions} [options]\n\t * @param {Layer} [source]\n\t */\n\t/**\n\t * Instantiates a `Popup` object given `latlng` where the popup 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 {PopupOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Popup);\n\t}\n\n\t/**\n\t * Alternative to `map.openPopup(popup)`.\n\t * Adds the popup to the map and closes the previous one.\n\t * @param {MaplairMap} map\n\t * @returns {this}\n\t */\n\topenOn(map) {\n\t\tmap = arguments.length ? map : this._source._map; // experimental, not the part of public api\n\n\t\tif (!map.hasLayer(this) && map._popup && map._popup.options.autoClose) {\n\t\t\tmap.removeLayer(map._popup);\n\t\t}\n\t\tmap._popup = this;\n\n\t\treturn super.openOn(map);\n\t}\n\n\t/**\n\t * Adds the popup to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\t// The element to return the focus to when closing the popup, e.g. a marker\n\t\tconst active = document.activeElement;\n\t\tthis._returnFocus = map._container.contains(active) && !this._container?.contains(active) ? active : null;\n\n\t\tsuper.onAdd(map);\n\n\t\tif (this._source?._clickedByKeyboard) {\n\t\t\t// Move the focus into the popup, so that its content is read and reachable\n\t\t\tif (!this._closeButton) {\n\t\t\t\tthis._container.tabIndex = -1;\n\t\t\t}\n\t\t\t(this._closeButton ?? this._container).focus({preventScroll: true});\n\t\t}\n\n\t\tmap.fire('popupopen', {popup: this});\n\n\t\tif (this._source) {\n\t\t\tthis._source.fire('popupopen', {popup: this}, true);\n\t\t\t// For non-path layers, we toggle the popup when clicking\n\t\t\t// again the layer, so prevent the map to reopen it.\n\t\t\tif (!(this._source instanceof Path)) {\n\t\t\t\tthis._source.on('preclick', DomEvent.stopPropagation);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes the popup from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this._container.contains(document.activeElement) && this._returnFocus?.isConnected) {\n\t\t\tthis._returnFocus.focus({preventScroll: true});\n\t\t}\n\t\tthis._returnFocus = null;\n\n\t\tsuper.onRemove(map);\n\n\t\tmap.fire('popupclose', {popup: this});\n\n\t\tif (this._source) {\n\t\t\tthis._source.fire('popupclose', {popup: this}, true);\n\t\t\tif (!(this._source instanceof Path)) {\n\t\t\t\tthis._source.off('preclick', DomEvent.stopPropagation);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the popup listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (this.options.closeOnClick ?? this._map.options.closePopupOnClick) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\tif (this.options.keepInView) {\n\t\t\tevents.moveend = this._adjustPan;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-popup',\n\t\tcontainer = this._container = DomUtil.create('div', `${prefix} ${this.options.className || ''} maplair-zoom-animated`);\n\n\t\tconst wrapper = this._wrapper = DomUtil.create('div', `${prefix}-content-wrapper`, container);\n\t\tthis._contentNode = DomUtil.create('div', `${prefix}-content`, wrapper);\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\t// The keyboard handler of the map does not get keys while the focus is in the popup\n\t\tDomEvent.on(container, 'keydown', (e) => {\n\t\t\tif (e.key === 'Escape' && this.options.closeOnEscapeKey) {\n\t\t\t\tthis.close();\n\t\t\t}\n\t\t});\n\t\tDomEvent.disableScrollPropagation(this._contentNode);\n\t\tDomEvent.on(container, 'contextmenu', DomEvent.stopPropagation);\n\n\t\tthis._tipContainer = DomUtil.create('div', `${prefix}-tip-container`, container);\n\t\tthis._tip = DomUtil.create('div', `${prefix}-tip`, this._tipContainer);\n\n\t\tif (this.options.closeButton) {\n\t\t\tconst closeButton = this._closeButton = DomUtil.create('button', `${prefix}-close-button`, container);\n\t\t\tcloseButton.type = 'button';\n\t\t\tcloseButton.setAttribute('aria-label', I18n.translate('Close popup'));\n\n\t\t\tcloseButton.innerHTML = '<span aria-hidden=\"true\">×</span>';\n\n\t\t\tDomEvent.on(closeButton, 'click', (ev) => {\n\t\t\t\tev.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.trackResize) {\n\t\t\tthis._resizeObserver = new ResizeObserver(((entries) => {\n\t\t\t\tif (!this._map) { return; }\n\t\t\t\tthis._containerWidth = entries[0]?.contentRect?.width;\n\t\t\t\tthis._containerHeight = entries[0]?.contentRect?.height;\n\n\t\t\t\tthis._updateLayout();\n\t\t\t\tthis._updatePosition();\n\t\t\t\tthis._adjustPan();\n\t\t\t}));\n\n\t\t\tthis._resizeObserver.observe(this._contentNode);\n\t\t}\n\t}\n\n\t_updateLayout() {\n\t\tconst container = this._contentNode,\n\t\tstyle = container.style;\n\n\t\tstyle.maxWidth = `${this.options.maxWidth}px`;\n\t\tstyle.minWidth = `${this.options.minWidth}px`;\n\n\t\tconst maxHeight = this.options.maxHeight,\n\t\tscrolledClass = 'maplair-popup-scrolled';\n\n\t\t// only measure the height (forcing a layout) if needed\n\t\tif (maxHeight && (this._containerHeight ?? container.offsetHeight) > maxHeight) {\n\t\t\tstyle.height = `${maxHeight}px`;\n\t\t\tcontainer.classList.add(scrolledClass);\n\t\t} else {\n\t\t\tcontainer.classList.remove(scrolledClass);\n\t\t}\n\n\t\tthis._containerWidth = this._container.offsetWidth;\n\t\tthis._containerHeight = this._container.offsetHeight;\n\t\t// read along with the size, so that _adjustPan doesn't force another style\n\t\t// recalculation and layout after the popup has been positioned\n\t\tthis._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),\n\t\tanchor = this._getAnchor();\n\t\tthis._setContainerPosition(pos.add(anchor));\n\t}\n\n\t_adjustPan() {\n\t\tif (!this.options.autoPan) { return; }\n\t\tthis._map._panAnim?.stop();\n\n\t\t// Stopping the pan fires `moveend`, whose listeners may have removed this popup.\n\t\tif (!this._map) { return; }\n\n\t\t// We can endlessly recurse if keepInView is set and the view resets.\n\t\t// Let's guard against that by exiting early if we're responding to our own autopan.\n\t\tif (this._autopanning) {\n\t\t\tthis._autopanning = false;\n\t\t\treturn;\n\t\t}\n\n\t\tconst map = this._map,\n\t\tmarginBottom = this._containerMarginBottom ?? (parseInt(getComputedStyle(this._container).marginBottom, 10) || 0),\n\t\tcontainerHeight = this._containerHeight + marginBottom,\n\t\tcontainerWidth = this._containerWidth,\n\t\tlayerPos = new Point(this._containerLeft, -containerHeight - this._containerBottom);\n\n\t\tlayerPos._add(this._getContainerPosition());\n\n\t\tconst containerPos = map.layerPointToContainerPoint(layerPos),\n\t\tpadding = Point.from(this.options.autoPanPadding),\n\t\tpaddingTL = Point.from(this.options.autoPanPaddingTopLeft ?? padding),\n\t\tpaddingBR = Point.from(this.options.autoPanPaddingBottomRight ?? padding),\n\t\tsize = map.getSize();\n\t\tlet dx = 0,\n\t\tdy = 0;\n\n\t\tif (containerPos.x + containerWidth + paddingBR.x > size.x) { // right\n\t\t\tdx = containerPos.x + containerWidth - size.x + paddingBR.x;\n\t\t}\n\t\tif (containerPos.x - dx - paddingTL.x < 0) { // left\n\t\t\tdx = containerPos.x - paddingTL.x;\n\t\t}\n\t\tif (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom\n\t\t\tdy = containerPos.y + containerHeight - size.y + paddingBR.y;\n\t\t}\n\t\tif (containerPos.y - dy - paddingTL.y < 0) { // top\n\t\t\tdy = containerPos.y - paddingTL.y;\n\t\t}\n\n\t\tif (dx || dy) {\n\t\t\t// Track that we're autopanning, as this function will be re-ran on moveend\n\t\t\tif (this.options.keepInView) {\n\t\t\t\tthis._autopanning = true;\n\t\t\t}\n\n\t\t\tmap\n\t\t\t\t.fire('autopanstart')\n\t\t\t\t.panBy([dx, dy]);\n\t\t}\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the popup on the source layer?\n\t\treturn new Point(this._source?._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);\n\t}\n\n\t/**\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.mergeOptions({\n\t\t\tclosePopupOnClick: true\n\t\t});\n\n\t\tMaplairMap.include(mapPopupMethods);\n\n\t\tLayer.include(layerPopupMethods);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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B,KAAK,IAAI,UAAU;EAE5D,IAAI,aAAa,IAAI,KAAK,UAAU,IAAI,GACvC,KAAK,aAAa,IAAI,UAAU;EAGjC,IAAI,MAAM,IAAI;GAEb,IAAI,KAAK,QAAQ,YAChB,KAAK,eAAe;GAGrB,IACE,KAAK,cAAc,CAAC,CACpB,MAAM,CAAC,IAAI,EAAE,CAAC;EACjB;CACD;CAEA,aAAa;EAEZ,OAAO,IAAI,MAAM,KAAK,SAAS,kBAAkB,KAAK,QAAQ,gBAAgB,IAAI,CAAC,GAAG,CAAC,CAAC;CACzF;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,mBAAmB,KACpB,CAAC;EAED,WAAW,QAAQ,eAAe;EAElC,MAAM,QAAQ,iBAAiB;CAChC;AACD"}
|
|
1
|
+
{"version":3,"file":"Popup.js","names":["DomEvent.stopPropagation","DomUtil.create"],"sources":["../../../src/layer/Popup.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport {Path} from './vector/Path.js';\nimport {FeatureGroup} from './FeatureGroup.js';\nimport {I18n} from '../core/I18n.js';\n\n/** @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, MaplairEvent, PopupEvent} from '../core/Events.js' */\n\n/**\n * Options of `Popup`.\n * @typedef {object} PopupOptions\n * @property {string} [pane='popupPane'] `Map pane` where the popup will be added.\n * @property {PointExpression} [offset=[0, 7]] The offset of the popup position.\n * @property {number} [maxWidth=300] Max width of the popup, in pixels.\n * @property {number} [minWidth=50] Min width of the popup, in pixels.\n * @property {number|null} [maxHeight=null] If set, creates a scrollable container of\n * the given height inside a popup if its content exceeds it. The scrollable container\n * can be styled using the `maplair-popup-scrolled` CSS class selector.\n * @property {boolean} [autoPan=true] Set it to `false` if you don't want the map to do\n * panning animation to fit the opened popup.\n * @property {PointExpression|null} [autoPanPaddingTopLeft=null] The margin between the\n * popup and the top left corner of the map view after autopanning was performed.\n * @property {PointExpression|null} [autoPanPaddingBottomRight=null] The margin between\n * the popup and the bottom right corner of the map view after autopanning was\n * performed.\n * @property {PointExpression} [autoPanPadding=[5, 5]] Equivalent of setting both top\n * left and bottom right autopan padding to the same value.\n * @property {boolean} [keepInView=false] Set it to `true` if you want to prevent users\n * from panning the popup off of the screen while it is open.\n * @property {boolean} [closeButton=true] Controls the presence of a close button in\n * the popup.\n * @property {boolean} [autoClose=true] Set it to `false` if you want to override the\n * default behavior of the popup closing when another popup is opened.\n * @property {boolean} [closeOnEscapeKey=true] Set it to `false` if you want to\n * override the default behavior of the ESC key for closing of the popup.\n * @property {boolean} [closeOnClick] Set it if you want to override the default\n * behavior of the popup closing when user clicks on the map. Defaults to the map's\n * [`closePopupOnClick`](#map-closepopuponclick) option.\n * @property {string} [className=''] A custom CSS class name to assign to the popup.\n * @property {boolean} [trackResize=true] Whether the popup shall react to changes in\n * the size of its contents (e.g. when an image inside the popup loads) and reposition\n * itself.\n * @extends DivOverlayOptions\n */\n\n/**\n * Map options of `Popup`.\n * @typedef {object} PopupMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [closePopupOnClick=true] Set it to `false` if you don't want\n * popups to close when user clicks the map.\n */\n\n/**\n * Methods of `MaplairMap` for popups.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#popupopen {PopupEvent} Fired when a popup is opened in the map.\n * @fires MaplairMap#popupclose {PopupEvent} Fired when a popup in the map is closed.\n * @fires MaplairMap#autopanstart {MaplairEvent} Fired when the map starts autopanning\n * when opening a popup.\n */\nconst mapPopupMethods = {\n\t/**\n\t * Opens the specified popup while closing the previously opened (to make sure only\n\t * one is opened at one time for usability).\n\t *\n\t * Alternatively, creates a popup with the specified content and options and opens\n\t * it in the given point on a map. String content is rendered as HTML; sanitize\n\t * untrusted input or pass an `HTMLElement` with safe `textContent` instead.\n\t * @group Methods for layers and controls\n\t * @param {Popup|DivOverlayContent} popup The popup, or the content of a new popup.\n\t * @param {LatLngExpression} [latlng]\n\t * @param {PopupOptions} [options]\n\t * @returns {this}\n\t */\n\topenPopup(popup, latlng, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._initOverlay(Popup, popup, latlng, options)\n\t\t\t.openOn(this);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the popup previously opened with [openPopup](#map-openpopup) (or the\n\t * given one).\n\t * @group Methods for layers and controls\n\t * @param {Popup} [popup]\n\t * @returns {this}\n\t */\n\tclosePopup(popup) {\n\t\tpopup = arguments.length ? popup : this._popup;\n\t\tpopup?.close();\n\t\treturn this;\n\t}\n};\n/** @typedef {typeof mapPopupMethods} MapPopupMethods */\n\n/**\n * Methods of `Layer` for popups. All layers share a set of methods convenient for\n * binding popups to it.\n *\n * ```js\n * const layer = new Polygon(latlngs).bindPopup('Hi There!').addTo(map);\n * layer.openPopup();\n * layer.closePopup();\n * ```\n *\n * Popups will also be automatically opened when the layer is clicked on and closed\n * when the layer is removed from the map or another popup is opened.\n *\n * @lends Layer.prototype\n * @fires Layer#popupopen {PopupEvent} Fired when a popup bound to this layer is opened.\n * @fires Layer#popupclose {PopupEvent} Fired when a popup bound to this layer is closed.\n */\nconst layerPopupMethods = {\n\t/**\n\t * Binds a popup 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 Popup methods\n\t * @param {DivOverlayContent|Popup} content\n\t * @param {PopupOptions} [options]\n\t * @returns {this}\n\t */\n\tbindPopup(content, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._popup = this._initOverlay(Popup, this._popup, content, options);\n\t\tthis.on({\n\t\t\tclick: this._openPopup,\n\t\t\tremove: this.closePopup,\n\t\t\tmove: this._movePopup\n\t\t});\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the popup previously bound with `bindPopup`.\n\t * @group Popup methods\n\t * @returns {this}\n\t */\n\tunbindPopup() {\n\t\tif (this._popup) {\n\t\t\tthis.off({\n\t\t\t\tclick: this._openPopup,\n\t\t\t\tremove: this.closePopup,\n\t\t\t\tmove: this._movePopup\n\t\t\t});\n\t\t\tthis._popup = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens the bound popup at the specified `latlng` or at the default popup anchor\n\t * if no `latlng` is passed.\n\t * @group Popup methods\n\t * @param {LatLngExpression} [latlng]\n\t * @returns {this}\n\t */\n\topenPopup(latlng) {\n\t\tif (this._popup) {\n\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\tthis._popup._source = this;\n\t\t\t}\n\t\t\tif (this._popup._prepareOpen(latlng || this._latlng)) {\n\t\t\t\t// open the popup on the map\n\t\t\t\tthis._popup.openOn(this._map);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the popup bound to this layer if it is open.\n\t * @group Popup methods\n\t * @returns {this}\n\t */\n\tclosePopup() {\n\t\tthis._popup?.close();\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens or closes the popup bound to this layer depending on its current state.\n\t * @group Popup methods\n\t * @returns {this}\n\t */\n\ttogglePopup() {\n\t\tthis._popup?.toggle(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the popup bound to this layer is currently open.\n\t * @group Popup methods\n\t * @returns {boolean}\n\t */\n\tisPopupOpen() {\n\t\treturn this._popup?.isOpen() ?? false;\n\t},\n\n\t/**\n\t * Sets the content of the popup 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 Popup methods\n\t * @param {DivOverlayContent} content\n\t * @returns {this}\n\t */\n\tsetPopupContent(content) {\n\t\tthis._popup?.setContent(content);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns the popup bound to this layer.\n\t * @group Popup methods\n\t * @returns {Popup|undefined}\n\t */\n\tgetPopup() {\n\t\treturn this._popup;\n\t},\n\n\t_openPopup(e) {\n\t\tif (!this._popup || !this._map) {\n\t\t\treturn;\n\t\t}\n\t\t// prevent map click\n\t\tDomEvent.stopPropagation(e);\n\n\t\tconst target = e.propagatedFrom ?? e.target;\n\t\tif (this._popup._source === target && !(target instanceof Path)) {\n\t\t\t// treat it like a marker and figure out\n\t\t\t// if we should toggle it open/closed\n\t\t\tif (this._map.hasLayer(this._popup)) {\n\t\t\t\tthis.closePopup();\n\t\t\t} else {\n\t\t\t\tthis.openPopup(e.latlng);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis._popup._source = target;\n\t\tthis.openPopup(e.latlng);\n\t},\n\n\t_movePopup(e) {\n\t\tthis._popup.setLatLng(e.latlng);\n\t}\n};\n/** @typedef {typeof layerPopupMethods} LayerPopupMethods */\n\n/**\n * Used to open popups in certain places of the map. Use [Map.openPopup](#map-openpopup) to\n * open popups while making sure that only one popup is open at one time\n * (recommended for usability), or use [Map.addLayer](#map-addlayer) to open as many as you want.\n *\n * @example\n * If you want to just bind a popup to marker click and then open it, it's really easy:\n *\n * ```js\n * marker.bindPopup(popupContent).openPopup();\n * ```\n * Path overlays like polylines also have a `bindPopup` method.\n *\n * A popup can be also standalone:\n *\n * ```js\n * const popup = new Popup()\n * \t.setLatLng(latlng)\n * \t.setContent('<p>Hello world!<br />This is a nice popup.</p>')\n * \t.openOn(map);\n * ```\n * or\n * ```js\n * const popup = new Popup(latlng, {content: '<p>Hello world!<br />This is a nice popup.</p>'})\n * \t.openOn(map);\n * ```\n *\n * **Security note.** Popup string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindPopup(el);\n * ```\n */\nexport class Popup extends DivOverlay {\n\n\tstatic defaultOptions = {\n\t\tpane: 'popupPane',\n\t\toffset: [0, 7],\n\t\tmaxWidth: 300,\n\t\tminWidth: 50,\n\t\tmaxHeight: null,\n\t\tautoPan: true,\n\t\tautoPanPaddingTopLeft: null,\n\t\tautoPanPaddingBottomRight: null,\n\t\tautoPanPadding: [5, 5],\n\t\tkeepInView: false,\n\t\tcloseButton: true,\n\t\tautoClose: true,\n\t\tcloseOnEscapeKey: true,\n\t\tclassName: '',\n\t\ttrackResize: true,\n\t};\n\n\t/**\n\t * Instantiates a `Popup` 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 popup with a reference to the Layer to which it refers.\n\t * @overload\n\t * @param {PopupOptions} [options]\n\t * @param {Layer} [source]\n\t */\n\t/**\n\t * Instantiates a `Popup` object given `latlng` where the popup 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 {PopupOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Popup);\n\t}\n\n\t/**\n\t * Alternative to `map.openPopup(popup)`.\n\t * Adds the popup to the map and closes the previous one.\n\t * @param {MaplairMap} map\n\t * @returns {this}\n\t */\n\topenOn(map) {\n\t\tmap = arguments.length ? map : this._source._map; // experimental, not the part of public api\n\n\t\tif (!map.hasLayer(this) && map._popup && map._popup.options.autoClose) {\n\t\t\tmap.removeLayer(map._popup);\n\t\t}\n\t\tmap._popup = this;\n\n\t\treturn super.openOn(map);\n\t}\n\n\t/**\n\t * Adds the popup to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\t// The element to return the focus to when closing the popup, e.g. a marker\n\t\tconst active = document.activeElement;\n\t\tthis._returnFocus = map._container.contains(active) && !this._container?.contains(active) ? active : null;\n\n\t\tsuper.onAdd(map);\n\n\t\tif (this._source?._clickedByKeyboard) {\n\t\t\t// Move the focus into the popup, so that its content is read and reachable\n\t\t\tif (!this._closeButton) {\n\t\t\t\tthis._container.tabIndex = -1;\n\t\t\t}\n\t\t\t(this._closeButton ?? this._container).focus({preventScroll: true});\n\t\t}\n\n\t\tmap.fire('popupopen', {popup: this});\n\n\t\tif (this._source) {\n\t\t\tthis._source.fire('popupopen', {popup: this}, true);\n\t\t\t// For non-path layers, we toggle the popup when clicking\n\t\t\t// again the layer, so prevent the map to reopen it.\n\t\t\tif (!(this._source instanceof Path)) {\n\t\t\t\tthis._source.on('preclick', DomEvent.stopPropagation);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes the popup from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this._container.contains(document.activeElement) && this._returnFocus?.isConnected) {\n\t\t\tthis._returnFocus.focus({preventScroll: true});\n\t\t}\n\t\tthis._returnFocus = null;\n\n\t\tsuper.onRemove(map);\n\n\t\tmap.fire('popupclose', {popup: this});\n\n\t\tif (this._source) {\n\t\t\tthis._source.fire('popupclose', {popup: this}, true);\n\t\t\tif (!(this._source instanceof Path)) {\n\t\t\t\tthis._source.off('preclick', DomEvent.stopPropagation);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the popup listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (this.options.closeOnClick ?? this._map.options.closePopupOnClick) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\tif (this.options.keepInView) {\n\t\t\tevents.moveend = this._adjustPan;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-popup',\n\t\tcontainer = this._container = DomUtil.create('div', `${prefix} ${this.options.className || ''} maplair-zoom-animated`);\n\n\t\tconst wrapper = this._wrapper = DomUtil.create('div', `${prefix}-content-wrapper`, container);\n\t\tthis._contentNode = DomUtil.create('div', `${prefix}-content`, wrapper);\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(this._contentNode);\n\t\tDomEvent.on(container, 'contextmenu', DomEvent.stopPropagation);\n\n\t\tthis._tipContainer = DomUtil.create('div', `${prefix}-tip-container`, container);\n\t\tthis._tip = DomUtil.create('div', `${prefix}-tip`, this._tipContainer);\n\n\t\tif (this.options.closeButton) {\n\t\t\tconst closeButton = this._closeButton = DomUtil.create('button', `${prefix}-close-button`, container);\n\t\t\tcloseButton.type = 'button';\n\t\t\tcloseButton.setAttribute('aria-label', I18n.translate('Close popup'));\n\n\t\t\tcloseButton.innerHTML = '<span aria-hidden=\"true\">×</span>';\n\n\t\t\tDomEvent.on(closeButton, 'click', (ev) => {\n\t\t\t\tev.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.trackResize) {\n\t\t\tthis._resizeObserver = new ResizeObserver(() => {\n\t\t\t\tif (!this._map) { return; }\n\t\t\t\tthis._updateLayout();\n\t\t\t\tthis._updatePosition();\n\t\t\t\tthis._adjustPan();\n\t\t\t});\n\n\t\t\tthis._resizeObserver.observe(this._contentNode);\n\t\t}\n\t}\n\n\t_updateLayout() {\n\t\tconst container = this._contentNode,\n\t\tstyle = container.style;\n\n\t\tstyle.maxWidth = `${this.options.maxWidth}px`;\n\t\tstyle.minWidth = `${this.options.minWidth}px`;\n\n\t\tstyle.height = '';\n\n\t\t// only measure the height of the content (forcing a layout) if needed\n\t\tconst maxHeight = this.options.maxHeight,\n\t\tscrolled = !!maxHeight && container.offsetHeight > maxHeight;\n\t\tif (scrolled) {\n\t\t\tstyle.height = `${maxHeight}px`;\n\t\t}\n\t\tcontainer.classList.toggle('maplair-popup-scrolled', scrolled);\n\n\t\tthis._containerWidth = this._container.offsetWidth;\n\t\tthis._containerHeight = this._container.offsetHeight;\n\t\t// read along with the size, so that _adjustPan doesn't force another style\n\t\t// recalculation and layout after the popup has been positioned\n\t\tthis._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),\n\t\tanchor = this._getAnchor();\n\t\tthis._setContainerPosition(pos.add(anchor));\n\t}\n\n\t_adjustPan() {\n\t\tif (!this.options.autoPan) { return; }\n\t\tthis._map._panAnim?.stop();\n\n\t\t// Stopping the pan fires `moveend`, whose listeners may have removed this popup.\n\t\tif (!this._map) { return; }\n\n\t\t// We can endlessly recurse if keepInView is set and the view resets.\n\t\t// Let's guard against that by exiting early if we're responding to our own autopan.\n\t\tif (this._autopanning) {\n\t\t\tthis._autopanning = false;\n\t\t\treturn;\n\t\t}\n\n\t\tconst map = this._map,\n\t\tmarginBottom = this._containerMarginBottom ?? (parseInt(getComputedStyle(this._container).marginBottom, 10) || 0),\n\t\tcontainerHeight = this._containerHeight + marginBottom,\n\t\tcontainerWidth = this._containerWidth,\n\t\tlayerPos = new Point(this._containerLeft, -containerHeight - this._containerBottom);\n\n\t\tlayerPos._add(this._getContainerPosition());\n\n\t\tconst containerPos = map.layerPointToContainerPoint(layerPos),\n\t\tpadding = Point.from(this.options.autoPanPadding),\n\t\tpaddingTL = Point.from(this.options.autoPanPaddingTopLeft ?? padding),\n\t\tpaddingBR = Point.from(this.options.autoPanPaddingBottomRight ?? padding),\n\t\tsize = map.getSize();\n\t\tlet dx = 0,\n\t\tdy = 0;\n\n\t\tif (containerPos.x + containerWidth + paddingBR.x > size.x) { // right\n\t\t\tdx = containerPos.x + containerWidth - size.x + paddingBR.x;\n\t\t}\n\t\tif (containerPos.x - dx - paddingTL.x < 0) { // left\n\t\t\tdx = containerPos.x - paddingTL.x;\n\t\t}\n\t\tif (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom\n\t\t\tdy = containerPos.y + containerHeight - size.y + paddingBR.y;\n\t\t}\n\t\tif (containerPos.y - dy - paddingTL.y < 0) { // top\n\t\t\tdy = containerPos.y - paddingTL.y;\n\t\t}\n\n\t\tif (dx || dy) {\n\t\t\t// Track that we're autopanning, as this function will be re-ran on moveend\n\t\t\tif (this.options.keepInView) {\n\t\t\t\tthis._autopanning = true;\n\t\t\t}\n\n\t\t\tmap\n\t\t\t\t.fire('autopanstart')\n\t\t\t\t.panBy([dx, dy]);\n\t\t}\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the popup on the source layer?\n\t\treturn new Point(this._source?._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]);\n\t}\n\n\t/**\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.mergeOptions({\n\t\t\tclosePopupOnClick: true\n\t\t});\n\n\t\tMaplairMap.include(mapPopupMethods);\n\n\t\tLayer.include(layerPopupMethods);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,kBAAkB;;;;;;;;;;;;;;CAcvB,UAAU,OAAO,QAAQ,SAAS;EAEjC,KAAK,aAAa,OAAO,OAAO,QAAQ,OAAO,CAAC,CAC9C,OAAO,IAAI;EAEb,OAAO;CACR;;;;;;;;CASA,WAAW,OAAO;EACjB,QAAQ,UAAU,SAAS,QAAQ,KAAK;EACxC,OAAO,MAAM;EACb,OAAO;CACR;AACD;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;;;;;;;;;;;;;CAazB,UAAU,SAAS,SAAS;EAE3B,KAAK,SAAS,KAAK,aAAa,OAAO,KAAK,QAAQ,SAAS,OAAO;EACpE,KAAK,GAAG;GACP,OAAO,KAAK;GACZ,QAA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sBAAsB,CAAC;EAE1C,MAAM,eAAe,IAAI,2BAA2B,QAAQ,GAC5D,UAAU,MAAM,KAAK,KAAK,QAAQ,cAAc,GAChD,YAAY,MAAM,KAAK,KAAK,QAAQ,yBAAyB,OAAO,GACpE,YAAY,MAAM,KAAK,KAAK,QAAQ,6BAA6B,OAAO,GACxE,OAAO,IAAI,QAAQ;EACnB,IAAI,KAAK,GACT,KAAK;EAEL,IAAI,aAAa,IAAI,iBAAiB,UAAU,IAAI,KAAK,GACxD,KAAK,aAAa,IAAI,iBAAiB,KAAK,IAAI,UAAU;EAE3D,IAAI,aAAa,IAAI,KAAK,UAAU,IAAI,GACvC,KAAK,aAAa,IAAI,UAAU;EAEjC,IAAI,aAAa,IAAI,kBAAkB,UAAU,IAAI,KAAK,GACzD,KAAK,aAAa,IAAI,kBAAkB,KAAK,IAAI,UAAU;EAE5D,IAAI,aAAa,IAAI,KAAK,UAAU,IAAI,GACvC,KAAK,aAAa,IAAI,UAAU;EAGjC,IAAI,MAAM,IAAI;GAEb,IAAI,KAAK,QAAQ,YAChB,KAAK,eAAe;GAGrB,IACE,KAAK,cAAc,CAAC,CACpB,MAAM,CAAC,IAAI,EAAE,CAAC;EACjB;CACD;CAEA,aAAa;EAEZ,OAAO,IAAI,MAAM,KAAK,SAAS,kBAAkB,KAAK,QAAQ,gBAAgB,IAAI,CAAC,GAAG,CAAC,CAAC;CACzF;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,mBAAmB,KACpB,CAAC;EAED,WAAW,QAAQ,eAAe;EAElC,MAAM,QAAQ,iBAAiB;CAChC;AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { splitWords } from "../core/Util.js";
|
|
2
2
|
import { ImageOverlay } from "./ImageOverlay.js";
|
|
3
|
-
|
|
3
|
+
// src/layer/SVGOverlay.js
|
|
4
4
|
/** @import {ImageOverlayOptions} from './ImageOverlay.js' */
|
|
5
5
|
/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
|
|
6
6
|
/**
|
|
@@ -45,7 +45,6 @@ var SVGOverlay = class SVGOverlay extends ImageOverlay {
|
|
|
45
45
|
if (this.options.className) el.classList.add(...splitWords(this.options.className));
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
//#endregion
|
|
49
48
|
export { SVGOverlay };
|
|
50
49
|
|
|
51
50
|
//# sourceMappingURL=SVGOverlay.js.map
|
|
@@ -5,7 +5,7 @@ import { create } from "../dom/DomUtil.js";
|
|
|
5
5
|
import { Layer } from "./Layer.js";
|
|
6
6
|
import { FeatureGroup } from "./FeatureGroup.js";
|
|
7
7
|
import { DivOverlay } from "./DivOverlay.js";
|
|
8
|
-
|
|
8
|
+
// src/layer/Tooltip.js
|
|
9
9
|
const directions = [
|
|
10
10
|
"top",
|
|
11
11
|
"bottom",
|
|
@@ -112,8 +112,9 @@ const layerTooltipMethods = {
|
|
|
112
112
|
* @returns {this}
|
|
113
113
|
*/
|
|
114
114
|
bindTooltip(content, options) {
|
|
115
|
-
|
|
116
|
-
this._tooltip
|
|
115
|
+
const old = this.isTooltipOpen() ? null : this._tooltip;
|
|
116
|
+
if (this._tooltip) this.unbindTooltip();
|
|
117
|
+
this._tooltip = this._initOverlay(Tooltip, old, content, options);
|
|
117
118
|
this._initTooltipInteractions();
|
|
118
119
|
if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) this.openTooltip();
|
|
119
120
|
return this;
|
|
@@ -132,21 +133,20 @@ const layerTooltipMethods = {
|
|
|
132
133
|
return this;
|
|
133
134
|
},
|
|
134
135
|
_initTooltipInteractions(remove) {
|
|
135
|
-
|
|
136
|
-
const onOff = remove ? "off" : "on", events = {
|
|
136
|
+
const { permanent, sticky } = this._tooltip.options, events = {
|
|
137
137
|
remove: this.closeTooltip,
|
|
138
138
|
move: this._moveTooltip
|
|
139
139
|
};
|
|
140
|
-
if (
|
|
140
|
+
if (permanent) events.add = this._openTooltip;
|
|
141
|
+
else {
|
|
141
142
|
events.pointerover = this._openTooltip;
|
|
142
143
|
events.pointerout = this.closeTooltip;
|
|
143
144
|
events.click = this._openTooltip;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
if (
|
|
148
|
-
this[
|
|
149
|
-
this._tooltipHandlersAdded = !remove;
|
|
145
|
+
events.add = this._toggleFocusListeners;
|
|
146
|
+
if (this._map) this._toggleFocusListeners(!remove);
|
|
147
|
+
}
|
|
148
|
+
if (sticky) events.pointermove = this._moveTooltip;
|
|
149
|
+
this[remove ? "off" : "on"](events);
|
|
150
150
|
},
|
|
151
151
|
/**
|
|
152
152
|
* Opens the bound tooltip at the specified `latlng` or at the default tooltip
|
|
@@ -212,9 +212,9 @@ const layerTooltipMethods = {
|
|
|
212
212
|
getTooltip() {
|
|
213
213
|
return this._tooltip;
|
|
214
214
|
},
|
|
215
|
-
|
|
216
|
-
if (this.getElement) this._addFocusListenersOnLayer(this,
|
|
217
|
-
else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer,
|
|
215
|
+
_toggleFocusListeners(add) {
|
|
216
|
+
if (this.getElement) this._addFocusListenersOnLayer(this, !add);
|
|
217
|
+
else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer, !add), this);
|
|
218
218
|
},
|
|
219
219
|
_addFocusListenersOnLayer(layer, remove) {
|
|
220
220
|
const el = typeof layer.getElement === "function" && layer.getElement();
|
|
@@ -447,7 +447,7 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
447
447
|
};
|
|
448
448
|
}
|
|
449
449
|
_updatePosition() {
|
|
450
|
-
const pos = this._map.latLngToLayerPoint(this._latlng);
|
|
450
|
+
const pos = this._map.latLngToLayerPoint(this._latlng)._round();
|
|
451
451
|
this._setPosition(pos);
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
@@ -476,7 +476,6 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
476
476
|
Layer.include(layerTooltipMethods);
|
|
477
477
|
}
|
|
478
478
|
};
|
|
479
|
-
//#endregion
|
|
480
479
|
export { Tooltip };
|
|
481
480
|
|
|
482
481
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -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.\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_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 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);\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 {type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Aa,YAAY,KAAK,MAAM,aAAa,SAAS,GACzF,WAAW,SAAS;GACpB,MAAM,IAAI,SAAS,MAAM;GACzB,MAAM,IAAI,MAAM,SAAS,aAAa,SAAS,YAAY,CAAC,CAAC,SAAS,MAAM;EAC7E;EACA,MAAM,UAAU,IAAI,MAAM,aAAa,WAAW;EAClD,OAAO;GAAC,KAAK,IAAI,IAAI,OAAO;GAAG,KAAK,IAAI,SAAS,OAAO;EAAC;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,GAAG;CAErC;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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;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"}
|
|
@@ -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' */
|
|
@@ -94,7 +94,6 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
//#endregion
|
|
98
97
|
export { VideoOverlay };
|
|
99
98
|
|
|
100
99
|
//# sourceMappingURL=VideoOverlay.js.map
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { Icon } from "./Icon.js";
|
|
2
|
-
|
|
2
|
+
// src/layer/marker/DefaultIcon.js
|
|
3
3
|
/** @import {IconOptions} from './Icon.js' */
|
|
4
4
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
5
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>`;
|
|
15
|
+
/**
|
|
6
16
|
* Options of `DefaultIcon`.
|
|
7
17
|
* @typedef {object} DefaultIconOptions
|
|
8
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'})`.
|
|
9
21
|
* @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
|
|
10
22
|
* @property {PointExpression|number} [iconSize=[25, 41]]
|
|
11
23
|
* @property {PointExpression} [iconAnchor=[12, 41]]
|
|
@@ -15,9 +27,9 @@ import { Icon } from "./Icon.js";
|
|
|
15
27
|
* @extends IconOptions
|
|
16
28
|
*/
|
|
17
29
|
/**
|
|
18
|
-
* A
|
|
19
|
-
*
|
|
20
|
-
* URIs, so they work with any bundler and need no image files.
|
|
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.
|
|
21
33
|
*
|
|
22
34
|
* In order to customize the default icon, just change the properties of
|
|
23
35
|
* `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
|
|
@@ -27,13 +39,14 @@ import { Icon } from "./Icon.js";
|
|
|
27
39
|
*/
|
|
28
40
|
var DefaultIcon = class DefaultIcon extends Icon {
|
|
29
41
|
static defaultOptions = {
|
|
30
|
-
iconUrl:
|
|
42
|
+
iconUrl: /* @__PURE__ */ marker("%23C2331B", "%23E2603F", 1, "%238F2D20", "%23B23A27"),
|
|
31
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>",
|
|
32
44
|
iconSize: [25, 41],
|
|
33
45
|
iconAnchor: [12, 41],
|
|
34
46
|
popupAnchor: [1, -34],
|
|
35
47
|
tooltipAnchor: [16, -28],
|
|
36
|
-
shadowSize: [41, 41]
|
|
48
|
+
shadowSize: [41, 41],
|
|
49
|
+
color: null
|
|
37
50
|
};
|
|
38
51
|
/**
|
|
39
52
|
* Creates the default icon, optionally with changed options.
|
|
@@ -43,8 +56,17 @@ var DefaultIcon = class DefaultIcon extends Icon {
|
|
|
43
56
|
super(...args);
|
|
44
57
|
this.callInitHooks(DefaultIcon);
|
|
45
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* @param {'icon'|'shadow'} name
|
|
61
|
+
* @returns {string|undefined}
|
|
62
|
+
*/
|
|
63
|
+
_getIconUrl(name) {
|
|
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\"/>");
|
|
68
|
+
}
|
|
46
69
|
};
|
|
47
|
-
//#endregion
|
|
48
70
|
export { DefaultIcon };
|
|
49
71
|
|
|
50
72
|
//# sourceMappingURL=DefaultIcon.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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
|
/**
|
|
@@ -73,7 +73,6 @@ var DivIcon = class DivIcon extends Icon {
|
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
//#endregion
|
|
77
76
|
export { DivIcon };
|
|
78
77
|
|
|
79
78
|
//# sourceMappingURL=DivIcon.js.map
|
|
@@ -1,7 +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
|
-
|
|
4
|
+
// src/layer/marker/Icon.js
|
|
5
5
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
6
6
|
/**
|
|
7
7
|
* Options of `Icon`.
|
|
@@ -113,6 +113,7 @@ var Icon = class Icon extends Class {
|
|
|
113
113
|
img.style.marginLeft = `${-anchor.x}px`;
|
|
114
114
|
img.style.marginTop = `${-anchor.y}px`;
|
|
115
115
|
}
|
|
116
|
+
img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
|
|
116
117
|
if (size) {
|
|
117
118
|
img.style.width = `${size.x}px`;
|
|
118
119
|
img.style.height = `${size.y}px`;
|
|
@@ -127,7 +128,6 @@ var Icon = class Icon extends Class {
|
|
|
127
128
|
return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
|
-
//#endregion
|
|
131
131
|
export { Icon };
|
|
132
132
|
|
|
133
133
|
//# sourceMappingURL=Icon.js.map
|
|
@@ -1 +1 @@
|
|
|
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\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAAE;GACpC,IAAI,MAAM,YAAa,GAAG,CAAC,OAAO,EAAE;EACrC;EAEA,IAAI,MAAM;GACT,IAAI,MAAM,QAAS,GAAG,KAAK,EAAE;GAC7B,IAAI,MAAM,SAAS,GAAG,KAAK,EAAE;EAC9B;CACD;CAEA,WAAW,KAAK,IAAI;EACnB,OAAO,SAAS,cAAc,KAAK;EACnC,GAAG,MAAM;EACT,OAAO;CACR;CAEA,YAAY,MAAM;EACjB,OAAO,OAAO,mBAAmB,KAAK,KAAK,QAAQ,GAAG,KAAK,eAAe,KAAK,QAAQ,GAAG,KAAK;CAChG;AACD"}
|
|
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":";;;;;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