-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple.html
185 lines (154 loc) · 7.07 KB
/
simple.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html lang="en">
<head>
<title>UNHCR</title>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css"/>
<link rel="stylesheet" href="woc.css"/>
<link href="http://www.unhcr.org/favicon.ico" rel="icon" type="image/x-icon">
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>
</head>
<body>
<div id="count-window">
<input id="thecount" disabled/>
</div>
<div id="map"></div>
<!--start infowindow template-->
<div id="filters">
<div class="wrapper">
<div class="context subheader">
<h1>Sites in Greece</h1>
<br>
</div>
<p>This interactive map collates available information from different data sources about sites hostings
refugees. <a href=''>Lorem ipsum dolor sit ame</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
</p>
<!--Copy and paste the div below for creating content blocks-->
<h6>Description</h6>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum</p>
<br>
<br><br><br>
<div id="logo-container"><img id="logo" height="40" src="unhcr.png" alt="Logo"></div>
<h4>Powered by the <a href="mailto:[email protected]">Winter Operations Cell</a></h4>
<div class='cartodb-legend bubble'>
<div class="legend-title">Site Capacity</div>
<ul>
<li>
150
</li>
<li class="graph" style="background: rgb(184, 22, 9);">
<div class="bubbles"></div>
</li>
<li>
2400
</li>
</ul>
</div>
<a href="#" id="close-window">X</a>
<div id="custom-infowindow">
</div><!--end infowindow template-->
</div>
<script>
// changing the cursor when hover on features http://bl.ocks.org/javisantana/6102814
function addCursorInteraction(layer) {
var hovers = [];
layer.bind('featureOver', function (e, latlon, pxPos, data, layer) {
hovers[layer] = 1;
if (_.any(hovers)) {
$('img.leaflet-tile').css('cursor', 'pointer');
}
});
layer.bind('featureOut', function (m, layer) {
hovers[layer] = 0;
if (!_.any(hovers)) {
$('img.leaflet-tile').css('cursor', 'auto');
}
});
}
function main() {
cartodb.createVis('map', 'https://unhcrinnovation.cartodb.com/api/v2/viz/5bcdabb8-e14f-11e5-a2e0-0ecd1babdde5/viz.json', {
shareable: false,
title: false,
description: true,
search: false,
infowindow: false,
tiles_loader: true,
center_lat: 39,
center_lon: 26,
zoom: 7
})
.done(function (vis, layers) {
// get the number of items
function getRecordsCount() {
$.getJSON('https://unhcrinnovation.cartodb.com/api/v2/sql/?q=SELECT count(*) FROM sites_greece_gdrive_cartodb', function (data) {
$.each(data.rows, function () {
var the_count = data.rows[0]["count"];
$("#thecount").val('Number of sites: ' + the_count);
});
});
}
getRecordsCount();
// layer 0 is the base layer, layer 1 is cartodb layer
layers[1].setInteraction(true);
layers[1].setInteractivity("cartodb_id,the_geom,capacity,comments,country,latitude,location_name,longitude,m_i,pcode,management,protection,nfi,shelter,health,wash,pop_20160303,last_update");
layers[1].on('featureClick', function (e, latlng, pos, data) {
$("#custom-infowindow").html(buildInfoWindow(data)).show();
$("#close-window").show();
});
addCursorInteraction(layers[1]);
})
.error(function (err) {
console.log(err);
});
$(document).on('click', '#close-window', function () {
$("#custom-infowindow").html('').css({'display': 'none'});
$("#close-window").css({'display': 'none'});
});
}
window.onload = main;
function buildInfoWindow(data) {
return '' +
'<div class="wrapper">' +
' <div class="item">' +
' <div class="header">' +
' <div class="infobar">' +
' <span class="idnumber"># PCODE ' + data.pcode + '</span>' +
' </div>' +
' </div>' +
' <div class="content">' +
' <h2 class="location">Site Name:<br><span class="main_location">' + data.location_name + '</span></>' +
getData('country', data.country) +
getData(data.m_i) +
getData('capacity', data.capacity) +
getData('Population', data.pop_20160303) +
getData('Camp Management', data.management) +
getData('protection', data.protection) +
getData('NFI', data.nfi) +
getData('Shelter', data.shelter) +
getData('Health', data.health) +
getData('WASH', data.WASH) +
getData('comments', data.comments) +
getData('longitude', data.longitude) +
getData('latitude', data.latitude) +
getData('Updated', data.last_update) +
' <p class="report" style="display: block;"><span class="viewreport download_button" tabindex="0"><a href="#" target="_blank">Download (soon)</a></span></p>' +
'<div class="viewassessment" tabindex="0"><a href="#" target="_blank">Cool blue button</div>' +
' </div>' +
' </div>' +
'</div>' +
'';
}
function getData(name, value) {
return typeof value == 'undefined' || value === null || value == '' ? '' :
'<p class="clusters">' + name + ':<br>' +
'<span class="clusters_content">' + value + '</span></p>';
}
</script>
</body>
</html>