* Fix max/min calculation for getBoundsZoom (fixes #5136) * Added test for inside param of L.Map.getBoundsZoom()
This commit is contained in:
parent
14c5f1602c
commit
ddc3a9ca61
@ -178,6 +178,7 @@ describe("Map", function () {
|
||||
describe("#getBoundsZoom", function () {
|
||||
var halfLength = 0.00025;
|
||||
var bounds = [[-halfLength, -halfLength], [halfLength, halfLength]];
|
||||
var wideBounds = [[-halfLength, -halfLength * 10], [halfLength, halfLength * 10]];
|
||||
var padding = [100, 100];
|
||||
var height = '400px';
|
||||
|
||||
@ -219,6 +220,14 @@ describe("Map", function () {
|
||||
map.setZoom(16);
|
||||
expect(map.getBoundsZoom(bounds, false, padding)).to.eql(9);
|
||||
});
|
||||
|
||||
it("respects the 'inside' parameter", function () {
|
||||
var container = map.getContainer();
|
||||
container.style.height = height;
|
||||
document.body.appendChild(container);
|
||||
expect(map.getBoundsZoom(wideBounds, false, padding)).to.be.equal(17);
|
||||
expect(map.getBoundsZoom(wideBounds, true, padding)).to.be.equal(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setMaxBounds', function () {
|
||||
|
@ -806,9 +806,11 @@ export var Map = Evented.extend({
|
||||
se = bounds.getSouthEast(),
|
||||
size = this.getSize().subtract(padding),
|
||||
boundsSize = toBounds(this.project(se, zoom), this.project(nw, zoom)).getSize(),
|
||||
snap = Browser.any3d ? this.options.zoomSnap : 1;
|
||||
snap = Browser.any3d ? this.options.zoomSnap : 1,
|
||||
scalex = size.x / boundsSize.x,
|
||||
scaley = size.y / boundsSize.y,
|
||||
scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley);
|
||||
|
||||
var scale = Math.min(size.x / boundsSize.x, size.y / boundsSize.y);
|
||||
zoom = this.getScaleZoom(scale, zoom);
|
||||
|
||||
if (snap) {
|
||||
|
Loading…
Reference in New Issue
Block a user