leaflet-range
Version:
A simple HTML5 range control for Leaflet maps
1 lines • 1.14 kB
JavaScript
L.Control.Range=L.Control.extend({options:{position:"topright",min:0,max:100,value:0,step:1,orient:"vertical",iconClass:"leaflet-range-icon",icon:!0},onAdd:function(n){var t=L.DomUtil.create("div","leaflet-range-control leaflet-bar "+this.options.orient),o=(this.options.icon&&L.DomUtil.create("span",this.options.iconClass,t),L.DomUtil.create("input","",t));return o.type="range",o.setAttribute("orient",this.options.orient),o.min=this.options.min,o.max=this.options.max,o.step=this.options.step,o.value=this.options.value,L.DomEvent.on(o,"mousedown mouseup click touchstart",L.DomEvent.stopPropagation),L.DomEvent.on(o,"mouseenter",function(t){n.dragging.disable()}),L.DomEvent.on(o,"mouseleave",function(t){n.dragging.enable()}),L.DomEvent.on(o,"change",function(t){this.fire("change",{value:t.target.value})}.bind(this)),L.DomEvent.on(o,"input",function(t){this.fire("input",{value:t.target.value})}.bind(this)),this._slider=o,this._container=t,this._container},setValue:function(t){this.options.value=t,this._slider.value=t}}),L.Control.Range.include(L.Evented.prototype),L.control.range=function(t){return new L.Control.Range(t)};