]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/leaflet/leaflet.zoom.js
HTMLize note browse pages
[rails.git] / vendor / assets / leaflet / leaflet.zoom.js
index 6ce96757cefa5654c2ace0d0ff01804948a87ee6..fe7e2f5d2f194e322ef7395168af91122b3095f5 100644 (file)
@@ -7,21 +7,18 @@ L.Control.Zoomslider = L.Control.extend({
 \r
        onAdd: function (map) {\r
                var className = 'leaflet-control-zoomslider',\r
-                               container = L.DomUtil.create('div', className);\r
+                       container = L.DomUtil.create('div', className);\r
+\r
+               L.DomEvent.disableClickPropagation(container);\r
 \r
-               L.DomEvent\r
-                       .on(container, 'click', L.DomEvent.stopPropagation)\r
-                       .on(container, 'mousedown', L.DomEvent.stopPropagation)\r
-                       .on(container, 'dblclick', L.DomEvent.stopPropagation);\r
-               \r
                this._map = map;\r
 \r
-               this._zoomInButton = this._createButton('+', 'Zoom in', className + '-in'\r
+               this._zoomInButton = this._createButton('Zoom in', className + '-in'\r
                                                                                                , container, this._zoomIn , this);\r
                this._createSlider(className + '-slider', container, map);\r
-               this._zoomOutButton = this._createButton('-', 'Zoom out', className + '-out'\r
+               this._zoomOutButton = this._createButton('Zoom out', className + '-out'\r
                                                                                                 , container, this._zoomOut, this);\r
-               \r
+\r
                map.on('layeradd layerremove', this._refresh, this);\r
 \r
                map.whenReady(function(){\r
@@ -45,6 +42,11 @@ L.Control.Zoomslider = L.Control.extend({
 \r
        _createSlider: function (className, container, map) {\r
                var zoomLevels = map.getMaxZoom() - map.getMinZoom();\r
+               // This means we have no tilelayers (or that they are setup in a strange way).\r
+               // Either way we don't want to add a slider here.\r
+               if(zoomLevels == Infinity){\r
+                       return undefined;\r
+               }\r
                this._sliderHeight = this.options.stepHeight * zoomLevels;\r
 \r
                var wrapper =  L.DomUtil.create('div', className + '-wrap', container);\r
@@ -68,9 +70,8 @@ L.Control.Zoomslider = L.Control.extend({
            this._map.zoomOut(e.shiftKey ? 3 : 1);\r
        },\r
 \r
-       _createButton: function (html, title, className, container, fn, context) {\r
+       _createButton: function (title, className, container, fn, context) {\r
                var link = L.DomUtil.create('a', className, container);\r
-               link.innerHTML = html;\r
                link.href = '#';\r
                link.title = title;\r
 \r
@@ -82,16 +83,12 @@ L.Control.Zoomslider = L.Control.extend({
        },\r
 \r
        _createDraggable: function() {\r
-               L.DomUtil.setPosition(this._knob, new L.Point(0, 0));\r
-               L.DomEvent\r
-                       .on(this._knob\r
-                               , L.Draggable.START\r
-                               , L.DomEvent.stopPropagation)\r
-                       .on(this._knob, 'click', L.DomEvent.stopPropagation);\r
+               L.DomUtil.setPosition(this._knob, L.point(0, 0));\r
+               L.DomEvent.disableClickPropagation(this._knob);\r
 \r
                var bounds = new L.Bounds(\r
-                       new L.Point(0, 0),\r
-                       new L.Point(0, this._sliderHeight)\r
+                       L.point(0, 0),\r
+                       L.point(0, this._sliderHeight)\r
                );\r
                var draggable = new L.BoundedDraggable(this._knob,\r
                                                                                           this._knob,\r
@@ -135,7 +132,7 @@ L.Control.Zoomslider = L.Control.extend({
                                : sliderValue;\r
                        var y = this._sliderHeight\r
                                - (sliderValue * this.options.stepHeight);\r
-                       L.DomUtil.setPosition(this._knob, new L.Point(0, y));\r
+                       L.DomUtil.setPosition(this._knob, L.point(0, y));\r
                }\r
        },\r
        _toZoomLevel: function(sliderValue) {\r
@@ -191,7 +188,7 @@ L.BoundedDraggable = L.Draggable.extend({
                }, this);\r
        },\r
        _fitPoint: function(point){\r
-               var closest = new L.Point(\r
+               var closest = L.point(\r
                        Math.min(point.x, this._bounds.max.x),\r
                        Math.min(point.y, this._bounds.max.y)\r
                );\r