var oldSize = this.getSize();
this._sizeChanged = true;
+ this._initialCenter = null;
if (this.options.maxBounds) {
this.setMaxBounds(this.options.maxBounds);
getCenter: function () { // (Boolean) -> LatLng
this._checkIfLoaded();
- if (!this._moved()) {
+ if (this._initialCenter && !this._moved()) {
return this._initialCenter;
}
return this.layerPointToLatLng(this._getCenterLayerPoint());
L.Map.DoubleClickZoom = L.Handler.extend({
addHooks: function () {
- this._map.on('dblclick', this._onDoubleClick);
+ this._map.on('dblclick', this._onDoubleClick, this);
},
removeHooks: function () {
- this._map.off('dblclick', this._onDoubleClick);
+ this._map.off('dblclick', this._onDoubleClick, this);
},
_onDoubleClick: function (e) {
- this.setZoomAround(e.containerPoint, this._zoom + 1);
+ var map = this._map,
+ zoom = map.getZoom() + 1;
+
+ if (map.options.doubleClickZoom === 'center') {
+ map.setZoom(zoom);
+ } else {
+ map.setZoomAround(e.containerPoint, zoom);
+ }
}
});
if (!delta) { return; }
- map.setZoomAround(this._lastMousePos, zoom + delta);
+ if (map.options.scrollWheelZoom === 'center') {
+ map.setZoom(zoom + delta);
+ } else {
+ map.setZoomAround(this._lastMousePos, zoom + delta);
+ }
}
});