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
|
@@ -43,11 +43,6 @@ export class BoxZoomHandler extends Handler {
|
|
|
43
43
|
*/
|
|
44
44
|
constructor(map) {
|
|
45
45
|
super(map);
|
|
46
|
-
this._container = map._container;
|
|
47
|
-
this._pane = map._panes.overlayPane;
|
|
48
|
-
this._resetStateTimeout = 0;
|
|
49
|
-
map.on('unload', this._destroy, this);
|
|
50
|
-
|
|
51
46
|
this.callInitHooks(BoxZoomHandler);
|
|
52
47
|
}
|
|
53
48
|
|
|
@@ -55,14 +50,14 @@ export class BoxZoomHandler extends Handler {
|
|
|
55
50
|
* Called when the handler is enabled, adds the event hooks.
|
|
56
51
|
*/
|
|
57
52
|
addHooks() {
|
|
58
|
-
DomEvent.on(this._container, 'pointerdown', this._onPointerDown, this);
|
|
53
|
+
DomEvent.on(this._map._container, 'pointerdown', this._onPointerDown, this);
|
|
59
54
|
}
|
|
60
55
|
|
|
61
56
|
/**
|
|
62
57
|
* Called when the handler is disabled, removes the event hooks.
|
|
63
58
|
*/
|
|
64
59
|
removeHooks() {
|
|
65
|
-
DomEvent.off(this._container, 'pointerdown', this._onPointerDown, this);
|
|
60
|
+
DomEvent.off(this._map._container, 'pointerdown', this._onPointerDown, this);
|
|
66
61
|
}
|
|
67
62
|
|
|
68
63
|
/**
|
|
@@ -73,29 +68,24 @@ export class BoxZoomHandler extends Handler {
|
|
|
73
68
|
return this._moved;
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
_destroy() {
|
|
77
|
-
this._pane.remove();
|
|
78
|
-
delete this._pane;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
71
|
_resetState() {
|
|
82
|
-
this._resetStateTimeout
|
|
72
|
+
clearTimeout(this._resetStateTimeout);
|
|
83
73
|
this._moved = false;
|
|
84
74
|
}
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this.
|
|
90
|
-
|
|
76
|
+
_toggleListeners(onOff) {
|
|
77
|
+
onOff(this._map._container, {
|
|
78
|
+
contextmenu: DomEvent.stop,
|
|
79
|
+
pointermove: this._onPointerMove,
|
|
80
|
+
pointerup: this._onPointerUp
|
|
81
|
+
}, this);
|
|
82
|
+
onOff(document, 'keydown', this._onKeyDown, this);
|
|
91
83
|
}
|
|
92
84
|
|
|
93
85
|
_onPointerDown(e) {
|
|
94
86
|
if (!e.shiftKey || (e.button !== 0)) { return false; }
|
|
95
87
|
|
|
96
|
-
//
|
|
97
|
-
// will interrupt the interaction and orphan a box element in the container.
|
|
98
|
-
this._clearDeferredResetState();
|
|
88
|
+
// also cancels a deferred reset that hasn't run yet, which would interrupt the interaction and orphan a box
|
|
99
89
|
this._resetState();
|
|
100
90
|
|
|
101
91
|
// stops both text selection and native image drag in every engine without restyling the page; it also
|
|
@@ -104,26 +94,22 @@ export class BoxZoomHandler extends Handler {
|
|
|
104
94
|
|
|
105
95
|
this._startPoint = this._map.pointerEventToContainerPoint(e);
|
|
106
96
|
|
|
107
|
-
DomEvent.on
|
|
108
|
-
contextmenu: DomEvent.stop,
|
|
109
|
-
pointermove: this._onPointerMove,
|
|
110
|
-
pointerup: this._onPointerUp,
|
|
111
|
-
keydown: this._onKeyDown
|
|
112
|
-
}, this);
|
|
113
|
-
DomEvent.on(document, 'keydown', this._onKeyDown, this);
|
|
97
|
+
this._toggleListeners(DomEvent.on);
|
|
114
98
|
}
|
|
115
99
|
|
|
116
100
|
_onPointerMove(e) {
|
|
101
|
+
const map = this._map;
|
|
102
|
+
|
|
117
103
|
if (!this._moved) {
|
|
118
104
|
this._moved = true;
|
|
119
105
|
|
|
120
|
-
this._box = DomUtil.create('div', 'maplair-zoom-box',
|
|
121
|
-
|
|
106
|
+
this._box = DomUtil.create('div', 'maplair-zoom-box', map._container);
|
|
107
|
+
map._container.classList.add('maplair-crosshair');
|
|
122
108
|
|
|
123
|
-
|
|
109
|
+
map.fire('boxzoomstart');
|
|
124
110
|
}
|
|
125
111
|
|
|
126
|
-
this._point =
|
|
112
|
+
this._point = map.pointerEventToContainerPoint(e);
|
|
127
113
|
|
|
128
114
|
const bounds = new Bounds(this._point, this._startPoint),
|
|
129
115
|
size = bounds.getSize();
|
|
@@ -137,15 +123,10 @@ export class BoxZoomHandler extends Handler {
|
|
|
137
123
|
_finish() {
|
|
138
124
|
if (this._moved) {
|
|
139
125
|
this._box.remove();
|
|
140
|
-
this._container.classList.remove('maplair-crosshair');
|
|
126
|
+
this._map._container.classList.remove('maplair-crosshair');
|
|
141
127
|
}
|
|
142
128
|
|
|
143
|
-
DomEvent.off
|
|
144
|
-
contextmenu: DomEvent.stop,
|
|
145
|
-
pointermove: this._onPointerMove,
|
|
146
|
-
pointerup: this._onPointerUp,
|
|
147
|
-
}, this);
|
|
148
|
-
DomEvent.off(document, 'keydown', this._onKeyDown, this);
|
|
129
|
+
this._toggleListeners(DomEvent.off);
|
|
149
130
|
}
|
|
150
131
|
|
|
151
132
|
_onPointerUp(e) {
|
|
@@ -156,8 +137,7 @@ export class BoxZoomHandler extends Handler {
|
|
|
156
137
|
if (!this._moved) { return; }
|
|
157
138
|
// Postpone to next JS tick so internal click event handling
|
|
158
139
|
// still see it as "moved".
|
|
159
|
-
this.
|
|
160
|
-
this._resetStateTimeout = setTimeout(this._resetState.bind(this), 0);
|
|
140
|
+
this._resetStateTimeout = setTimeout(() => this._resetState(), 0);
|
|
161
141
|
|
|
162
142
|
const bounds = new LatLngBounds(
|
|
163
143
|
this._map.containerPointToLatLng(this._startPoint),
|
|
@@ -175,7 +155,6 @@ export class BoxZoomHandler extends Handler {
|
|
|
175
155
|
_onKeyDown(e) {
|
|
176
156
|
if (e.code === 'Escape') {
|
|
177
157
|
this._finish();
|
|
178
|
-
this._clearDeferredResetState();
|
|
179
158
|
this._resetState();
|
|
180
159
|
}
|
|
181
160
|
}
|
|
@@ -57,10 +57,6 @@ export class KeyboardHandler extends Handler {
|
|
|
57
57
|
*/
|
|
58
58
|
constructor(map) {
|
|
59
59
|
super(map);
|
|
60
|
-
|
|
61
|
-
this._setPanDelta(map.options.keyboardPanDelta);
|
|
62
|
-
this._setZoomDelta(map.options.zoomDelta);
|
|
63
|
-
|
|
64
60
|
this.callInitHooks(KeyboardHandler);
|
|
65
61
|
}
|
|
66
62
|
|
|
@@ -85,12 +81,8 @@ export class KeyboardHandler extends Handler {
|
|
|
85
81
|
on(container, {
|
|
86
82
|
focus: this._onFocus,
|
|
87
83
|
blur: this._onBlur,
|
|
88
|
-
pointerdown: this._onPointerDown
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this._map.on({
|
|
92
|
-
focus: this._addHooks,
|
|
93
|
-
blur: this._removeHooks
|
|
84
|
+
pointerdown: this._onPointerDown,
|
|
85
|
+
keydown: this._onContainerKeyDown
|
|
94
86
|
}, this);
|
|
95
87
|
}
|
|
96
88
|
|
|
@@ -98,7 +90,7 @@ export class KeyboardHandler extends Handler {
|
|
|
98
90
|
* Called when the handler is disabled, removes the event hooks.
|
|
99
91
|
*/
|
|
100
92
|
removeHooks() {
|
|
101
|
-
this.
|
|
93
|
+
off(document, 'keydown', this._onKeyDown, this);
|
|
102
94
|
|
|
103
95
|
if (this._map.options.ariaKeyShortcuts) {
|
|
104
96
|
this._map._container.removeAttribute('aria-keyshortcuts');
|
|
@@ -107,12 +99,8 @@ export class KeyboardHandler extends Handler {
|
|
|
107
99
|
off(this._map._container, {
|
|
108
100
|
focus: this._onFocus,
|
|
109
101
|
blur: this._onBlur,
|
|
110
|
-
pointerdown: this._onPointerDown
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._map.off({
|
|
114
|
-
focus: this._addHooks,
|
|
115
|
-
blur: this._removeHooks
|
|
102
|
+
pointerdown: this._onPointerDown,
|
|
103
|
+
keydown: this._onContainerKeyDown
|
|
116
104
|
}, this);
|
|
117
105
|
|
|
118
106
|
this._help?.remove();
|
|
@@ -166,38 +154,34 @@ export class KeyboardHandler extends Handler {
|
|
|
166
154
|
|
|
167
155
|
_onFocus() {
|
|
168
156
|
this._focused = true;
|
|
157
|
+
on(document, 'keydown', this._onKeyDown, this);
|
|
169
158
|
this._map.fire('focus');
|
|
170
159
|
}
|
|
171
160
|
|
|
172
161
|
_onBlur() {
|
|
173
162
|
this._focused = false;
|
|
163
|
+
off(document, 'keydown', this._onKeyDown, this);
|
|
174
164
|
this._map.fire('blur');
|
|
175
165
|
}
|
|
176
166
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
167
|
+
// on the container rather than the document, so that Escape also works when focus is on a marker or
|
|
168
|
+
// inside the popup, which blurs the container and removes the document listener; controls are left
|
|
169
|
+
// out so that e.g. Escape in a geocoder input doesn't close an unrelated popup
|
|
170
|
+
_onContainerKeyDown(e) {
|
|
171
|
+
const map = this._map,
|
|
172
|
+
popup = map._popup;
|
|
180
173
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
for (const key of down) { panKeys[key] = [0, panDelta]; }
|
|
184
|
-
for (const key of up) { panKeys[key] = [0, -panDelta]; }
|
|
185
|
-
}
|
|
174
|
+
if (e.key !== 'Escape' || e.defaultPrevented || !popup?.options.closeOnEscapeKey ||
|
|
175
|
+
map._controlContainer?.contains(e.target)) { return; }
|
|
186
176
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
{zoomIn, zoomOut} = KeyboardHandler.keys;
|
|
177
|
+
const inPopup = popup._container.contains(e.target),
|
|
178
|
+
icon = popup._source?._icon;
|
|
190
179
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
180
|
+
map.closePopup();
|
|
181
|
+
e.preventDefault();
|
|
194
182
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
_removeHooks() {
|
|
200
|
-
off(document, 'keydown', this._onKeyDown, this);
|
|
183
|
+
// closing removes the focused element, which would send focus back to the start of the page
|
|
184
|
+
if (inPopup) { (icon?.tabIndex >= 0 ? icon : map._container).focus(); }
|
|
201
185
|
}
|
|
202
186
|
|
|
203
187
|
_onKeyDown(e) {
|
|
@@ -210,32 +194,29 @@ export class KeyboardHandler extends Handler {
|
|
|
210
194
|
}
|
|
211
195
|
|
|
212
196
|
const key = e.key,
|
|
213
|
-
map = this._map
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
197
|
+
map = this._map,
|
|
198
|
+
{left, right, down, up, zoomIn, zoomOut} = KeyboardHandler.keys,
|
|
199
|
+
x = +right.includes(key) - +left.includes(key),
|
|
200
|
+
y = +down.includes(key) - +up.includes(key),
|
|
201
|
+
dz = +zoomIn.includes(key) - +zoomOut.includes(key),
|
|
202
|
+
k = e.shiftKey ? 3 : 1;
|
|
203
|
+
|
|
204
|
+
if (x || y) {
|
|
205
|
+
if (!map._panAnim?._inProgress) {
|
|
206
|
+
let offset = new Point(x, y).multiplyBy(k * map.options.keyboardPanDelta);
|
|
223
207
|
if (map.options.maxBounds) {
|
|
224
|
-
offset = map._limitOffset(
|
|
208
|
+
offset = map._limitOffset(offset, map.options.maxBounds);
|
|
225
209
|
}
|
|
226
210
|
|
|
227
211
|
map._setUserEvent(e);
|
|
228
212
|
map.panBy(offset);
|
|
229
213
|
}
|
|
230
|
-
} else if (
|
|
214
|
+
} else if (dz) {
|
|
231
215
|
if (!map._zoomInputBlocked()) {
|
|
232
216
|
map._setUserEvent(e);
|
|
233
|
-
map.setZoom(map.getZoom() +
|
|
217
|
+
map.setZoom(map.getZoom() + k * dz * map.options.zoomDelta);
|
|
234
218
|
}
|
|
235
219
|
|
|
236
|
-
} else if (key === 'Escape' && map._popup && map._popup.options.closeOnEscapeKey) {
|
|
237
|
-
map.closePopup();
|
|
238
|
-
|
|
239
220
|
} else {
|
|
240
221
|
return;
|
|
241
222
|
}
|
package/src/maplair.css
CHANGED
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
position: absolute;
|
|
68
68
|
left: 0;
|
|
69
69
|
top: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* gives popups room to grow to their max-width; not set on icons and layers, which are sized by JS or content */
|
|
73
|
+
.maplair-pane {
|
|
70
74
|
width: 100%;
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -108,6 +112,7 @@
|
|
|
108
112
|
|
|
109
113
|
.maplair-container {
|
|
110
114
|
overflow: hidden;
|
|
115
|
+
isolation: isolate;
|
|
111
116
|
|
|
112
117
|
.maplair-overlay-pane svg {
|
|
113
118
|
max-width: none !important;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Projection.LonLat.js","names":[],"sources":["../../../../src/geo/projection/Projection.LonLat.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Projection} from './index.js' */\n\n/**\n * Equirectangular, or Plate Carree projection — the most simple projection,\n * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as\n * latitude. Also suitable for flat worlds, e.g. game maps. Used by the\n * `EPSG4326` and `SimpleCRS` CRS.\n * @type {Projection}\n */\nexport const LonLat = {\n\tproject(latlng) {\n\t\tlatlng = LatLng.from(latlng);\n\t\treturn new Point(latlng.lng, latlng.lat);\n\t},\n\n\tunproject(point) {\n\t\tpoint = Point.from(point);\n\t\treturn new LatLng(point.y, point.x);\n\t},\n\n\tbounds: /* @__PURE__ */ new Bounds([-180, -90], [180, 90])\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,SAAS;CACrB,QAAQ,QAAQ;EACf,SAAS,OAAO,KAAK,MAAM;EAC3B,OAAO,IAAI,MAAM,OAAO,KAAK,OAAO,GAAG;CACxC;CAEA,UAAU,OAAO;EAChB,QAAQ,MAAM,KAAK,KAAK;EACxB,OAAO,IAAI,OAAO,MAAM,GAAG,MAAM,CAAC;CACnC;CAEA,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;AAC1D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Projection.Mercator.js","names":[],"sources":["../../../../src/geo/projection/Projection.Mercator.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Projection} from './index.js' */\n\nconst earthRadius = 6378137;\n\n/**\n * Elliptical Mercator projection — more complex than Spherical Mercator. Assumes that\n * Earth is an ellipsoid. Used by the EPSG:3395 CRS.\n * @type {Projection & {R: number, R_MINOR: number}}\n */\nexport const Mercator = {\n\tR: earthRadius,\n\tR_MINOR: 6356752.314245179,\n\n\tbounds: /* @__PURE__ */ new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),\n\n\tproject(latlng) {\n\t\tlatlng = LatLng.from(latlng);\n\t\tconst d = Math.PI / 180,\n\t\tr = this.R,\n\t\ttmp = this.R_MINOR / r,\n\t\te = Math.sqrt(1 - tmp * tmp);\n\t\tlet y = latlng.lat * d;\n\t\tconst con = e * Math.sin(y);\n\n\t\tconst ts = Math.tan(Math.PI / 4 - y / 2) / ((1 - con) / (1 + con)) ** (e / 2);\n\t\ty = -r * Math.log(Math.max(ts, 1E-10));\n\n\t\treturn new Point(latlng.lng * d * r, y);\n\t},\n\n\tunproject(point) {\n\t\tpoint = Point.from(point);\n\t\tconst d = 180 / Math.PI,\n\t\tr = this.R,\n\t\ttmp = this.R_MINOR / r,\n\t\te = Math.sqrt(1 - tmp * tmp),\n\t\tts = Math.exp(-point.y / r);\n\t\tlet phi = Math.PI / 2 - 2 * Math.atan(ts);\n\n\t\tfor (let i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {\n\t\t\tcon = e * Math.sin(phi);\n\t\t\tcon = ((1 - con) / (1 + con)) ** (e / 2);\n\t\t\tdphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi;\n\t\t\tphi += dphi;\n\t\t}\n\n\t\treturn new LatLng(phi * d, point.x * d / r);\n\t}\n};\n"],"mappings":";;;;;;;;AAaA,MAAa,WAAW;CACvB,GAAG;CACH,SAAS;CAET,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,eAAe,GAAG,CAAC,gBAAgB,cAAc,CAAC;CAEvG,QAAQ,QAAQ;EACf,SAAS,OAAO,KAAK,MAAM;EAC3B,MAAM,IAAI,KAAK,KAAK,KACpB,IAAI,KAAK,GACT,MAAM,KAAK,UAAU,GACrB,IAAI,KAAK,KAAK,IAAI,MAAM,GAAG;EAC3B,IAAI,IAAI,OAAO,MAAM;EACrB,MAAM,MAAM,IAAI,KAAK,IAAI,CAAC;EAE1B,MAAM,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,IAAI,UAAU,IAAI;EAC3E,IAAI,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC;EAErC,OAAO,IAAI,MAAM,OAAO,MAAM,IAAI,GAAG,CAAC;CACvC;CAEA,UAAU,OAAO;EAChB,QAAQ,MAAM,KAAK,KAAK;EACxB,MAAM,IAAI,MAAM,KAAK,IACrB,IAAI,KAAK,GACT,MAAM,KAAK,UAAU,GACrB,IAAI,KAAK,KAAK,IAAI,MAAM,GAAG,GAC3B,KAAK,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC;EAC1B,IAAI,MAAM,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;EAExC,KAAK,IAAI,IAAI,GAAG,OAAO,IAAK,KAAK,IAAI,MAAM,KAAK,IAAI,IAAI,IAAI,MAAM,KAAK;GACtE,MAAM,IAAI,KAAK,IAAI,GAAG;GACtB,QAAQ,IAAI,QAAQ,IAAI,UAAU,IAAI;GACtC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,GAAG,IAAI;GAC/C,OAAO;EACR;EAEA,OAAO,IAAI,OAAO,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC;CAC3C;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Projection.SphericalMercator.js","names":[],"sources":["../../../../src/geo/projection/Projection.SphericalMercator.js"],"sourcesContent":["import {LatLng} from '../LatLng.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Projection} from './index.js' */\n\nconst earthRadius = 6378137;\n\n/**\n * Spherical Mercator projection — the most common projection for online maps,\n * used by almost all free and commercial tile providers. Assumes that Earth is\n * a sphere. Used by the `EPSG:3857` CRS.\n * @type {Projection & {R: number, MAX_LATITUDE: number}}\n */\nexport const SphericalMercator = {\n\n\tR: earthRadius,\n\tMAX_LATITUDE: 85.0511287798,\n\n\tproject(latlng) {\n\t\tlatlng = LatLng.from(latlng);\n\t\tconst d = Math.PI / 180,\n\t\tmax = this.MAX_LATITUDE,\n\t\tlat = Math.max(Math.min(max, latlng.lat), -max),\n\t\tsin = Math.sin(lat * d);\n\n\t\treturn new Point(\n\t\t\tthis.R * latlng.lng * d,\n\t\t\tthis.R * Math.log((1 + sin) / (1 - sin)) / 2);\n\t},\n\n\tunproject(point) {\n\t\tpoint = Point.from(point);\n\t\tconst d = 180 / Math.PI;\n\n\t\treturn new LatLng(\n\t\t\t(2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,\n\t\t\tpoint.x * d / this.R);\n\t},\n\n\tbounds: /* @__PURE__ */ (() => {\n\t\tconst d = earthRadius * Math.PI;\n\t\treturn new Bounds([-d, -d], [d, d]);\n\t})()\n};\n"],"mappings":";;;;;AAMA,MAAM,cAAc;;;;;;;AAQpB,MAAa,oBAAoB;CAEhC,GAAG;CACH,cAAc;CAEd,QAAQ,QAAQ;EACf,SAAS,OAAO,KAAK,MAAM;EAC3B,MAAM,IAAI,KAAK,KAAK,KACpB,MAAM,KAAK,cACX,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,OAAO,GAAG,GAAG,CAAC,GAAG,GAC9C,MAAM,KAAK,IAAI,MAAM,CAAC;EAEtB,OAAO,IAAI,MACV,KAAK,IAAI,OAAO,MAAM,GACtB,KAAK,IAAI,KAAK,KAAK,IAAI,QAAQ,IAAI,IAAI,IAAI,CAAC;CAC9C;CAEA,UAAU,OAAO;EAChB,QAAQ,MAAM,KAAK,KAAK;EACxB,MAAM,IAAI,MAAM,KAAK;EAErB,OAAO,IAAI,QACT,IAAI,KAAK,KAAK,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,IAAK,KAAK,KAAK,KAAM,GAC9D,MAAM,IAAI,IAAI,KAAK,CAAC;CACtB;CAEA,QAAwB,uBAAO;EAC9B,MAAM,IAAI,cAAc,KAAK;EAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnC,EAAA,CAAG;AACJ"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { SphericalMercator } from "./Projection.SphericalMercator.js";
|
|
3
|
-
import { LonLat } from "./Projection.LonLat.js";
|
|
4
|
-
import { Mercator } from "./Projection.Mercator.js";
|
|
5
|
-
//#region src/geo/projection/index.js
|
|
6
|
-
var projection_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
-
LonLat: () => LonLat,
|
|
8
|
-
Mercator: () => Mercator,
|
|
9
|
-
SphericalMercator: () => SphericalMercator
|
|
10
|
-
});
|
|
11
|
-
//#endregion
|
|
12
|
-
export { LonLat, Mercator, SphericalMercator, projection_exports };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/geo/projection/index.js"],"sourcesContent":["/** @import {Bounds} from '../../geometry/Bounds.js' */\n/** @import {Point} from '../../geometry/Point.js' */\n/** @import {LatLng} from '../LatLng.js' */\n\n/**\n * An object with methods for projecting geographical coordinates of the world onto\n * a flat surface (and back). See [Map projection](https://en.wikipedia.org/wiki/Map_projection).\n *\n * Maplair comes with a set of already defined projections out of the box: `LonLat`,\n * `Mercator` and `SphericalMercator` (in the `Projection` namespace).\n *\n * Note that the projection instances do not inherit from Maplair's `Class` object,\n * and can't be instantiated. Also, new classes can't inherit from them,\n * and methods can't be added to them with the `include` function.\n *\n * @typedef {object} Projection\n * @property {Bounds} bounds The bounds (specified in CRS units) where the projection is\n * valid.\n * @property {(latlng: LatLng) => Point} project Projects geographical coordinates into\n * a 2D point. Only accepts actual `LatLng` instances, not arrays.\n * @property {(point: Point) => LatLng} unproject The inverse of `project`. Projects a\n * 2D point into a geographical location. Only accepts actual `Point` instances, not\n * arrays.\n */\n\nexport {LonLat} from './Projection.LonLat.js';\nexport {Mercator} from './Projection.Mercator.js';\nexport {SphericalMercator} from './Projection.SphericalMercator.js';\n"],"mappings":""}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { MarkerDrag } from "./Marker.Drag.js";
|
|
2
|
-
import { Marker } from "./Marker.js";
|
|
3
|
-
//#region src/layer/marker/Marker.Rotation.js
|
|
4
|
-
const { _setPos: setPos } = Marker.prototype, { _onDrag: onDrag } = MarkerDrag.prototype;
|
|
5
|
-
/**
|
|
6
|
-
* Options of `Marker` for the rotation of marker icons, see the
|
|
7
|
-
* [marker rotation](#marker-setrotationangle).
|
|
8
|
-
* @typedef {object} MarkerRotationOptions
|
|
9
|
-
* @lends MarkerOptions
|
|
10
|
-
* @property {number} [rotationAngle=0] Rotation of the icon in degrees, clockwise, e.g.
|
|
11
|
-
* for the heading of a vehicle. On a rotated map, the angle is relative to the screen,
|
|
12
|
-
* or to north with `rotateWithView`. The shadow is not rotated.
|
|
13
|
-
* @property {string} [rotationOrigin] The CSS
|
|
14
|
-
* [`transform-origin`](https://developer.mozilla.org/docs/Web/CSS/transform-origin) to
|
|
15
|
-
* rotate the icon around, e.g. `'center'`. By default the anchor of the icon.
|
|
16
|
-
* @property {boolean} [rotateWithView=false] On a rotated map (see
|
|
17
|
-
* `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
|
|
18
|
-
* pointing in a geographic direction) instead of staying upright.
|
|
19
|
-
*/
|
|
20
|
-
Marker.include({ options: {
|
|
21
|
-
rotationAngle: 0,
|
|
22
|
-
rotationOrigin: void 0,
|
|
23
|
-
rotateWithView: false
|
|
24
|
-
} });
|
|
25
|
-
/** @typedef {typeof markerRotationMethods} MarkerRotationMethods */
|
|
26
|
-
Marker.include({
|
|
27
|
-
/**
|
|
28
|
-
* Changes the [`rotationAngle`](#markeroptions-rotationangle) of the icon.
|
|
29
|
-
* @group Marker rotation
|
|
30
|
-
* @param {number} angle
|
|
31
|
-
* @returns {this}
|
|
32
|
-
*/
|
|
33
|
-
setRotationAngle(angle) {
|
|
34
|
-
this.options.rotationAngle = angle;
|
|
35
|
-
return this.update();
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Changes the [`rotationOrigin`](#markeroptions-rotationorigin) of the icon.
|
|
39
|
-
* @group Marker rotation
|
|
40
|
-
* @param {string} origin
|
|
41
|
-
* @returns {this}
|
|
42
|
-
*/
|
|
43
|
-
setRotationOrigin(origin) {
|
|
44
|
-
this.options.rotationOrigin = origin;
|
|
45
|
-
return this.update();
|
|
46
|
-
},
|
|
47
|
-
_setPos(pos) {
|
|
48
|
-
setPos.call(this, pos);
|
|
49
|
-
this._rotateIcon();
|
|
50
|
-
},
|
|
51
|
-
_rotateIcon() {
|
|
52
|
-
const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing?.() ?? 0;
|
|
53
|
-
this._rotateElement(this._icon, bearing + (this.options.rotationAngle || 0), this.options.rotationOrigin);
|
|
54
|
-
this._rotateElement(this._shadow, bearing);
|
|
55
|
-
},
|
|
56
|
-
_rotateElement(el, angle, origin) {
|
|
57
|
-
if (!el) return;
|
|
58
|
-
if (angle % 360) {
|
|
59
|
-
el.style.transform += ` rotate(${angle}deg)`;
|
|
60
|
-
el.style.transformOrigin = origin ?? `${-parseFloat(el.style.marginLeft) || 0}px ${-parseFloat(el.style.marginTop) || 0}px`;
|
|
61
|
-
} else if (el.style.transformOrigin) el.style.transformOrigin = "";
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
MarkerDrag.include({ _onDrag(e) {
|
|
65
|
-
onDrag.call(this, e);
|
|
66
|
-
this._marker._rotateIcon();
|
|
67
|
-
} });
|
|
68
|
-
//#endregion
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=Marker.Rotation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.Rotation.js","names":[],"sources":["../../../../src/layer/marker/Marker.Rotation.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {MarkerDrag} from './Marker.Drag.js';\n\n// The methods extended below\nconst {_setPos: setPos} = Marker.prototype,\n{_onDrag: onDrag} = MarkerDrag.prototype;\n\n/**\n * Options of `Marker` for the rotation of marker icons, see the\n * [marker rotation](#marker-setrotationangle).\n * @typedef {object} MarkerRotationOptions\n * @lends MarkerOptions\n * @property {number} [rotationAngle=0] Rotation of the icon in degrees, clockwise, e.g.\n * for the heading of a vehicle. On a rotated map, the angle is relative to the screen,\n * or to north with `rotateWithView`. The shadow is not rotated.\n * @property {string} [rotationOrigin] The CSS\n * [`transform-origin`](https://developer.mozilla.org/docs/Web/CSS/transform-origin) to\n * rotate the icon around, e.g. `'center'`. By default the anchor of the icon.\n * @property {boolean} [rotateWithView=false] On a rotated map (see\n * `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows\n * pointing in a geographic direction) instead of staying upright.\n */\nMarker.include({\n\toptions: {\n\t\trotationAngle: 0,\n\t\trotationOrigin: undefined,\n\t\trotateWithView: false\n\t}\n});\n\n/**\n * Methods of `Marker` for the rotation of marker icons, an optional feature: import\n * this module to add the `rotationAngle`, `rotationOrigin` and `rotateWithView` options\n * and `setRotationAngle()`/`setRotationOrigin()` to `Marker` (it is also part of the\n * map rotation, see `MaplairMap.setBearing()`).\n *\n * ```js\n * import 'maplair/marker-rotation';\n *\n * new Marker([47.27, 11.40], {rotationAngle: 45}).addTo(map);\n * ```\n *\n * Inspired by the [Leaflet.RotatedMarker](https://github.com/bbecquet/Leaflet.RotatedMarker) plugin.\n * @lends Marker.prototype\n */\nconst markerRotationMethods = {\n\t/**\n\t * Changes the [`rotationAngle`](#markeroptions-rotationangle) of the icon.\n\t * @group Marker rotation\n\t * @param {number} angle\n\t * @returns {this}\n\t */\n\tsetRotationAngle(angle) {\n\t\tthis.options.rotationAngle = angle;\n\t\treturn this.update();\n\t},\n\n\t/**\n\t * Changes the [`rotationOrigin`](#markeroptions-rotationorigin) of the icon.\n\t * @group Marker rotation\n\t * @param {string} origin\n\t * @returns {this}\n\t */\n\tsetRotationOrigin(origin) {\n\t\tthis.options.rotationOrigin = origin;\n\t\treturn this.update();\n\t},\n\n\t_setPos(pos) {\n\t\tsetPos.call(this, pos);\n\t\tthis._rotateIcon();\n\t},\n\n\t// Rotates the icon by the `rotationAngle`, and keeps the icon and the shadow\n\t// upright on a rotated map\n\t_rotateIcon() {\n\t\tconst bearing = this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0);\n\t\tthis._rotateElement(this._icon, bearing + (this.options.rotationAngle || 0), this.options.rotationOrigin);\n\t\tthis._rotateElement(this._shadow, bearing);\n\t},\n\n\t// Rotates an element positioned with `DomUtil.setPosition()` around its anchor (or `origin`)\n\t_rotateElement(el, angle, origin) {\n\t\tif (!el) { return; }\n\t\tif (angle % 360) {\n\t\t\tel.style.transform += ` rotate(${angle}deg)`;\n\t\t\tel.style.transformOrigin = origin ?? `${-parseFloat(el.style.marginLeft) || 0}px ${-parseFloat(el.style.marginTop) || 0}px`;\n\t\t} else if (el.style.transformOrigin) {\n\t\t\tel.style.transformOrigin = '';\n\t\t}\n\t}\n};\n/** @typedef {typeof markerRotationMethods} MarkerRotationMethods */\n\nMarker.include(markerRotationMethods);\n\nMarkerDrag.include({\n\t_onDrag(e) {\n\t\tonDrag.call(this, e);\n\t\t// dragging positions the icon without the rotation\n\t\tthis._marker._rotateIcon();\n\t}\n});\n"],"mappings":";;;AAIA,MAAM,EAAC,SAAS,WAAU,OAAO,WACjC,EAAC,SAAS,WAAU,WAAW;;;;;;;;;;;;;;;;AAiB/B,OAAO,QAAQ,EACd,SAAS;CACR,eAAe;CACf,gBAAgB,KAAA;CAChB,gBAAgB;AACjB,EACD,CAAC;;AAkED,OAAO,QAAQ;;;;;;;CA1Cd,iBAAiB,OAAO;EACvB,KAAK,QAAQ,gBAAgB;EAC7B,OAAO,KAAK,OAAO;CACpB;;;;;;;CAQA,kBAAkB,QAAQ;EACzB,KAAK,QAAQ,iBAAiB;EAC9B,OAAO,KAAK,OAAO;CACpB;CAEA,QAAQ,KAAK;EACZ,OAAO,KAAK,MAAM,GAAG;EACrB,KAAK,YAAY;CAClB;CAIA,cAAc;EACb,MAAM,UAAU,KAAK,QAAQ,iBAAiB,IAAK,KAAK,MAAM,aAAa,KAAK;EAChF,KAAK,eAAe,KAAK,OAAO,WAAW,KAAK,QAAQ,iBAAiB,IAAI,KAAK,QAAQ,cAAc;EACxG,KAAK,eAAe,KAAK,SAAS,OAAO;CAC1C;CAGA,eAAe,IAAI,OAAO,QAAQ;EACjC,IAAI,CAAC,IAAM;EACX,IAAI,QAAQ,KAAK;GAChB,GAAG,MAAM,aAAa,WAAW,MAAM;GACvC,GAAG,MAAM,kBAAkB,UAAU,GAAG,CAAC,WAAW,GAAG,MAAM,UAAU,KAAK,EAAE,KAAK,CAAC,WAAW,GAAG,MAAM,SAAS,KAAK,EAAE;EACzH,OAAO,IAAI,GAAG,MAAM,iBACnB,GAAG,MAAM,kBAAkB;CAE7B;AAIkC,CAAC;AAEpC,WAAW,QAAQ,EAClB,QAAQ,GAAG;CACV,OAAO,KAAK,MAAM,CAAC;CAEnB,KAAK,QAAQ,YAAY;AAC1B,EACD,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {Marker} from './Marker.js';
|
|
2
|
-
import {MarkerDrag} from './Marker.Drag.js';
|
|
3
|
-
|
|
4
|
-
// The methods extended below
|
|
5
|
-
const {_setPos: setPos} = Marker.prototype,
|
|
6
|
-
{_onDrag: onDrag} = MarkerDrag.prototype;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Options of `Marker` for the rotation of marker icons, see the
|
|
10
|
-
* [marker rotation](#marker-setrotationangle).
|
|
11
|
-
* @typedef {object} MarkerRotationOptions
|
|
12
|
-
* @lends MarkerOptions
|
|
13
|
-
* @property {number} [rotationAngle=0] Rotation of the icon in degrees, clockwise, e.g.
|
|
14
|
-
* for the heading of a vehicle. On a rotated map, the angle is relative to the screen,
|
|
15
|
-
* or to north with `rotateWithView`. The shadow is not rotated.
|
|
16
|
-
* @property {string} [rotationOrigin] The CSS
|
|
17
|
-
* [`transform-origin`](https://developer.mozilla.org/docs/Web/CSS/transform-origin) to
|
|
18
|
-
* rotate the icon around, e.g. `'center'`. By default the anchor of the icon.
|
|
19
|
-
* @property {boolean} [rotateWithView=false] On a rotated map (see
|
|
20
|
-
* `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
|
|
21
|
-
* pointing in a geographic direction) instead of staying upright.
|
|
22
|
-
*/
|
|
23
|
-
Marker.include({
|
|
24
|
-
options: {
|
|
25
|
-
rotationAngle: 0,
|
|
26
|
-
rotationOrigin: undefined,
|
|
27
|
-
rotateWithView: false
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Methods of `Marker` for the rotation of marker icons, an optional feature: import
|
|
33
|
-
* this module to add the `rotationAngle`, `rotationOrigin` and `rotateWithView` options
|
|
34
|
-
* and `setRotationAngle()`/`setRotationOrigin()` to `Marker` (it is also part of the
|
|
35
|
-
* map rotation, see `MaplairMap.setBearing()`).
|
|
36
|
-
*
|
|
37
|
-
* ```js
|
|
38
|
-
* import 'maplair/marker-rotation';
|
|
39
|
-
*
|
|
40
|
-
* new Marker([47.27, 11.40], {rotationAngle: 45}).addTo(map);
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* Inspired by the [Leaflet.RotatedMarker](https://github.com/bbecquet/Leaflet.RotatedMarker) plugin.
|
|
44
|
-
* @lends Marker.prototype
|
|
45
|
-
*/
|
|
46
|
-
const markerRotationMethods = {
|
|
47
|
-
/**
|
|
48
|
-
* Changes the [`rotationAngle`](#markeroptions-rotationangle) of the icon.
|
|
49
|
-
* @group Marker rotation
|
|
50
|
-
* @param {number} angle
|
|
51
|
-
* @returns {this}
|
|
52
|
-
*/
|
|
53
|
-
setRotationAngle(angle) {
|
|
54
|
-
this.options.rotationAngle = angle;
|
|
55
|
-
return this.update();
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Changes the [`rotationOrigin`](#markeroptions-rotationorigin) of the icon.
|
|
60
|
-
* @group Marker rotation
|
|
61
|
-
* @param {string} origin
|
|
62
|
-
* @returns {this}
|
|
63
|
-
*/
|
|
64
|
-
setRotationOrigin(origin) {
|
|
65
|
-
this.options.rotationOrigin = origin;
|
|
66
|
-
return this.update();
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
_setPos(pos) {
|
|
70
|
-
setPos.call(this, pos);
|
|
71
|
-
this._rotateIcon();
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// Rotates the icon by the `rotationAngle`, and keeps the icon and the shadow
|
|
75
|
-
// upright on a rotated map
|
|
76
|
-
_rotateIcon() {
|
|
77
|
-
const bearing = this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0);
|
|
78
|
-
this._rotateElement(this._icon, bearing + (this.options.rotationAngle || 0), this.options.rotationOrigin);
|
|
79
|
-
this._rotateElement(this._shadow, bearing);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
// Rotates an element positioned with `DomUtil.setPosition()` around its anchor (or `origin`)
|
|
83
|
-
_rotateElement(el, angle, origin) {
|
|
84
|
-
if (!el) { return; }
|
|
85
|
-
if (angle % 360) {
|
|
86
|
-
el.style.transform += ` rotate(${angle}deg)`;
|
|
87
|
-
el.style.transformOrigin = origin ?? `${-parseFloat(el.style.marginLeft) || 0}px ${-parseFloat(el.style.marginTop) || 0}px`;
|
|
88
|
-
} else if (el.style.transformOrigin) {
|
|
89
|
-
el.style.transformOrigin = '';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
/** @typedef {typeof markerRotationMethods} MarkerRotationMethods */
|
|
94
|
-
|
|
95
|
-
Marker.include(markerRotationMethods);
|
|
96
|
-
|
|
97
|
-
MarkerDrag.include({
|
|
98
|
-
_onDrag(e) {
|
|
99
|
-
onDrag.call(this, e);
|
|
100
|
-
// dragging positions the icon without the rotation
|
|
101
|
-
this._marker._rotateIcon();
|
|
102
|
-
}
|
|
103
|
-
});
|