1 L.Control.Pan = L.Control.extend({
7 onAdd: function (map) {
8 var className = 'leaflet-control-pan',
9 container = L.DomUtil.create('div', className),
10 off = this.options.panOffset;
12 this._panButton('Up' , className + '-up'
13 , container, map, new L.Point( 0 , -off));
14 this._panButton('Left' , className + '-left'
15 , container, map, new L.Point( -off , 0));
16 this._panButton('Right', className + '-right'
17 , container, map, new L.Point( off , 0));
18 this._panButton('Down' , className + '-down'
19 , container, map, new L.Point( 0 , off));
24 _panButton: function (title, className, container, map, offset, text) {
25 var wrapper = L.DomUtil.create('div', className + "-wrap", container);
26 var link = L.DomUtil.create('a', className, wrapper);
30 .on(link, 'click', L.DomEvent.stopPropagation)
31 .on(link, 'click', L.DomEvent.preventDefault)
32 .on(link, 'click', function(){ map.panBy(offset); }, map)
33 .on(link, 'dblclick', L.DomEvent.stopPropagation)
43 L.Map.addInitHook(function () {
44 if (this.options.panControl) {
45 this.panControl = new L.Control.Pan();
46 this.addControl(this.panControl);
50 L.control.pan = function (options) {
51 return new L.Control.Pan(options);