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.
@@ -4,7 +4,9 @@
4
4
  * @see https://github.com/Leaflet/Leaflet/tree/v1.9.3/src/layer/vector/Renderer.js
5
5
  */
6
6
 
7
- const rendererProto = L.extend({}, L.Renderer.prototype);
7
+ const rendererProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Renderer.prototype));
8
+ const rendererBase = Object.getPrototypeOf(L.Renderer.prototype);
9
+ const rendererGetEvents = rendererProto.getEvents || rendererBase.getEvents;
8
10
 
9
11
  L.Renderer.include({
10
12
 
@@ -14,8 +16,9 @@ L.Renderer.include({
14
16
  *
15
17
  * @listens L.Map~rotate
16
18
  */
17
- getEvents: function() {
18
- return L.extend(rendererProto.getEvents.apply(this, arguments), { rotate: this._update });
19
+ getEvents() {
20
+ const events = rendererGetEvents.apply(this, arguments);
21
+ return L.version.startsWith('2.') ? events : Object.assign(events, { rotate: this._update });
19
22
  },
20
23
 
21
24
  /**
@@ -23,7 +26,7 @@ L.Renderer.include({
23
26
  *
24
27
  * @see https://github.com/Leaflet/Leaflet/pull/8794
25
28
  */
26
- onAdd: function() {
29
+ onAdd() {
27
30
  rendererProto.onAdd.apply(this, arguments);
28
31
  if (L.version <= "1.9.3") {
29
32
  // always keep transform-origin as 0 0
@@ -50,7 +53,18 @@ L.Renderer.include({
50
53
  *
51
54
  * @see https://github.com/Leaflet/Leaflet/compare/v1.7.0...v1.9.3
52
55
  */
53
- _updateTransform: function(center, zoom) {
56
+ _updateTransform(center, zoom) {
57
+ if (L.version.startsWith('2.')) {
58
+ if (this._map._rotate) {
59
+ const scale = this._map.getZoomScale(zoom, this._zoom),
60
+ offset = this._topLeftPoint.multiplyBy(scale)
61
+ .subtract(this._map._getNewPixelOrigin(center, zoom));
62
+
63
+ L.DomUtil.setTransform(this._container, offset, scale);
64
+ return;
65
+ }
66
+ return rendererBase._updateTransform.apply(this, arguments);
67
+ }
54
68
  if (!this._map._rotate) {
55
69
  return rendererProto._updateTransform.apply(this, arguments);
56
70
  }
@@ -61,13 +75,39 @@ L.Renderer.include({
61
75
  /**
62
76
  * @FIXME see path._renderer._reset();
63
77
  */
64
- var scale = this._map.getZoomScale(zoom, this._zoom),
78
+ const scale = this._map.getZoomScale(zoom, this._zoom),
65
79
  offset = this._map._latLngToNewLayerPoint(this._topLeft, zoom, center);
66
80
 
67
81
  L.DomUtil.setTransform(this._container, offset, scale);
68
82
 
69
83
  },
70
84
 
85
+ _onMoveEnd(ev) {
86
+ if (!L.version.startsWith('2.') || !this._map._rotate) {
87
+ return rendererBase._onMoveEnd.apply(this, arguments);
88
+ }
89
+
90
+ this._bounds = this._map._getPaddedPixelBounds(this.options.padding);
91
+ this._topLeft = this._map.layerPointToLatLng(this._bounds.min);
92
+ this._center = this._map.getCenter();
93
+ this._zoom = this._map.getZoom();
94
+ this._topLeftPoint = this._map._getNewPixelOrigin(this._center, this._zoom).add(this._bounds.min);
95
+ this._updateTransform(this._center, this._zoom);
96
+ this._resizeContainer();
97
+ this._onSettled(ev);
98
+ },
99
+
100
+ _resizeContainer() {
101
+ if (!L.version.startsWith('2.') || !this._map._rotate || !this._bounds) {
102
+ return rendererBase._resizeContainer.apply(this, arguments);
103
+ }
104
+
105
+ const size = this._bounds.getSize();
106
+ this._container.style.width = size.x + 'px';
107
+ this._container.style.height = size.y + 'px';
108
+ return size;
109
+ },
110
+
71
111
  // getEvents() {
72
112
  // const events = {
73
113
  // viewreset: this._reset,
@@ -110,7 +150,7 @@ L.Renderer.include({
110
150
  // }
111
151
  // },
112
152
 
113
- _update: function() {
153
+ _update() {
114
154
  if (!this._map._rotate) {
115
155
  return rendererProto._update.apply(this, arguments);
116
156
  }
package/src/map/Map.js CHANGED
@@ -4,13 +4,15 @@
4
4
  * @see https://github.com/Leaflet/Leaflet/blob/v1.9.3/src/map/Map.js
5
5
  */
6
6
 
7
- const mapProto = L.extend({}, L.Map.prototype);
7
+ import { toPoint } from '../geometry/Point';
8
+
9
+ const mapProto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(L.Map.prototype));
8
10
 
9
11
  L.Map.mergeOptions({ rotate: false, bearing: 0, });
10
12
 
11
13
  L.Map.include({
12
14
 
13
- _animateZoomNoDelay: function(center, zoom) {
15
+ _animateZoomNoDelay(center, zoom) {
14
16
  if (!this._mapPane) { return; }
15
17
 
16
18
  this._animatingZoom = true;
@@ -24,7 +26,7 @@ L.Map.include({
24
26
  * @param {(HTMLElement|String)} id html selector
25
27
  * @param {Object} [options={}] leaflet map options
26
28
  */
27
- initialize: function(id, options) {
29
+ initialize(id, options) {
28
30
  if (options.rotate) {
29
31
  this._rotate = true;
30
32
  this._bearing = 0;
@@ -43,11 +45,11 @@ L.Map.include({
43
45
  * @param {L.Point} point pixel screen coordinates
44
46
  * @returns {L.Point} transformed pixel point
45
47
  */
46
- containerPointToLayerPoint: function(point) {
48
+ containerPointToLayerPoint(point) {
47
49
  if (!this._rotate) {
48
50
  return mapProto.containerPointToLayerPoint.apply(this, arguments);
49
51
  }
50
- return L.point(point)
52
+ return toPoint(point)
51
53
  .subtract(this._getMapPanePos())
52
54
  .rotateFrom(-this._bearing, this._getRotatePanePos())
53
55
  .subtract(this._getRotatePanePos());
@@ -60,11 +62,11 @@ L.Map.include({
60
62
  * @param {L.Point} point pixel screen coordinates
61
63
  * @returns {L.Point} transformed pixel point
62
64
  */
63
- layerPointToContainerPoint: function(point) {
65
+ layerPointToContainerPoint(point) {
64
66
  if (!this._rotate) {
65
67
  return mapProto.layerPointToContainerPoint.apply(this, arguments);
66
68
  }
67
- return L.point(point)
69
+ return toPoint(point)
68
70
  .add(this._getRotatePanePos())
69
71
  .rotateFrom(this._bearing, this._getRotatePanePos())
70
72
  .add(this._getMapPanePos());
@@ -82,8 +84,8 @@ L.Map.include({
82
84
  *
83
85
  * @since leaflet-rotate (v0.1)
84
86
  */
85
- rotatedPointToMapPanePoint: function(point) {
86
- return L.point(point)
87
+ rotatedPointToMapPanePoint(point) {
88
+ return toPoint(point)
87
89
  .rotate(this._bearing)
88
90
  ._add(this._getRotatePanePos());
89
91
  },
@@ -99,18 +101,18 @@ L.Map.include({
99
101
  *
100
102
  * @since leaflet-rotate (v0.1)
101
103
  */
102
- mapPanePointToRotatedPoint: function(point) {
103
- return L.point(point)
104
+ mapPanePointToRotatedPoint(point) {
105
+ return toPoint(point)
104
106
  ._subtract(this._getRotatePanePos())
105
107
  .rotate(-this._bearing);
106
108
  },
107
109
 
108
- // latLngToLayerPoint: function (latlng) {
109
- // var projectedPoint = this.project(L.latLng(latlng))._round();
110
+ // latLngToLayerPoint(latlng) {
111
+ // const projectedPoint = this.project(L.latLng(latlng))._round();
110
112
  // return projectedPoint._subtract(this.getPixelOrigin());
111
113
  // },
112
114
 
113
- // latLngToContainerPoint: function (latlng) {
115
+ // latLngToContainerPoint(latlng) {
114
116
  // return this.layerPointToContainerPoint(this.latLngToLayerPoint(toLatLng(latlng)));
115
117
  // },
116
118
 
@@ -125,7 +127,7 @@ L.Map.include({
125
127
  *
126
128
  * @since leaflet-rotate (v0.2)
127
129
  */
128
- mapBoundsToContainerBounds: function (bounds) {
130
+ mapBoundsToContainerBounds(bounds) {
129
131
  if (!this._rotate && mapProto.mapBoundsToContainerBounds) {
130
132
  return mapProto.mapBoundsToContainerBounds.apply(this, arguments);
131
133
  }
@@ -142,9 +144,9 @@ L.Map.include({
142
144
  sw = this.layerPointToContainerPoint(this.project(bounds.getSouthWest())._subtract(origin)),
143
145
  se = this.layerPointToContainerPoint(this.project(bounds.getSouthEast())._subtract(origin));
144
146
 
145
- return L.bounds([
146
- L.point(Math.min(nw.x, ne.x, se.x, sw.x), Math.min(nw.y, ne.y, se.y, sw.y)), // [ minX, minY ]
147
- L.point(Math.max(nw.x, ne.x, se.x, sw.x), Math.max(nw.y, ne.y, se.y, sw.y)) // [ maxX, maxY ]
147
+ return new L.Bounds([
148
+ new L.Point(Math.min(nw.x, ne.x, se.x, sw.x), Math.min(nw.y, ne.y, se.y, sw.y)), // [ minX, minY ]
149
+ new L.Point(Math.max(nw.x, ne.x, se.x, sw.x), Math.max(nw.y, ne.y, se.y, sw.y)) // [ maxX, maxY ]
148
150
  ]);
149
151
  },
150
152
 
@@ -158,14 +160,14 @@ L.Map.include({
158
160
  *
159
161
  * @returns {L.LatLngBounds}
160
162
  */
161
- getBounds: function() {
163
+ getBounds() {
162
164
  if (!this._rotate) {
163
165
  return mapProto.getBounds.apply(this, arguments);
164
166
  }
165
167
 
166
168
  // SEE: https://github.com/fnicollet/Leaflet/pull/22
167
169
  //
168
- // var bounds = this.getPixelBounds(),
170
+ // const bounds = this.getPixelBounds(),
169
171
  // sw = this.unproject(bounds.getBottomLeft()),
170
172
  // ne = this.unproject(bounds.getTopRight());
171
173
  // return new LatLngBounds(sw, ne);
@@ -173,7 +175,7 @@ L.Map.include({
173
175
 
174
176
  // LatLngBounds' constructor automatically
175
177
  // extends the bounds to fit the passed points
176
- var size = this.getSize();
178
+ const size = this.getSize();
177
179
  return new L.LatLngBounds([
178
180
  this.containerPointToLatLng([0, 0]), // topleft
179
181
  this.containerPointToLatLng([size.x, 0]), // topright
@@ -210,56 +212,56 @@ L.Map.include({
210
212
  *
211
213
  * @since leaflet-rotate (v0.1)
212
214
  */
213
- setBearing: function(theta, options) {
214
- if (!L.Browser.any3d || !this._rotate) { return; }
215
+ setBearing(theta, options) {
216
+ if (!this._rotate) { return; }
215
217
 
216
218
  if (options && options.animate) {
217
219
  this._bearingAnimationId = (this._bearingAnimationId || 0) + 1;
218
- var animationId = this._bearingAnimationId;
220
+ const animationId = this._bearingAnimationId;
219
221
  if (this._bearingAnimationFrame) {
220
- L.Util.cancelAnimFrame(this._bearingAnimationFrame);
222
+ cancelAnimationFrame(this._bearingAnimationFrame);
221
223
  }
222
224
 
223
- var startBearing = this.getBearing(),
225
+ const startBearing = this.getBearing(),
224
226
  endBearing = L.Util.wrapNum(theta, [0, 360]),
225
227
  delta = ((endBearing - startBearing + 540) % 360) - 180,
226
228
  duration = Math.max(0, options.duration == null ? 0.25 : options.duration) * 1000,
227
229
  easeLinearity = Math.max(options.easeLinearity || 0.5, 0.2),
228
230
  startTime = performance.now();
229
231
 
230
- var animate = function() {
232
+ const animate = function() {
231
233
  if (!this._mapPane) {
232
234
  delete this._bearingAnimationFrame;
233
235
  return;
234
236
  }
235
237
 
236
- var progress = duration ? Math.min((performance.now() - startTime) / duration, 1) : 1,
238
+ const progress = duration ? Math.min((performance.now() - startTime) / duration, 1) : 1,
237
239
  eased = 1 - Math.pow(1 - progress, 1 / easeLinearity);
238
240
 
239
241
  this._setBearing(progress === 1 ? endBearing : startBearing + delta * eased);
240
242
  if (this._bearingAnimationId !== animationId) { return; }
241
243
  if (progress < 1) {
242
- this._bearingAnimationFrame = L.Util.requestAnimFrame(animate, this);
244
+ this._bearingAnimationFrame = requestAnimationFrame(animate.bind(this));
243
245
  } else {
244
246
  delete this._bearingAnimationFrame;
245
247
  }
246
248
  };
247
249
 
248
- this._bearingAnimationFrame = L.Util.requestAnimFrame(animate, this);
250
+ this._bearingAnimationFrame = requestAnimationFrame(animate.bind(this));
249
251
  return;
250
252
  }
251
253
 
252
254
  this._bearingAnimationId = (this._bearingAnimationId || 0) + 1;
253
255
  if (this._bearingAnimationFrame) {
254
- L.Util.cancelAnimFrame(this._bearingAnimationFrame);
256
+ cancelAnimationFrame(this._bearingAnimationFrame);
255
257
  delete this._bearingAnimationFrame;
256
258
  }
257
259
 
258
260
  this._setBearing(theta);
259
261
  },
260
262
 
261
- _setBearing: function(theta) {
262
- var bearing = L.Util.wrapNum(theta, [0, 360]) * L.DomUtil.DEG_TO_RAD,
263
+ _setBearing(theta) {
264
+ const bearing = L.Util.wrapNum(theta, [0, 360]) * (Math.PI / 180),
263
265
  center = this._getPixelCenter(),
264
266
  oldPos = this._getRotatePanePos().rotateFrom(-this._bearing, center),
265
267
  newPos = oldPos.rotateFrom(bearing, center);
@@ -281,8 +283,8 @@ L.Map.include({
281
283
  *
282
284
  * @since leaflet-rotate (v0.1)
283
285
  */
284
- getBearing: function() {
285
- return this._bearing * L.DomUtil.RAD_TO_DEG;
286
+ getBearing() {
287
+ return this._bearing * (180 / Math.PI);
286
288
  },
287
289
 
288
290
  /**
@@ -294,7 +296,7 @@ L.Map.include({
294
296
  * @param {HTMLElement} [container] parent element
295
297
  * @returns {HTMLElement} pane container
296
298
  */
297
- // createPane: function(name, container) {
299
+ // createPane(name, container) {
298
300
  // if (!this._rotate || name == 'mapPane') {
299
301
  // return mapProto.createPane.apply(this, arguments);
300
302
  // }
@@ -323,8 +325,8 @@ L.Map.include({
323
325
  * - tooltipPane [HTMLElement = 650] - Pane for tooltips.
324
326
  * - popupPane [HTMLElement = 700] - Pane for popups.
325
327
  */
326
- _initPanes: function() {
327
- var panes = this._panes = {};
328
+ _initPanes() {
329
+ const panes = this._panes = {};
328
330
  this._paneRenderers = {};
329
331
 
330
332
  this._mapPane = this.createPane('mapPane', this._container);
@@ -333,6 +335,9 @@ L.Map.include({
333
335
  if (this._rotate) {
334
336
  this._rotatePane = this.createPane('rotatePane', this._mapPane);
335
337
  this._norotatePane = this.createPane('norotatePane', this._mapPane);
338
+ if (L.version.startsWith('2.')) {
339
+ this._rotatePane.style.transformOrigin = '0 0';
340
+ }
336
341
  // rotatePane
337
342
  this.createPane('tilePane', this._rotatePane);
338
343
  this.createPane('overlayPane', this._rotatePane);
@@ -351,8 +356,8 @@ L.Map.include({
351
356
  }
352
357
 
353
358
  if (!this.options.markerZoomAnimation) {
354
- L.DomUtil.addClass(panes.markerPane, 'leaflet-zoom-hide');
355
- L.DomUtil.addClass(panes.shadowPane, 'leaflet-zoom-hide');
359
+ panes.markerPane.classList.add('leaflet-zoom-hide');
360
+ panes.shadowPane.classList.add('leaflet-zoom-hide');
356
361
  }
357
362
  },
358
363
 
@@ -376,17 +381,17 @@ L.Map.include({
376
381
 
377
382
  options = options || {};
378
383
 
379
- const paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]),
380
- paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]),
384
+ const paddingTL = toPoint(options.paddingTopLeft || options.padding || [0, 0]),
385
+ paddingBR = toPoint(options.paddingBottomRight || options.padding || [0, 0]),
381
386
  /** @TODO use mapProto.panInside */
382
387
  // pixelPoint = this.project(latlng),
383
388
  // pixelBounds = this.getPixelBounds(),
384
389
  // pixelCenter = this.project(this.getCenter()),
385
390
  pixelPoint = this.latLngToContainerPoint(latlng),
386
- pixelBounds = L.bounds([L.point(0, 0), this.getSize()]),
391
+ pixelBounds = new L.Bounds([new L.Point(0, 0), this.getSize()]),
387
392
  pixelCenter = pixelBounds.getCenter(),
388
393
  //
389
- paddedBounds = L.bounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]),
394
+ paddedBounds = new L.Bounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]),
390
395
  paddedSize = paddedBounds.getSize();
391
396
 
392
397
  if (!paddedBounds.contains(pixelPoint)) {
@@ -418,9 +423,9 @@ L.Map.include({
418
423
  * @param {Object} [options] pan options
419
424
  * @returns {L.Map} current map instance
420
425
  */
421
- // panInsideBounds: function (bounds, options) {
426
+ // panInsideBounds(bounds, options) {
422
427
  // this._enforcingBounds = true;
423
- // var center = this.getCenter(),
428
+ // const center = this.getCenter(),
424
429
  // newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));
425
430
  //
426
431
  // if (!center.equals(newCenter)) {
@@ -496,8 +501,8 @@ L.Map.include({
496
501
  return mapProto.getBoundsZoom.apply(this, arguments);
497
502
  }
498
503
 
499
- bounds = L.latLngBounds(bounds);
500
- padding = L.point(padding || [0, 0]);
504
+ bounds = bounds instanceof L.LatLngBounds ? bounds : new L.LatLngBounds(bounds);
505
+ padding = toPoint(padding || [0, 0]);
501
506
 
502
507
  let zoom = this.getZoom() || 0;
503
508
  const min = this.getMinZoom(),
@@ -529,7 +534,7 @@ L.Map.include({
529
534
  *
530
535
  * @returns {L.Point} layer center
531
536
  */
532
- // _getCenterLayerPoint: function () {
537
+ // _getCenterLayerPoint() {
533
538
  // return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
534
539
  // },
535
540
 
@@ -538,8 +543,8 @@ L.Map.include({
538
543
  *
539
544
  * @param {L.LatLng} latlng map coordinates
540
545
  */
541
- _getCenterOffset: function(latlng) {
542
- var centerOffset = mapProto._getCenterOffset.apply(this, arguments);
546
+ _getCenterOffset(latlng) {
547
+ let centerOffset = mapProto._getCenterOffset.apply(this, arguments);
543
548
  if (this._rotate) {
544
549
  centerOffset = centerOffset.rotate(this._bearing);
545
550
  }
@@ -549,7 +554,7 @@ L.Map.include({
549
554
  /**
550
555
  * @since leaflet-rotate (v0.1)
551
556
  */
552
- _getRotatePanePos: function() {
557
+ _getRotatePanePos() {
553
558
  return this._rotatePanePos || new L.Point(0, 0);
554
559
  // return L.DomUtil.getPosition(this._rotatePane) || new L.Point(0, 0);
555
560
  },
@@ -559,11 +564,11 @@ L.Map.include({
559
564
  // return this.project(latlng, zoom)._subtract(topLeft);
560
565
  //},
561
566
 
562
- _getNewPixelOrigin: function(center, zoom) {
563
- if (!this._rotate) {
567
+ _getNewPixelOrigin(center, zoom) {
568
+ if (!this._rotate || L.version.startsWith('2.')) {
564
569
  return mapProto._getNewPixelOrigin.apply(this, arguments);
565
570
  }
566
- var viewHalf = this.getSize()._divideBy(2);
571
+ const viewHalf = this.getSize()._divideBy(2);
567
572
  return this.project(center, zoom)
568
573
  .rotate(this._bearing)
569
574
  ._subtract(viewHalf)
@@ -578,13 +583,13 @@ L.Map.include({
578
583
  *
579
584
  * @see src\layer\tile\GridLayer::_getTiledPixelBounds()
580
585
  */
581
- _getNewPixelBounds: function(center, zoom) {
586
+ _getNewPixelBounds(center, zoom) {
582
587
  center = center || this.getCenter();
583
588
  zoom = zoom || this.getZoom();
584
589
  if (!this._rotate && mapProto._getNewPixelBounds) {
585
590
  return mapProto._getNewPixelBounds.apply(this, arguments);
586
591
  }
587
- var mapZoom = this._animatingZoom ? Math.max(this._animateToZoom, this.getZoom()) : this.getZoom(),
592
+ const mapZoom = this._animatingZoom ? Math.max(this._animateToZoom, this.getZoom()) : this.getZoom(),
588
593
  scale = this.getZoomScale(mapZoom, zoom),
589
594
  pixelCenter = this.project(center, zoom).floor(),
590
595
  size = this.getSize(),
@@ -603,7 +608,7 @@ L.Map.include({
603
608
  *
604
609
  * @return {L.Point} map pivot point (center)
605
610
  */
606
- _getPixelCenter: function() {
611
+ _getPixelCenter() {
607
612
  if (!this._rotate && mapProto._getPixelCenter) {
608
613
  return mapProto._getPixelCenter.apply(this, arguments);
609
614
  }
@@ -615,11 +620,11 @@ L.Map.include({
615
620
  *
616
621
  * @see src\layer\vector\Renderer::_update()
617
622
  */
618
- _getPaddedPixelBounds: function(padding) {
623
+ _getPaddedPixelBounds(padding) {
619
624
  if (!this._rotate && mapProto._getPaddedPixelBounds) {
620
625
  return mapProto._getPaddedPixelBounds.apply(this, arguments);
621
626
  }
622
- var p = padding,
627
+ const p = padding,
623
628
  size = this.getSize(),
624
629
  padMin = size.multiplyBy(-p),
625
630
  padMax = size.multiplyBy(1 + p);
@@ -633,10 +638,10 @@ L.Map.include({
633
638
  ]);
634
639
  },
635
640
 
636
- _handleGeolocationResponse: function(pos) {
641
+ _handleGeolocationResponse(pos) {
637
642
  if (!this._container._leaflet_id) { return; }
638
643
 
639
- var lat = pos.coords.latitude,
644
+ const lat = pos.coords.latitude,
640
645
  lng = pos.coords.longitude,
641
646
  /** @TODO use mapProto._handleGeolocationResponse */
642
647
  hdg = pos.coords.heading,
@@ -645,11 +650,11 @@ L.Map.include({
645
650
  options = this._locateOptions;
646
651
 
647
652
  if (options.setView) {
648
- var zoom = this.getBoundsZoom(bounds);
653
+ const zoom = this.getBoundsZoom(bounds);
649
654
  this.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom);
650
655
  }
651
656
 
652
- var data = {
657
+ const data = {
653
658
  latlng: latlng,
654
659
  bounds: bounds,
655
660
  timestamp: pos.timestamp,
@@ -657,7 +662,7 @@ L.Map.include({
657
662
  heading: hdg
658
663
  };
659
664
 
660
- for (var i in pos.coords) {
665
+ for (const i in pos.coords) {
661
666
  if (typeof pos.coords[i] === 'number') {
662
667
  data[i] = pos.coords[i];
663
668
  }
@@ -676,7 +681,7 @@ L.Map.include({
676
681
  * @returns {L.Bounds}
677
682
  */
678
683
  // toCircumscribedBounds(points) {
679
- // var minX = points.reduce(function (pv, v) { return Math.min(pv, v.x); }, points[0].x),
684
+ // const minX = points.reduce(function (pv, v) { return Math.min(pv, v.x); }, points[0].x),
680
685
  // maxX = points.reduce(function (pv, v) { return Math.max(pv, v.x); }, points[0].x),
681
686
  // minY = points.reduce(function (pv, v) { return Math.min(pv, v.y); }, points[0].y),
682
687
  // maxY = points.reduce(function (pv, v) { return Math.max(pv, v.y); }, points[0].y);
@@ -6,7 +6,7 @@
6
6
 
7
7
  L.Map.CompassBearing = L.Handler.extend({
8
8
 
9
- initialize: function(map) {
9
+ initialize(map) {
10
10
  this._map = map;
11
11
  /** @see https://caniuse.com/?search=DeviceOrientation */
12
12
  if ('ondeviceorientationabsolute' in window) {
@@ -17,7 +17,7 @@ L.Map.CompassBearing = L.Handler.extend({
17
17
  this._throttled = L.Util.throttle(this._onDeviceOrientation, 100, this);
18
18
  },
19
19
 
20
- addHooks: function() {
20
+ addHooks() {
21
21
  if (this._map._rotate && this.__deviceOrientationEvent) {
22
22
  L.DomEvent.on(window, this.__deviceOrientationEvent, this._throttled, this);
23
23
  } else {
@@ -27,7 +27,7 @@ L.Map.CompassBearing = L.Handler.extend({
27
27
  }
28
28
  },
29
29
 
30
- removeHooks: function() {
30
+ removeHooks() {
31
31
  if (this._map._rotate && this.__deviceOrientationEvent) {
32
32
  L.DomEvent.off(window, this.__deviceOrientationEvent, this._throttled, this);
33
33
  }
@@ -51,9 +51,9 @@ L.Map.CompassBearing = L.Handler.extend({
51
51
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/alpha
52
52
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/orientation
53
53
  */
54
- _onDeviceOrientation: function(e) {
55
- var angle = e.webkitCompassHeading != null ? e.webkitCompassHeading : e.alpha;
56
- var deviceOrientation = 0;
54
+ _onDeviceOrientation(e) {
55
+ let angle = e.webkitCompassHeading != null ? e.webkitCompassHeading : e.alpha;
56
+ let deviceOrientation = 0;
57
57
 
58
58
  if (!Number.isFinite(angle)) { return; }
59
59
 
@@ -27,7 +27,7 @@ L.Map.mergeOptions({
27
27
 
28
28
  L.Map.ContainerMutation = L.Handler.extend({
29
29
 
30
- addHooks: function() {
30
+ addHooks() {
31
31
  // if (!L.Browser.mutation) { return; }
32
32
  if (!this._observer) {
33
33
  this._observer = new MutationObserver(L.Util.bind(this._map.invalidateSize, this._map));
@@ -41,7 +41,7 @@ L.Map.ContainerMutation = L.Handler.extend({
41
41
  });
42
42
  },
43
43
 
44
- removeHooks: function() {
44
+ removeHooks() {
45
45
  // if (!L.Browser.mutation) { return; }
46
46
  this._observer.disconnect();
47
47
  },
@@ -17,22 +17,22 @@ L.Map.mergeOptions({
17
17
 
18
18
  L.Map.ShiftKeyRotate = L.Handler.extend({
19
19
 
20
- addHooks: function() {
20
+ addHooks() {
21
21
  L.DomEvent.on(this._map._container, "wheel", this._handleShiftScroll, this);
22
22
  // this._map.shiftKeyRotate.enable();
23
23
  this._map.shiftKeyRotate.rotate = true;
24
24
  },
25
25
 
26
- removeHooks: function() {
26
+ removeHooks() {
27
27
  L.DomEvent.off(this._map._container, "wheel", this._handleShiftScroll, this);
28
28
  this._map.shiftKeyRotate.rotate = false;
29
29
  },
30
30
 
31
- _handleShiftScroll: function(e) {
31
+ _handleShiftScroll(e) {
32
32
  if (e.shiftKey) {
33
33
  e.preventDefault();
34
34
  this._map.scrollWheelZoom.disable();
35
- this._map.setBearing((this._map._bearing * L.DomUtil.RAD_TO_DEG) + Math.sign(e.deltaY) * 5);
35
+ this._map.setBearing((this._map._bearing * (180 / Math.PI)) + Math.sign(e.deltaY) * 5);
36
36
  } else {
37
37
  this._map.scrollWheelZoom.enable();
38
38
  }