-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
146 lines (133 loc) · 3.63 KB
/
index.php
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
<?php
$dataset = $_GET["dataset"];
$xmls = array(
'architecturalheritage',
'beaches',
'bicycleroutes',
'botanicalroutes',
'carmotorbikeroutes',
'caves',
'churches-monasteries',
'e4',
'gorges',
'healthservices',
'museums',
'organisations',
'rockclimbingroutes',
'shelters',
'sights'
);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Hack4Med</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<style>
#map {
width: 100%;
height: 100%;
max-height: 100%;
position: relative;
background-color: rgb(229, 227, 223);
overflow: hidden;
-webkit-transform: translateZ(0px);
}
html, body{
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<div id="map" style=""></div>
<script type="text/javascript">
var locations = [
<?php
//for($x=0; $x<sizeof($xmls); $x++){
$xml=simplexml_load_file("opendata/".$xmls[$dataset].".xml");
for($i=0; $i<sizeof($xml->property); $i++){
$name = (string)$xml->property[$i]->name;
//$name = preg_replace('#[^\w()/.%\-&]#',"",$name);
$name = str_replace("'","",$name);
$name = str_replace("<","",$name);
$name = str_replace("<","",$name);
$key = str_replace(" ","%20",$name);
$key = htmlspecialchars($key);
$latitude = $xml->property[$i]->latitude;
$longitude = $xml->property[$i]->longitude;
$keyword = $key;//.'%20'.$xmls[$dataset];
$jsrc = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=".$keyword;
$json = file_get_contents($jsrc);
$jset = json_decode($json, true);
//print_r($jset);
$image = $jset["responseData"]["results"][2]["url"];
if($i<sizeof($xml->property)-1)
echo '["'.$name.'",'.$latitude.','.$longitude.','.$i.',"'.$image.'"],';
else
echo '["'.$name.'",'.$latitude.','.$longitude.','.$i.',"'.$image.'"]';
}
//break;
//}
?>
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 9,
center: new google.maps.LatLng(locations[0][1], locations[0][2]),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent('<div class="info_contenct">'+locations[i][0]+'<br /><img src="'+locations[i][4]+'" /></div>');
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
<?php
/*
for($i=0; $i<100; $i++){
$jsrc = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=knosos";
$json = file_get_contents($jsrc);
$jset = json_decode($json, true);
echo '<img src="'.$jset["responseData"]["results"][0]["url"].'" />';
}
*/
$xmls = array(
'architecturalheritage',
'beaches',
'bicycleroutes',
'botanicalroutes',
'carmotorbikeroutes',
'caves',
'churches-monasteries',
'e4',
'gorges',
'healthservices',
'museums',
'organisations',
'rockclimbingroutes',
'shelters',
'sights'
);
for($x=0; $x<sizeof($xmls); $x++){
$xml=simplexml_load_file("opendata/".$xmls[0].".xml");
for($i=0; $i<sizeof($xml->property); $i++){
$name = (string)$xml->property[$i]->name;
$latitude = $xml->property[$i]->latitude;
$longitude = $xml->property[$i]->longitude;
//echo $latitude.' '.$longitude.' '.$name.'<br />';
}
}
?>