add fromZoom arg to Map getZoomScale and getScaleZoom
This commit is contained in:
parent
1b8f68d806
commit
dc04b9dbe2
@ -102,7 +102,7 @@ L.TileLayer = L.GridLayer.extend({
|
||||
|
||||
// increase tile size when overscaling
|
||||
return zoomN && zoom > zoomN ?
|
||||
Math.round(map.getZoomScale(zoom) / map.getZoomScale(zoomN) * options.tileSize) :
|
||||
Math.round(map.getZoomScale(zoomN, zoom) * options.tileSize) :
|
||||
options.tileSize;
|
||||
},
|
||||
|
||||
|
@ -348,13 +348,15 @@ L.Map = L.Evented.extend({
|
||||
|
||||
// TODO replace with universal implementation after refactoring projections
|
||||
|
||||
getZoomScale: function (toZoom) {
|
||||
getZoomScale: function (toZoom, fromZoom) {
|
||||
var crs = this.options.crs;
|
||||
return crs.scale(toZoom) / crs.scale(this._zoom);
|
||||
fromZoom = fromZoom === undefined ? this._zoom : fromZoom;
|
||||
return crs.scale(toZoom) / crs.scale(fromZoom);
|
||||
},
|
||||
|
||||
getScaleZoom: function (scale) {
|
||||
return this._zoom + (Math.log(scale) / Math.LN2);
|
||||
getScaleZoom: function (scale, fromZoom) {
|
||||
fromZoom = fromZoom === undefined ? this._zoom : fromZoom;
|
||||
return fromZoom + (Math.log(scale) / Math.LN2);
|
||||
},
|
||||
|
||||
|
||||
|
@ -6,8 +6,9 @@ L.Map.include({
|
||||
to = this.project(center),
|
||||
u1 = to.distanceTo(from),
|
||||
size = this.getSize(),
|
||||
zoom = this._zoom,
|
||||
w0 = Math.max(size.x, size.y),
|
||||
w1 = w0 * this.getZoomScale(this._zoom) / this.getZoomScale(targetZoom),
|
||||
w1 = w0 * this.getZoomScale(targetZoom, zoom),
|
||||
rho = 1.42,
|
||||
rho2 = rho * rho;
|
||||
|
||||
@ -26,10 +27,11 @@ L.Map.include({
|
||||
function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; }
|
||||
|
||||
function step(s) {
|
||||
var center = this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1))),
|
||||
zoom = this.getScaleZoom(this.getZoomScale(this._zoom) * w0 / w(s));
|
||||
var center = this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), targetZoom),
|
||||
newZoom = this.getScaleZoom(w0 / w(s), zoom);
|
||||
|
||||
this._animateZoom(center, zoom);
|
||||
this._resetView(center, newZoom, true, true);
|
||||
this._animateZoom(center, newZoom);
|
||||
}
|
||||
|
||||
function easeOut(t) { return 1 - Math.pow(1 - t, 2); }
|
||||
|
Loading…
Reference in New Issue
Block a user