leaflet-rotate 0.3.0 → 0.4.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/README.md +1 -1
- package/build/test.js +18 -0
- package/dist/leaflet-rotate-src.js +261 -216
- package/dist/leaflet-rotate-src.js.map +3 -3
- package/dist/leaflet-rotate.js +1 -1
- package/dist/leaflet-rotate.js.map +3 -3
- package/lib/debug.js +84 -66
- package/lib/debug.min.js +1 -1
- package/misc/leaflet-heat-rotate.js +7 -7
- package/misc/loremIpsum.js +1 -1
- package/misc/places.js +1 -1
- package/misc/route.js +1 -1
- package/package.json +5 -5
- package/src/control/Rotate.js +20 -24
- package/src/dom/DomUtil.js +31 -47
- package/src/dom/Draggable.js +1 -1
- package/src/geometry/Point.js +16 -7
- package/src/layer/DivOverlay.js +10 -8
- package/src/layer/Popup.js +15 -13
- package/src/layer/Tooltip.js +5 -5
- package/src/layer/marker/Icon.js +8 -8
- package/src/layer/marker/Marker.js +18 -18
- package/src/layer/tile/GridLayer.js +4 -4
- package/src/layer/vector/Renderer.js +47 -7
- package/src/map/Map.js +71 -66
- package/src/map/handler/CompassBearing.js +6 -6
- package/src/map/handler/ContainerMutation.js +2 -2
- package/src/map/handler/ShiftKeyRotate.js +4 -4
- package/src/map/handler/TouchGestures.js +29 -23
- package/src/map/handler/TouchRotate.js +2 -2
- package/src/map/handler/TouchZoom.js +4 -4
- package/test/features/example.feature +5 -0
- package/test/index.html +59 -22
- package/test/steps/bearing.steps.js +3 -3
- package/test/steps/example.steps.js +72 -11
- package/test/steps/gestures.steps.js +4 -4
- package/test/steps/overlays.steps.js +32 -32
- package/test/support/hooks.js +50 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leaflet-rotate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A Leaflet plugin that allows to add rotation functionality to map tiles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/leaflet-rotate.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "node build/dev.js",
|
|
11
11
|
"build": "node build/build.js",
|
|
12
|
-
"test": "
|
|
12
|
+
"test": "node build/test.js",
|
|
13
13
|
"version": "npm run build && git add -A dist"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"url": "https://github.com/Raruto/leaflet-rotate/issues"
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/Raruto/leaflet-rotate#readme",
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"leaflet": "^1.9.3 || ^2.0.0-alpha.1"
|
|
51
|
+
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@cucumber/cucumber": "^10.3.1",
|
|
51
54
|
"esbuild": "^0.28.2",
|
|
52
55
|
"playwright": "^1.64.1"
|
|
53
|
-
},
|
|
54
|
-
"peerDependencies": {
|
|
55
|
-
"leaflet": "^1.9.3"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/control/Rotate.js
CHANGED
|
@@ -15,12 +15,12 @@ L.Control.Rotate = L.Control.extend({
|
|
|
15
15
|
closeOnZeroBearing: true
|
|
16
16
|
},
|
|
17
17
|
|
|
18
|
-
onAdd
|
|
19
|
-
|
|
18
|
+
onAdd(map) {
|
|
19
|
+
const container = this._container = L.DomUtil.create('div', 'leaflet-control-rotate leaflet-bar');
|
|
20
20
|
|
|
21
21
|
// this.button = L.Control.Zoom.prototype._createButton.call(this, 'R', 'leaflet-control-rotate', 'leaflet-control-rotate', container, this._toggleLock);
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const arrow = this._arrow = L.DomUtil.create('span', 'leaflet-control-rotate-arrow');
|
|
24
24
|
|
|
25
25
|
arrow.style.backgroundImage = `url("data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")`;
|
|
26
26
|
arrow.style.cursor = 'grab';
|
|
@@ -31,7 +31,7 @@ L.Control.Rotate = L.Control.extend({
|
|
|
31
31
|
arrow.style.backgroundPosition = '50%';
|
|
32
32
|
|
|
33
33
|
// Copy-pasted from L.Control.Zoom
|
|
34
|
-
|
|
34
|
+
const link = this._link = L.DomUtil.create('a', 'leaflet-control-rotate-toggle', container);
|
|
35
35
|
link.appendChild(arrow);
|
|
36
36
|
link.href = '#';
|
|
37
37
|
link.title = 'Rotate map';
|
|
@@ -43,10 +43,6 @@ L.Control.Rotate = L.Control.extend({
|
|
|
43
43
|
.on(link, 'click', this._cycleState, this)
|
|
44
44
|
.on(link, 'click', this._refocusOnMap, this);
|
|
45
45
|
|
|
46
|
-
if (!L.Browser.any3d) {
|
|
47
|
-
L.DomUtil.addClass(link, 'leaflet-disabled');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
this._restyle();
|
|
51
47
|
|
|
52
48
|
map.on('rotate', this._restyle, this);
|
|
@@ -62,11 +58,11 @@ L.Control.Rotate = L.Control.extend({
|
|
|
62
58
|
return container;
|
|
63
59
|
},
|
|
64
60
|
|
|
65
|
-
onRemove
|
|
61
|
+
onRemove(map) {
|
|
66
62
|
map.off('rotate', this._restyle, this);
|
|
67
63
|
},
|
|
68
64
|
|
|
69
|
-
_handleMouseDown
|
|
65
|
+
_handleMouseDown(e) {
|
|
70
66
|
L.DomEvent.stop(e);
|
|
71
67
|
this.dragging = true;
|
|
72
68
|
this.dragstartX = e.pageX;
|
|
@@ -76,7 +72,7 @@ L.Control.Rotate = L.Control.extend({
|
|
|
76
72
|
.on(document, 'mouseup', this._handleMouseUp, this);
|
|
77
73
|
},
|
|
78
74
|
|
|
79
|
-
_handleMouseUp
|
|
75
|
+
_handleMouseUp(e) {
|
|
80
76
|
L.DomEvent.stop(e);
|
|
81
77
|
this.dragging = false;
|
|
82
78
|
|
|
@@ -85,18 +81,18 @@ L.Control.Rotate = L.Control.extend({
|
|
|
85
81
|
.off(document, 'mouseup', this._handleMouseUp, this);
|
|
86
82
|
},
|
|
87
83
|
|
|
88
|
-
_handleMouseDrag
|
|
84
|
+
_handleMouseDrag(e) {
|
|
89
85
|
if (!this.dragging) { return; }
|
|
90
|
-
|
|
86
|
+
const deltaX = e.clientX - this.dragstartX;
|
|
91
87
|
this._map.setBearing(deltaX);
|
|
92
88
|
},
|
|
93
89
|
|
|
94
|
-
_cycleState
|
|
90
|
+
_cycleState(ev) {
|
|
95
91
|
if (!this._map) {
|
|
96
92
|
return;
|
|
97
93
|
}
|
|
98
94
|
|
|
99
|
-
|
|
95
|
+
const map = this._map;
|
|
100
96
|
|
|
101
97
|
// Touch mode
|
|
102
98
|
if (!map.touchRotate.enabled() && !map.compassBearing.enabled()) {
|
|
@@ -124,12 +120,12 @@ L.Control.Rotate = L.Control.extend({
|
|
|
124
120
|
this._restyle();
|
|
125
121
|
},
|
|
126
122
|
|
|
127
|
-
_restyle
|
|
123
|
+
_restyle() {
|
|
128
124
|
if (!this._map.options.rotate) {
|
|
129
|
-
|
|
125
|
+
this._link.classList.add('leaflet-disabled');
|
|
130
126
|
} else {
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
const map = this._map;
|
|
128
|
+
const bearing = map.getBearing();
|
|
133
129
|
|
|
134
130
|
this._arrow.style.transform = 'rotate(' + bearing + 'deg)';
|
|
135
131
|
|
|
@@ -159,9 +155,9 @@ L.Control.Rotate = L.Control.extend({
|
|
|
159
155
|
|
|
160
156
|
});
|
|
161
157
|
|
|
162
|
-
L.control
|
|
163
|
-
|
|
164
|
-
}
|
|
158
|
+
if (L.control) {
|
|
159
|
+
L.control.rotate = options => new L.Control.Rotate(options);
|
|
160
|
+
}
|
|
165
161
|
|
|
166
162
|
L.Map.mergeOptions({
|
|
167
163
|
rotateControl: true,
|
|
@@ -169,8 +165,8 @@ L.Map.mergeOptions({
|
|
|
169
165
|
|
|
170
166
|
L.Map.addInitHook(function() {
|
|
171
167
|
if (this.options.rotateControl) {
|
|
172
|
-
|
|
173
|
-
this.rotateControl = L.
|
|
168
|
+
const options = typeof this.options.rotateControl === 'object' ? this.options.rotateControl : {};
|
|
169
|
+
this.rotateControl = new L.Control.Rotate(options);
|
|
174
170
|
this.addControl(this.rotateControl);
|
|
175
171
|
}
|
|
176
172
|
});
|
package/src/dom/DomUtil.js
CHANGED
|
@@ -4,75 +4,59 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/dom/DomUtil.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const domUtilProto =
|
|
8
|
-
|
|
9
|
-
L.extend(L.DomUtil, {
|
|
7
|
+
const domUtilProto = Object.assign({}, L.DomUtil);
|
|
10
8
|
|
|
9
|
+
Object.assign(L.DomUtil, {
|
|
11
10
|
/**
|
|
12
|
-
* Resets the 3D CSS transform of `el` so it is
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param {HTMLElement} el
|
|
18
|
-
* @param {L.Point} offset
|
|
11
|
+
* Resets the 3D CSS transform of `el` so it is translated by `offset` pixels,
|
|
12
|
+
* optionally scaled by `scale`, and rotated around `pivot` when `bearing` is set.
|
|
13
|
+
*
|
|
14
|
+
* @param {HTMLElement} el
|
|
15
|
+
* @param {L.Point} offset
|
|
19
16
|
* @param {Number} scale
|
|
20
|
-
* @param {Number} bearing
|
|
21
|
-
* @param {L.Point} pivot
|
|
17
|
+
* @param {Number} bearing
|
|
18
|
+
* @param {L.Point} pivot
|
|
22
19
|
*/
|
|
23
|
-
setTransform
|
|
24
|
-
|
|
20
|
+
setTransform(el, offset, scale, bearing, pivot) {
|
|
21
|
+
let pos = offset || new L.Point(0, 0);
|
|
25
22
|
|
|
26
23
|
if (!bearing) {
|
|
27
|
-
|
|
28
|
-
return domUtilProto.setTransform.apply(this, arguments);
|
|
24
|
+
return domUtilProto.setTransform(el, pos._round(), scale);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
pos = pos.rotateFrom(bearing, pivot);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'translate3d(' + pos.x + 'px,' + pos.y + 'px' + ',0)' +
|
|
28
|
+
el.style.transform =
|
|
29
|
+
'translate3d(' + pos.x + 'px,' + pos.y + 'px,0)' +
|
|
35
30
|
(scale ? ' scale(' + scale + ')' : '') +
|
|
36
31
|
' rotate(' + bearing + 'rad)';
|
|
37
32
|
},
|
|
38
33
|
|
|
39
34
|
/**
|
|
40
|
-
* Sets the position of `el` to
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param {HTMLElement} el
|
|
46
|
-
* @param {L.Point} point
|
|
35
|
+
* Sets the position of `el` to `point`, using CSS transforms or top/left positioning
|
|
36
|
+
* depending on browser support, and optionally rotating it around `pivot`.
|
|
37
|
+
*
|
|
38
|
+
* @param {HTMLElement} el
|
|
39
|
+
* @param {L.Point} point
|
|
47
40
|
* @param {Number} bearing
|
|
48
|
-
* @param {L.Point} pivot
|
|
49
|
-
* @param {Number} scale
|
|
41
|
+
* @param {L.Point} pivot
|
|
42
|
+
* @param {Number} scale
|
|
50
43
|
*/
|
|
51
|
-
setPosition
|
|
44
|
+
setPosition(el, point, bearing, pivot, scale) {
|
|
52
45
|
if (!bearing) {
|
|
53
|
-
return domUtilProto.setPosition
|
|
46
|
+
return domUtilProto.setPosition(el, point);
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
/*eslint-disable */
|
|
57
49
|
el._leaflet_pos = point;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (L.Browser.any3d) {
|
|
61
|
-
L.DomUtil.setTransform(el, point, scale, bearing, pivot);
|
|
62
|
-
} else {
|
|
63
|
-
el.style.left = point.x + 'px';
|
|
64
|
-
el.style.top = point.y + 'px';
|
|
65
|
-
}
|
|
50
|
+
L.DomUtil.setTransform(el, point, scale, bearing, pivot);
|
|
66
51
|
},
|
|
67
52
|
|
|
68
53
|
/**
|
|
69
|
-
*
|
|
54
|
+
* Returns the position assigned to `el`.
|
|
55
|
+
*
|
|
56
|
+
* @param {HTMLElement} el
|
|
57
|
+
* @returns {L.Point}
|
|
70
58
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* @constant degrees = radians × 180°/π
|
|
75
|
-
*/
|
|
76
|
-
RAD_TO_DEG: 180 / Math.PI,
|
|
77
|
-
|
|
59
|
+
getPosition(el) {
|
|
60
|
+
return el._leaflet_pos || domUtilProto.getPosition(el);
|
|
61
|
+
}
|
|
78
62
|
});
|
package/src/dom/Draggable.js
CHANGED
package/src/geometry/Point.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/geometry/Point.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Object.assign(L.Point.prototype, {
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Rotate around (0,0) by applying the 2D rotation matrix:
|
|
@@ -14,7 +14,7 @@ L.extend(L.Point.prototype, {
|
|
|
14
14
|
*
|
|
15
15
|
* @param theta must be given in radians.
|
|
16
16
|
*/
|
|
17
|
-
rotate
|
|
17
|
+
rotate(theta) {
|
|
18
18
|
return this.rotateFrom(theta, new L.Point(0,0))
|
|
19
19
|
},
|
|
20
20
|
|
|
@@ -32,13 +32,13 @@ L.extend(L.Point.prototype, {
|
|
|
32
32
|
*
|
|
33
33
|
* @returns {L.Point}
|
|
34
34
|
*/
|
|
35
|
-
rotateFrom
|
|
35
|
+
rotateFrom(theta, pivot) {
|
|
36
36
|
if (!theta) { return this; }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const sinTheta = Math.sin(theta);
|
|
38
|
+
const cosTheta = Math.cos(theta);
|
|
39
|
+
const cx = pivot.x,
|
|
40
40
|
cy = pivot.y;
|
|
41
|
-
|
|
41
|
+
const x = this.x - cx,
|
|
42
42
|
y = this.y - cy;
|
|
43
43
|
|
|
44
44
|
return new L.Point(
|
|
@@ -48,3 +48,12 @@ L.extend(L.Point.prototype, {
|
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
export function toPoint(point) {
|
|
53
|
+
if (point == null || point instanceof L.Point) {
|
|
54
|
+
return point;
|
|
55
|
+
}
|
|
56
|
+
return Array.isArray(point)
|
|
57
|
+
? new L.Point(point[0], point[1])
|
|
58
|
+
: new L.Point(point.x, point.y);
|
|
59
|
+
}
|
package/src/layer/DivOverlay.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/DivOverlay.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { toPoint } from '../geometry/Point';
|
|
8
|
+
|
|
9
|
+
const divOverlayProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.DivOverlay.prototype));
|
|
8
10
|
|
|
9
11
|
L.DivOverlay.include({
|
|
10
12
|
|
|
@@ -14,24 +16,24 @@ L.DivOverlay.include({
|
|
|
14
16
|
*
|
|
15
17
|
* @listens L.Map~rotate
|
|
16
18
|
*/
|
|
17
|
-
getEvents
|
|
18
|
-
return
|
|
19
|
+
getEvents() {
|
|
20
|
+
return Object.assign(divOverlayProto.getEvents.apply(this, arguments), { rotate: this._updatePosition });
|
|
19
21
|
},
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* 0. update element anchor point (divOverlayProto v1.9.3)
|
|
23
25
|
* 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
|
|
24
26
|
*/
|
|
25
|
-
_updatePosition
|
|
27
|
+
_updatePosition() {
|
|
26
28
|
if (!this._map) { return; }
|
|
27
29
|
divOverlayProto._updatePosition.apply(this, arguments);
|
|
28
30
|
if (this._map._rotate && this._zoomAnimated) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const anchor = this._getAnchor();
|
|
32
|
+
const pos = L.DomUtil.getPosition(this._container).subtract(anchor);
|
|
31
33
|
L.DomUtil.setPosition(this._container, this._map.rotatedPointToMapPanePoint(pos).add(anchor));
|
|
32
34
|
} else if (this._map._rotate) {
|
|
33
|
-
|
|
34
|
-
offset =
|
|
35
|
+
const mapPanePoint = this._map.rotatedPointToMapPanePoint(this._map.latLngToLayerPoint(this._latlng)),
|
|
36
|
+
offset = toPoint(this.options.offset || [0, 0]),
|
|
35
37
|
anchor = this._getAnchor();
|
|
36
38
|
|
|
37
39
|
this._containerLeft = -Math.round(this._containerWidth / 2) + mapPanePoint.x + offset.x + anchor.x;
|
package/src/layer/Popup.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/Popup.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { toPoint } from '../geometry/Point';
|
|
8
|
+
|
|
9
|
+
const popupProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Popup.prototype));
|
|
8
10
|
|
|
9
11
|
L.Popup.include({
|
|
10
12
|
|
|
@@ -12,11 +14,11 @@ L.Popup.include({
|
|
|
12
14
|
* 0. update element anchor point (popupProto v1.9.3)
|
|
13
15
|
* 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
|
|
14
16
|
*/
|
|
15
|
-
_animateZoom
|
|
17
|
+
_animateZoom(e) {
|
|
16
18
|
popupProto._animateZoom.apply(this, arguments);
|
|
17
19
|
if (this._map && this._map._rotate) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const anchor = this._getAnchor();
|
|
21
|
+
const pos = L.DomUtil.getPosition(this._container).subtract(anchor);
|
|
20
22
|
L.DomUtil.setPosition(this._container, this._map.rotatedPointToMapPanePoint(pos).add(anchor));
|
|
21
23
|
}
|
|
22
24
|
},
|
|
@@ -26,7 +28,7 @@ L.Popup.include({
|
|
|
26
28
|
*
|
|
27
29
|
* @see https://github.com/fnicollet/Leaflet/pull/21
|
|
28
30
|
*/
|
|
29
|
-
_adjustPan
|
|
31
|
+
_adjustPan() {
|
|
30
32
|
if (!this.options.autoPan || (this._map._panAnim && this._map._panAnim._inProgress)) { return; }
|
|
31
33
|
|
|
32
34
|
// We can endlessly recurse if keepInView is set and the view resets.
|
|
@@ -36,8 +38,8 @@ L.Popup.include({
|
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
marginBottom = parseInt(
|
|
41
|
+
const map = this._map,
|
|
42
|
+
marginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0,
|
|
41
43
|
containerHeight = this._container.offsetHeight + marginBottom,
|
|
42
44
|
containerWidth = this._containerWidth,
|
|
43
45
|
layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
|
|
@@ -46,12 +48,12 @@ L.Popup.include({
|
|
|
46
48
|
|
|
47
49
|
/** @TODO use popupProto._adjustPan */
|
|
48
50
|
// var containerPos = map.layerPointToContainerPoint(layerPos);
|
|
49
|
-
|
|
50
|
-
padding =
|
|
51
|
-
paddingTL =
|
|
52
|
-
paddingBR =
|
|
53
|
-
size = map.getSize()
|
|
54
|
-
|
|
51
|
+
const containerPos = layerPos._add(this._map._getMapPanePos()),
|
|
52
|
+
padding = toPoint(this.options.autoPanPadding || [0, 0]),
|
|
53
|
+
paddingTL = toPoint(this.options.autoPanPaddingTopLeft || padding),
|
|
54
|
+
paddingBR = toPoint(this.options.autoPanPaddingBottomRight || padding),
|
|
55
|
+
size = map.getSize();
|
|
56
|
+
let dx = 0,
|
|
55
57
|
dy = 0;
|
|
56
58
|
|
|
57
59
|
if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right
|
package/src/layer/Tooltip.js
CHANGED
|
@@ -4,25 +4,25 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/Tooltip.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const tooltipProto =
|
|
7
|
+
const tooltipProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Tooltip.prototype));
|
|
8
8
|
|
|
9
9
|
L.Tooltip.include({
|
|
10
10
|
|
|
11
|
-
_animateZoom
|
|
11
|
+
_animateZoom(e) {
|
|
12
12
|
if (!this._map._rotate) {
|
|
13
13
|
return tooltipProto._animateZoom.apply(this, arguments);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
let pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
|
|
16
16
|
|
|
17
17
|
pos = this._map.rotatedPointToMapPanePoint(pos);
|
|
18
18
|
this._setPosition(pos);
|
|
19
19
|
},
|
|
20
20
|
|
|
21
|
-
_updatePosition
|
|
21
|
+
_updatePosition() {
|
|
22
22
|
if (!this._map._rotate) {
|
|
23
23
|
return tooltipProto._updatePosition.apply(this, arguments);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
let pos = this._map.latLngToLayerPoint(this._latlng);
|
|
26
26
|
|
|
27
27
|
pos = this._map.rotatedPointToMapPanePoint(pos);
|
|
28
28
|
this._setPosition(pos);
|
package/src/layer/marker/Icon.js
CHANGED
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/marker/Icon.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const iconProto =
|
|
7
|
+
const iconProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Icon.prototype));
|
|
8
8
|
|
|
9
9
|
L.Icon.include({
|
|
10
10
|
|
|
11
|
-
_setIconStyles
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
_setIconStyles(img, name) {
|
|
12
|
+
const options = this.options;
|
|
13
|
+
let sizeOption = options[name + 'Size'];
|
|
14
14
|
|
|
15
15
|
if (typeof sizeOption === 'number') {
|
|
16
16
|
sizeOption = [sizeOption, sizeOption];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const size = sizeOption ? new L.Point(...(Array.isArray(sizeOption) ? sizeOption : [sizeOption.x, sizeOption.y])) : null,
|
|
20
|
+
anchorOption = name === 'shadow' && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true),
|
|
21
|
+
anchor = anchorOption ? new L.Point(...(Array.isArray(anchorOption) ? anchorOption : [anchorOption.x, anchorOption.y])) : null;
|
|
22
22
|
|
|
23
23
|
img.className = 'leaflet-marker-' + name + ' ' + (options.className || '');
|
|
24
24
|
|
|
@@ -26,7 +26,7 @@ L.Icon.include({
|
|
|
26
26
|
img.style.marginLeft = (-anchor.x) + 'px';
|
|
27
27
|
img.style.marginTop = (-anchor.y) + 'px';
|
|
28
28
|
/** @TODO use iconProto._setIconStyles */
|
|
29
|
-
img.style
|
|
29
|
+
img.style.transformOrigin = anchor.x + "px " + anchor.y + "px 0px";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (size) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/dom/Draggable.js
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const markerProto =
|
|
10
|
+
const markerProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Marker.prototype));
|
|
11
11
|
|
|
12
12
|
L.Marker.mergeOptions({
|
|
13
13
|
|
|
@@ -41,23 +41,23 @@ L.Marker.mergeOptions({
|
|
|
41
41
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
let markerDragProto; // retrived at runtime (see below: L.Marker::_initInteraction())
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const MarkerDrag = {
|
|
47
47
|
|
|
48
|
-
// _onDragStart
|
|
48
|
+
// _onDragStart() {
|
|
49
49
|
// if (!this._marker._map._rotate) {
|
|
50
50
|
// return markerDragProto._onDragStart.apply(this, arguments);
|
|
51
51
|
// }
|
|
52
52
|
// this._draggable.updateMapBearing(this._marker._map._bearing);
|
|
53
53
|
// },
|
|
54
54
|
|
|
55
|
-
_onDrag
|
|
56
|
-
|
|
55
|
+
_onDrag(e) {
|
|
56
|
+
const marker = this._marker,
|
|
57
57
|
/** @TODO use markerDragProto._onDrag */
|
|
58
58
|
rotated_marker = marker.options.rotation || marker.options.rotateWithView,
|
|
59
|
-
shadow = marker._shadow
|
|
60
|
-
|
|
59
|
+
shadow = marker._shadow;
|
|
60
|
+
let iconPos = L.DomUtil.getPosition(marker._icon);
|
|
61
61
|
|
|
62
62
|
/** @TODO use markerDragProto._onDrag */
|
|
63
63
|
// update shadow position
|
|
@@ -70,7 +70,7 @@ var MarkerDrag = {
|
|
|
70
70
|
// Reverse calculation from mapPane coordinates to rotatePane coordinates
|
|
71
71
|
iconPos = marker._map.mapPanePointToRotatedPoint(iconPos);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
const latlng = marker._map.layerPointToLatLng(iconPos);
|
|
74
74
|
|
|
75
75
|
marker._latlng = latlng;
|
|
76
76
|
e.latlng = latlng;
|
|
@@ -86,7 +86,7 @@ var MarkerDrag = {
|
|
|
86
86
|
.fire('drag', e);
|
|
87
87
|
},
|
|
88
88
|
|
|
89
|
-
_onDragEnd
|
|
89
|
+
_onDragEnd(e) {
|
|
90
90
|
if (this._marker._map._rotate) {
|
|
91
91
|
this._marker.update();
|
|
92
92
|
}
|
|
@@ -103,12 +103,12 @@ L.Marker.include({
|
|
|
103
103
|
*
|
|
104
104
|
* @listens L.Map~rotate
|
|
105
105
|
*/
|
|
106
|
-
getEvents
|
|
107
|
-
return
|
|
106
|
+
getEvents() {
|
|
107
|
+
return Object.assign(markerProto.getEvents.apply(this, arguments), { rotate: this.update });
|
|
108
108
|
},
|
|
109
109
|
|
|
110
|
-
_initInteraction
|
|
111
|
-
|
|
110
|
+
_initInteraction() {
|
|
111
|
+
const ret = markerProto._initInteraction.apply(this, arguments);
|
|
112
112
|
if (this.dragging && this.dragging.enabled() && this._map && this._map._rotate) {
|
|
113
113
|
// L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable
|
|
114
114
|
markerDragProto = markerDragProto || Object.getPrototypeOf(this.dragging);
|
|
@@ -123,7 +123,7 @@ L.Marker.include({
|
|
|
123
123
|
return ret;
|
|
124
124
|
},
|
|
125
125
|
|
|
126
|
-
_setPos
|
|
126
|
+
_setPos(pos) {
|
|
127
127
|
|
|
128
128
|
/** @TODO use markerProto._setPos */
|
|
129
129
|
if (this._map._rotate) {
|
|
@@ -131,7 +131,7 @@ L.Marker.include({
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/** @TODO use markerProto._setPos */
|
|
134
|
-
|
|
134
|
+
let bearing = this.options.rotation || 0;
|
|
135
135
|
if (this.options.rotateWithView) {
|
|
136
136
|
bearing += this._map._bearing;
|
|
137
137
|
}
|
|
@@ -158,14 +158,14 @@ L.Marker.include({
|
|
|
158
158
|
this._resetZIndex();
|
|
159
159
|
},
|
|
160
160
|
|
|
161
|
-
// _updateZIndex
|
|
161
|
+
// _updateZIndex(offset) {
|
|
162
162
|
// if (!this._map._rotate) {
|
|
163
163
|
// return markerProto._updateZIndex.apply(this, arguments);
|
|
164
164
|
// }
|
|
165
165
|
// this._icon.style.zIndex = Math.round(this._zIndex + offset);
|
|
166
166
|
// },
|
|
167
167
|
|
|
168
|
-
setRotation
|
|
168
|
+
setRotation(rotation) {
|
|
169
169
|
this.options.rotation = rotation;
|
|
170
170
|
this.update();
|
|
171
171
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/tile/GridLayer.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const gridLayerProto =
|
|
7
|
+
const gridLayerProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.GridLayer.prototype));
|
|
8
8
|
|
|
9
9
|
L.GridLayer.include({
|
|
10
10
|
|
|
@@ -14,8 +14,8 @@ L.GridLayer.include({
|
|
|
14
14
|
*
|
|
15
15
|
* @listens L.Map~rotate
|
|
16
16
|
*/
|
|
17
|
-
getEvents
|
|
18
|
-
|
|
17
|
+
getEvents() {
|
|
18
|
+
const events = gridLayerProto.getEvents.apply(this, arguments);
|
|
19
19
|
if (this._map._rotate && !this.options.updateWhenIdle) {
|
|
20
20
|
if (!this._onRotate) {
|
|
21
21
|
this._onRotate = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);
|
|
@@ -25,7 +25,7 @@ L.GridLayer.include({
|
|
|
25
25
|
return events;
|
|
26
26
|
},
|
|
27
27
|
|
|
28
|
-
_getTiledPixelBounds
|
|
28
|
+
_getTiledPixelBounds(center) {
|
|
29
29
|
if (!this._map._rotate) {
|
|
30
30
|
return gridLayerProto._getTiledPixelBounds.apply(this, arguments);
|
|
31
31
|
}
|