-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeaflet.messageboxV2.js
More file actions
59 lines (46 loc) · 1.53 KB
/
Leaflet.messageboxV2.js
File metadata and controls
59 lines (46 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* message box leaflet plugin @https://github.com/tinuzz/leaflet-messagebox*/
/* modified by Alex Dacurro Github @ adacurro-usgs */
L.Control.Messagebox = L.Control.extend({
options: {
position: 'topright',
timeout: 0,
setClass: ''
},
onAdd: function(map) {
// add custom class on the messagebox. (you can add bootstrap class if you want)
this._container = L.DomUtil.create('div', 'leaflet-control-messagebox ' + this.options.setClass);
//L.DomEvent.disableClickPropagation(this._container);
return this._container;
},
show: function(message, timeout) {
var elem = this._container;
elem.innerHTML = message;
elem.style.display = 'block';
timeout = timeout || this.options.timeout;
/* if you want a permanent message box like me */
if (timeout > 0) {
if (typeof this.timeoutID == 'number') {
clearTimeout(this.timeoutID);
}
this.timeoutID = setTimeout(function() {
elem.style.display = 'none';
}, timeout);
}
},
hide: function() {
var elem = this._container;
elem.style.display = 'none';
}
});
L.Map.mergeOptions({
messagebox: false
});
L.Map.addInitHook(function() {
if (this.options.messagebox) {
this.messagebox = new L.Control.Messagebox();
this.addControl(new this.messagebox);
}
});
L.control.messagebox = function(options) {
return new L.Control.Messagebox(options);
};