leaflet-rotate 0.2.0 → 0.2.1
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 +170 -70
- package/dist/leaflet-rotate-src.js.map +1 -1
- package/dist/leaflet-rotate.js +170 -70
- package/dist/leaflet-rotate.js.map +1 -1
- package/lib/debug.js +42 -4
- package/lib/debug.min.js +1 -1
- package/package.json +1 -1
- package/src/dom/DomUtil.js +4 -4
- package/src/layer/DivOverlay.js +2 -2
- package/src/layer/Popup.js +1 -1
- package/src/layer/Tooltip.js +2 -2
- package/src/layer/marker/Marker.js +12 -8
- package/src/layer/tile/GridLayer.js +2 -2
- package/src/layer/vector/Canvas.js +3 -3
- package/src/layer/vector/Renderer.js +4 -4
- package/src/layer/vector/SVG.js +1 -1
- package/src/map/Map.js +139 -43
- package/test/index.html +1 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
if (!bearing) {
|
|
20
20
|
offset = pos._round();
|
|
21
|
-
return domUtilProto.setTransform.
|
|
21
|
+
return domUtilProto.setTransform.apply(this, arguments);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
pos = pos.rotateFrom(bearing, pivot);
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
' rotate(' + bearing + 'rad)';
|
|
30
30
|
},
|
|
31
31
|
|
|
32
|
-
setPosition: function(el, point, bearing, pivot) { // (HTMLElement, Point[, Boolean])
|
|
32
|
+
setPosition: function(el, point, bearing, pivot, scale) { // (HTMLElement, Point[, Boolean])
|
|
33
33
|
if (!bearing) {
|
|
34
|
-
return domUtilProto.setPosition.
|
|
34
|
+
return domUtilProto.setPosition.apply(this, arguments);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/*eslint-disable */
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/*eslint-enable */
|
|
40
40
|
|
|
41
41
|
if (L.Browser.any3d) {
|
|
42
|
-
L.DomUtil.setTransform(el, point,
|
|
42
|
+
L.DomUtil.setTransform(el, point, scale, bearing, pivot);
|
|
43
43
|
} else {
|
|
44
44
|
el.style.left = point.x + 'px';
|
|
45
45
|
el.style.top = point.y + 'px';
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
L.DivOverlay.include({
|
|
124
124
|
|
|
125
125
|
getEvents: function() {
|
|
126
|
-
return L.extend(divOverlayProto.getEvents.
|
|
126
|
+
return L.extend(divOverlayProto.getEvents.apply(this, arguments), { rotate: this._updatePosition });
|
|
127
127
|
},
|
|
128
128
|
|
|
129
129
|
_updatePosition: function() {
|
|
130
130
|
// 0. update anchor (leaflet v1.9.3)
|
|
131
|
-
divOverlayProto._updatePosition.
|
|
131
|
+
divOverlayProto._updatePosition.apply(this, arguments);
|
|
132
132
|
// 1. subtract anchor
|
|
133
133
|
// 2. rotate element
|
|
134
134
|
// 3. restore anchor
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
|
|
155
155
|
_animateZoom: function(e) {
|
|
156
156
|
// 0. update anchor (leaflet v1.9.3)
|
|
157
|
-
popupProto._animateZoom.
|
|
157
|
+
popupProto._animateZoom.apply(this, arguments);
|
|
158
158
|
// 1. subtract anchor
|
|
159
159
|
// 2. rotate element
|
|
160
160
|
// 3. restore anchor
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
|
|
241
241
|
_animateZoom: function(e) {
|
|
242
242
|
if (!this._map._rotate) {
|
|
243
|
-
return tooltipProto._animateZoom.
|
|
243
|
+
return tooltipProto._animateZoom.apply(this, arguments);
|
|
244
244
|
}
|
|
245
245
|
var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
|
|
246
246
|
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
|
|
251
251
|
_updatePosition: function() {
|
|
252
252
|
if (!this._map._rotate) {
|
|
253
|
-
return tooltipProto._updatePosition.
|
|
253
|
+
return tooltipProto._updatePosition.apply(this, arguments);
|
|
254
254
|
}
|
|
255
255
|
var pos = this._map.latLngToLayerPoint(this._latlng);
|
|
256
256
|
|
|
@@ -318,6 +318,10 @@
|
|
|
318
318
|
// Rotate this marker when map rotates
|
|
319
319
|
rotateWithView: false,
|
|
320
320
|
|
|
321
|
+
// @option scale: Number = undefined
|
|
322
|
+
// Scale of the marker icon
|
|
323
|
+
scale: undefined,
|
|
324
|
+
|
|
321
325
|
});
|
|
322
326
|
|
|
323
327
|
var markerDragProto; // retrived at runtime (see below: L.Marker::_initInteraction())
|
|
@@ -326,7 +330,7 @@
|
|
|
326
330
|
|
|
327
331
|
// _onDragStart: function() {
|
|
328
332
|
// if (!this._marker._map._rotate) {
|
|
329
|
-
// return markerDragProto._onDragStart.
|
|
333
|
+
// return markerDragProto._onDragStart.apply(this, arguments);
|
|
330
334
|
// }
|
|
331
335
|
// this._draggable.updateMapBearing(this._marker._map._bearing);
|
|
332
336
|
// },
|
|
@@ -369,7 +373,7 @@
|
|
|
369
373
|
if (this._marker._map._rotate) {
|
|
370
374
|
this._marker.update();
|
|
371
375
|
}
|
|
372
|
-
markerDragProto._onDragEnd.
|
|
376
|
+
markerDragProto._onDragEnd.apply(this, arguments);
|
|
373
377
|
},
|
|
374
378
|
|
|
375
379
|
};
|
|
@@ -377,16 +381,16 @@
|
|
|
377
381
|
L.Marker.include({
|
|
378
382
|
|
|
379
383
|
getEvents: function() {
|
|
380
|
-
return L.extend(markerProto.getEvents.
|
|
384
|
+
return L.extend(markerProto.getEvents.apply(this, arguments), { rotate: this.update });
|
|
381
385
|
},
|
|
382
386
|
|
|
383
387
|
onAdd: function(map) {
|
|
384
|
-
markerProto.onAdd.
|
|
388
|
+
markerProto.onAdd.apply(this, arguments);
|
|
385
389
|
map.on('rotate', this.update, this);
|
|
386
390
|
},
|
|
387
391
|
|
|
388
392
|
_initInteraction: function() {
|
|
389
|
-
var ret = markerProto._initInteraction.
|
|
393
|
+
var ret = markerProto._initInteraction.apply(this, arguments);
|
|
390
394
|
if (this.dragging && this.dragging.enabled() && this._map && this._map._rotate) {
|
|
391
395
|
// L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable
|
|
392
396
|
markerDragProto = markerDragProto || Object.getPrototypeOf(this.dragging);
|
|
@@ -416,12 +420,12 @@
|
|
|
416
420
|
|
|
417
421
|
/** @TODO use markerProto._setPos */
|
|
418
422
|
if (this._icon) {
|
|
419
|
-
L.DomUtil.setPosition(this._icon, pos, bearing, pos);
|
|
423
|
+
L.DomUtil.setPosition(this._icon, pos, bearing, pos, this.options.scale);
|
|
420
424
|
}
|
|
421
425
|
|
|
422
426
|
/** @TODO use markerProto._setPos */
|
|
423
427
|
if (this._shadow) {
|
|
424
|
-
L.DomUtil.setPosition(this._shadow, pos, bearing, pos);
|
|
428
|
+
L.DomUtil.setPosition(this._shadow, pos, bearing, pos, this.options.scale);
|
|
425
429
|
}
|
|
426
430
|
|
|
427
431
|
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
@@ -431,7 +435,7 @@
|
|
|
431
435
|
|
|
432
436
|
_updateZIndex: function(offset) {
|
|
433
437
|
if (!this._map._rotate) {
|
|
434
|
-
return markerProto._updateZIndex.
|
|
438
|
+
return markerProto._updateZIndex.apply(this, arguments);
|
|
435
439
|
}
|
|
436
440
|
this._icon.style.zIndex = Math.round(this._zIndex + offset);
|
|
437
441
|
},
|
|
@@ -454,7 +458,7 @@
|
|
|
454
458
|
L.GridLayer.include({
|
|
455
459
|
|
|
456
460
|
getEvents: function() {
|
|
457
|
-
var events = gridLayerProto.getEvents.
|
|
461
|
+
var events = gridLayerProto.getEvents.apply(this, arguments);
|
|
458
462
|
if (this._map._rotate && !this.options.updateWhenIdle) {
|
|
459
463
|
if (!this._onRotate) {
|
|
460
464
|
this._onRotate = L.Util.throttle(this._onMoveEnd, this.options.updateInterval, this);
|
|
@@ -466,7 +470,7 @@
|
|
|
466
470
|
|
|
467
471
|
_getTiledPixelBounds: function(center) {
|
|
468
472
|
if (!this._map._rotate) {
|
|
469
|
-
return gridLayerProto._getTiledPixelBounds.
|
|
473
|
+
return gridLayerProto._getTiledPixelBounds.apply(this, arguments);
|
|
470
474
|
}
|
|
471
475
|
|
|
472
476
|
return this._map._getNewPixelBounds(center, this._tileZoom);
|
|
@@ -485,18 +489,18 @@
|
|
|
485
489
|
L.Canvas.include({
|
|
486
490
|
|
|
487
491
|
// onAdd: function() {
|
|
488
|
-
// canvasProto.onAdd.
|
|
492
|
+
// canvasProto.onAdd.apply(this, arguments);
|
|
489
493
|
// // When rotating the canvas itself, it is cleared by some weird reason, so redraw.
|
|
490
494
|
// this._map.on('rotate', this._redraw, this);
|
|
491
495
|
// },
|
|
492
496
|
|
|
493
497
|
// onRemove: function() {
|
|
494
|
-
// canvasProto.onRemove.
|
|
498
|
+
// canvasProto.onRemove.apply(this, arguments);
|
|
495
499
|
// this._map.off('rotate', this._redraw, this);
|
|
496
500
|
// },
|
|
497
501
|
|
|
498
502
|
// _update: function() {
|
|
499
|
-
// canvasProto._update.
|
|
503
|
+
// canvasProto._update.apply(this, arguments);
|
|
500
504
|
// // Tell paths to redraw themselves
|
|
501
505
|
// this.fire('update')
|
|
502
506
|
// },
|
|
@@ -514,12 +518,12 @@
|
|
|
514
518
|
L.Renderer.include({
|
|
515
519
|
|
|
516
520
|
// onAdd: function() {
|
|
517
|
-
// rendererProto.onAdd.
|
|
521
|
+
// rendererProto.onAdd.apply(this, arguments);
|
|
518
522
|
// // this._map.on('rotate', this._update, this);
|
|
519
523
|
// },
|
|
520
524
|
|
|
521
525
|
// onRemove: function() {
|
|
522
|
-
// rendererProto.onRemove.
|
|
526
|
+
// rendererProto.onRemove.apply(this, arguments);
|
|
523
527
|
// // this._map.off('rotate', this._update, this);
|
|
524
528
|
// },
|
|
525
529
|
|
|
@@ -530,7 +534,7 @@
|
|
|
530
534
|
*/
|
|
531
535
|
_updateTransform: function(center, zoom) {
|
|
532
536
|
if (!this._map._rotate) {
|
|
533
|
-
return rendererProto._updateTransform.
|
|
537
|
+
return rendererProto._updateTransform.apply(this, arguments);
|
|
534
538
|
}
|
|
535
539
|
var scale = this._map.getZoomScale(zoom, this._zoom),
|
|
536
540
|
offset = this._map._latLngToNewLayerPoint(this._topLeft, zoom, center);
|
|
@@ -543,7 +547,7 @@
|
|
|
543
547
|
|
|
544
548
|
_update: function() {
|
|
545
549
|
if (!this._map._rotate) {
|
|
546
|
-
return rendererProto._update.
|
|
550
|
+
return rendererProto._update.apply(this, arguments);
|
|
547
551
|
}
|
|
548
552
|
// Update pixel bounds of renderer container (for positioning/sizing/clipping later)
|
|
549
553
|
// Subclasses are responsible of firing the 'update' event.
|
|
@@ -566,7 +570,7 @@
|
|
|
566
570
|
L.SVG.include({
|
|
567
571
|
|
|
568
572
|
// _update: function() {
|
|
569
|
-
// svgProto._update.
|
|
573
|
+
// svgProto._update.apply(this, arguments);
|
|
570
574
|
// if (this._map._rotate) {
|
|
571
575
|
// this.fire('update');
|
|
572
576
|
// }
|
|
@@ -595,7 +599,7 @@
|
|
|
595
599
|
this._rotate = true;
|
|
596
600
|
this._bearing = 0;
|
|
597
601
|
}
|
|
598
|
-
mapProto.initialize.
|
|
602
|
+
mapProto.initialize.apply(this, arguments);
|
|
599
603
|
if(this.options.rotate){
|
|
600
604
|
this.setBearing(this.options.bearing);
|
|
601
605
|
}
|
|
@@ -611,7 +615,7 @@
|
|
|
611
615
|
*/
|
|
612
616
|
containerPointToLayerPoint: function(point) {
|
|
613
617
|
if (!this._rotate) {
|
|
614
|
-
return mapProto.containerPointToLayerPoint.
|
|
618
|
+
return mapProto.containerPointToLayerPoint.apply(this, arguments);
|
|
615
619
|
}
|
|
616
620
|
return L.point(point)
|
|
617
621
|
.subtract(this._getMapPanePos())
|
|
@@ -626,9 +630,9 @@
|
|
|
626
630
|
* @param {L.Point} point pixel screen coordinates
|
|
627
631
|
* @returns {L.Point} transformed pixel point
|
|
628
632
|
*/
|
|
629
|
-
layerPointToContainerPoint: function(point) {
|
|
633
|
+
layerPointToContainerPoint: function(point) {
|
|
630
634
|
if (!this._rotate) {
|
|
631
|
-
return mapProto.layerPointToContainerPoint.
|
|
635
|
+
return mapProto.layerPointToContainerPoint.apply(this, arguments);
|
|
632
636
|
}
|
|
633
637
|
return L.point(point)
|
|
634
638
|
.add(this._getRotatePanePos())
|
|
@@ -645,6 +649,8 @@
|
|
|
645
649
|
*
|
|
646
650
|
* @param {L.Point} point pixel screen coordinates
|
|
647
651
|
* @returns {L.Point}
|
|
652
|
+
*
|
|
653
|
+
* @since leaflet-rotate (v0.1)
|
|
648
654
|
*/
|
|
649
655
|
rotatedPointToMapPanePoint: function(point) {
|
|
650
656
|
return L.point(point)
|
|
@@ -660,6 +666,8 @@
|
|
|
660
666
|
* (norotatePane) --> (rotatePane)
|
|
661
667
|
*
|
|
662
668
|
* @param {L.Point} point pixel screen coordinates
|
|
669
|
+
*
|
|
670
|
+
* @since leaflet-rotate (v0.1)
|
|
663
671
|
*/
|
|
664
672
|
mapPanePointToRotatedPoint: function(point) {
|
|
665
673
|
return L.point(point)
|
|
@@ -667,6 +675,31 @@
|
|
|
667
675
|
.rotate(-this._bearing);
|
|
668
676
|
},
|
|
669
677
|
|
|
678
|
+
/**
|
|
679
|
+
* Given latlng bounds, returns the bounds in projected pixel
|
|
680
|
+
* relative to the map container.
|
|
681
|
+
*
|
|
682
|
+
* @see https://github.com/ronikar/Leaflet/blob/5c480ef959b947c3beed7065425a5a36c486262b/src/map/Map.js#L1114-L1135
|
|
683
|
+
*
|
|
684
|
+
* @param {L.LatLngBounds} bounds
|
|
685
|
+
* @returns {L.Bounds}
|
|
686
|
+
*
|
|
687
|
+
* @since leaflet-rotate (v0.2)
|
|
688
|
+
*/
|
|
689
|
+
mapBoundsToContainerBounds: function (bounds) {
|
|
690
|
+
if (!this._rotate && mapProto.mapBoundsToContainerBounds) {
|
|
691
|
+
return mapProto.mapBoundsToContainerBounds.apply(this, arguments);
|
|
692
|
+
}
|
|
693
|
+
const nw = this.latLngToContainerPoint(bounds.getNorthWest()),
|
|
694
|
+
ne = this.latLngToContainerPoint(bounds.getNorthEast()),
|
|
695
|
+
sw = this.latLngToContainerPoint(bounds.getSouthWest()),
|
|
696
|
+
se = this.latLngToContainerPoint(bounds.getSouthEast());
|
|
697
|
+
return L.bounds([
|
|
698
|
+
L.point(Math.min(nw.x, ne.x, se.x, sw.x), Math.min(nw.y, ne.y, se.y, sw.y)), // [ minX, minY ]
|
|
699
|
+
L.point(Math.max(nw.x, ne.x, se.x, sw.x), Math.max(nw.y, ne.y, se.y, sw.y)) // [ maxX, maxY ]
|
|
700
|
+
]);
|
|
701
|
+
},
|
|
702
|
+
|
|
670
703
|
/**
|
|
671
704
|
* Returns geographical bounds visible in the current map view
|
|
672
705
|
*
|
|
@@ -679,7 +712,7 @@
|
|
|
679
712
|
*/
|
|
680
713
|
getBounds: function() {
|
|
681
714
|
if (!this._rotate) {
|
|
682
|
-
return mapProto.getBounds.
|
|
715
|
+
return mapProto.getBounds.apply(this, arguments);
|
|
683
716
|
}
|
|
684
717
|
|
|
685
718
|
// SEE: https://github.com/fnicollet/Leaflet/pull/22
|
|
@@ -722,6 +755,8 @@
|
|
|
722
755
|
* Change map rotation
|
|
723
756
|
*
|
|
724
757
|
* @param {number} theta map degrees
|
|
758
|
+
*
|
|
759
|
+
* @since leaflet-rotate (v0.1)
|
|
725
760
|
*/
|
|
726
761
|
setBearing: function(theta) {
|
|
727
762
|
if (!L.Browser.any3d || !this._rotate) { return; }
|
|
@@ -745,6 +780,8 @@
|
|
|
745
780
|
* Get current map rotation
|
|
746
781
|
*
|
|
747
782
|
* @returns {number} theta map degrees
|
|
783
|
+
*
|
|
784
|
+
* @since leaflet-rotate (v0.1)
|
|
748
785
|
*/
|
|
749
786
|
getBearing: function() {
|
|
750
787
|
return this._bearing * L.DomUtil.RAD_TO_DEG;
|
|
@@ -761,7 +798,7 @@
|
|
|
761
798
|
*/
|
|
762
799
|
// createPane: function(name, container) {
|
|
763
800
|
// if (!this._rotate || name == 'mapPane') {
|
|
764
|
-
// return mapProto.createPane.
|
|
801
|
+
// return mapProto.createPane.apply(this, arguments);
|
|
765
802
|
// }
|
|
766
803
|
// // init "rotatePane"
|
|
767
804
|
// if (!this._rotatePane) {
|
|
@@ -884,15 +921,108 @@
|
|
|
884
921
|
// this._enforcingBounds = true;
|
|
885
922
|
// var center = this.getCenter(),
|
|
886
923
|
// newCenter = this._limitCenter(center, this._zoom, L.latLngBounds(bounds));
|
|
887
|
-
|
|
924
|
+
//
|
|
888
925
|
// if (!center.equals(newCenter)) {
|
|
889
926
|
// this.panTo(newCenter, options);
|
|
890
927
|
// }
|
|
891
|
-
|
|
928
|
+
//
|
|
892
929
|
// this._enforcingBounds = false;
|
|
893
930
|
// return this;
|
|
894
931
|
// },
|
|
895
932
|
|
|
933
|
+
// adjust center for view to get inside bounds
|
|
934
|
+
// _limitCenter(center, zoom, bounds) {
|
|
935
|
+
//
|
|
936
|
+
// if (!bounds) { return center; }
|
|
937
|
+
//
|
|
938
|
+
// const centerPoint = this.project(center, zoom),
|
|
939
|
+
// viewHalf = this.getSize().divideBy(2),
|
|
940
|
+
// viewBounds = new Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),
|
|
941
|
+
// offset = this._getBoundsOffset(viewBounds, bounds, zoom);
|
|
942
|
+
//
|
|
943
|
+
// // If offset is less than a pixel, ignore.
|
|
944
|
+
// // This prevents unstable projections from getting into
|
|
945
|
+
// // an infinite loop of tiny offsets.
|
|
946
|
+
// if (Math.abs(offset.x) <= 1 && Math.abs(offset.y) <= 1) {
|
|
947
|
+
// return center;
|
|
948
|
+
// }
|
|
949
|
+
//
|
|
950
|
+
// return this.unproject(centerPoint.add(offset), zoom);
|
|
951
|
+
// },
|
|
952
|
+
|
|
953
|
+
// @method flyToBounds(bounds: LatLngBounds, options?: fitBounds options): this
|
|
954
|
+
// Sets the view of the map with a smooth animation like [`flyTo`](#map-flyto),
|
|
955
|
+
// but takes a bounds parameter like [`fitBounds`](#map-fitbounds).
|
|
956
|
+
// flyToBounds(bounds, options) {
|
|
957
|
+
// const target = this._getBoundsCenterZoom(bounds, options);
|
|
958
|
+
// return this.flyTo(target.center, target.zoom, options);
|
|
959
|
+
// },
|
|
960
|
+
|
|
961
|
+
// _getBoundsCenterZoom(bounds, options) {
|
|
962
|
+
//
|
|
963
|
+
// options = options || {};
|
|
964
|
+
// bounds = bounds.getBounds ? bounds.getBounds() : toLatLngBounds(bounds);
|
|
965
|
+
//
|
|
966
|
+
// const paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]),
|
|
967
|
+
// paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]);
|
|
968
|
+
//
|
|
969
|
+
// let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
970
|
+
//
|
|
971
|
+
// zoom = (typeof options.maxZoom === 'number') ? Math.min(options.maxZoom, zoom) : zoom;
|
|
972
|
+
//
|
|
973
|
+
// if (zoom === Infinity) {
|
|
974
|
+
// return { center: bounds.getCenter(), zoom };
|
|
975
|
+
// }
|
|
976
|
+
//
|
|
977
|
+
// return { center, zoom };
|
|
978
|
+
//
|
|
979
|
+
// },
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Returns the maximum zoom level on which the given bounds fit to the map
|
|
983
|
+
* view in its entirety. If `inside` (optional) is set to `true`, the method
|
|
984
|
+
* instead returns the minimum zoom level on which the map view fits into
|
|
985
|
+
* the given bounds in its entirety.
|
|
986
|
+
*
|
|
987
|
+
* @param {L.LatLngBounds} bounds
|
|
988
|
+
* @param {Boolean} [inside=false]
|
|
989
|
+
* @param {L.Point} [padding=[0,0]]
|
|
990
|
+
*
|
|
991
|
+
* @returns {Number} zoom level
|
|
992
|
+
*/
|
|
993
|
+
getBoundsZoom(bounds, inside, padding) {
|
|
994
|
+
if (!this._rotate || Math.abs(this._bearing).toFixed(1) < 0.1) {
|
|
995
|
+
return mapProto.getBoundsZoom.apply(this, arguments);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
bounds = L.latLngBounds(bounds);
|
|
999
|
+
padding = L.point(padding || [0, 0]);
|
|
1000
|
+
|
|
1001
|
+
let zoom = this.getZoom() || 0;
|
|
1002
|
+
const min = this.getMinZoom(),
|
|
1003
|
+
max = this.getMaxZoom(),
|
|
1004
|
+
/** @TODO use mapProto.getBoundsZoom */
|
|
1005
|
+
// nw = bounds.getNorthWest(),
|
|
1006
|
+
// se = bounds.getSouthEast(),
|
|
1007
|
+
// size = this.getSize().subtract(padding),
|
|
1008
|
+
// boundsSize = L.bounds(this.project(se, zoom), this.project(nw, zoom)).getSize(),
|
|
1009
|
+
size = this.getSize().subtract(padding),
|
|
1010
|
+
boundsSize = this.mapBoundsToContainerBounds(bounds).getSize(),
|
|
1011
|
+
snap = this.options.zoomSnap,
|
|
1012
|
+
scalex = size.x / boundsSize.x,
|
|
1013
|
+
scaley = size.y / boundsSize.y,
|
|
1014
|
+
scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley);
|
|
1015
|
+
|
|
1016
|
+
zoom = this.getScaleZoom(scale, zoom);
|
|
1017
|
+
|
|
1018
|
+
if (snap) {
|
|
1019
|
+
zoom = Math.round(zoom / (snap / 100)) * (snap / 100); // don't jump if within 1% of a snap level
|
|
1020
|
+
zoom = inside ? Math.ceil(zoom / snap) * snap : Math.floor(zoom / snap) * snap;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
return Math.max(min, Math.min(max, zoom));
|
|
1024
|
+
},
|
|
1025
|
+
|
|
896
1026
|
/**
|
|
897
1027
|
* Layer point of the current center
|
|
898
1028
|
*
|
|
@@ -908,13 +1038,16 @@
|
|
|
908
1038
|
* @param {L.LatLng} latlng map coordinates
|
|
909
1039
|
*/
|
|
910
1040
|
_getCenterOffset: function(latlng) {
|
|
911
|
-
var centerOffset = mapProto._getCenterOffset.
|
|
1041
|
+
var centerOffset = mapProto._getCenterOffset.apply(this, arguments);
|
|
912
1042
|
if (this._rotate) {
|
|
913
1043
|
centerOffset = centerOffset.rotate(this._bearing);
|
|
914
1044
|
}
|
|
915
1045
|
return centerOffset;
|
|
916
1046
|
},
|
|
917
1047
|
|
|
1048
|
+
/**
|
|
1049
|
+
* @since leaflet-rotate (v0.1)
|
|
1050
|
+
*/
|
|
918
1051
|
_getRotatePanePos: function() {
|
|
919
1052
|
return this._rotatePanePos || new L.Point(0, 0);
|
|
920
1053
|
// return L.DomUtil.getPosition(this._rotatePane) || new L.Point(0, 0);
|
|
@@ -923,7 +1056,7 @@
|
|
|
923
1056
|
_getNewPixelOrigin: function(center, zoom) {
|
|
924
1057
|
var viewHalf = this.getSize()._divideBy(2);
|
|
925
1058
|
if (!this._rotate) {
|
|
926
|
-
return mapProto._getNewPixelOrigin.
|
|
1059
|
+
return mapProto._getNewPixelOrigin.apply(this, arguments);
|
|
927
1060
|
}
|
|
928
1061
|
return this.project(center, zoom)
|
|
929
1062
|
.rotate(this._bearing)
|
|
@@ -1030,39 +1163,6 @@
|
|
|
1030
1163
|
this.fire('locationfound', data);
|
|
1031
1164
|
},
|
|
1032
1165
|
|
|
1033
|
-
/**
|
|
1034
|
-
* Given latlng bounds, returns the bounds in projected pixel
|
|
1035
|
-
* relative to the map container.
|
|
1036
|
-
*
|
|
1037
|
-
* @see https://github.com/ronikar/Leaflet/blob/5c480ef959b947c3beed7065425a5a36c486262b/src/map/Map.js#L1114-L1135
|
|
1038
|
-
*
|
|
1039
|
-
* @param {L.LatLngBounds} bounds
|
|
1040
|
-
* @returns {L.Bounds}
|
|
1041
|
-
*/
|
|
1042
|
-
// boundsToContainerBounds: function (bounds) {
|
|
1043
|
-
// if (this._rotate) {
|
|
1044
|
-
// var northWest = this.latLngToContainerPoint(bounds.getNorthWest());
|
|
1045
|
-
// var northEast = this.latLngToContainerPoint(bounds.getNorthEast());
|
|
1046
|
-
// var southWest = this.latLngToContainerPoint(bounds.getSouthWest());
|
|
1047
|
-
// var southEast = this.latLngToContainerPoint(bounds.getSouthEast());
|
|
1048
|
-
//
|
|
1049
|
-
// var minX = Math.min(northWest.x, northEast.x, southEast.x, southWest.x);
|
|
1050
|
-
// var maxX = Math.max(northWest.x, northEast.x, southEast.x, southWest.x);
|
|
1051
|
-
// var minY = Math.min(northWest.y, northEast.y, southEast.y, southWest.y);
|
|
1052
|
-
// var maxY = Math.max(northWest.y, northEast.y, southEast.y, southWest.y);
|
|
1053
|
-
//
|
|
1054
|
-
// return L.bounds(
|
|
1055
|
-
// L.point(minX, minY).multiplyBy(-1),
|
|
1056
|
-
// L.point(maxX, maxY).multiplyBy(-1).add(this.getSize())
|
|
1057
|
-
// );
|
|
1058
|
-
// } else {
|
|
1059
|
-
// return L.Bounds(
|
|
1060
|
-
// this.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1),
|
|
1061
|
-
// this.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1).add(this.getSize())
|
|
1062
|
-
// );
|
|
1063
|
-
// }
|
|
1064
|
-
// },
|
|
1065
|
-
|
|
1066
1166
|
/**
|
|
1067
1167
|
* @see https://github.com/ronikar/Leaflet/blob/5c480ef959b947c3beed7065425a5a36c486262b/src/geo/LatLngBounds.js#L253-L264
|
|
1068
1168
|
*
|