-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
45 lines (42 loc) · 1.16 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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Geocodemany Demo</title>
</head>
<body>
<style>
body { margin:0; padding:10px; }
p { display:block; margin-bottom:10px; }
</style>
<p>View console.log for result</p>
<div id='progress'></div>
<script src='geocodemany.js'></script>
<script src='data.js'></script>
<script>
function progressChart(elem, w, h) {
var c = elem.appendChild(document.createElement('canvas'));
c.width = w;
c.height = h;
var ctx = c.getContext('2d');
var ratio;
var fill = {
success: '#A2D398',
error: '#D498BA'
};
return function(e) {
if (!ratio) ratio = h / e.todo;
ctx.fillStyle = fill[e.status];
ctx.fillRect(0, (e.done - 1) * ratio, w, e.done * ratio);
};
}
var prog = progressChart(document.getElementById('progress'), 100, 200);
function transform(obj) { return obj.name; }
function progress(e) { prog(e); }
function done() { console.log(arguments); }
var accessToken = 'pk.eyJ1IjoidHJpc3RlbiIsImEiOiJiUzBYOEJzIn0.VyXs9qNWgTfABLzSI3YcrQ';
var geocoder = geocodemany(accessToken, 0);
geocoder(data, transform, progress, done);
</script>
</body>
</html>