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
|
@@ -3,6 +3,10 @@ var leafletRotate = (() => {
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,75 +19,69 @@ var leafletRotate = (() => {
|
|
|
15
19
|
|
|
16
20
|
// src/index.js
|
|
17
21
|
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
toPoint: () => toPoint
|
|
24
|
+
});
|
|
18
25
|
|
|
19
26
|
// src/dom/DomUtil.js
|
|
20
|
-
var domUtilProto =
|
|
21
|
-
|
|
27
|
+
var domUtilProto = Object.assign({}, L.DomUtil);
|
|
28
|
+
Object.assign(L.DomUtil, {
|
|
22
29
|
/**
|
|
23
|
-
* Resets the 3D CSS transform of `el` so it is
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param {HTMLElement} el
|
|
29
|
-
* @param {L.Point} offset
|
|
30
|
+
* Resets the 3D CSS transform of `el` so it is translated by `offset` pixels,
|
|
31
|
+
* optionally scaled by `scale`, and rotated around `pivot` when `bearing` is set.
|
|
32
|
+
*
|
|
33
|
+
* @param {HTMLElement} el
|
|
34
|
+
* @param {L.Point} offset
|
|
30
35
|
* @param {Number} scale
|
|
31
|
-
* @param {Number} bearing
|
|
32
|
-
* @param {L.Point} pivot
|
|
36
|
+
* @param {Number} bearing
|
|
37
|
+
* @param {L.Point} pivot
|
|
33
38
|
*/
|
|
34
|
-
setTransform
|
|
35
|
-
|
|
39
|
+
setTransform(el, offset, scale, bearing, pivot) {
|
|
40
|
+
let pos = offset || new L.Point(0, 0);
|
|
36
41
|
if (!bearing) {
|
|
37
|
-
|
|
38
|
-
return domUtilProto.setTransform.apply(this, arguments);
|
|
42
|
+
return domUtilProto.setTransform(el, pos._round(), scale);
|
|
39
43
|
}
|
|
40
44
|
pos = pos.rotateFrom(bearing, pivot);
|
|
41
|
-
el.style
|
|
45
|
+
el.style.transform = "translate3d(" + pos.x + "px," + pos.y + "px,0)" + (scale ? " scale(" + scale + ")" : "") + " rotate(" + bearing + "rad)";
|
|
42
46
|
},
|
|
43
47
|
/**
|
|
44
|
-
* Sets the position of `el` to
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param {HTMLElement} el
|
|
50
|
-
* @param {L.Point} point
|
|
48
|
+
* Sets the position of `el` to `point`, using CSS transforms or top/left positioning
|
|
49
|
+
* depending on browser support, and optionally rotating it around `pivot`.
|
|
50
|
+
*
|
|
51
|
+
* @param {HTMLElement} el
|
|
52
|
+
* @param {L.Point} point
|
|
51
53
|
* @param {Number} bearing
|
|
52
|
-
* @param {L.Point} pivot
|
|
53
|
-
* @param {Number} scale
|
|
54
|
+
* @param {L.Point} pivot
|
|
55
|
+
* @param {Number} scale
|
|
54
56
|
*/
|
|
55
|
-
setPosition
|
|
57
|
+
setPosition(el, point, bearing, pivot, scale) {
|
|
56
58
|
if (!bearing) {
|
|
57
|
-
return domUtilProto.setPosition
|
|
59
|
+
return domUtilProto.setPosition(el, point);
|
|
58
60
|
}
|
|
59
61
|
el._leaflet_pos = point;
|
|
60
|
-
|
|
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
|
-
}
|
|
62
|
+
L.DomUtil.setTransform(el, point, scale, bearing, pivot);
|
|
66
63
|
},
|
|
67
64
|
/**
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* @constant degrees = radians × 180°/π
|
|
65
|
+
* Returns the position assigned to `el`.
|
|
66
|
+
*
|
|
67
|
+
* @param {HTMLElement} el
|
|
68
|
+
* @returns {L.Point}
|
|
73
69
|
*/
|
|
74
|
-
|
|
70
|
+
getPosition(el) {
|
|
71
|
+
return el._leaflet_pos || domUtilProto.getPosition(el);
|
|
72
|
+
}
|
|
75
73
|
});
|
|
76
74
|
|
|
77
75
|
// src/dom/Draggable.js
|
|
78
76
|
L.Draggable.include({
|
|
79
77
|
/** @TODO */
|
|
80
|
-
// updateMapBearing
|
|
78
|
+
// updateMapBearing(mapBearing) {
|
|
81
79
|
// this._mapBearing = mapBearing;
|
|
82
80
|
// },
|
|
83
81
|
});
|
|
84
82
|
|
|
85
83
|
// src/geometry/Point.js
|
|
86
|
-
|
|
84
|
+
Object.assign(L.Point.prototype, {
|
|
87
85
|
/**
|
|
88
86
|
* Rotate around (0,0) by applying the 2D rotation matrix:
|
|
89
87
|
*
|
|
@@ -92,7 +90,7 @@ var leafletRotate = (() => {
|
|
|
92
90
|
*
|
|
93
91
|
* @param theta must be given in radians.
|
|
94
92
|
*/
|
|
95
|
-
rotate
|
|
93
|
+
rotate(theta) {
|
|
96
94
|
return this.rotateFrom(theta, new L.Point(0, 0));
|
|
97
95
|
},
|
|
98
96
|
/**
|
|
@@ -109,23 +107,29 @@ var leafletRotate = (() => {
|
|
|
109
107
|
*
|
|
110
108
|
* @returns {L.Point}
|
|
111
109
|
*/
|
|
112
|
-
rotateFrom
|
|
110
|
+
rotateFrom(theta, pivot) {
|
|
113
111
|
if (!theta) {
|
|
114
112
|
return this;
|
|
115
113
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
const sinTheta = Math.sin(theta);
|
|
115
|
+
const cosTheta = Math.cos(theta);
|
|
116
|
+
const cx = pivot.x, cy = pivot.y;
|
|
117
|
+
const x = this.x - cx, y = this.y - cy;
|
|
120
118
|
return new L.Point(
|
|
121
119
|
x * cosTheta - y * sinTheta + cx,
|
|
122
120
|
x * sinTheta + y * cosTheta + cy
|
|
123
121
|
);
|
|
124
122
|
}
|
|
125
123
|
});
|
|
124
|
+
function toPoint(point) {
|
|
125
|
+
if (point == null || point instanceof L.Point) {
|
|
126
|
+
return point;
|
|
127
|
+
}
|
|
128
|
+
return Array.isArray(point) ? new L.Point(point[0], point[1]) : new L.Point(point.x, point.y);
|
|
129
|
+
}
|
|
126
130
|
|
|
127
131
|
// src/layer/DivOverlay.js
|
|
128
|
-
var divOverlayProto =
|
|
132
|
+
var divOverlayProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.DivOverlay.prototype));
|
|
129
133
|
L.DivOverlay.include({
|
|
130
134
|
/**
|
|
131
135
|
* Update L.Popup and L.Tooltip anchor positions after
|
|
@@ -133,24 +137,24 @@ var leafletRotate = (() => {
|
|
|
133
137
|
*
|
|
134
138
|
* @listens L.Map~rotate
|
|
135
139
|
*/
|
|
136
|
-
getEvents
|
|
137
|
-
return
|
|
140
|
+
getEvents() {
|
|
141
|
+
return Object.assign(divOverlayProto.getEvents.apply(this, arguments), { rotate: this._updatePosition });
|
|
138
142
|
},
|
|
139
143
|
/**
|
|
140
144
|
* 0. update element anchor point (divOverlayProto v1.9.3)
|
|
141
145
|
* 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
|
|
142
146
|
*/
|
|
143
|
-
_updatePosition
|
|
147
|
+
_updatePosition() {
|
|
144
148
|
if (!this._map) {
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
147
151
|
divOverlayProto._updatePosition.apply(this, arguments);
|
|
148
152
|
if (this._map._rotate && this._zoomAnimated) {
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
const anchor = this._getAnchor();
|
|
154
|
+
const pos = L.DomUtil.getPosition(this._container).subtract(anchor);
|
|
151
155
|
L.DomUtil.setPosition(this._container, this._map.rotatedPointToMapPanePoint(pos).add(anchor));
|
|
152
156
|
} else if (this._map._rotate) {
|
|
153
|
-
|
|
157
|
+
const mapPanePoint = this._map.rotatedPointToMapPanePoint(this._map.latLngToLayerPoint(this._latlng)), offset = toPoint(this.options.offset || [0, 0]), anchor = this._getAnchor();
|
|
154
158
|
this._containerLeft = -Math.round(this._containerWidth / 2) + mapPanePoint.x + offset.x + anchor.x;
|
|
155
159
|
this._containerBottom = -(mapPanePoint.y + offset.y + anchor.y);
|
|
156
160
|
this._container.style.left = this._containerLeft + "px";
|
|
@@ -163,17 +167,17 @@ var leafletRotate = (() => {
|
|
|
163
167
|
});
|
|
164
168
|
|
|
165
169
|
// src/layer/Popup.js
|
|
166
|
-
var popupProto =
|
|
170
|
+
var popupProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Popup.prototype));
|
|
167
171
|
L.Popup.include({
|
|
168
172
|
/**
|
|
169
173
|
* 0. update element anchor point (popupProto v1.9.3)
|
|
170
174
|
* 1. rotate around anchor point (subtract anchor -> rotate point -> add anchor)
|
|
171
175
|
*/
|
|
172
|
-
_animateZoom
|
|
176
|
+
_animateZoom(e) {
|
|
173
177
|
popupProto._animateZoom.apply(this, arguments);
|
|
174
178
|
if (this._map && this._map._rotate) {
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
const anchor = this._getAnchor();
|
|
180
|
+
const pos = L.DomUtil.getPosition(this._container).subtract(anchor);
|
|
177
181
|
L.DomUtil.setPosition(this._container, this._map.rotatedPointToMapPanePoint(pos).add(anchor));
|
|
178
182
|
}
|
|
179
183
|
},
|
|
@@ -182,7 +186,7 @@ var leafletRotate = (() => {
|
|
|
182
186
|
*
|
|
183
187
|
* @see https://github.com/fnicollet/Leaflet/pull/21
|
|
184
188
|
*/
|
|
185
|
-
_adjustPan
|
|
189
|
+
_adjustPan() {
|
|
186
190
|
if (!this.options.autoPan || this._map._panAnim && this._map._panAnim._inProgress) {
|
|
187
191
|
return;
|
|
188
192
|
}
|
|
@@ -190,9 +194,10 @@ var leafletRotate = (() => {
|
|
|
190
194
|
this._autopanning = false;
|
|
191
195
|
return;
|
|
192
196
|
}
|
|
193
|
-
|
|
197
|
+
const map = this._map, marginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0, containerHeight = this._container.offsetHeight + marginBottom, containerWidth = this._containerWidth, layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
|
|
194
198
|
layerPos._add(L.DomUtil.getPosition(this._container));
|
|
195
|
-
|
|
199
|
+
const containerPos = layerPos._add(this._map._getMapPanePos()), padding = toPoint(this.options.autoPanPadding || [0, 0]), paddingTL = toPoint(this.options.autoPanPaddingTopLeft || padding), paddingBR = toPoint(this.options.autoPanPaddingBottomRight || padding), size = map.getSize();
|
|
200
|
+
let dx = 0, dy = 0;
|
|
196
201
|
if (containerPos.x + containerWidth + paddingBR.x > size.x) {
|
|
197
202
|
dx = containerPos.x + containerWidth - size.x + paddingBR.x;
|
|
198
203
|
}
|
|
@@ -215,41 +220,41 @@ var leafletRotate = (() => {
|
|
|
215
220
|
});
|
|
216
221
|
|
|
217
222
|
// src/layer/Tooltip.js
|
|
218
|
-
var tooltipProto =
|
|
223
|
+
var tooltipProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Tooltip.prototype));
|
|
219
224
|
L.Tooltip.include({
|
|
220
|
-
_animateZoom
|
|
225
|
+
_animateZoom(e) {
|
|
221
226
|
if (!this._map._rotate) {
|
|
222
227
|
return tooltipProto._animateZoom.apply(this, arguments);
|
|
223
228
|
}
|
|
224
|
-
|
|
229
|
+
let pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
|
|
225
230
|
pos = this._map.rotatedPointToMapPanePoint(pos);
|
|
226
231
|
this._setPosition(pos);
|
|
227
232
|
},
|
|
228
|
-
_updatePosition
|
|
233
|
+
_updatePosition() {
|
|
229
234
|
if (!this._map._rotate) {
|
|
230
235
|
return tooltipProto._updatePosition.apply(this, arguments);
|
|
231
236
|
}
|
|
232
|
-
|
|
237
|
+
let pos = this._map.latLngToLayerPoint(this._latlng);
|
|
233
238
|
pos = this._map.rotatedPointToMapPanePoint(pos);
|
|
234
239
|
this._setPosition(pos);
|
|
235
240
|
}
|
|
236
241
|
});
|
|
237
242
|
|
|
238
243
|
// src/layer/marker/Icon.js
|
|
239
|
-
var iconProto =
|
|
244
|
+
var iconProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Icon.prototype));
|
|
240
245
|
L.Icon.include({
|
|
241
|
-
_setIconStyles
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
_setIconStyles(img, name) {
|
|
247
|
+
const options = this.options;
|
|
248
|
+
let sizeOption = options[name + "Size"];
|
|
244
249
|
if (typeof sizeOption === "number") {
|
|
245
250
|
sizeOption = [sizeOption, sizeOption];
|
|
246
251
|
}
|
|
247
|
-
|
|
252
|
+
const size = sizeOption ? new L.Point(...Array.isArray(sizeOption) ? sizeOption : [sizeOption.x, sizeOption.y]) : null, anchorOption = name === "shadow" && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true), anchor = anchorOption ? new L.Point(...Array.isArray(anchorOption) ? anchorOption : [anchorOption.x, anchorOption.y]) : null;
|
|
248
253
|
img.className = "leaflet-marker-" + name + " " + (options.className || "");
|
|
249
254
|
if (anchor) {
|
|
250
255
|
img.style.marginLeft = -anchor.x + "px";
|
|
251
256
|
img.style.marginTop = -anchor.y + "px";
|
|
252
|
-
img.style
|
|
257
|
+
img.style.transformOrigin = anchor.x + "px " + anchor.y + "px 0px";
|
|
253
258
|
}
|
|
254
259
|
if (size) {
|
|
255
260
|
img.style.width = size.x + "px";
|
|
@@ -259,7 +264,7 @@ var leafletRotate = (() => {
|
|
|
259
264
|
});
|
|
260
265
|
|
|
261
266
|
// src/layer/marker/Marker.js
|
|
262
|
-
var markerProto =
|
|
267
|
+
var markerProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Marker.prototype));
|
|
263
268
|
L.Marker.mergeOptions({
|
|
264
269
|
/**
|
|
265
270
|
* Rotation of this marker in rad
|
|
@@ -288,21 +293,22 @@ var leafletRotate = (() => {
|
|
|
288
293
|
});
|
|
289
294
|
var markerDragProto;
|
|
290
295
|
var MarkerDrag = {
|
|
291
|
-
// _onDragStart
|
|
296
|
+
// _onDragStart() {
|
|
292
297
|
// if (!this._marker._map._rotate) {
|
|
293
298
|
// return markerDragProto._onDragStart.apply(this, arguments);
|
|
294
299
|
// }
|
|
295
300
|
// this._draggable.updateMapBearing(this._marker._map._bearing);
|
|
296
301
|
// },
|
|
297
|
-
_onDrag
|
|
298
|
-
|
|
302
|
+
_onDrag(e) {
|
|
303
|
+
const marker = this._marker, rotated_marker = marker.options.rotation || marker.options.rotateWithView, shadow = marker._shadow;
|
|
304
|
+
let iconPos = L.DomUtil.getPosition(marker._icon);
|
|
299
305
|
if (!rotated_marker && shadow) {
|
|
300
306
|
L.DomUtil.setPosition(shadow, iconPos);
|
|
301
307
|
}
|
|
302
308
|
if (marker._map._rotate) {
|
|
303
309
|
iconPos = marker._map.mapPanePointToRotatedPoint(iconPos);
|
|
304
310
|
}
|
|
305
|
-
|
|
311
|
+
const latlng = marker._map.layerPointToLatLng(iconPos);
|
|
306
312
|
marker._latlng = latlng;
|
|
307
313
|
e.latlng = latlng;
|
|
308
314
|
e.oldLatLng = this._oldLatLng;
|
|
@@ -310,7 +316,7 @@ var leafletRotate = (() => {
|
|
|
310
316
|
else marker.fire("move", e);
|
|
311
317
|
marker.fire("drag", e);
|
|
312
318
|
},
|
|
313
|
-
_onDragEnd
|
|
319
|
+
_onDragEnd(e) {
|
|
314
320
|
if (this._marker._map._rotate) {
|
|
315
321
|
this._marker.update();
|
|
316
322
|
}
|
|
@@ -324,11 +330,11 @@ var leafletRotate = (() => {
|
|
|
324
330
|
*
|
|
325
331
|
* @listens L.Map~rotate
|
|
326
332
|
*/
|
|
327
|
-
getEvents
|
|
328
|
-
return
|
|
333
|
+
getEvents() {
|
|
334
|
+
return Object.assign(markerProto.getEvents.apply(this, arguments), { rotate: this.update });
|
|
329
335
|
},
|
|
330
|
-
_initInteraction
|
|
331
|
-
|
|
336
|
+
_initInteraction() {
|
|
337
|
+
const ret = markerProto._initInteraction.apply(this, arguments);
|
|
332
338
|
if (this.dragging && this.dragging.enabled() && this._map && this._map._rotate) {
|
|
333
339
|
markerDragProto = markerDragProto || Object.getPrototypeOf(this.dragging);
|
|
334
340
|
this.dragging.disable();
|
|
@@ -341,11 +347,11 @@ var leafletRotate = (() => {
|
|
|
341
347
|
}
|
|
342
348
|
return ret;
|
|
343
349
|
},
|
|
344
|
-
_setPos
|
|
350
|
+
_setPos(pos) {
|
|
345
351
|
if (this._map._rotate) {
|
|
346
352
|
pos = this._map.rotatedPointToMapPanePoint(pos);
|
|
347
353
|
}
|
|
348
|
-
|
|
354
|
+
let bearing = this.options.rotation || 0;
|
|
349
355
|
if (this.options.rotateWithView) {
|
|
350
356
|
bearing += this._map._bearing;
|
|
351
357
|
}
|
|
@@ -365,20 +371,20 @@ var leafletRotate = (() => {
|
|
|
365
371
|
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
366
372
|
this._resetZIndex();
|
|
367
373
|
},
|
|
368
|
-
// _updateZIndex
|
|
374
|
+
// _updateZIndex(offset) {
|
|
369
375
|
// if (!this._map._rotate) {
|
|
370
376
|
// return markerProto._updateZIndex.apply(this, arguments);
|
|
371
377
|
// }
|
|
372
378
|
// this._icon.style.zIndex = Math.round(this._zIndex + offset);
|
|
373
379
|
// },
|
|
374
|
-
setRotation
|
|
380
|
+
setRotation(rotation) {
|
|
375
381
|
this.options.rotation = rotation;
|
|
376
382
|
this.update();
|
|
377
383
|
}
|
|
378
384
|
});
|
|
379
385
|
|
|
380
386
|
// src/layer/tile/GridLayer.js
|
|
381
|
-
var gridLayerProto =
|
|
387
|
+
var gridLayerProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.GridLayer.prototype));
|
|
382
388
|
L.GridLayer.include({
|
|
383
389
|
/**
|
|
384
390
|
* Redraw L.TileLayer bounds after the map is
|
|
@@ -386,8 +392,8 @@ var leafletRotate = (() => {
|
|
|
386
392
|
*
|
|
387
393
|
* @listens L.Map~rotate
|
|
388
394
|
*/
|
|
389
|
-
getEvents
|
|
390
|
-
|
|
395
|
+
getEvents() {
|
|
396
|
+
const events = gridLayerProto.getEvents.apply(this, arguments);
|
|
391
397
|
if (this._map._rotate && !this.options.updateWhenIdle) {
|
|
392
398
|
if (!this._onRotate) {
|
|
393
399
|
this._onRotate = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);
|
|
@@ -396,7 +402,7 @@ var leafletRotate = (() => {
|
|
|
396
402
|
}
|
|
397
403
|
return events;
|
|
398
404
|
},
|
|
399
|
-
_getTiledPixelBounds
|
|
405
|
+
_getTiledPixelBounds(center) {
|
|
400
406
|
if (!this._map._rotate) {
|
|
401
407
|
return gridLayerProto._getTiledPixelBounds.apply(this, arguments);
|
|
402
408
|
}
|
|
@@ -405,7 +411,9 @@ var leafletRotate = (() => {
|
|
|
405
411
|
});
|
|
406
412
|
|
|
407
413
|
// src/layer/vector/Renderer.js
|
|
408
|
-
var rendererProto =
|
|
414
|
+
var rendererProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Renderer.prototype));
|
|
415
|
+
var rendererBase = Object.getPrototypeOf(L.Renderer.prototype);
|
|
416
|
+
var rendererGetEvents = rendererProto.getEvents || rendererBase.getEvents;
|
|
409
417
|
L.Renderer.include({
|
|
410
418
|
/**
|
|
411
419
|
* Redraw L.Canvas and L.SVG renderer bounds after the
|
|
@@ -413,15 +421,16 @@ var leafletRotate = (() => {
|
|
|
413
421
|
*
|
|
414
422
|
* @listens L.Map~rotate
|
|
415
423
|
*/
|
|
416
|
-
getEvents
|
|
417
|
-
|
|
424
|
+
getEvents() {
|
|
425
|
+
const events = rendererGetEvents.apply(this, arguments);
|
|
426
|
+
return L.version.startsWith("2.") ? events : Object.assign(events, { rotate: this._update });
|
|
418
427
|
},
|
|
419
428
|
/**
|
|
420
429
|
* Fix for `map.flyTo()` when `false === map.options.zoomAnimation`
|
|
421
430
|
*
|
|
422
431
|
* @see https://github.com/Leaflet/Leaflet/pull/8794
|
|
423
432
|
*/
|
|
424
|
-
onAdd
|
|
433
|
+
onAdd() {
|
|
425
434
|
rendererProto.onAdd.apply(this, arguments);
|
|
426
435
|
if (L.version <= "1.9.3") {
|
|
427
436
|
this._container.classList.add("leaflet-zoom-animated");
|
|
@@ -446,16 +455,46 @@ var leafletRotate = (() => {
|
|
|
446
455
|
*
|
|
447
456
|
* @see https://github.com/Leaflet/Leaflet/compare/v1.7.0...v1.9.3
|
|
448
457
|
*/
|
|
449
|
-
_updateTransform
|
|
458
|
+
_updateTransform(center, zoom) {
|
|
459
|
+
if (L.version.startsWith("2.")) {
|
|
460
|
+
if (this._map._rotate) {
|
|
461
|
+
const scale2 = this._map.getZoomScale(zoom, this._zoom), offset2 = this._topLeftPoint.multiplyBy(scale2).subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
462
|
+
L.DomUtil.setTransform(this._container, offset2, scale2);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
return rendererBase._updateTransform.apply(this, arguments);
|
|
466
|
+
}
|
|
450
467
|
if (!this._map._rotate) {
|
|
451
468
|
return rendererProto._updateTransform.apply(this, arguments);
|
|
452
469
|
}
|
|
453
470
|
if (zoom === this._zoom) {
|
|
454
471
|
return;
|
|
455
472
|
}
|
|
456
|
-
|
|
473
|
+
const scale = this._map.getZoomScale(zoom, this._zoom), offset = this._map._latLngToNewLayerPoint(this._topLeft, zoom, center);
|
|
457
474
|
L.DomUtil.setTransform(this._container, offset, scale);
|
|
458
475
|
},
|
|
476
|
+
_onMoveEnd(ev) {
|
|
477
|
+
if (!L.version.startsWith("2.") || !this._map._rotate) {
|
|
478
|
+
return rendererBase._onMoveEnd.apply(this, arguments);
|
|
479
|
+
}
|
|
480
|
+
this._bounds = this._map._getPaddedPixelBounds(this.options.padding);
|
|
481
|
+
this._topLeft = this._map.layerPointToLatLng(this._bounds.min);
|
|
482
|
+
this._center = this._map.getCenter();
|
|
483
|
+
this._zoom = this._map.getZoom();
|
|
484
|
+
this._topLeftPoint = this._map._getNewPixelOrigin(this._center, this._zoom).add(this._bounds.min);
|
|
485
|
+
this._updateTransform(this._center, this._zoom);
|
|
486
|
+
this._resizeContainer();
|
|
487
|
+
this._onSettled(ev);
|
|
488
|
+
},
|
|
489
|
+
_resizeContainer() {
|
|
490
|
+
if (!L.version.startsWith("2.") || !this._map._rotate || !this._bounds) {
|
|
491
|
+
return rendererBase._resizeContainer.apply(this, arguments);
|
|
492
|
+
}
|
|
493
|
+
const size = this._bounds.getSize();
|
|
494
|
+
this._container.style.width = size.x + "px";
|
|
495
|
+
this._container.style.height = size.y + "px";
|
|
496
|
+
return size;
|
|
497
|
+
},
|
|
459
498
|
// getEvents() {
|
|
460
499
|
// const events = {
|
|
461
500
|
// viewreset: this._reset,
|
|
@@ -491,7 +530,7 @@ var leafletRotate = (() => {
|
|
|
491
530
|
// this._layers[id]._update();
|
|
492
531
|
// }
|
|
493
532
|
// },
|
|
494
|
-
_update
|
|
533
|
+
_update() {
|
|
495
534
|
if (!this._map._rotate) {
|
|
496
535
|
return rendererProto._update.apply(this, arguments);
|
|
497
536
|
}
|
|
@@ -503,10 +542,10 @@ var leafletRotate = (() => {
|
|
|
503
542
|
});
|
|
504
543
|
|
|
505
544
|
// src/map/Map.js
|
|
506
|
-
var mapProto =
|
|
545
|
+
var mapProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Map.prototype));
|
|
507
546
|
L.Map.mergeOptions({ rotate: false, bearing: 0 });
|
|
508
547
|
L.Map.include({
|
|
509
|
-
_animateZoomNoDelay
|
|
548
|
+
_animateZoomNoDelay(center, zoom) {
|
|
510
549
|
if (!this._mapPane) {
|
|
511
550
|
return;
|
|
512
551
|
}
|
|
@@ -520,7 +559,7 @@ var leafletRotate = (() => {
|
|
|
520
559
|
* @param {(HTMLElement|String)} id html selector
|
|
521
560
|
* @param {Object} [options={}] leaflet map options
|
|
522
561
|
*/
|
|
523
|
-
initialize
|
|
562
|
+
initialize(id, options) {
|
|
524
563
|
if (options.rotate) {
|
|
525
564
|
this._rotate = true;
|
|
526
565
|
this._bearing = 0;
|
|
@@ -538,11 +577,11 @@ var leafletRotate = (() => {
|
|
|
538
577
|
* @param {L.Point} point pixel screen coordinates
|
|
539
578
|
* @returns {L.Point} transformed pixel point
|
|
540
579
|
*/
|
|
541
|
-
containerPointToLayerPoint
|
|
580
|
+
containerPointToLayerPoint(point) {
|
|
542
581
|
if (!this._rotate) {
|
|
543
582
|
return mapProto.containerPointToLayerPoint.apply(this, arguments);
|
|
544
583
|
}
|
|
545
|
-
return
|
|
584
|
+
return toPoint(point).subtract(this._getMapPanePos()).rotateFrom(-this._bearing, this._getRotatePanePos()).subtract(this._getRotatePanePos());
|
|
546
585
|
},
|
|
547
586
|
/**
|
|
548
587
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -551,11 +590,11 @@ var leafletRotate = (() => {
|
|
|
551
590
|
* @param {L.Point} point pixel screen coordinates
|
|
552
591
|
* @returns {L.Point} transformed pixel point
|
|
553
592
|
*/
|
|
554
|
-
layerPointToContainerPoint
|
|
593
|
+
layerPointToContainerPoint(point) {
|
|
555
594
|
if (!this._rotate) {
|
|
556
595
|
return mapProto.layerPointToContainerPoint.apply(this, arguments);
|
|
557
596
|
}
|
|
558
|
-
return
|
|
597
|
+
return toPoint(point).add(this._getRotatePanePos()).rotateFrom(this._bearing, this._getRotatePanePos()).add(this._getMapPanePos());
|
|
559
598
|
},
|
|
560
599
|
/**
|
|
561
600
|
* Converts a coordinate from the rotated pane reference system
|
|
@@ -569,8 +608,8 @@ var leafletRotate = (() => {
|
|
|
569
608
|
*
|
|
570
609
|
* @since leaflet-rotate (v0.1)
|
|
571
610
|
*/
|
|
572
|
-
rotatedPointToMapPanePoint
|
|
573
|
-
return
|
|
611
|
+
rotatedPointToMapPanePoint(point) {
|
|
612
|
+
return toPoint(point).rotate(this._bearing)._add(this._getRotatePanePos());
|
|
574
613
|
},
|
|
575
614
|
/**
|
|
576
615
|
* Converts a coordinate from the not rotated map pane reference system
|
|
@@ -583,14 +622,14 @@ var leafletRotate = (() => {
|
|
|
583
622
|
*
|
|
584
623
|
* @since leaflet-rotate (v0.1)
|
|
585
624
|
*/
|
|
586
|
-
mapPanePointToRotatedPoint
|
|
587
|
-
return
|
|
625
|
+
mapPanePointToRotatedPoint(point) {
|
|
626
|
+
return toPoint(point)._subtract(this._getRotatePanePos()).rotate(-this._bearing);
|
|
588
627
|
},
|
|
589
|
-
// latLngToLayerPoint
|
|
590
|
-
//
|
|
628
|
+
// latLngToLayerPoint(latlng) {
|
|
629
|
+
// const projectedPoint = this.project(L.latLng(latlng))._round();
|
|
591
630
|
// return projectedPoint._subtract(this.getPixelOrigin());
|
|
592
631
|
// },
|
|
593
|
-
// latLngToContainerPoint
|
|
632
|
+
// latLngToContainerPoint(latlng) {
|
|
594
633
|
// return this.layerPointToContainerPoint(this.latLngToLayerPoint(toLatLng(latlng)));
|
|
595
634
|
// },
|
|
596
635
|
/**
|
|
@@ -604,16 +643,16 @@ var leafletRotate = (() => {
|
|
|
604
643
|
*
|
|
605
644
|
* @since leaflet-rotate (v0.2)
|
|
606
645
|
*/
|
|
607
|
-
mapBoundsToContainerBounds
|
|
646
|
+
mapBoundsToContainerBounds(bounds) {
|
|
608
647
|
if (!this._rotate && mapProto.mapBoundsToContainerBounds) {
|
|
609
648
|
return mapProto.mapBoundsToContainerBounds.apply(this, arguments);
|
|
610
649
|
}
|
|
611
650
|
const origin = this.getPixelOrigin();
|
|
612
651
|
const nw = this.layerPointToContainerPoint(this.project(bounds.getNorthWest())._subtract(origin)), ne = this.layerPointToContainerPoint(this.project(bounds.getNorthEast())._subtract(origin)), sw = this.layerPointToContainerPoint(this.project(bounds.getSouthWest())._subtract(origin)), se = this.layerPointToContainerPoint(this.project(bounds.getSouthEast())._subtract(origin));
|
|
613
|
-
return L.
|
|
614
|
-
L.
|
|
652
|
+
return new L.Bounds([
|
|
653
|
+
new L.Point(Math.min(nw.x, ne.x, se.x, sw.x), Math.min(nw.y, ne.y, se.y, sw.y)),
|
|
615
654
|
// [ minX, minY ]
|
|
616
|
-
L.
|
|
655
|
+
new L.Point(Math.max(nw.x, ne.x, se.x, sw.x), Math.max(nw.y, ne.y, se.y, sw.y))
|
|
617
656
|
// [ maxX, maxY ]
|
|
618
657
|
]);
|
|
619
658
|
},
|
|
@@ -627,11 +666,11 @@ var leafletRotate = (() => {
|
|
|
627
666
|
*
|
|
628
667
|
* @returns {L.LatLngBounds}
|
|
629
668
|
*/
|
|
630
|
-
getBounds
|
|
669
|
+
getBounds() {
|
|
631
670
|
if (!this._rotate) {
|
|
632
671
|
return mapProto.getBounds.apply(this, arguments);
|
|
633
672
|
}
|
|
634
|
-
|
|
673
|
+
const size = this.getSize();
|
|
635
674
|
return new L.LatLngBounds([
|
|
636
675
|
this.containerPointToLatLng([0, 0]),
|
|
637
676
|
// topleft
|
|
@@ -670,45 +709,45 @@ var leafletRotate = (() => {
|
|
|
670
709
|
*
|
|
671
710
|
* @since leaflet-rotate (v0.1)
|
|
672
711
|
*/
|
|
673
|
-
setBearing
|
|
674
|
-
if (!
|
|
712
|
+
setBearing(theta, options) {
|
|
713
|
+
if (!this._rotate) {
|
|
675
714
|
return;
|
|
676
715
|
}
|
|
677
716
|
if (options && options.animate) {
|
|
678
717
|
this._bearingAnimationId = (this._bearingAnimationId || 0) + 1;
|
|
679
|
-
|
|
718
|
+
const animationId = this._bearingAnimationId;
|
|
680
719
|
if (this._bearingAnimationFrame) {
|
|
681
|
-
|
|
720
|
+
cancelAnimationFrame(this._bearingAnimationFrame);
|
|
682
721
|
}
|
|
683
|
-
|
|
684
|
-
|
|
722
|
+
const startBearing = this.getBearing(), endBearing = L.Util.wrapNum(theta, [0, 360]), delta = (endBearing - startBearing + 540) % 360 - 180, duration = Math.max(0, options.duration == null ? 0.25 : options.duration) * 1e3, easeLinearity = Math.max(options.easeLinearity || 0.5, 0.2), startTime = performance.now();
|
|
723
|
+
const animate = function() {
|
|
685
724
|
if (!this._mapPane) {
|
|
686
725
|
delete this._bearingAnimationFrame;
|
|
687
726
|
return;
|
|
688
727
|
}
|
|
689
|
-
|
|
728
|
+
const progress = duration ? Math.min((performance.now() - startTime) / duration, 1) : 1, eased = 1 - Math.pow(1 - progress, 1 / easeLinearity);
|
|
690
729
|
this._setBearing(progress === 1 ? endBearing : startBearing + delta * eased);
|
|
691
730
|
if (this._bearingAnimationId !== animationId) {
|
|
692
731
|
return;
|
|
693
732
|
}
|
|
694
733
|
if (progress < 1) {
|
|
695
|
-
this._bearingAnimationFrame =
|
|
734
|
+
this._bearingAnimationFrame = requestAnimationFrame(animate.bind(this));
|
|
696
735
|
} else {
|
|
697
736
|
delete this._bearingAnimationFrame;
|
|
698
737
|
}
|
|
699
738
|
};
|
|
700
|
-
this._bearingAnimationFrame =
|
|
739
|
+
this._bearingAnimationFrame = requestAnimationFrame(animate.bind(this));
|
|
701
740
|
return;
|
|
702
741
|
}
|
|
703
742
|
this._bearingAnimationId = (this._bearingAnimationId || 0) + 1;
|
|
704
743
|
if (this._bearingAnimationFrame) {
|
|
705
|
-
|
|
744
|
+
cancelAnimationFrame(this._bearingAnimationFrame);
|
|
706
745
|
delete this._bearingAnimationFrame;
|
|
707
746
|
}
|
|
708
747
|
this._setBearing(theta);
|
|
709
748
|
},
|
|
710
|
-
_setBearing
|
|
711
|
-
|
|
749
|
+
_setBearing(theta) {
|
|
750
|
+
const bearing = L.Util.wrapNum(theta, [0, 360]) * (Math.PI / 180), center = this._getPixelCenter(), oldPos = this._getRotatePanePos().rotateFrom(-this._bearing, center), newPos = oldPos.rotateFrom(bearing, center);
|
|
712
751
|
L.DomUtil.setPosition(this._rotatePane, oldPos, bearing, center);
|
|
713
752
|
this._pivot = center;
|
|
714
753
|
this._bearing = bearing;
|
|
@@ -722,8 +761,8 @@ var leafletRotate = (() => {
|
|
|
722
761
|
*
|
|
723
762
|
* @since leaflet-rotate (v0.1)
|
|
724
763
|
*/
|
|
725
|
-
getBearing
|
|
726
|
-
return this._bearing *
|
|
764
|
+
getBearing() {
|
|
765
|
+
return this._bearing * (180 / Math.PI);
|
|
727
766
|
},
|
|
728
767
|
/**
|
|
729
768
|
* Creates a new [map pane](#map-pane) with the given name if it doesn't
|
|
@@ -734,7 +773,7 @@ var leafletRotate = (() => {
|
|
|
734
773
|
* @param {HTMLElement} [container] parent element
|
|
735
774
|
* @returns {HTMLElement} pane container
|
|
736
775
|
*/
|
|
737
|
-
// createPane
|
|
776
|
+
// createPane(name, container) {
|
|
738
777
|
// if (!this._rotate || name == 'mapPane') {
|
|
739
778
|
// return mapProto.createPane.apply(this, arguments);
|
|
740
779
|
// }
|
|
@@ -762,14 +801,17 @@ var leafletRotate = (() => {
|
|
|
762
801
|
* - tooltipPane [HTMLElement = 650] - Pane for tooltips.
|
|
763
802
|
* - popupPane [HTMLElement = 700] - Pane for popups.
|
|
764
803
|
*/
|
|
765
|
-
_initPanes
|
|
766
|
-
|
|
804
|
+
_initPanes() {
|
|
805
|
+
const panes = this._panes = {};
|
|
767
806
|
this._paneRenderers = {};
|
|
768
807
|
this._mapPane = this.createPane("mapPane", this._container);
|
|
769
808
|
L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));
|
|
770
809
|
if (this._rotate) {
|
|
771
810
|
this._rotatePane = this.createPane("rotatePane", this._mapPane);
|
|
772
811
|
this._norotatePane = this.createPane("norotatePane", this._mapPane);
|
|
812
|
+
if (L.version.startsWith("2.")) {
|
|
813
|
+
this._rotatePane.style.transformOrigin = "0 0";
|
|
814
|
+
}
|
|
773
815
|
this.createPane("tilePane", this._rotatePane);
|
|
774
816
|
this.createPane("overlayPane", this._rotatePane);
|
|
775
817
|
this.createPane("shadowPane", this._norotatePane);
|
|
@@ -785,8 +827,8 @@ var leafletRotate = (() => {
|
|
|
785
827
|
this.createPane("popupPane");
|
|
786
828
|
}
|
|
787
829
|
if (!this.options.markerZoomAnimation) {
|
|
788
|
-
|
|
789
|
-
|
|
830
|
+
panes.markerPane.classList.add("leaflet-zoom-hide");
|
|
831
|
+
panes.shadowPane.classList.add("leaflet-zoom-hide");
|
|
790
832
|
}
|
|
791
833
|
},
|
|
792
834
|
/**
|
|
@@ -807,7 +849,7 @@ var leafletRotate = (() => {
|
|
|
807
849
|
return mapProto.panInside.apply(this, arguments);
|
|
808
850
|
}
|
|
809
851
|
options = options || {};
|
|
810
|
-
const paddingTL =
|
|
852
|
+
const paddingTL = toPoint(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = toPoint(options.paddingBottomRight || options.padding || [0, 0]), pixelPoint = this.latLngToContainerPoint(latlng), pixelBounds = new L.Bounds([new L.Point(0, 0), this.getSize()]), pixelCenter = pixelBounds.getCenter(), paddedBounds = new L.Bounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]), paddedSize = paddedBounds.getSize();
|
|
811
853
|
if (!paddedBounds.contains(pixelPoint)) {
|
|
812
854
|
this._enforcingBounds = true;
|
|
813
855
|
const centerOffset = pixelPoint.subtract(paddedBounds.getCenter());
|
|
@@ -833,9 +875,9 @@ var leafletRotate = (() => {
|
|
|
833
875
|
* @param {Object} [options] pan options
|
|
834
876
|
* @returns {L.Map} current map instance
|
|
835
877
|
*/
|
|
836
|
-
// panInsideBounds
|
|
878
|
+
// panInsideBounds(bounds, options) {
|
|
837
879
|
// this._enforcingBounds = true;
|
|
838
|
-
//
|
|
880
|
+
// const center = this.getCenter(),
|
|
839
881
|
// newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));
|
|
840
882
|
//
|
|
841
883
|
// if (!center.equals(newCenter)) {
|
|
@@ -906,8 +948,8 @@ var leafletRotate = (() => {
|
|
|
906
948
|
if (!this._rotate || Math.abs(this._bearing).toFixed(1) < 0.1) {
|
|
907
949
|
return mapProto.getBoundsZoom.apply(this, arguments);
|
|
908
950
|
}
|
|
909
|
-
bounds = L.
|
|
910
|
-
padding =
|
|
951
|
+
bounds = bounds instanceof L.LatLngBounds ? bounds : new L.LatLngBounds(bounds);
|
|
952
|
+
padding = toPoint(padding || [0, 0]);
|
|
911
953
|
let zoom = this.getZoom() || 0;
|
|
912
954
|
const min = this.getMinZoom(), max = this.getMaxZoom(), size = this.getSize().subtract(padding), boundsSize = this.mapBoundsToContainerBounds(bounds).getSize(), snap = this.options.zoomSnap, scalex = size.x / boundsSize.x, scaley = size.y / boundsSize.y, scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley);
|
|
913
955
|
zoom = this.getScaleZoom(scale, zoom);
|
|
@@ -922,7 +964,7 @@ var leafletRotate = (() => {
|
|
|
922
964
|
*
|
|
923
965
|
* @returns {L.Point} layer center
|
|
924
966
|
*/
|
|
925
|
-
// _getCenterLayerPoint
|
|
967
|
+
// _getCenterLayerPoint() {
|
|
926
968
|
// return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
|
|
927
969
|
// },
|
|
928
970
|
/**
|
|
@@ -930,8 +972,8 @@ var leafletRotate = (() => {
|
|
|
930
972
|
*
|
|
931
973
|
* @param {L.LatLng} latlng map coordinates
|
|
932
974
|
*/
|
|
933
|
-
_getCenterOffset
|
|
934
|
-
|
|
975
|
+
_getCenterOffset(latlng) {
|
|
976
|
+
let centerOffset = mapProto._getCenterOffset.apply(this, arguments);
|
|
935
977
|
if (this._rotate) {
|
|
936
978
|
centerOffset = centerOffset.rotate(this._bearing);
|
|
937
979
|
}
|
|
@@ -940,18 +982,18 @@ var leafletRotate = (() => {
|
|
|
940
982
|
/**
|
|
941
983
|
* @since leaflet-rotate (v0.1)
|
|
942
984
|
*/
|
|
943
|
-
_getRotatePanePos
|
|
985
|
+
_getRotatePanePos() {
|
|
944
986
|
return this._rotatePanePos || new L.Point(0, 0);
|
|
945
987
|
},
|
|
946
988
|
// _latLngToNewLayerPoint(latlng, zoom, center) {
|
|
947
989
|
// const topLeft = this._getNewPixelOrigin(center, zoom);
|
|
948
990
|
// return this.project(latlng, zoom)._subtract(topLeft);
|
|
949
991
|
//},
|
|
950
|
-
_getNewPixelOrigin
|
|
951
|
-
if (!this._rotate) {
|
|
992
|
+
_getNewPixelOrigin(center, zoom) {
|
|
993
|
+
if (!this._rotate || L.version.startsWith("2.")) {
|
|
952
994
|
return mapProto._getNewPixelOrigin.apply(this, arguments);
|
|
953
995
|
}
|
|
954
|
-
|
|
996
|
+
const viewHalf = this.getSize()._divideBy(2);
|
|
955
997
|
return this.project(center, zoom).rotate(this._bearing)._subtract(viewHalf)._add(this._getMapPanePos())._add(this._getRotatePanePos()).rotate(-this._bearing)._round();
|
|
956
998
|
},
|
|
957
999
|
/**
|
|
@@ -959,13 +1001,13 @@ var leafletRotate = (() => {
|
|
|
959
1001
|
*
|
|
960
1002
|
* @see src\layer\tile\GridLayer::_getTiledPixelBounds()
|
|
961
1003
|
*/
|
|
962
|
-
_getNewPixelBounds
|
|
1004
|
+
_getNewPixelBounds(center, zoom) {
|
|
963
1005
|
center = center || this.getCenter();
|
|
964
1006
|
zoom = zoom || this.getZoom();
|
|
965
1007
|
if (!this._rotate && mapProto._getNewPixelBounds) {
|
|
966
1008
|
return mapProto._getNewPixelBounds.apply(this, arguments);
|
|
967
1009
|
}
|
|
968
|
-
|
|
1010
|
+
const mapZoom = this._animatingZoom ? Math.max(this._animateToZoom, this.getZoom()) : this.getZoom(), scale = this.getZoomScale(mapZoom, zoom), pixelCenter = this.project(center, zoom).floor(), size = this.getSize(), halfSize = new L.Bounds([
|
|
969
1011
|
this.containerPointToLayerPoint([0, 0]).floor(),
|
|
970
1012
|
this.containerPointToLayerPoint([size.x, 0]).floor(),
|
|
971
1013
|
this.containerPointToLayerPoint([0, size.y]).floor(),
|
|
@@ -978,7 +1020,7 @@ var leafletRotate = (() => {
|
|
|
978
1020
|
*
|
|
979
1021
|
* @return {L.Point} map pivot point (center)
|
|
980
1022
|
*/
|
|
981
|
-
_getPixelCenter
|
|
1023
|
+
_getPixelCenter() {
|
|
982
1024
|
if (!this._rotate && mapProto._getPixelCenter) {
|
|
983
1025
|
return mapProto._getPixelCenter.apply(this, arguments);
|
|
984
1026
|
}
|
|
@@ -989,11 +1031,11 @@ var leafletRotate = (() => {
|
|
|
989
1031
|
*
|
|
990
1032
|
* @see src\layer\vector\Renderer::_update()
|
|
991
1033
|
*/
|
|
992
|
-
_getPaddedPixelBounds
|
|
1034
|
+
_getPaddedPixelBounds(padding) {
|
|
993
1035
|
if (!this._rotate && mapProto._getPaddedPixelBounds) {
|
|
994
1036
|
return mapProto._getPaddedPixelBounds.apply(this, arguments);
|
|
995
1037
|
}
|
|
996
|
-
|
|
1038
|
+
const p = padding, size = this.getSize(), padMin = size.multiplyBy(-p), padMax = size.multiplyBy(1 + p);
|
|
997
1039
|
return new L.Bounds([
|
|
998
1040
|
this.containerPointToLayerPoint([padMin.x, padMin.y]).floor(),
|
|
999
1041
|
this.containerPointToLayerPoint([padMin.x, padMax.y]).floor(),
|
|
@@ -1001,23 +1043,23 @@ var leafletRotate = (() => {
|
|
|
1001
1043
|
this.containerPointToLayerPoint([padMax.x, padMax.y]).floor()
|
|
1002
1044
|
]);
|
|
1003
1045
|
},
|
|
1004
|
-
_handleGeolocationResponse
|
|
1046
|
+
_handleGeolocationResponse(pos) {
|
|
1005
1047
|
if (!this._container._leaflet_id) {
|
|
1006
1048
|
return;
|
|
1007
1049
|
}
|
|
1008
|
-
|
|
1050
|
+
const lat = pos.coords.latitude, lng = pos.coords.longitude, hdg = pos.coords.heading, latlng = new L.LatLng(lat, lng), bounds = latlng.toBounds(pos.coords.accuracy), options = this._locateOptions;
|
|
1009
1051
|
if (options.setView) {
|
|
1010
|
-
|
|
1052
|
+
const zoom = this.getBoundsZoom(bounds);
|
|
1011
1053
|
this.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom);
|
|
1012
1054
|
}
|
|
1013
|
-
|
|
1055
|
+
const data = {
|
|
1014
1056
|
latlng,
|
|
1015
1057
|
bounds,
|
|
1016
1058
|
timestamp: pos.timestamp,
|
|
1017
1059
|
/** @TODO use mapProto._handleGeolocationResponse */
|
|
1018
1060
|
heading: hdg
|
|
1019
1061
|
};
|
|
1020
|
-
for (
|
|
1062
|
+
for (const i in pos.coords) {
|
|
1021
1063
|
if (typeof pos.coords[i] === "number") {
|
|
1022
1064
|
data[i] = pos.coords[i];
|
|
1023
1065
|
}
|
|
@@ -1031,7 +1073,7 @@ var leafletRotate = (() => {
|
|
|
1031
1073
|
* @returns {L.Bounds}
|
|
1032
1074
|
*/
|
|
1033
1075
|
// toCircumscribedBounds(points) {
|
|
1034
|
-
//
|
|
1076
|
+
// const minX = points.reduce(function (pv, v) { return Math.min(pv, v.x); }, points[0].x),
|
|
1035
1077
|
// maxX = points.reduce(function (pv, v) { return Math.max(pv, v.x); }, points[0].x),
|
|
1036
1078
|
// minY = points.reduce(function (pv, v) { return Math.min(pv, v.y); }, points[0].y),
|
|
1037
1079
|
// maxY = points.reduce(function (pv, v) { return Math.max(pv, v.y); }, points[0].y);
|
|
@@ -1042,7 +1084,7 @@ var leafletRotate = (() => {
|
|
|
1042
1084
|
|
|
1043
1085
|
// src/map/handler/CompassBearing.js
|
|
1044
1086
|
L.Map.CompassBearing = L.Handler.extend({
|
|
1045
|
-
initialize
|
|
1087
|
+
initialize(map) {
|
|
1046
1088
|
this._map = map;
|
|
1047
1089
|
if ("ondeviceorientationabsolute" in window) {
|
|
1048
1090
|
this.__deviceOrientationEvent = "deviceorientationabsolute";
|
|
@@ -1051,14 +1093,14 @@ var leafletRotate = (() => {
|
|
|
1051
1093
|
}
|
|
1052
1094
|
this._throttled = L.Util.throttle(this._onDeviceOrientation, 100, this);
|
|
1053
1095
|
},
|
|
1054
|
-
addHooks
|
|
1096
|
+
addHooks() {
|
|
1055
1097
|
if (this._map._rotate && this.__deviceOrientationEvent) {
|
|
1056
1098
|
L.DomEvent.on(window, this.__deviceOrientationEvent, this._throttled, this);
|
|
1057
1099
|
} else {
|
|
1058
1100
|
this.disable();
|
|
1059
1101
|
}
|
|
1060
1102
|
},
|
|
1061
|
-
removeHooks
|
|
1103
|
+
removeHooks() {
|
|
1062
1104
|
if (this._map._rotate && this.__deviceOrientationEvent) {
|
|
1063
1105
|
L.DomEvent.off(window, this.__deviceOrientationEvent, this._throttled, this);
|
|
1064
1106
|
}
|
|
@@ -1081,9 +1123,9 @@ var leafletRotate = (() => {
|
|
|
1081
1123
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/alpha
|
|
1082
1124
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/orientation
|
|
1083
1125
|
*/
|
|
1084
|
-
_onDeviceOrientation
|
|
1085
|
-
|
|
1086
|
-
|
|
1126
|
+
_onDeviceOrientation(e) {
|
|
1127
|
+
let angle = e.webkitCompassHeading != null ? e.webkitCompassHeading : e.alpha;
|
|
1128
|
+
let deviceOrientation = 0;
|
|
1087
1129
|
if (!Number.isFinite(angle)) {
|
|
1088
1130
|
return;
|
|
1089
1131
|
}
|
|
@@ -1113,7 +1155,7 @@ var leafletRotate = (() => {
|
|
|
1113
1155
|
trackContainerMutation: false
|
|
1114
1156
|
});
|
|
1115
1157
|
L.Map.ContainerMutation = L.Handler.extend({
|
|
1116
|
-
addHooks
|
|
1158
|
+
addHooks() {
|
|
1117
1159
|
if (!this._observer) {
|
|
1118
1160
|
this._observer = new MutationObserver(L.Util.bind(this._map.invalidateSize, this._map));
|
|
1119
1161
|
}
|
|
@@ -1125,13 +1167,20 @@ var leafletRotate = (() => {
|
|
|
1125
1167
|
attributeFilter: ["style"]
|
|
1126
1168
|
});
|
|
1127
1169
|
},
|
|
1128
|
-
removeHooks
|
|
1170
|
+
removeHooks() {
|
|
1129
1171
|
this._observer.disconnect();
|
|
1130
1172
|
}
|
|
1131
1173
|
});
|
|
1132
1174
|
L.Map.addInitHook("addHandler", "trackContainerMutation", L.Map.ContainerMutation);
|
|
1133
1175
|
|
|
1134
1176
|
// src/map/handler/TouchGestures.js
|
|
1177
|
+
function touchToContainerPoint(map, touch) {
|
|
1178
|
+
const container = map.getContainer(), rect = container.getBoundingClientRect();
|
|
1179
|
+
return new L.Point(
|
|
1180
|
+
touch.clientX - rect.left - container.clientLeft,
|
|
1181
|
+
touch.clientY - rect.top - container.clientTop
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1135
1184
|
L.Map.mergeOptions({
|
|
1136
1185
|
/**
|
|
1137
1186
|
* Set it to false if you don't want the map to
|
|
@@ -1143,23 +1192,23 @@ var leafletRotate = (() => {
|
|
|
1143
1192
|
bounceAtZoomLimits: true
|
|
1144
1193
|
});
|
|
1145
1194
|
L.Map.TouchGestures = L.Handler.extend({
|
|
1146
|
-
initialize
|
|
1195
|
+
initialize(map) {
|
|
1147
1196
|
this._map = map;
|
|
1148
1197
|
this.rotate = !!this._map.options.touchRotate;
|
|
1149
1198
|
this.zoom = !!this._map.options.touchZoom;
|
|
1150
1199
|
},
|
|
1151
|
-
addHooks
|
|
1200
|
+
addHooks() {
|
|
1152
1201
|
L.DomEvent.on(this._map._container, "touchstart", this._onTouchStart, this);
|
|
1153
1202
|
},
|
|
1154
|
-
removeHooks
|
|
1203
|
+
removeHooks() {
|
|
1155
1204
|
L.DomEvent.off(this._map._container, "touchstart", this._onTouchStart, this);
|
|
1156
1205
|
},
|
|
1157
|
-
_onTouchStart
|
|
1158
|
-
|
|
1206
|
+
_onTouchStart(e) {
|
|
1207
|
+
const map = this._map;
|
|
1159
1208
|
if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming || this._rotating) {
|
|
1160
1209
|
return;
|
|
1161
1210
|
}
|
|
1162
|
-
|
|
1211
|
+
const p1 = touchToContainerPoint(map, e.touches[0]), p2 = touchToContainerPoint(map, e.touches[1]), vector = p1.subtract(p2);
|
|
1163
1212
|
this._centerPoint = map.getSize()._divideBy(2);
|
|
1164
1213
|
this._startLatLng = map.containerPointToLatLng(this._centerPoint);
|
|
1165
1214
|
if (this.zoom) {
|
|
@@ -1187,14 +1236,15 @@ var leafletRotate = (() => {
|
|
|
1187
1236
|
L.DomEvent.on(document, "touchmove", this._onTouchMove, this).on(document, "touchend touchcancel", this._onTouchEnd, this);
|
|
1188
1237
|
L.DomEvent.preventDefault(e);
|
|
1189
1238
|
},
|
|
1190
|
-
_onTouchMove
|
|
1239
|
+
_onTouchMove(e) {
|
|
1191
1240
|
if (!e.touches || e.touches.length !== 2 || !(this._zooming || this._rotating)) {
|
|
1192
1241
|
return;
|
|
1193
1242
|
}
|
|
1194
|
-
|
|
1243
|
+
const map = this._map, p1 = touchToContainerPoint(map, e.touches[0]), p2 = touchToContainerPoint(map, e.touches[1]), vector = p1.subtract(p2), scale = p1.distanceTo(p2) / this._startDist;
|
|
1244
|
+
let delta;
|
|
1195
1245
|
if (this._rotating) {
|
|
1196
|
-
|
|
1197
|
-
|
|
1246
|
+
const theta = Math.atan(vector.x / vector.y);
|
|
1247
|
+
let bearingDelta = (theta - this._startTheta) * (180 / Math.PI);
|
|
1198
1248
|
if (vector.y < 0) {
|
|
1199
1249
|
bearingDelta += 180;
|
|
1200
1250
|
}
|
|
@@ -1217,7 +1267,7 @@ var leafletRotate = (() => {
|
|
|
1217
1267
|
if (scale === 1 && delta.x === 0 && delta.y === 0) {
|
|
1218
1268
|
return;
|
|
1219
1269
|
}
|
|
1220
|
-
|
|
1270
|
+
const alpha = -map.getBearing() * (Math.PI / 180);
|
|
1221
1271
|
this._center = map.unproject(map.project(this._pinchStartLatLng).subtract(delta.rotate(alpha)));
|
|
1222
1272
|
}
|
|
1223
1273
|
}
|
|
@@ -1225,9 +1275,8 @@ var leafletRotate = (() => {
|
|
|
1225
1275
|
map._moveStart(true, false);
|
|
1226
1276
|
this._moved = true;
|
|
1227
1277
|
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
this._animRequest = L.Util.requestAnimFrame(moveFn, this, true);
|
|
1278
|
+
const moveFn = map._move.bind(map, this._center, this._zoom, { pinch: true, round: false }, void 0);
|
|
1279
|
+
moveFn();
|
|
1231
1280
|
if (this.zoom) {
|
|
1232
1281
|
if (map.options.zoomAnimation) {
|
|
1233
1282
|
map._animateZoomNoDelay(this._center, map._limitZoom(this._zoom));
|
|
@@ -1237,14 +1286,13 @@ var leafletRotate = (() => {
|
|
|
1237
1286
|
}
|
|
1238
1287
|
L.DomEvent.preventDefault(e);
|
|
1239
1288
|
},
|
|
1240
|
-
_onTouchEnd
|
|
1289
|
+
_onTouchEnd() {
|
|
1241
1290
|
if (!this._moved || !(this._zooming || this._rotating)) {
|
|
1242
1291
|
this._zooming = false;
|
|
1243
1292
|
return;
|
|
1244
1293
|
}
|
|
1245
1294
|
this._zooming = false;
|
|
1246
1295
|
this._rotating = false;
|
|
1247
|
-
L.Util.cancelAnimFrame(this._animRequest);
|
|
1248
1296
|
L.DomEvent.off(document, "touchmove", this._onTouchMove, this).off(document, "touchend touchcancel", this._onTouchEnd, this);
|
|
1249
1297
|
if (this.zoom) {
|
|
1250
1298
|
if (this._map.options.zoomAnimation) {
|
|
@@ -1267,11 +1315,11 @@ var leafletRotate = (() => {
|
|
|
1267
1315
|
touchRotate: false
|
|
1268
1316
|
});
|
|
1269
1317
|
L.Map.TouchRotate = L.Handler.extend({
|
|
1270
|
-
addHooks
|
|
1318
|
+
addHooks() {
|
|
1271
1319
|
this._map.touchGestures.enable();
|
|
1272
1320
|
this._map.touchGestures.rotate = true;
|
|
1273
1321
|
},
|
|
1274
|
-
removeHooks
|
|
1322
|
+
removeHooks() {
|
|
1275
1323
|
this._map.touchGestures.rotate = false;
|
|
1276
1324
|
}
|
|
1277
1325
|
});
|
|
@@ -1286,19 +1334,19 @@ var leafletRotate = (() => {
|
|
|
1286
1334
|
shiftKeyRotate: true
|
|
1287
1335
|
});
|
|
1288
1336
|
L.Map.ShiftKeyRotate = L.Handler.extend({
|
|
1289
|
-
addHooks
|
|
1337
|
+
addHooks() {
|
|
1290
1338
|
L.DomEvent.on(this._map._container, "wheel", this._handleShiftScroll, this);
|
|
1291
1339
|
this._map.shiftKeyRotate.rotate = true;
|
|
1292
1340
|
},
|
|
1293
|
-
removeHooks
|
|
1341
|
+
removeHooks() {
|
|
1294
1342
|
L.DomEvent.off(this._map._container, "wheel", this._handleShiftScroll, this);
|
|
1295
1343
|
this._map.shiftKeyRotate.rotate = false;
|
|
1296
1344
|
},
|
|
1297
|
-
_handleShiftScroll
|
|
1345
|
+
_handleShiftScroll(e) {
|
|
1298
1346
|
if (e.shiftKey) {
|
|
1299
1347
|
e.preventDefault();
|
|
1300
1348
|
this._map.scrollWheelZoom.disable();
|
|
1301
|
-
this._map.setBearing(this._map._bearing *
|
|
1349
|
+
this._map.setBearing(this._map._bearing * (180 / Math.PI) + Math.sign(e.deltaY) * 5);
|
|
1302
1350
|
} else {
|
|
1303
1351
|
this._map.scrollWheelZoom.enable();
|
|
1304
1352
|
}
|
|
@@ -1336,13 +1384,13 @@ var leafletRotate = (() => {
|
|
|
1336
1384
|
bounceAtZoomLimits: false
|
|
1337
1385
|
});
|
|
1338
1386
|
L.Map.TouchZoom = L.Handler.extend({
|
|
1339
|
-
addHooks
|
|
1340
|
-
|
|
1387
|
+
addHooks() {
|
|
1388
|
+
this._map._container.classList.add("leaflet-touch-zoom");
|
|
1341
1389
|
this._map.touchGestures.enable();
|
|
1342
1390
|
this._map.touchGestures.zoom = true;
|
|
1343
1391
|
},
|
|
1344
|
-
removeHooks
|
|
1345
|
-
|
|
1392
|
+
removeHooks() {
|
|
1393
|
+
this._map._container.classList.remove("leaflet-touch-zoom");
|
|
1346
1394
|
this._map.touchGestures.zoom = false;
|
|
1347
1395
|
}
|
|
1348
1396
|
});
|
|
@@ -1354,9 +1402,9 @@ var leafletRotate = (() => {
|
|
|
1354
1402
|
position: "topleft",
|
|
1355
1403
|
closeOnZeroBearing: true
|
|
1356
1404
|
},
|
|
1357
|
-
onAdd
|
|
1358
|
-
|
|
1359
|
-
|
|
1405
|
+
onAdd(map) {
|
|
1406
|
+
const container = this._container = L.DomUtil.create("div", "leaflet-control-rotate leaflet-bar");
|
|
1407
|
+
const arrow = this._arrow = L.DomUtil.create("span", "leaflet-control-rotate-arrow");
|
|
1360
1408
|
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")`;
|
|
1361
1409
|
arrow.style.cursor = "grab";
|
|
1362
1410
|
arrow.style.display = "block";
|
|
@@ -1364,14 +1412,11 @@ var leafletRotate = (() => {
|
|
|
1364
1412
|
arrow.style.height = "100%";
|
|
1365
1413
|
arrow.style.backgroundRepeat = "no-repeat";
|
|
1366
1414
|
arrow.style.backgroundPosition = "50%";
|
|
1367
|
-
|
|
1415
|
+
const link = this._link = L.DomUtil.create("a", "leaflet-control-rotate-toggle", container);
|
|
1368
1416
|
link.appendChild(arrow);
|
|
1369
1417
|
link.href = "#";
|
|
1370
1418
|
link.title = "Rotate map";
|
|
1371
1419
|
L.DomEvent.on(link, "dblclick", L.DomEvent.stopPropagation).on(link, "mousedown", this._handleMouseDown, this).on(link, "click", L.DomEvent.stop).on(link, "click", this._cycleState, this).on(link, "click", this._refocusOnMap, this);
|
|
1372
|
-
if (!L.Browser.any3d) {
|
|
1373
|
-
L.DomUtil.addClass(link, "leaflet-disabled");
|
|
1374
|
-
}
|
|
1375
1420
|
this._restyle();
|
|
1376
1421
|
map.on("rotate", this._restyle, this);
|
|
1377
1422
|
this._follow = false;
|
|
@@ -1381,33 +1426,33 @@ var leafletRotate = (() => {
|
|
|
1381
1426
|
}
|
|
1382
1427
|
return container;
|
|
1383
1428
|
},
|
|
1384
|
-
onRemove
|
|
1429
|
+
onRemove(map) {
|
|
1385
1430
|
map.off("rotate", this._restyle, this);
|
|
1386
1431
|
},
|
|
1387
|
-
_handleMouseDown
|
|
1432
|
+
_handleMouseDown(e) {
|
|
1388
1433
|
L.DomEvent.stop(e);
|
|
1389
1434
|
this.dragging = true;
|
|
1390
1435
|
this.dragstartX = e.pageX;
|
|
1391
1436
|
this.dragstartY = e.pageY;
|
|
1392
1437
|
L.DomEvent.on(document, "mousemove", this._handleMouseDrag, this).on(document, "mouseup", this._handleMouseUp, this);
|
|
1393
1438
|
},
|
|
1394
|
-
_handleMouseUp
|
|
1439
|
+
_handleMouseUp(e) {
|
|
1395
1440
|
L.DomEvent.stop(e);
|
|
1396
1441
|
this.dragging = false;
|
|
1397
1442
|
L.DomEvent.off(document, "mousemove", this._handleMouseDrag, this).off(document, "mouseup", this._handleMouseUp, this);
|
|
1398
1443
|
},
|
|
1399
|
-
_handleMouseDrag
|
|
1444
|
+
_handleMouseDrag(e) {
|
|
1400
1445
|
if (!this.dragging) {
|
|
1401
1446
|
return;
|
|
1402
1447
|
}
|
|
1403
|
-
|
|
1448
|
+
const deltaX = e.clientX - this.dragstartX;
|
|
1404
1449
|
this._map.setBearing(deltaX);
|
|
1405
1450
|
},
|
|
1406
|
-
_cycleState
|
|
1451
|
+
_cycleState(ev) {
|
|
1407
1452
|
if (!this._map) {
|
|
1408
1453
|
return;
|
|
1409
1454
|
}
|
|
1410
|
-
|
|
1455
|
+
const map = this._map;
|
|
1411
1456
|
if (!map.touchRotate.enabled() && !map.compassBearing.enabled()) {
|
|
1412
1457
|
map.touchRotate.enable();
|
|
1413
1458
|
} else if (!map.compassBearing.enabled()) {
|
|
@@ -1422,12 +1467,12 @@ var leafletRotate = (() => {
|
|
|
1422
1467
|
}
|
|
1423
1468
|
this._restyle();
|
|
1424
1469
|
},
|
|
1425
|
-
_restyle
|
|
1470
|
+
_restyle() {
|
|
1426
1471
|
if (!this._map.options.rotate) {
|
|
1427
|
-
|
|
1472
|
+
this._link.classList.add("leaflet-disabled");
|
|
1428
1473
|
} else {
|
|
1429
|
-
|
|
1430
|
-
|
|
1474
|
+
const map = this._map;
|
|
1475
|
+
const bearing = map.getBearing();
|
|
1431
1476
|
this._arrow.style.transform = "rotate(" + bearing + "deg)";
|
|
1432
1477
|
if (bearing && this.options.closeOnZeroBearing) {
|
|
1433
1478
|
this._container.style.display = "block";
|
|
@@ -1445,16 +1490,16 @@ var leafletRotate = (() => {
|
|
|
1445
1490
|
}
|
|
1446
1491
|
}
|
|
1447
1492
|
});
|
|
1448
|
-
L.control
|
|
1449
|
-
|
|
1450
|
-
}
|
|
1493
|
+
if (L.control) {
|
|
1494
|
+
L.control.rotate = (options) => new L.Control.Rotate(options);
|
|
1495
|
+
}
|
|
1451
1496
|
L.Map.mergeOptions({
|
|
1452
1497
|
rotateControl: true
|
|
1453
1498
|
});
|
|
1454
1499
|
L.Map.addInitHook(function() {
|
|
1455
1500
|
if (this.options.rotateControl) {
|
|
1456
|
-
|
|
1457
|
-
this.rotateControl = L.
|
|
1501
|
+
const options = typeof this.options.rotateControl === "object" ? this.options.rotateControl : {};
|
|
1502
|
+
this.rotateControl = new L.Control.Rotate(options);
|
|
1458
1503
|
this.addControl(this.rotateControl);
|
|
1459
1504
|
}
|
|
1460
1505
|
});
|