maplair 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +178 -0
- package/dist/esm/Maplair.js +18 -17
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +25 -16
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +10 -13
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +2 -5
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +10 -18
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +6 -9
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +170 -65
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +8 -11
- package/dist/esm/control/LegendControl.js.map +1 -1
- package/dist/esm/control/MiniMapControl.js +15 -18
- package/dist/esm/control/MiniMapControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +2 -5
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +8 -11
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +100 -19
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +2 -5
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/TextControl.js +6 -9
- package/dist/esm/control/TextControl.js.map +1 -1
- package/dist/esm/control/TimeControl.js +407 -0
- package/dist/esm/control/TimeControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +23 -36
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +28 -44
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +22 -10
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +23 -14
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +15 -4
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +26 -24
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +3 -18
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +18 -60
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +15 -70
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +21 -21
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +4 -27
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +16 -7
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +5 -6
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +5 -6
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +4 -5
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +3 -4
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +4 -5
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +5 -6
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +5 -6
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +37 -32
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +24 -51
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +7 -10
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +16 -22
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +17 -155
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +74 -0
- package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
- package/dist/esm/layer/HeatLayer.js +17 -20
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +22 -29
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +9 -12
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +53 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +35 -58
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +3 -7
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -34
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +13 -17
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +38 -49
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +8 -11
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +9 -12
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +44 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +5 -8
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +115 -47
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +301 -0
- package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
- package/dist/esm/layer/marker/SvgIcon.js +7 -10
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +89 -101
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +36 -44
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +33 -27
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +8 -17
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +6 -5
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +19 -10
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +3 -5
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +28 -22
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +22 -7
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +3 -4
- package/dist/esm/layer/vector/Polyline.js +25 -10
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +17 -17
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +12 -9
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +41 -22
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +125 -126
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +25 -47
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +7 -10
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +20 -21
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +48 -68
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +13 -5
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +4 -6
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +13 -7
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +6495 -5981
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +6206 -5673
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1213
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/i18n/cs.json +6 -0
- package/i18n/de.json +6 -0
- package/i18n/en.json +6 -0
- package/i18n/es.json +6 -0
- package/i18n/fr.json +6 -0
- package/i18n/hu.json +6 -0
- package/i18n/it.json +6 -0
- package/i18n/rm.json +6 -0
- package/i18n/sk.json +6 -0
- package/i18n/sl.json +6 -0
- package/package.json +11 -18
- package/src/Maplair.all.js +0 -1
- package/src/control/AttributionControl.js +25 -18
- package/src/control/ButtonControl.js +9 -11
- package/src/control/ContextMenu.js +3 -5
- package/src/control/Control.js +9 -19
- package/src/control/FullscreenControl.js +5 -7
- package/src/control/LayersControl.js +196 -86
- package/src/control/LegendControl.js +7 -9
- package/src/control/MiniMapControl.js +9 -11
- package/src/control/RotateControl.js +3 -5
- package/src/control/ScaleControl.js +7 -9
- package/src/control/SearchControl.js +102 -19
- package/src/control/SideBySideControl.js +3 -5
- package/src/control/TextControl.js +5 -7
- package/src/control/TimeControl.js +471 -0
- package/src/control/ZoomControl.js +22 -38
- package/src/control/index.js +1 -0
- package/src/core/Class.js +37 -45
- package/src/core/Events.js +22 -3
- package/src/core/Handler.js +25 -13
- package/src/core/Util.js +20 -2
- package/src/core/index.js +0 -1
- package/src/dom/DomEvent.DoubleTap.js +18 -10
- package/src/dom/DomEvent.PointerEvents.js +3 -26
- package/src/dom/DomEvent.js +17 -85
- package/src/dom/DomUtil.js +22 -78
- package/src/dom/Draggable.js +32 -23
- package/src/dom/PosAnimation.js +3 -25
- package/src/dom/index.js +0 -1
- package/src/geo/LatLng.js +20 -3
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +4 -4
- package/src/geo/crs/EPSG3857.js +4 -4
- package/src/geo/crs/EPSG4326.js +3 -3
- package/src/geo/crs/EarthCRS.js +2 -8
- package/src/geo/crs/SimpleCRS.js +3 -3
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +2 -2
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +2 -2
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +2 -2
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +48 -49
- package/src/geometry/PolyUtil.js +39 -76
- package/src/layer/BlanketOverlay.js +6 -10
- package/src/layer/DivOverlay.js +16 -27
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +17 -218
- package/src/layer/GeoJSONUtil.js +85 -0
- package/src/layer/HeatLayer.js +10 -12
- package/src/layer/ImageOverlay.js +21 -32
- package/src/layer/Layer.js +8 -10
- package/src/layer/LayerGroup.js +72 -1
- package/src/layer/Popup.js +37 -62
- package/src/layer/SVGOverlay.js +1 -5
- package/src/layer/Tooltip.js +34 -36
- package/src/layer/VideoOverlay.js +12 -15
- package/src/layer/marker/DefaultIcon.js +40 -58
- package/src/layer/marker/DivIcon.js +9 -11
- package/src/layer/marker/Icon.js +9 -10
- package/src/layer/marker/Marker.Drag.js +54 -6
- package/src/layer/marker/Marker.Move.js +4 -6
- package/src/layer/marker/Marker.js +145 -52
- package/src/layer/marker/MarkerClusterGroup.js +370 -0
- package/src/layer/marker/SvgIcon.js +7 -9
- package/src/layer/marker/index.js +1 -0
- package/src/layer/tile/GridLayer.js +108 -135
- package/src/layer/tile/TileLayer.js +44 -49
- package/src/layer/tile/WMSTileLayer.js +31 -26
- package/src/layer/vector/Canvas.js +13 -19
- package/src/layer/vector/Circle.js +9 -3
- package/src/layer/vector/CircleMarker.js +19 -7
- package/src/layer/vector/Path.DashAnimation.js +1 -2
- package/src/layer/vector/Path.js +30 -21
- package/src/layer/vector/Polygon.js +29 -6
- package/src/layer/vector/Polyline.js +26 -7
- package/src/layer/vector/Renderer.getRenderer.js +20 -19
- package/src/layer/vector/SVG.js +17 -7
- package/src/map/Map.Rotation.js +40 -8
- package/src/map/Map.js +158 -153
- package/src/map/handler/BoxZoomHandler.js +30 -50
- package/src/map/handler/DisplaceHandler.js +6 -8
- package/src/map/handler/DragHandler.js +25 -28
- package/src/map/handler/KeyboardHandler.js +65 -90
- package/src/map/handler/PinchZoomHandler.js +16 -5
- package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
- package/src/map/handler/TapHoldHandler.js +15 -4
- package/src/map/index.js +1 -1
- package/src/maplair.css +153 -98
- package/dist/esm/core/Browser.js +0 -100
- package/dist/esm/core/Browser.js.map +0 -1
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/dist/images/layers.svg +0 -1
- package/dist/images/marker-icon.svg +0 -1
- package/dist/images/marker-shadow.svg +0 -1
- package/src/core/Browser.js +0 -110
- package/src/images/layers.svg +0 -1
- package/src/images/marker-icon.svg +0 -1
- package/src/images/marker-shadow.svg +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
package/src/layer/Popup.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {DivOverlay} from './DivOverlay.js';
|
|
2
2
|
import * as DomEvent from '../dom/DomEvent.js';
|
|
3
3
|
import * as DomUtil from '../dom/DomUtil.js';
|
|
4
|
-
import Browser from '../core/Browser.js';
|
|
5
4
|
import {Point} from '../geometry/Point.js';
|
|
6
5
|
import {Layer} from './Layer.js';
|
|
7
6
|
import {Path} from './vector/Path.js';
|
|
@@ -24,9 +23,8 @@ import {I18n} from '../core/I18n.js';
|
|
|
24
23
|
* @property {number|null} [maxHeight=null] If set, creates a scrollable container of
|
|
25
24
|
* the given height inside a popup if its content exceeds it. The scrollable container
|
|
26
25
|
* can be styled using the `maplair-popup-scrolled` CSS class selector.
|
|
27
|
-
* @property {boolean} [autoPan] Set it to `false` if you don't want the map to do
|
|
28
|
-
* panning animation to fit the opened popup.
|
|
29
|
-
* prefers reduced motion (`Browser.reducedMotion`).
|
|
26
|
+
* @property {boolean} [autoPan=true] Set it to `false` if you don't want the map to do
|
|
27
|
+
* panning animation to fit the opened popup.
|
|
30
28
|
* @property {PointExpression|null} [autoPanPaddingTopLeft=null] The margin between the
|
|
31
29
|
* popup and the top left corner of the map view after autopanning was performed.
|
|
32
30
|
* @property {PointExpression|null} [autoPanPaddingBottomRight=null] The margin between
|
|
@@ -138,15 +136,11 @@ const layerPopupMethods = {
|
|
|
138
136
|
bindPopup(content, options) {
|
|
139
137
|
// eslint-disable-next-line no-use-before-define -- defined below, used when called
|
|
140
138
|
this._popup = this._initOverlay(Popup, this._popup, content, options);
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
move: this._movePopup
|
|
147
|
-
});
|
|
148
|
-
this._popupHandlersAdded = true;
|
|
149
|
-
}
|
|
139
|
+
this.on({
|
|
140
|
+
click: this._openPopup,
|
|
141
|
+
remove: this.closePopup,
|
|
142
|
+
move: this._movePopup
|
|
143
|
+
});
|
|
150
144
|
|
|
151
145
|
return this;
|
|
152
146
|
},
|
|
@@ -160,11 +154,9 @@ const layerPopupMethods = {
|
|
|
160
154
|
if (this._popup) {
|
|
161
155
|
this.off({
|
|
162
156
|
click: this._openPopup,
|
|
163
|
-
keypress: this._onKeyPress,
|
|
164
157
|
remove: this.closePopup,
|
|
165
158
|
move: this._movePopup
|
|
166
159
|
});
|
|
167
|
-
this._popupHandlersAdded = false;
|
|
168
160
|
this._popup = null;
|
|
169
161
|
}
|
|
170
162
|
return this;
|
|
@@ -246,7 +238,7 @@ const layerPopupMethods = {
|
|
|
246
238
|
return;
|
|
247
239
|
}
|
|
248
240
|
// prevent map click
|
|
249
|
-
DomEvent.
|
|
241
|
+
DomEvent.stopPropagation(e);
|
|
250
242
|
|
|
251
243
|
const target = e.propagatedFrom ?? e.target;
|
|
252
244
|
if (this._popup._source === target && !(target instanceof Path)) {
|
|
@@ -265,14 +257,6 @@ const layerPopupMethods = {
|
|
|
265
257
|
|
|
266
258
|
_movePopup(e) {
|
|
267
259
|
this._popup.setLatLng(e.latlng);
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
_onKeyPress(e) {
|
|
271
|
-
if (e.originalEvent.code === 'Enter') {
|
|
272
|
-
this._popup._openedByKeyboard = true;
|
|
273
|
-
this._openPopup(e);
|
|
274
|
-
this._popup._openedByKeyboard = false;
|
|
275
|
-
}
|
|
276
260
|
}
|
|
277
261
|
};
|
|
278
262
|
/** @typedef {typeof layerPopupMethods} LayerPopupMethods */
|
|
@@ -317,25 +301,23 @@ const layerPopupMethods = {
|
|
|
317
301
|
*/
|
|
318
302
|
export class Popup extends DivOverlay {
|
|
319
303
|
|
|
320
|
-
static {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
});
|
|
338
|
-
}
|
|
304
|
+
static defaultOptions = {
|
|
305
|
+
pane: 'popupPane',
|
|
306
|
+
offset: [0, 7],
|
|
307
|
+
maxWidth: 300,
|
|
308
|
+
minWidth: 50,
|
|
309
|
+
maxHeight: null,
|
|
310
|
+
autoPan: true,
|
|
311
|
+
autoPanPaddingTopLeft: null,
|
|
312
|
+
autoPanPaddingBottomRight: null,
|
|
313
|
+
autoPanPadding: [5, 5],
|
|
314
|
+
keepInView: false,
|
|
315
|
+
closeButton: true,
|
|
316
|
+
autoClose: true,
|
|
317
|
+
closeOnEscapeKey: true,
|
|
318
|
+
className: '',
|
|
319
|
+
trackResize: true,
|
|
320
|
+
};
|
|
339
321
|
|
|
340
322
|
/**
|
|
341
323
|
* Instantiates a `Popup` object given an optional `options` object that describes
|
|
@@ -388,7 +370,7 @@ export class Popup extends DivOverlay {
|
|
|
388
370
|
|
|
389
371
|
super.onAdd(map);
|
|
390
372
|
|
|
391
|
-
if (this.
|
|
373
|
+
if (this._source?._clickedByKeyboard) {
|
|
392
374
|
// Move the focus into the popup, so that its content is read and reachable
|
|
393
375
|
if (!this._closeButton) {
|
|
394
376
|
this._container.tabIndex = -1;
|
|
@@ -456,12 +438,6 @@ export class Popup extends DivOverlay {
|
|
|
456
438
|
this._contentNode = DomUtil.create('div', `${prefix}-content`, wrapper);
|
|
457
439
|
|
|
458
440
|
DomEvent.disableClickPropagation(container);
|
|
459
|
-
// The keyboard handler of the map does not get keys while the focus is in the popup
|
|
460
|
-
DomEvent.on(container, 'keydown', (e) => {
|
|
461
|
-
if (e.key === 'Escape' && this.options.closeOnEscapeKey) {
|
|
462
|
-
this.close();
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
441
|
DomEvent.disableScrollPropagation(this._contentNode);
|
|
466
442
|
DomEvent.on(container, 'contextmenu', DomEvent.stopPropagation);
|
|
467
443
|
|
|
@@ -482,15 +458,12 @@ export class Popup extends DivOverlay {
|
|
|
482
458
|
}
|
|
483
459
|
|
|
484
460
|
if (this.options.trackResize) {
|
|
485
|
-
this._resizeObserver = new ResizeObserver((
|
|
461
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
486
462
|
if (!this._map) { return; }
|
|
487
|
-
this._containerWidth = entries[0]?.contentRect?.width;
|
|
488
|
-
this._containerHeight = entries[0]?.contentRect?.height;
|
|
489
|
-
|
|
490
463
|
this._updateLayout();
|
|
491
464
|
this._updatePosition();
|
|
492
465
|
this._adjustPan();
|
|
493
|
-
})
|
|
466
|
+
});
|
|
494
467
|
|
|
495
468
|
this._resizeObserver.observe(this._contentNode);
|
|
496
469
|
}
|
|
@@ -503,16 +476,15 @@ export class Popup extends DivOverlay {
|
|
|
503
476
|
style.maxWidth = `${this.options.maxWidth}px`;
|
|
504
477
|
style.minWidth = `${this.options.minWidth}px`;
|
|
505
478
|
|
|
506
|
-
|
|
507
|
-
scrolledClass = 'maplair-popup-scrolled';
|
|
479
|
+
style.height = '';
|
|
508
480
|
|
|
509
|
-
// only measure the height (forcing a layout) if needed
|
|
510
|
-
|
|
481
|
+
// only measure the height of the content (forcing a layout) if needed
|
|
482
|
+
const maxHeight = this.options.maxHeight,
|
|
483
|
+
scrolled = !!maxHeight && container.offsetHeight > maxHeight;
|
|
484
|
+
if (scrolled) {
|
|
511
485
|
style.height = `${maxHeight}px`;
|
|
512
|
-
container.classList.add(scrolledClass);
|
|
513
|
-
} else {
|
|
514
|
-
container.classList.remove(scrolledClass);
|
|
515
486
|
}
|
|
487
|
+
container.classList.toggle('maplair-popup-scrolled', scrolled);
|
|
516
488
|
|
|
517
489
|
this._containerWidth = this._container.offsetWidth;
|
|
518
490
|
this._containerHeight = this._container.offsetHeight;
|
|
@@ -531,6 +503,9 @@ export class Popup extends DivOverlay {
|
|
|
531
503
|
if (!this.options.autoPan) { return; }
|
|
532
504
|
this._map._panAnim?.stop();
|
|
533
505
|
|
|
506
|
+
// Stopping the pan fires `moveend`, whose listeners may have removed this popup.
|
|
507
|
+
if (!this._map) { return; }
|
|
508
|
+
|
|
534
509
|
// We can endlessly recurse if keepInView is set and the view resets.
|
|
535
510
|
// Let's guard against that by exiting early if we're responding to our own autopan.
|
|
536
511
|
if (this._autopanning) {
|
package/src/layer/SVGOverlay.js
CHANGED
|
@@ -44,11 +44,7 @@ export class SVGOverlay extends ImageOverlay {
|
|
|
44
44
|
_initImage() {
|
|
45
45
|
const el = this._image = this._url;
|
|
46
46
|
|
|
47
|
-
el.classList.add('maplair-image-layer');
|
|
48
|
-
if (this._zoomAnimated) { el.classList.add('maplair-zoom-animated'); }
|
|
47
|
+
el.classList.add('maplair-image-layer', 'maplair-zoom-animated');
|
|
49
48
|
if (this.options.className) { el.classList.add(...Util.splitWords(this.options.className)); }
|
|
50
|
-
|
|
51
|
-
el.onselectstart = Util.falseFn;
|
|
52
|
-
el.onpointermove = Util.falseFn;
|
|
53
49
|
}
|
|
54
50
|
}
|
package/src/layer/Tooltip.js
CHANGED
|
@@ -121,13 +121,16 @@ const layerTooltipMethods = {
|
|
|
121
121
|
* @returns {this}
|
|
122
122
|
*/
|
|
123
123
|
bindTooltip(content, options) {
|
|
124
|
+
// an open tooltip is replaced, a closed one reused
|
|
125
|
+
const old = this.isTooltipOpen() ? null : this._tooltip;
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
// the handlers depend on the old options, so they go before the new ones are applied
|
|
128
|
+
if (this._tooltip) {
|
|
126
129
|
this.unbindTooltip();
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
// eslint-disable-next-line no-use-before-define -- defined below, used when called
|
|
130
|
-
this._tooltip = this._initOverlay(Tooltip,
|
|
133
|
+
this._tooltip = this._initOverlay(Tooltip, old, content, options);
|
|
131
134
|
this._initTooltipInteractions();
|
|
132
135
|
|
|
133
136
|
if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) {
|
|
@@ -152,29 +155,27 @@ const layerTooltipMethods = {
|
|
|
152
155
|
},
|
|
153
156
|
|
|
154
157
|
_initTooltipInteractions(remove) {
|
|
155
|
-
|
|
156
|
-
const onOff = remove ? 'off' : 'on',
|
|
158
|
+
const {permanent, sticky} = this._tooltip.options,
|
|
157
159
|
events = {
|
|
158
160
|
remove: this.closeTooltip,
|
|
159
161
|
move: this._moveTooltip
|
|
160
162
|
};
|
|
161
|
-
if (
|
|
163
|
+
if (permanent) {
|
|
164
|
+
events.add = this._openTooltip;
|
|
165
|
+
} else {
|
|
162
166
|
events.pointerover = this._openTooltip;
|
|
163
167
|
events.pointerout = this.closeTooltip;
|
|
164
168
|
events.click = this._openTooltip;
|
|
169
|
+
// layer elements can be recreated on every add
|
|
170
|
+
events.add = this._toggleFocusListeners;
|
|
165
171
|
if (this._map) {
|
|
166
|
-
this.
|
|
167
|
-
} else {
|
|
168
|
-
events.add = () => this._addFocusListeners(remove);
|
|
172
|
+
this._toggleFocusListeners(!remove);
|
|
169
173
|
}
|
|
170
|
-
} else {
|
|
171
|
-
events.add = this._openTooltip;
|
|
172
174
|
}
|
|
173
|
-
if (
|
|
175
|
+
if (sticky) {
|
|
174
176
|
events.pointermove = this._moveTooltip;
|
|
175
177
|
}
|
|
176
|
-
this[
|
|
177
|
-
this._tooltipHandlersAdded = !remove;
|
|
178
|
+
this[remove ? 'off' : 'on'](events);
|
|
178
179
|
},
|
|
179
180
|
|
|
180
181
|
/**
|
|
@@ -204,15 +205,13 @@ const layerTooltipMethods = {
|
|
|
204
205
|
},
|
|
205
206
|
|
|
206
207
|
/**
|
|
207
|
-
* Closes the tooltip bound to this layer if it is open.
|
|
208
|
-
* (not the layer), or `undefined` without one.
|
|
208
|
+
* Closes the tooltip bound to this layer if it is open.
|
|
209
209
|
* @group Tooltip methods
|
|
210
|
-
* @returns {
|
|
210
|
+
* @returns {this}
|
|
211
211
|
*/
|
|
212
212
|
closeTooltip() {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
213
|
+
this._tooltip?.close();
|
|
214
|
+
return this;
|
|
216
215
|
},
|
|
217
216
|
|
|
218
217
|
/**
|
|
@@ -231,7 +230,7 @@ const layerTooltipMethods = {
|
|
|
231
230
|
* @returns {boolean}
|
|
232
231
|
*/
|
|
233
232
|
isTooltipOpen() {
|
|
234
|
-
return this._tooltip
|
|
233
|
+
return this._tooltip?.isOpen() ?? false;
|
|
235
234
|
},
|
|
236
235
|
|
|
237
236
|
/**
|
|
@@ -256,11 +255,12 @@ const layerTooltipMethods = {
|
|
|
256
255
|
return this._tooltip;
|
|
257
256
|
},
|
|
258
257
|
|
|
259
|
-
|
|
258
|
+
// also the `add` listener, so any truthy argument adds
|
|
259
|
+
_toggleFocusListeners(add) {
|
|
260
260
|
if (this.getElement) {
|
|
261
|
-
this._addFocusListenersOnLayer(this,
|
|
261
|
+
this._addFocusListenersOnLayer(this, !add);
|
|
262
262
|
} else if (this.eachLayer) {
|
|
263
|
-
this.eachLayer(layer => this._addFocusListenersOnLayer(layer,
|
|
263
|
+
this.eachLayer(layer => this._addFocusListenersOnLayer(layer, !add), this);
|
|
264
264
|
}
|
|
265
265
|
},
|
|
266
266
|
|
|
@@ -374,16 +374,14 @@ const layerTooltipMethods = {
|
|
|
374
374
|
*/
|
|
375
375
|
export class Tooltip extends DivOverlay {
|
|
376
376
|
|
|
377
|
-
static {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
});
|
|
386
|
-
}
|
|
377
|
+
static defaultOptions = {
|
|
378
|
+
pane: 'tooltipPane',
|
|
379
|
+
offset: [0, 0],
|
|
380
|
+
direction: 'auto',
|
|
381
|
+
permanent: false,
|
|
382
|
+
sticky: false,
|
|
383
|
+
opacity: 0.9
|
|
384
|
+
};
|
|
387
385
|
|
|
388
386
|
/**
|
|
389
387
|
* Instantiates a `Tooltip` object given an optional `options` object that describes
|
|
@@ -457,7 +455,7 @@ export class Tooltip extends DivOverlay {
|
|
|
457
455
|
|
|
458
456
|
_initLayout() {
|
|
459
457
|
const prefix = 'maplair-tooltip',
|
|
460
|
-
className = `${prefix} ${this.options.className || ''} maplair-zoom
|
|
458
|
+
className = `${prefix} ${this.options.className || ''} maplair-zoom-animated`;
|
|
461
459
|
|
|
462
460
|
this._contentNode = this._container = DomUtil.create('div', className);
|
|
463
461
|
|
|
@@ -584,7 +582,7 @@ export class Tooltip extends DivOverlay {
|
|
|
584
582
|
}
|
|
585
583
|
|
|
586
584
|
_updatePosition() {
|
|
587
|
-
const pos = this._map.latLngToLayerPoint(this._latlng);
|
|
585
|
+
const pos = this._map.latLngToLayerPoint(this._latlng)._round();
|
|
588
586
|
this._setPosition(pos);
|
|
589
587
|
}
|
|
590
588
|
|
|
@@ -597,7 +595,7 @@ export class Tooltip extends DivOverlay {
|
|
|
597
595
|
this.options.opacity = opacity;
|
|
598
596
|
|
|
599
597
|
if (this._container) {
|
|
600
|
-
this._container.style.opacity = opacity
|
|
598
|
+
this._container.style.opacity = `${opacity}`;
|
|
601
599
|
}
|
|
602
600
|
}
|
|
603
601
|
|
|
@@ -45,16 +45,14 @@ import * as Util from '../core/Util.js';
|
|
|
45
45
|
*/
|
|
46
46
|
export class VideoOverlay extends ImageOverlay {
|
|
47
47
|
|
|
48
|
-
static {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
}
|
|
48
|
+
static defaultOptions = {
|
|
49
|
+
autoplay: true,
|
|
50
|
+
controls: false,
|
|
51
|
+
loop: true,
|
|
52
|
+
keepAspectRatio: true,
|
|
53
|
+
muted: false,
|
|
54
|
+
playsInline: true
|
|
55
|
+
};
|
|
58
56
|
|
|
59
57
|
/**
|
|
60
58
|
* Instantiates a video overlay object given the URL of the video (or array of
|
|
@@ -73,11 +71,10 @@ export class VideoOverlay extends ImageOverlay {
|
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
_initImage() {
|
|
76
|
-
const wasElementSupplied = this._url
|
|
74
|
+
const wasElementSupplied = this._url instanceof HTMLVideoElement;
|
|
77
75
|
const vid = this._image = wasElementSupplied ? this._url : DomUtil.create('video');
|
|
78
76
|
|
|
79
|
-
vid.classList.add('maplair-image-layer');
|
|
80
|
-
if (this._zoomAnimated) { vid.classList.add('maplair-zoom-animated'); }
|
|
77
|
+
vid.classList.add('maplair-image-layer', 'maplair-zoom-animated');
|
|
81
78
|
if (this.options.className) { vid.classList.add(...Util.splitWords(this.options.className)); }
|
|
82
79
|
|
|
83
80
|
DomEvent.on(vid, 'pointerdown', (e) => {
|
|
@@ -91,14 +88,14 @@ export class VideoOverlay extends ImageOverlay {
|
|
|
91
88
|
|
|
92
89
|
if (wasElementSupplied) {
|
|
93
90
|
const sourceElements = vid.getElementsByTagName('source');
|
|
94
|
-
const sources =
|
|
91
|
+
const sources = Array.from(sourceElements, e => e.src);
|
|
95
92
|
this._url = (sourceElements.length > 0) ? sources : [vid.src];
|
|
96
93
|
return;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
if (!Array.isArray(this._url)) { this._url = [this._url]; }
|
|
100
97
|
|
|
101
|
-
if (!this.options.keepAspectRatio
|
|
98
|
+
if (!this.options.keepAspectRatio) {
|
|
102
99
|
vid.style['objectFit'] = 'fill';
|
|
103
100
|
}
|
|
104
101
|
vid.autoplay = !!this.options.autoplay;
|
|
@@ -1,53 +1,59 @@
|
|
|
1
1
|
import {Icon} from './Icon.js';
|
|
2
|
-
import * as DomUtil from '../../dom/DomUtil.js';
|
|
3
2
|
/** @import {IconOptions} from './Icon.js' */
|
|
4
3
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// The maple leaf marker. The pin is drawn white under its fill, which fades to it at the top with a `fillTopOpacity`
|
|
6
|
+
// below 1, so that a single color gets a highlight like the default one; the outline keeps light colors visible,
|
|
7
|
+
// but would double the antialiased edges of the default pin.
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} fill
|
|
10
|
+
* @param {string} fillTop
|
|
11
|
+
* @param {number} fillTopOpacity
|
|
12
|
+
* @param {string} stroke
|
|
13
|
+
* @param {string} strokeTop
|
|
14
|
+
* @param {string} [outline]
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
const marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = '') => `data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${fill}"/><stop offset="1" stop-color="${fillTop}" stop-opacity="${fillTopOpacity}"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${stroke}"/><stop offset="1" stop-color="${strokeTop}"/></linearGradient></defs><g fill="%23FFF"><path id="p" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/></g><use href="%23p" fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10"/>${outline}<path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>`;
|
|
8
18
|
|
|
9
19
|
/**
|
|
10
20
|
* Options of `DefaultIcon`.
|
|
11
21
|
* @typedef {object} DefaultIconOptions
|
|
12
|
-
* @property {string} [iconUrl
|
|
13
|
-
* @property {string} [
|
|
14
|
-
*
|
|
22
|
+
* @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
|
|
23
|
+
* @property {string|null} [color=null] Paints the pin in the given CSS color instead of
|
|
24
|
+
* the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.
|
|
25
|
+
* @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
|
|
15
26
|
* @property {PointExpression|number} [iconSize=[25, 41]]
|
|
16
27
|
* @property {PointExpression} [iconAnchor=[12, 41]]
|
|
17
28
|
* @property {PointExpression} [popupAnchor=[1, -34]]
|
|
18
29
|
* @property {PointExpression} [tooltipAnchor=[16, -28]]
|
|
19
30
|
* @property {PointExpression|number} [shadowSize=[41, 41]]
|
|
20
|
-
* @property {string} [imagePath] `DefaultIcon` will try to auto-detect the location of
|
|
21
|
-
* the blue icon images. If you are placing these images in a non-standard way, set this
|
|
22
|
-
* option to point to the right path.
|
|
23
31
|
* @extends IconOptions
|
|
24
32
|
*/
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
|
-
* A
|
|
28
|
-
*
|
|
29
|
-
*
|
|
35
|
+
* A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is
|
|
36
|
+
* specified, optionally in another `color`. The maple leaf marker and its shadow are
|
|
37
|
+
* inlined as SVG data URIs, so they work with any bundler and need no image files.
|
|
30
38
|
*
|
|
31
39
|
* In order to customize the default icon, just change the properties of
|
|
32
|
-
* `DefaultIcon.
|
|
40
|
+
* `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
|
|
33
41
|
*
|
|
34
42
|
* If you want to _completely_ replace the default icon, override the
|
|
35
|
-
* `Marker.
|
|
43
|
+
* `Marker.defaultOptions.icon` with your own icon instead.
|
|
36
44
|
*/
|
|
37
45
|
export class DefaultIcon extends Icon {
|
|
38
46
|
|
|
39
|
-
static {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}
|
|
47
|
+
static defaultOptions = {
|
|
48
|
+
iconUrl: /* @__PURE__ */ marker('%23C2331B', '%23E2603F', 1, '%238F2D20', '%23B23A27'),
|
|
49
|
+
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>',
|
|
50
|
+
iconSize: [25, 41],
|
|
51
|
+
iconAnchor: [12, 41],
|
|
52
|
+
popupAnchor: [1, -34],
|
|
53
|
+
tooltipAnchor: [16, -28],
|
|
54
|
+
shadowSize: [41, 41],
|
|
55
|
+
color: null
|
|
56
|
+
};
|
|
51
57
|
|
|
52
58
|
/**
|
|
53
59
|
* Creates the default icon, optionally with changed options.
|
|
@@ -58,38 +64,14 @@ export class DefaultIcon extends Icon {
|
|
|
58
64
|
this.callInitHooks(DefaultIcon);
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
/**
|
|
68
|
+
* @param {'icon'|'shadow'} name
|
|
69
|
+
* @returns {string|undefined}
|
|
70
|
+
*/
|
|
61
71
|
_getIconUrl(name) {
|
|
62
|
-
|
|
63
|
-
if (!
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const url = super._getIconUrl(name);
|
|
68
|
-
if (!url) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// see the `imagePath` option
|
|
73
|
-
return (this.options.imagePath ?? DefaultIcon.imagePath) + url;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
_stripUrl(path) { // separate function to use in tests
|
|
77
|
-
const strip = function (str, re, idx) {
|
|
78
|
-
const match = re.exec(str);
|
|
79
|
-
return match && match[idx];
|
|
80
|
-
};
|
|
81
|
-
path = strip(path, URL_RE, 2);
|
|
82
|
-
return path && strip(path, MARKER_ICON_RE, 1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
_detectIconPath() {
|
|
86
|
-
const el = DomUtil.create('div', 'maplair-default-icon-path', document.body);
|
|
87
|
-
const path = this._stripUrl(getComputedStyle(el).backgroundImage);
|
|
88
|
-
|
|
89
|
-
document.body.removeChild(el);
|
|
90
|
-
if (path) { return path; }
|
|
91
|
-
const link = document.querySelector('link[href$="maplair.css"]');
|
|
92
|
-
if (!link) { return ''; }
|
|
93
|
-
return link.href.substring(0, link.href.length - 'maplair.css'.length - 1);
|
|
72
|
+
const {color} = this.options;
|
|
73
|
+
if (!color || name !== 'icon') { return super._getIconUrl(name); }
|
|
74
|
+
const c = encodeURIComponent(color);
|
|
75
|
+
return marker(c, c, 0.75, c, c, '<use href="%23p" fill="none" stroke="%23666" stroke-opacity=".4"/>');
|
|
94
76
|
}
|
|
95
77
|
}
|
|
@@ -34,18 +34,16 @@ import {Point} from '../../geometry/Point.js';
|
|
|
34
34
|
*/
|
|
35
35
|
export class DivIcon extends Icon {
|
|
36
36
|
|
|
37
|
-
static {
|
|
38
|
-
|
|
39
|
-
iconSize: [12, 12], // also can be set through CSS
|
|
37
|
+
static defaultOptions = {
|
|
38
|
+
iconSize: [12, 12], // also can be set through CSS
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
// iconAnchor: (Point),
|
|
41
|
+
// popupAnchor: (Point),
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
43
|
+
html: false,
|
|
44
|
+
bgPos: null,
|
|
45
|
+
className: 'maplair-div-icon'
|
|
46
|
+
};
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
49
|
* Creates a `DivIcon` instance with the given options.
|
|
@@ -63,7 +61,7 @@ export class DivIcon extends Icon {
|
|
|
63
61
|
* @returns {HTMLElement}
|
|
64
62
|
*/
|
|
65
63
|
createIcon(oldIcon) {
|
|
66
|
-
const div =
|
|
64
|
+
const div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement('div'),
|
|
67
65
|
options = this.options;
|
|
68
66
|
|
|
69
67
|
if (options.html instanceof Element) {
|
package/src/layer/marker/Icon.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Class} from '../../core/Class.js';
|
|
2
2
|
import {setOptions} from '../../core/Util.js';
|
|
3
3
|
import {Point} from '../../geometry/Point.js';
|
|
4
|
-
import Browser from '../../core/Browser.js';
|
|
5
4
|
|
|
6
5
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
7
6
|
|
|
@@ -63,13 +62,11 @@ import Browser from '../../core/Browser.js';
|
|
|
63
62
|
*/
|
|
64
63
|
export class Icon extends Class {
|
|
65
64
|
|
|
66
|
-
static {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
65
|
+
static defaultOptions = {
|
|
66
|
+
popupAnchor: [0, 0],
|
|
67
|
+
tooltipAnchor: [0, 0],
|
|
68
|
+
crossOrigin: false
|
|
69
|
+
};
|
|
73
70
|
|
|
74
71
|
/**
|
|
75
72
|
* Creates an icon instance with the given options.
|
|
@@ -111,7 +108,7 @@ export class Icon extends Class {
|
|
|
111
108
|
return null;
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
const img = this._createImg(src, oldIcon
|
|
111
|
+
const img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);
|
|
115
112
|
this._setIconStyles(img, name);
|
|
116
113
|
|
|
117
114
|
if (this.options.crossOrigin || this.options.crossOrigin === '') {
|
|
@@ -140,6 +137,8 @@ export class Icon extends Class {
|
|
|
140
137
|
img.style.marginLeft = `${-anchor.x}px`;
|
|
141
138
|
img.style.marginTop = `${-anchor.y}px`;
|
|
142
139
|
}
|
|
140
|
+
// the origin of the marker rotation: the anchor, which is the top left corner without one
|
|
141
|
+
img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : '0 0';
|
|
143
142
|
|
|
144
143
|
if (size) {
|
|
145
144
|
img.style.width = `${size.x}px`;
|
|
@@ -154,6 +153,6 @@ export class Icon extends Class {
|
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
_getIconUrl(name) {
|
|
157
|
-
return
|
|
156
|
+
return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
|
|
158
157
|
}
|
|
159
158
|
}
|