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