lib/leaflet/src/map/handler/Map.DoubleClickZoom.js in leaflet-js-0.6.beta4 vs lib/leaflet/src/map/handler/Map.DoubleClickZoom.js in leaflet-js-0.7.0
- old
+ new
@@ -6,18 +6,25 @@
doubleClickZoom: true
});
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() + (e.originalEvent.shiftKey ? -1 : 1);
+
+ if (map.options.doubleClickZoom === 'center') {
+ map.setZoom(zoom);
+ } else {
+ map.setZoomAround(e.containerPoint, zoom);
+ }
}
});
L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);