Merge pull request #4077 from Leaflet/fix-2427

When limiting center to bounds, ignore offsets less than a pixel.
This commit is contained in:
Vladimir Agafonkin 2015-12-08 21:23:46 -08:00
commit 0cf95c5f5d

View File

@ -790,6 +790,13 @@ L.Map = L.Evented.extend({
viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),
offset = this._getBoundsOffset(viewBounds, bounds, zoom);
// If offset is less than a pixel, ignore.
// This prevents unstable projections from getting into
// an infinite loop of tiny offsets.
if (offset.round().equals([0, 0])) {
return center;
}
return this.unproject(centerPoint.add(offset), zoom);
},