\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
\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
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
},\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
: 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
}, 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