Use all four corners when projecting ImageOverlay during animation (#4993)

Close #4886.
This commit is contained in:
Per Liedman 2016-10-02 21:07:05 +02:00 committed by Vladimir Agafonkin
parent 7f350e4442
commit 350919b2ff
2 changed files with 11 additions and 1 deletions

View File

@ -172,7 +172,7 @@ L.ImageOverlay = L.Layer.extend({
_animateZoom: function (e) {
var scale = this._map.getZoomScale(e.zoom),
offset = this._map._latLngToNewLayerPoint(this._bounds.getNorthWest(), e.zoom, e.center);
offset = this._map._latLngBoundsToNewLayerBounds(this._bounds, e.zoom, e.center).min;
L.DomUtil.setTransform(this._image, offset, scale);
},

View File

@ -1378,6 +1378,16 @@ L.Map = L.Evented.extend({
return this.project(latlng, zoom)._subtract(topLeft);
},
_latLngBoundsToNewLayerBounds: function (latLngBounds, zoom, center) {
var topLeft = this._getNewPixelOrigin(center, zoom);
return L.bounds([
this.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft),
this.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft),
this.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft),
this.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft)
]);
},
// layer point of the current center
_getCenterLayerPoint: function () {
return this.containerPointToLayerPoint(this.getSize()._divideBy(2));