fix GridLayer to not reset if tile zoom didn't change

This commit is contained in:
Vladimir Agafonkin 2014-01-20 20:29:44 +02:00
parent dc04b9dbe2
commit e093979297

View File

@ -187,27 +187,27 @@ L.GridLayer = L.Layer.extend({
_reset: function (e) { _reset: function (e) {
var map = this._map, var map = this._map,
zoom = map.getZoom(), zoom = map.getZoom(),
roundZoom = Math.round(zoom); tileZoom = Math.round(zoom),
tileZoomChanged = this._tileZoom !== tileZoom;
if (this._abortLoading) { if (this._abortLoading) {
this._abortLoading(); this._abortLoading();
} }
this._clearTiles(); if (tileZoomChanged || e && e.hard) {
this._clearTiles();
if (this._tileZoom !== roundZoom) { this._tileZoom = tileZoom;
this._tileZoom = roundZoom; this._pxOrigin = map.project(map.unproject(map.getPixelOrigin()), tileZoom).round();
this._resetGrid(); this._resetGrid();
} }
if (this._zoomAnimated) { if (this._zoomAnimated) {
this._origScale = map.getZoomScale(zoom) / map.getZoomScale(this._tileZoom); this._origScale = map.getZoomScale(zoom, tileZoom);
this._origTranslate = map.containerPointToLayerPoint(map.getSize().divideBy(2)) this._origTranslate = this._pxOrigin.multiplyBy(this._origScale).subtract(map.getPixelOrigin()).round();
.multiplyBy((1 - this._origScale));
L.DomUtil.setTransform(this._tileContainer, this._origTranslate, this._origScale); L.DomUtil.setTransform(this._tileContainer, this._origTranslate, this._origScale);
} }
this._pxOrigin = map._getNewPixelOrigin(map.getCenter(), roundZoom);
if (this._zoomAnimated && e && e.hard) { if (this._zoomAnimated && e && e.hard) {
this._clearBgBuffer(); this._clearBgBuffer();