-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-legend.js
43 lines (40 loc) · 1.17 KB
/
simple-legend.js
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
/* Creates a simple legend to display minor a major occurrences for all indicative maps.
*
* legendTitle - Name to display as the legend title
*/
exports.minorMajorLegend = function(legendTitle) {
var legend = ui.Panel({style: {position: 'bottom-left', padding: '8px 15px'}});
var makeRow = function(color, name) {
var colorBox = ui.Label({
style: {color: '#ffffff',
backgroundColor: color,
padding: '10px',
margin: '0 0 4px 0',
}
});
var description = ui.Label({
value: name,
style: {
margin: '0px 0 4px 6px',
}
});
return ui.Panel({
widgets: [colorBox, description],
layout: ui.Panel.Layout.Flow('horizontal')}
)};
var title = ui.Label({
value: legendTitle,
style: {fontWeight: 'bold',
fontSize: '16px',
margin: '0px 0 4px 0px'}});
legend.add(title);
legend.add(makeRow('red','Major occurrences'));
legend.add(makeRow('yellow','Minor occurrences'));
return legend;
}
/* Create the title label. */
exports.titleLabel = function() {
var title = ui.Label('IUCN Global Ecosystem Typology');
title.style().set('position', 'bottom-center');
return title;
}