Repository navigation
Expand file tree
/
Copy pathmap-with-slider.js
More file actions
103 lines (102 loc) · 3.69 KB
/
Copy pathmap-with-slider.js
File metadata and controls
103 lines (102 loc) · 3.69 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
var sliderVal = [-1.5, 3.75];
this.default = function () {
var colorCodes = ['#7E9CDC', '#DCD57E', '#7EDCA2', '#6EB5D0', '#A6DC7E', '#DCA87E', '#d075c6'];
var maps = new ej.maps.Maps({
margin: {
bottom: 20
},
titleSettings: {
text: 'Average annual population growth in North American countries',
textStyle: {
size: '16px'
}
},
// custom code start
loaded: function (args) {
if (!ej.base.isNullOrUndefined(document.getElementById('mapslider_Annotation_0'))) {
annotationRender(sliderVal);
}
},
// custom code end
zoomSettings: {
enable: false
},
annotations: [
{
content: '#mapslider-annotation',
horizontalAlignment: 'Center',
y: '93%'
}
],
layers: [
{
shapeData: new ej.maps.MapAjax('./src/maps/map-data/north-america.json'),
shapePropertyPath: 'name',
shapeDataPath: 'name',
dataSource: new ej.maps.MapAjax('./src/maps/map-data/population-growth.json'),
shapeSettings: {
colorValuePath: 'population',
colorMapping: [
{
from: -1.5, to: -0.75, color: '#7E9CDC'
},
{
from: -0.75, to: 0, color: '#DCD57E'
},
{
from: 0.1, to: 0.75, color: '#7EDCA2'
},
{
from: 0.76, to: 1.5, color: '#6EB5D0'
},
{
from: 1.5, to: 2.25, color: '#A6DC7E'
},
{
from: 2.25, to: 3, color: '#DCA87E'
},
{
from: 3, to: 3.75, color: '#d075c6'
}
]
},
tooltipSettings: {
visible: true,
format: '${name} : ${population}%'
}
}
],
// custom code start
load: function (args) {
var theme = location.hash.split('/')[1];
theme = theme ? theme : 'Material';
args.maps.theme = (theme.charAt(0).toUpperCase() + theme.slice(1));
}
// custom code end
});
maps.appendTo('#mapslider');
function annotationRender(val) {
var slider = new ej.inputs.Slider({
min: -1.5, max: 3.75,
value: val,
step: 0.75,
type: 'Range',
ticks: { placement: 'After', largeStep: 0.75 },
changed: function (args) {
if (!isNaN(args.value[0]) && !isNaN(args.value[1])) {
for (var i = 0; i < maps.layers[0].shapeSettings.colorMapping.length; i++) {
if (maps.layers[0].shapeSettings.colorMapping[i].from < args.value[0] ||
maps.layers[0].shapeSettings.colorMapping[i].to > args.value[1]) {
maps.layers[0].shapeSettings.colorMapping[i].color = '#E5E5E5';
} else {
maps.layers[0].shapeSettings.colorMapping[i].color = colorCodes[i];
}
}
sliderVal = args.value;
maps.refresh();
}
}
});
slider.appendTo('#mapannotation');
}
};