]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/leaflet/leaflet.js
Update leaflet.locate (fixes #438)
[rails.git] / vendor / assets / leaflet / leaflet.js
index 794496b35130fb5121ef764b3947b33187787ff5..b972941d97a06cbb5705ce998d7382fa682e355c 100644 (file)
@@ -1752,6 +1752,7 @@ L.Map = L.Class.extend({
 
                var oldSize = this.getSize();
                this._sizeChanged = true;
+               this._initialCenter = null;
 
                if (this.options.maxBounds) {
                        this.setMaxBounds(this.options.maxBounds);
@@ -1825,7 +1826,7 @@ L.Map = L.Class.extend({
        getCenter: function () { // (Boolean) -> LatLng
                this._checkIfLoaded();
 
-               if (!this._moved()) {
+               if (this._initialCenter && !this._moved()) {
                        return this._initialCenter;
                }
                return this.layerPointToLatLng(this._getCenterLayerPoint());
@@ -6765,15 +6766,22 @@ L.Map.mergeOptions({
 
 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);
+               }
        }
 });
 
@@ -6833,7 +6841,11 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
 
                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);
+               }
        }
 });