-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
141 lines (118 loc) · 3.29 KB
/
index.html
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html>
<head>
<base target="_parent" />
<meta charset=utf-8 />
<title>OTI Global</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.3/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.3/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.leaflet-popup-content .marker-title {
font-size: 14px;
}
.leaflet-popup-content {
padding: 10px 10px 10px;
margin:0;
line-height:inherit;
}
</style>
</head>
<body>
<style>
.legend label {
display:inline-block;
font: 12px/20px 'Helvetica Neue',Arial,Helvetica,sans-serif;
text-align: left;
vertical-align: middle;
color:rgba(0,0,0,.75);
padding-left:5px;
margin-bottom:13px;
}
.legend span {
display:inline-block;
height:20px;
width:20px;
}
.legend-row {
display:block;
height:25px;
}
.legend-title {
display:block;
font-size:14px;
font-weight:700;
margin-bottom:5px;
}
</style>
<div id='legend' style='display:none;'>
<span class='legend-title'>OTI Program Status</span>
<nav class='legend clearfix'>
<div class='legend-row'>
<span style='background:#0075A2;'></span>
<label>Active</label>
</div>
<div class ='legend-row'>
<span style='background:#6CAD5F;'></span>
<label>Closed</label>
</div>
</div>
<div id='map'></div>
<script src='./global-oti.js'></script>
<script>
var map = L.mapbox.map('map', 'otigiu.oti-global')
.setView([10, 25], 2);
map.legendControl.addLegend(document.getElementById('legend').innerHTML);
var popup = new L.Popup({ autoPan: false });
var otiLayer = L.geoJson(otiCountries, {
style: getStyle,
onEachFeature: onEachFeature
}).addTo(map);
function getStyle(feature) {
return {
weight: 1,
opacity: 0.5,
color: '#eee',
fillOpacity: 0.6,
fillColor: getColor(feature.properties.status)
};
}
// // get color depending on program status
function getColor(s) {
return s == 'Active' ? '#0075A2' :
s == 'Closed' ? '#6CAD5F' :
'#000';
}
function onEachFeature(feature, layer) {
var popupContent = '';
popupContent += '<div class="marker-title">' + layer.feature.properties.OTI_name + '</div>';
popupContent += '<b>' + 'Status: ' + '</b>' + layer.feature.properties.status;
if (layer.feature.properties.summary !== undefined && layer.feature.properties.summary > '') {
popupContent += '<br>' + '<b>Summary: </b>' + layer.feature.properties.summary;
}
if (layer.feature.properties.link !== undefined && layer.feature.properties.link > '') {
popupContent += '<a href="' + layer.feature.properties.link + '">' + ' Learn more' + '</a>';
}
layer.bindPopup(popupContent);
layer.on({
mousemove: mousemove,
mouseout: mouseout,
});
};
function mousemove(e) {
var layer = e.target;
popup.setLatLng(e.latlng);
// highlight feature
layer.setStyle({
weight: 2,
fillOpacity: 0.9
});
}
function mouseout(e) {
otiLayer.resetStyle(e.target);
}
</script>
</body>
</html>