source: binary-improvements/webserver/js/leaflet.control.reloadtiles.js@ 248

Last change on this file since 248 was 244, checked in by alloc, 9 years ago

Fixes intermediate state

File size: 1.2 KB
RevLine 
[244]1L.Control.ReloadTiles = L.Control.extend({
2 options: {
3 position: 'bottomleft',
4 layers: []
5 },
6
7 onAdd: function (map) {
8 var name = 'control-reloadtiles',
9 container = L.DomUtil.create('div', name + ' webmap-control');
10
11 L.DomEvent.on (container, 'mousemove', L.DomEvent.stopPropagation);
12
13 this._map = map;
14
15 this._reloadbutton = this._createButton(
16 "Reload tiles", "Reload tiles",
17 name + "-btn", container, this._reload, this);
18
19 return container;
20 },
21
22 onRemove: function (map) {
23 },
24
25 _reload: function (e) {
26 var newTileTime = new Date().getTime();
27
28 for (var i = 0; i < this.options.layers.length; i++) {
29 this.options.layers [i].options.time = newTileTime;
30 this.options.layers [i].redraw ();
31 }
32 },
33
34 _createButton: function (html, title, className, container, fn, context) {
35 var link = L.DomUtil.create('a', className, container);
36 link.innerHTML = html;
37 link.href = '#';
38 link.title = title;
39
40 var stop = L.DomEvent.stopPropagation;
41
42 L.DomEvent
43 .on(link, 'click', stop)
44 .on(link, 'mousedown', stop)
45 .on(link, 'dblclick', stop)
46 .on(link, 'click', L.DomEvent.preventDefault)
47 .on(link, 'click', fn, context)
48 .on(link, 'click', this._refocusOnMap, context);
49
50 return link;
51 }
52
53});
54
Note: See TracBrowser for help on using the repository browser.