]> git.openstreetmap.org Git - rails.git/blob - vendor/assets/leaflet/leaflet.pan.js
Style disabled permalinks appropriately
[rails.git] / vendor / assets / leaflet / leaflet.pan.js
1 L.Control.Pan = L.Control.extend({
2         options: {
3                 position: 'topleft',
4                 panOffset: 500
5         },
6
7         onAdd: function (map) {
8                 var className = 'leaflet-control-pan',
9                         container = L.DomUtil.create('div', className),
10                         off = this.options.panOffset;
11
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));
20                 
21                 return container;
22         },
23
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);
27                 link.href = '#';
28                 link.title = title;
29                 L.DomEvent
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)
34
35                 return link;
36         }
37 });
38
39 L.Map.mergeOptions({
40     panControl: true
41 });
42
43 L.Map.addInitHook(function () {
44     if (this.options.panControl) {
45                 this.panControl = new L.Control.Pan();
46                 this.addControl(this.panControl);
47         }
48 });
49
50 L.control.pan = function (options) {
51     return new L.Control.Pan(options);
52 };