leaflet-rotate 0.2.1 → 0.2.3
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/dist/leaflet-rotate-src.js +364 -211
- package/dist/leaflet-rotate-src.js.map +1 -1
- package/dist/leaflet-rotate.js +364 -211
- package/dist/leaflet-rotate.js.map +1 -1
- package/package.json +1 -1
- package/src/control/Rotate.js +42 -41
- package/src/dom/DomUtil.js +32 -2
- package/src/dom/Draggable.js +7 -0
- package/src/geo/LatLngBounds.js +13 -0
- package/src/geometry/Bounds.js +13 -0
- package/src/geometry/Point.js +5 -0
- package/src/index.js +16 -3
- package/src/layer/DivOverlay.js +11 -4
- package/src/layer/Popup.js +6 -6
- package/src/layer/marker/Marker.js +29 -17
- package/src/layer/tile/GridLayer.js +6 -0
- package/src/layer/vector/Renderer.js +83 -13
- package/src/map/Map.js +6 -1
- package/src/map/handler/CompassBearing.js +52 -11
- package/src/map/handler/ContainerMutation.js +23 -24
- package/src/map/handler/ShiftKeyRotate.js +11 -10
- package/src/map/handler/TouchGestures.js +20 -10
- package/src/map/handler/TouchRotate.js +10 -8
- package/src/map/handler/TouchZoom.js +20 -15
- package/test/index.html +2 -1
- package/src/layer/vector/Canvas.js +0 -28
- package/src/layer/vector/SVG.js +0 -18
package/src/control/Rotate.js
CHANGED
|
@@ -16,8 +16,6 @@ L.Control.Rotate = L.Control.extend({
|
|
|
16
16
|
},
|
|
17
17
|
|
|
18
18
|
onAdd: function(map) {
|
|
19
|
-
this._onDeviceOrientation = L.Util.throttle(this._unthrottledOnDeviceOrientation, 100, this);
|
|
20
|
-
|
|
21
19
|
var container = this._container = L.DomUtil.create('div', 'leaflet-control-rotate leaflet-bar');
|
|
22
20
|
|
|
23
21
|
// this.button = L.Control.Zoom.prototype._createButton.call(this, 'R', 'leaflet-control-rotate', 'leaflet-control-rotate', container, this._toggleLock);
|
|
@@ -37,7 +35,6 @@ L.Control.Rotate = L.Control.extend({
|
|
|
37
35
|
link.appendChild(arrow);
|
|
38
36
|
link.href = '#';
|
|
39
37
|
link.title = 'Rotate map';
|
|
40
|
-
// link.draggable = false;
|
|
41
38
|
|
|
42
39
|
L.DomEvent
|
|
43
40
|
.on(link, 'dblclick', L.DomEvent.stopPropagation)
|
|
@@ -52,7 +49,7 @@ L.Control.Rotate = L.Control.extend({
|
|
|
52
49
|
|
|
53
50
|
this._restyle();
|
|
54
51
|
|
|
55
|
-
map.on('rotate', this._restyle
|
|
52
|
+
map.on('rotate', this._restyle, this);
|
|
56
53
|
|
|
57
54
|
// State flag
|
|
58
55
|
this._follow = false;
|
|
@@ -64,9 +61,13 @@ L.Control.Rotate = L.Control.extend({
|
|
|
64
61
|
|
|
65
62
|
return container;
|
|
66
63
|
},
|
|
64
|
+
|
|
65
|
+
onRemove: function(map) {
|
|
66
|
+
map.off('rotate', this._restyle, this);
|
|
67
|
+
},
|
|
67
68
|
|
|
68
69
|
_handleMouseDown: function(e) {
|
|
69
|
-
L.DomEvent.stop(e);
|
|
70
|
+
L.DomEvent.stop(e);
|
|
70
71
|
this.dragging = true;
|
|
71
72
|
this.dragstartX = e.pageX;
|
|
72
73
|
this.dragstartY = e.pageY;
|
|
@@ -76,7 +77,7 @@ L.Control.Rotate = L.Control.extend({
|
|
|
76
77
|
},
|
|
77
78
|
|
|
78
79
|
_handleMouseUp: function(e) {
|
|
79
|
-
L.DomEvent.stop(e);
|
|
80
|
+
L.DomEvent.stop(e);
|
|
80
81
|
this.dragging = false;
|
|
81
82
|
|
|
82
83
|
L.DomEvent
|
|
@@ -91,64 +92,64 @@ L.Control.Rotate = L.Control.extend({
|
|
|
91
92
|
},
|
|
92
93
|
|
|
93
94
|
_cycleState: function(ev) {
|
|
94
|
-
|
|
95
|
+
if (!this._map) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
95
98
|
|
|
96
|
-
|
|
99
|
+
var map = this._map;
|
|
97
100
|
|
|
101
|
+
// Touch mode
|
|
98
102
|
if (!map.touchRotate.enabled() && !map.compassBearing.enabled()) {
|
|
99
|
-
// Go from disabled to touch
|
|
100
103
|
map.touchRotate.enable();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Compass mode
|
|
107
|
+
else if (!map.compassBearing.enabled()) {
|
|
108
|
+
map.touchRotate.disable();
|
|
109
|
+
map.compassBearing.enable();
|
|
110
|
+
}
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
map.touchRotate.
|
|
108
|
-
map.compassBearing.enable();
|
|
109
|
-
|
|
110
|
-
// console.log('state is now: compass');
|
|
111
|
-
|
|
112
|
-
// It is possible that compass is not supported. If so,
|
|
113
|
-
// the hangler will automatically go from compass to disabled.
|
|
114
|
-
} else {
|
|
115
|
-
// Go from compass to disabled
|
|
116
|
-
map.compassBearing.disable();
|
|
117
|
-
|
|
118
|
-
// console.log('state is now: locked');
|
|
119
|
-
|
|
120
|
-
map.setBearing(0);
|
|
121
|
-
if (this.options.closeOnZeroBearing) {
|
|
122
|
-
map.touchRotate.enable();
|
|
123
|
-
}
|
|
112
|
+
// Locked mode
|
|
113
|
+
else {
|
|
114
|
+
map.compassBearing.disable();
|
|
115
|
+
map.setBearing(0);
|
|
116
|
+
if (this.options.closeOnZeroBearing) {
|
|
117
|
+
map.touchRotate.enable();
|
|
124
118
|
}
|
|
125
119
|
}
|
|
126
120
|
this._restyle();
|
|
127
121
|
},
|
|
128
122
|
|
|
129
123
|
_restyle: function() {
|
|
130
|
-
if (this._map.options.rotate) {
|
|
124
|
+
if (!this._map.options.rotate) {
|
|
125
|
+
L.DomUtil.addClass(this._link, 'leaflet-disabled');
|
|
126
|
+
} else {
|
|
131
127
|
var map = this._map;
|
|
132
128
|
var bearing = map.getBearing();
|
|
133
|
-
|
|
129
|
+
|
|
130
|
+
this._arrow.style.transform = 'rotate(' + bearing + 'deg)';
|
|
131
|
+
|
|
132
|
+
if (bearing && this.options.closeOnZeroBearing) {
|
|
134
133
|
this._container.style.display = 'block';
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
|
|
138
|
-
this._arrow.style.transform = cssTransform;
|
|
139
|
-
|
|
136
|
+
// Compass mode
|
|
140
137
|
if (map.compassBearing.enabled()) {
|
|
141
138
|
this._link.style.backgroundColor = 'orange';
|
|
142
|
-
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Touch mode
|
|
142
|
+
else if (map.touchRotate.enabled()) {
|
|
143
143
|
this._link.style.backgroundColor = null;
|
|
144
|
-
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Locked mode
|
|
147
|
+
else {
|
|
145
148
|
this._link.style.backgroundColor = 'grey';
|
|
146
|
-
if (this.options.closeOnZeroBearing
|
|
149
|
+
if (0 === bearing && this.options.closeOnZeroBearing) {
|
|
147
150
|
this._container.style.display = 'none';
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
|
-
} else {
|
|
151
|
-
L.DomUtil.addClass(this._link, 'leaflet-disabled');
|
|
152
153
|
}
|
|
153
154
|
},
|
|
154
155
|
|
package/src/dom/DomUtil.js
CHANGED
|
@@ -8,6 +8,18 @@ const domUtilProto = L.extend({}, L.DomUtil);
|
|
|
8
8
|
|
|
9
9
|
L.extend(L.DomUtil, {
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Resets the 3D CSS transform of `el` so it is
|
|
13
|
+
* translated by `offset` pixels and optionally
|
|
14
|
+
* scaled by `scale`. Does not have an effect if
|
|
15
|
+
* the browser doesn't support 3D CSS transforms.
|
|
16
|
+
*
|
|
17
|
+
* @param {HTMLElement} el
|
|
18
|
+
* @param {L.Point} offset
|
|
19
|
+
* @param {Number} scale
|
|
20
|
+
* @param {Number} bearing
|
|
21
|
+
* @param {L.Point} pivot
|
|
22
|
+
*/
|
|
11
23
|
setTransform: function(el, offset, scale, bearing, pivot) {
|
|
12
24
|
var pos = offset || new L.Point(0, 0);
|
|
13
25
|
|
|
@@ -24,7 +36,19 @@ L.extend(L.DomUtil, {
|
|
|
24
36
|
' rotate(' + bearing + 'rad)';
|
|
25
37
|
},
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Sets the position of `el` to coordinates specified by
|
|
41
|
+
* `position`, using CSS translate or top/left positioning
|
|
42
|
+
* depending on the browser (used by Leaflet internally
|
|
43
|
+
* to position its layers).
|
|
44
|
+
*
|
|
45
|
+
* @param {HTMLElement} el
|
|
46
|
+
* @param {L.Point} point
|
|
47
|
+
* @param {Number} bearing
|
|
48
|
+
* @param {L.Point} pivot
|
|
49
|
+
* @param {Number} scale
|
|
50
|
+
*/
|
|
51
|
+
setPosition: function(el, point, bearing, pivot, scale) {
|
|
28
52
|
if (!bearing) {
|
|
29
53
|
return domUtilProto.setPosition.apply(this, arguments);
|
|
30
54
|
}
|
|
@@ -41,8 +65,14 @@ L.extend(L.DomUtil, {
|
|
|
41
65
|
}
|
|
42
66
|
},
|
|
43
67
|
|
|
44
|
-
|
|
68
|
+
/**
|
|
69
|
+
* @constant radians = degrees × π/180°
|
|
70
|
+
*/
|
|
45
71
|
DEG_TO_RAD: Math.PI / 180,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @constant degrees = radians × 180°/π
|
|
75
|
+
*/
|
|
46
76
|
RAD_TO_DEG: 180 / Math.PI,
|
|
47
77
|
|
|
48
78
|
});
|
package/src/dom/Draggable.js
CHANGED
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/dom/Draggable.js
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A class for making DOM elements draggable (including touch support).
|
|
9
|
+
* Used internally for map and marker dragging. Only works for elements
|
|
10
|
+
* that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition).
|
|
11
|
+
*/
|
|
12
|
+
|
|
7
13
|
L.Draggable.include({
|
|
8
14
|
|
|
15
|
+
/** @TODO */
|
|
9
16
|
// updateMapBearing: function(mapBearing) {
|
|
10
17
|
// this._mapBearing = mapBearing;
|
|
11
18
|
// },
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @external L.LatLngBounds
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/geo/LatLngBounds.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @TODO find out if should override here some functions in order
|
|
9
|
+
* to always get correct { _southWest, _northEast } bounds on a rotaded
|
|
10
|
+
* map, for example: at 180° "_southWest" should becomes "_northEast"?
|
|
11
|
+
*
|
|
12
|
+
* @see L.Map.getBounds()
|
|
13
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @external L.Bounds
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/geometry/Bounds.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @TODO find out if should override here some functions in order
|
|
9
|
+
* to always get correct { min, max } pixel bounds on a rotaded
|
|
10
|
+
* map, for example: at 180° "min" should becomes "max"?
|
|
11
|
+
*
|
|
12
|
+
* @see L.Map.getPixelBounds()
|
|
13
|
+
*/
|
package/src/geometry/Point.js
CHANGED
|
@@ -26,6 +26,11 @@ L.extend(L.Point.prototype, {
|
|
|
26
26
|
* 3. add (pivot.x, pivot.y) back
|
|
27
27
|
*
|
|
28
28
|
* same as `this.subtract(pivot).rotate(theta).add(pivot)`
|
|
29
|
+
*
|
|
30
|
+
* @param {Number} theta
|
|
31
|
+
* @param {L.Point} pivot
|
|
32
|
+
*
|
|
33
|
+
* @returns {L.Point}
|
|
29
34
|
*/
|
|
30
35
|
rotateFrom: function(theta, pivot) {
|
|
31
36
|
if (!theta) { return this; }
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Export Leaflet classes in the same order as the core library
|
|
3
|
+
*
|
|
2
4
|
* @external L
|
|
3
5
|
*
|
|
4
6
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/Leaflet.js
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/control/index.js
|
|
9
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/core/index.js
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/dom/index.js
|
|
12
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/geometry/index.js
|
|
13
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/geo/index.js
|
|
14
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/index.js
|
|
15
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/marker/index.js
|
|
16
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/tile/index.js
|
|
17
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/layer/vector/index.js
|
|
18
|
+
* @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/map/index.js
|
|
5
19
|
*/
|
|
6
20
|
|
|
7
21
|
// import {version} from '../package.json';
|
|
@@ -19,9 +33,10 @@ export * from './dom/Draggable';
|
|
|
19
33
|
|
|
20
34
|
// geometry
|
|
21
35
|
export * from './geometry/Point';
|
|
36
|
+
export * from './geometry/Bounds';
|
|
22
37
|
|
|
23
38
|
// geo
|
|
24
|
-
|
|
39
|
+
export * from './geo/LatLngBounds';
|
|
25
40
|
|
|
26
41
|
// layer
|
|
27
42
|
export * from './layer/DivOverlay';
|
|
@@ -30,9 +45,7 @@ export * from './layer/Tooltip';
|
|
|
30
45
|
export * from './layer/marker/Icon';
|
|
31
46
|
export * from './layer/marker/Marker';
|
|
32
47
|
export * from './layer/tile/GridLayer';
|
|
33
|
-
export * from './layer/vector/Canvas';
|
|
34
48
|
export * from './layer/vector/Renderer';
|
|
35
|
-
export * from './layer/vector/SVG';
|
|
36
49
|
|
|
37
50
|
// map
|
|
38
51
|
export * from './map/Map';
|
package/src/layer/DivOverlay.js
CHANGED
|
@@ -8,16 +8,23 @@ const divOverlayProto = L.extend({}, L.DivOverlay.prototype);
|
|
|
8
8
|
|
|
9
9
|
L.DivOverlay.include({
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Update L.Popup and L.Tooltip anchor positions after
|
|
13
|
+
* the map is moved by calling `map.setBearing(theta)`
|
|
14
|
+
*
|
|
15
|
+
* @listens L.Map~rotate
|
|
16
|
+
*/
|
|
11
17
|
getEvents: function() {
|
|
12
18
|
return L.extend(divOverlayProto.getEvents.apply(this, arguments), { rotate: this._updatePosition });
|
|
13
19
|
},
|
|
14
20
|
|
|
21
|
+
/**
|
|
22
|
+
* 0. update element anchor point (divOverlayProto v1.9.3)
|
|
23
|
+
* 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
|
|
24
|
+
*/
|
|
15
25
|
_updatePosition: function() {
|
|
16
|
-
|
|
26
|
+
if (!this._map) { return; }
|
|
17
27
|
divOverlayProto._updatePosition.apply(this, arguments);
|
|
18
|
-
// 1. subtract anchor
|
|
19
|
-
// 2. rotate element
|
|
20
|
-
// 3. restore anchor
|
|
21
28
|
if (this._map && this._map._rotate && this._zoomAnimated) {
|
|
22
29
|
var anchor = this._getAnchor();
|
|
23
30
|
var pos = L.DomUtil.getPosition(this._container).subtract(anchor);
|
package/src/layer/Popup.js
CHANGED
|
@@ -8,12 +8,12 @@ const popupProto = L.extend({}, L.Popup.prototype);
|
|
|
8
8
|
|
|
9
9
|
L.Popup.include({
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* 0. update element anchor point (popupProto v1.9.3)
|
|
13
|
+
* 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
|
|
14
|
+
*/
|
|
11
15
|
_animateZoom: function(e) {
|
|
12
|
-
// 0. update anchor (leaflet v1.9.3)
|
|
13
16
|
popupProto._animateZoom.apply(this, arguments);
|
|
14
|
-
// 1. subtract anchor
|
|
15
|
-
// 2. rotate element
|
|
16
|
-
// 3. restore anchor
|
|
17
17
|
if (this._map && this._map._rotate) {
|
|
18
18
|
var anchor = this._getAnchor();
|
|
19
19
|
var pos = L.DomUtil.getPosition(this._container).subtract(anchor);
|
|
@@ -22,7 +22,7 @@ L.Popup.include({
|
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Fix for L.popup({ keepInView = true })
|
|
26
26
|
*
|
|
27
27
|
* @see https://github.com/fnicollet/Leaflet/pull/21
|
|
28
28
|
*/
|
|
@@ -44,8 +44,8 @@ L.Popup.include({
|
|
|
44
44
|
|
|
45
45
|
layerPos._add(L.DomUtil.getPosition(this._container));
|
|
46
46
|
|
|
47
|
-
// var containerPos = map.layerPointToContainerPoint(layerPos);
|
|
48
47
|
/** @TODO use popupProto._adjustPan */
|
|
48
|
+
// var containerPos = map.layerPointToContainerPoint(layerPos);
|
|
49
49
|
var containerPos = layerPos._add(this._map._getMapPanePos()),
|
|
50
50
|
padding = L.point(this.options.autoPanPadding),
|
|
51
51
|
paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),
|
|
@@ -3,22 +3,33 @@
|
|
|
3
3
|
* @external L.Handler.MarkerDrag
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/marker/Marker.js
|
|
6
|
+
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/marker/Marker.Drag.js
|
|
7
|
+
* @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/dom/Draggable.js
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
const markerProto = L.extend({}, L.Marker.prototype);
|
|
9
11
|
|
|
10
12
|
L.Marker.mergeOptions({
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Rotation of this marker in rad
|
|
16
|
+
*
|
|
17
|
+
* @type {Number}
|
|
18
|
+
*/
|
|
14
19
|
rotation: 0,
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Rotate this marker when map rotates
|
|
23
|
+
*
|
|
24
|
+
* @type {Boolean}
|
|
25
|
+
*/
|
|
18
26
|
rotateWithView: false,
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Scale of the marker icon
|
|
30
|
+
*
|
|
31
|
+
* @type {Number}
|
|
32
|
+
*/
|
|
22
33
|
scale: undefined,
|
|
23
34
|
|
|
24
35
|
});
|
|
@@ -79,15 +90,16 @@ var MarkerDrag = {
|
|
|
79
90
|
|
|
80
91
|
L.Marker.include({
|
|
81
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Update L.Marker anchor position after the map
|
|
95
|
+
* is moved by calling `map.setBearing(theta)`
|
|
96
|
+
*
|
|
97
|
+
* @listens L.Map~rotate
|
|
98
|
+
*/
|
|
82
99
|
getEvents: function() {
|
|
83
100
|
return L.extend(markerProto.getEvents.apply(this, arguments), { rotate: this.update });
|
|
84
101
|
},
|
|
85
102
|
|
|
86
|
-
onAdd: function(map) {
|
|
87
|
-
markerProto.onAdd.apply(this, arguments);
|
|
88
|
-
map.on('rotate', this.update, this);
|
|
89
|
-
},
|
|
90
|
-
|
|
91
103
|
_initInteraction: function() {
|
|
92
104
|
var ret = markerProto._initInteraction.apply(this, arguments);
|
|
93
105
|
if (this.dragging && this.dragging.enabled() && this._map && this._map._rotate) {
|
|
@@ -132,12 +144,12 @@ L.Marker.include({
|
|
|
132
144
|
this._resetZIndex();
|
|
133
145
|
},
|
|
134
146
|
|
|
135
|
-
_updateZIndex: function(offset) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
},
|
|
147
|
+
// _updateZIndex: function(offset) {
|
|
148
|
+
// if (!this._map._rotate) {
|
|
149
|
+
// return markerProto._updateZIndex.apply(this, arguments);
|
|
150
|
+
// }
|
|
151
|
+
// this._icon.style.zIndex = Math.round(this._zIndex + offset);
|
|
152
|
+
// },
|
|
141
153
|
|
|
142
154
|
setRotation: function(rotation) {
|
|
143
155
|
this.options.rotation = rotation;
|
|
@@ -8,6 +8,12 @@ const gridLayerProto = L.extend({}, L.GridLayer.prototype);
|
|
|
8
8
|
|
|
9
9
|
L.GridLayer.include({
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Redraw L.TileLayer bounds after the map is
|
|
13
|
+
* moved by just calling `map.setBearing(theta)`
|
|
14
|
+
*
|
|
15
|
+
* @listens L.Map~rotate
|
|
16
|
+
*/
|
|
11
17
|
getEvents: function() {
|
|
12
18
|
var events = gridLayerProto.getEvents.apply(this, arguments);
|
|
13
19
|
if (this._map._rotate && !this.options.updateWhenIdle) {
|
|
@@ -8,17 +8,44 @@ const rendererProto = L.extend({}, L.Renderer.prototype);
|
|
|
8
8
|
|
|
9
9
|
L.Renderer.include({
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Redraw L.Canvas and L.SVG renderer bounds after the
|
|
13
|
+
* map is moved by just calling `map.setBearing(theta)`
|
|
14
|
+
*
|
|
15
|
+
* @listens L.Map~rotate
|
|
16
|
+
*/
|
|
17
|
+
getEvents: function() {
|
|
18
|
+
return L.extend(rendererProto.getEvents.apply(this, arguments), { rotate: this._update });
|
|
19
|
+
},
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Fix for `map.flyTo()` when `false === map.options.zoomAnimation`
|
|
23
|
+
*
|
|
24
|
+
* @see https://github.com/Leaflet/Leaflet/pull/8794
|
|
25
|
+
*/
|
|
26
|
+
onAdd: function() {
|
|
27
|
+
rendererProto.onAdd.apply(this, arguments);
|
|
28
|
+
if (L.version <= "1.9.3") {
|
|
29
|
+
// always keep transform-origin as 0 0
|
|
30
|
+
this._container.classList.add('leaflet-zoom-animated');
|
|
31
|
+
}
|
|
32
|
+
},
|
|
20
33
|
|
|
21
34
|
/**
|
|
35
|
+
* @FIXME layer drifts on `map.setZoom()` (eg. zoom during animation)
|
|
36
|
+
*
|
|
37
|
+
* the main cause seems to be related to `this._updateTransform(path._center, path._zoom))`
|
|
38
|
+
* and `this._topLeft = this._map.layerPointToLatLng(this._bounds.min);`
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* map.setZoom(2);
|
|
42
|
+
* path._renderer._update();
|
|
43
|
+
* path._renderer._updateTransform(path._renderer._center, path._renderer._zoom);
|
|
44
|
+
*
|
|
45
|
+
* @see https://github.com/Leaflet/Leaflet/pull/8794
|
|
46
|
+
* @see https://github.com/Leaflet/Leaflet/pull/8103
|
|
47
|
+
* @see https://github.com/Leaflet/Leaflet/issues/7466
|
|
48
|
+
*
|
|
22
49
|
* @TODO rechek this changes from leaflet@v1.9.3
|
|
23
50
|
*
|
|
24
51
|
* @see https://github.com/Leaflet/Leaflet/compare/v1.7.0...v1.9.3
|
|
@@ -27,15 +54,58 @@ L.Renderer.include({
|
|
|
27
54
|
if (!this._map._rotate) {
|
|
28
55
|
return rendererProto._updateTransform.apply(this, arguments);
|
|
29
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* @FIXME see path._renderer._reset();
|
|
59
|
+
*/
|
|
30
60
|
var scale = this._map.getZoomScale(zoom, this._zoom),
|
|
31
61
|
offset = this._map._latLngToNewLayerPoint(this._topLeft, zoom, center);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
L.DomUtil.setPosition(this._container, offset);
|
|
36
|
-
}
|
|
62
|
+
|
|
63
|
+
L.DomUtil.setTransform(this._container, offset, scale);
|
|
64
|
+
|
|
37
65
|
},
|
|
38
66
|
|
|
67
|
+
// getEvents() {
|
|
68
|
+
// const events = {
|
|
69
|
+
// viewreset: this._reset,
|
|
70
|
+
// zoom: this._onZoom,
|
|
71
|
+
// moveend: this._update,
|
|
72
|
+
// zoomend: this._onZoomEnd
|
|
73
|
+
// };
|
|
74
|
+
// if (this._zoomAnimated) {
|
|
75
|
+
// events.zoomanim = this._onAnimZoom;
|
|
76
|
+
// }
|
|
77
|
+
// return events;
|
|
78
|
+
// },
|
|
79
|
+
|
|
80
|
+
// _onAnimZoom(ev) {
|
|
81
|
+
// this._updateTransform(ev.center, ev.zoom);
|
|
82
|
+
// },
|
|
83
|
+
|
|
84
|
+
// _onZoom() {
|
|
85
|
+
// this._updateTransform(this._map.getCenter(), this._map.getZoom());
|
|
86
|
+
// },
|
|
87
|
+
|
|
88
|
+
// _onZoomEnd() {
|
|
89
|
+
// for (const id in this._layers) {
|
|
90
|
+
// this._layers[id]._project();
|
|
91
|
+
// }
|
|
92
|
+
// },
|
|
93
|
+
|
|
94
|
+
// _reset() {
|
|
95
|
+
// this._update();
|
|
96
|
+
// this._updateTransform(this._center, this._zoom);
|
|
97
|
+
|
|
98
|
+
// for (const id in this._layers) {
|
|
99
|
+
// this._layers[id]._reset();
|
|
100
|
+
// }
|
|
101
|
+
// },
|
|
102
|
+
|
|
103
|
+
// _updatePaths() {
|
|
104
|
+
// for (const id in this._layers) {
|
|
105
|
+
// this._layers[id]._update();
|
|
106
|
+
// }
|
|
107
|
+
// },
|
|
108
|
+
|
|
39
109
|
_update: function() {
|
|
40
110
|
if (!this._map._rotate) {
|
|
41
111
|
return rendererProto._update.apply(this, arguments);
|
package/src/map/Map.js
CHANGED
|
@@ -473,11 +473,16 @@ L.Map.include({
|
|
|
473
473
|
// return L.DomUtil.getPosition(this._rotatePane) || new L.Point(0, 0);
|
|
474
474
|
},
|
|
475
475
|
|
|
476
|
+
// _latLngToNewLayerPoint(latlng, zoom, center) {
|
|
477
|
+
// const topLeft = this._getNewPixelOrigin(center, zoom);
|
|
478
|
+
// return this.project(latlng, zoom)._subtract(topLeft);
|
|
479
|
+
//},
|
|
480
|
+
|
|
476
481
|
_getNewPixelOrigin: function(center, zoom) {
|
|
477
|
-
var viewHalf = this.getSize()._divideBy(2);
|
|
478
482
|
if (!this._rotate) {
|
|
479
483
|
return mapProto._getNewPixelOrigin.apply(this, arguments);
|
|
480
484
|
}
|
|
485
|
+
var viewHalf = this.getSize()._divideBy(2);
|
|
481
486
|
return this.project(center, zoom)
|
|
482
487
|
.rotate(this._bearing)
|
|
483
488
|
._subtract(viewHalf)
|