Merge pull request #2492 from bsstoner/bsstoner/2489

Enforce maxZoom before applying paddingOffset in Map.fitBounds, fixes #2489
This commit is contained in:
Vladimir Agafonkin 2014-02-27 02:56:14 +02:00
commit 920e7b03d9

View File

@ -91,15 +91,16 @@ L.Map = L.Evented.extend({
var paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]),
paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]),
zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR)),
paddingOffset = paddingBR.subtract(paddingTL).divideBy(2),
zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
zoom = options.maxZoom ? Math.min(options.maxZoom, zoom) : zoom;
var paddingOffset = paddingBR.subtract(paddingTL).divideBy(2),
swPoint = this.project(bounds.getSouthWest(), zoom),
nePoint = this.project(bounds.getNorthEast(), zoom),
center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom);
zoom = options && options.maxZoom ? Math.min(options.maxZoom, zoom) : zoom;
return this.setView(center, zoom, options);
},