-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_location_data.html
100 lines (83 loc) · 3.21 KB
/
get_location_data.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Gerda Steiner & Jörg Lenzlinger</title>
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script src="lib/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="lib/mxn/source/mxn.js?(googlev3)" type="text/javascript"></script>
<script src="lib/timeline/timeline-1.2.js" type="text/javascript"></script>
<script src="lib/timemap/timemap.js" type="text/javascript"></script>
<link href="css/style.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript">
var tm;
var ausstellungenData = [];
// First load the data
$(function() {
console.log('test')
var geocoder = new google.maps.Geocoder();
function codeAddress(address, resultObject) {
resultObject.done = false
resultObject.lat = -1
resultObject.lon = -1
$.getJSON("https://maps.google.com/maps/api/geocode/json?sensor=false&address="+String(address), function(data){
var status = data.status
, results = data.results;
if (status == google.maps.GeocoderStatus.OK) {
resultObject.lat = results[0].geometry.location.lat
resultObject.lon = results[0].geometry.location.lng // console.log(results[0].geometry.location);
console.log(address);
console.log(results[0].geometry.location.lat);
console.log(results[0].geometry.location.lng);
//resultObject.done = true
} else {
console.log("Geocode for " + address + " was not successful for the following reason: " + status);
console.log(results)
}
})
// How to use the geocoding API without the whole code around it:
//https://maps.google.com/maps/api/geocode/json?address=Kunsthaus,%20Z%C3%BCrich
}
console.log($.getJSON( "data/GerdaSteiner_Ausstellung_AUSST_DATUM_AUSST_INSTITUT.json", function( data ) {
window.rawdata = data;
window.counter = 0
window.amount = 3;
window.timeoutID = window.setInterval(function(){
var data = rawdata.slice(window.counter * amount, (window.counter+1) * amount)
if (data.length == 0){
window.clearInterval(window.timeoutID)
window.setTimeout(startRendering, 1000)
return
}
window.counter += 1
console.log(window.counter)
data = data.filter(
function(item){
return item["AUSST_ORT"] != ""
}).map(
function(item){
var location = {};
location.lat = 0
location.lon = 0
codeAddress("" + item.AUSST_ORT + ", " + item.AUSST_INSTITUT, location)
item.coordinates = location
delete item["N/A"]
return item
})
//append all the elements in data into ausstellungenData
Array.prototype.push.apply(window.ausstellungenData,data)
},
500)
}))
});
function startRendering() {
$("#data").html(JSON.stringify(ausstellungenData, null, 1))
}
</script>
</head>
<body>
<pre id="data">
</pre>
</body>
</html>