-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patholdmap.php
243 lines (208 loc) · 8.91 KB
/
oldmap.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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html lang="en">
<head>
<?php
include("res/php/auth.php");
include("res/php/loadfunc.php");
include("res/php/links.php");
?>
<?php
mysql_connect($mysql_host,$username,$password);
$con = mysql_connect($mysql_host,$username,$password);
if (!$con) {
die("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Error: </strong>" . mysql_error() . "</strong></div>");
}
$db = mysql_select_db($database);
?>
<?php
$sql = 'SELECT * FROM `Buildings` LIMIT 0, 30 ';
$rs = mysql_query($sql);
if (!$rs) { die("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Error: </strong>" . mysql_error() . "</strong></div>"); } ?>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
// Init map options
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(40.0150, -105.2700),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
// Markers
var id;
var markers = {};
var infowindow = new google.maps.InfoWindow();
// Add Init markers
var addInitMarker = function (alatlng, name, id, tagarr, ratingarr) {
marker = new google.maps.Marker({
position: alatlng,
map: map,
draggable: true,
animation: google.maps.Animation.DROP
});
var contentString = "<h3>" + name + "</h3>";
var first = true;
var playTags;
for(var tag in tagarr){
if (first) { playTags = tagarr[tag]; first = false; }
else { playTags += "+" + tagarr[tag]; }
contentString += "<span class='badge badge-jam'>" + tagarr[tag] + " ( " + ratingarr[tag] + " )</span> ";
}
contentString += "<p>"+playTags+"</p>";
contentString += "<div>" +
"<button class='btn btn-jam control-conatiner pull-left'>" +
"<i onclick='toggleMusic()' id='control' class='icon-pause icon-white'></i>" +
"</button>" +
"<div class='progress progress-jam progress-striped active'>" +
"<div class='bar' id='time'><span id='current' class='badge badge-jam'></span></div>" +
"</div></div>";
makeInfoWindowEvent(map, infowindow, contentString, marker);
id = marker.__gm_id
markers[id] = marker;
google.maps.event.addListener(marker, "rightclick", function (point) {
id = this.__gm_id;
delMarker(id);
});
google.maps.event.addListener(marker, 'click', function(point) {
id = this.__gm_id;
infowindow.open(map, markers[id]);
});
var circleOptions = {
strokeColor: "#8800CC",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#8800CC",
fillOpacity: 0.35,
map: map,
center: alatlng,
radius: 150
};
musicCircle = new google.maps.Circle(circleOptions);
}
// Add markers
var addMarker = function (alatlng) {
marker = new google.maps.Marker({
position: alatlng,
map: map,
draggable: true,
animation: google.maps.Animation.DROP
});
var contentString = "<form class='addPlace' method='get' action='res/php/add.php'>" +
"<input type='text' name='name' placeholder='Name of Building' autofocus='autofocus'/><br/>" +
"<input type='text' name='tag1' id='tag' placeholder='mood, genre, or artist'/><br/>" +
"<input type='text' name='tag2' id='tag' placeholder='mood, genre, or artist'/><br/>" +
"<input type='text' name='tag3' id='tag' placeholder='mood, genre, or artist'/><br/>" +
"<input type='text' name='lat' value='"+alatlng.lat()+"' style='display:none;'/><br/>" +
"<input type='text' name='lng' value='"+alatlng.lng()+"' style='display:none;'/>" +
"<button type='submit' class='btn btn-jam'>Save</button></form>";
makeInfoWindowEvent(map, infowindow, contentString, marker);
//map.panTo(alatLng);
id = marker.__gm_id
markers[id] = marker;
google.maps.event.addListener(marker, "rightclick", function (point) { id = this.__gm_id; delMarker(id) });
google.maps.event.addListener(marker, 'click', function(point) {
id = this.__gm_id;
infowindow.open(map, markers[id]);
});
}
// Delete marker on right click
var delMarker = function (id) {
marker = markers[id];
marker.setMap(null);
}
function makeInfoWindowEvent(map, infowindow, contentString, marker) {
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map, marker);
});
}
// Right click handler
google.maps.event.addListener(map, "rightclick", function(event) {
var lat = event.latLng.lat();
var lng = event.latLng.lng();
var myLatlng = new google.maps.LatLng(lat, lng);
addMarker(myLatlng);
});
<?php while($row = mysql_fetch_array($rs)) { ?>
<?php $sql2 = "SELECT * FROM `Tags` WHERE `building` = '".$row['id']."'";
$rs2 = mysql_query($sql2);
if (!$rs2) { die("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Error: </strong>" . mysql_error() . "</strong></div>"); }
?>
var tagarr = [];
var ratingarr = [];
var i = 0;
<?php while($row2 = mysql_fetch_array($rs2)) { ?>
tagarr[i] = "<?=$row2['tag']?>";
ratingarr[i] = "<?=$row2['rating']?>";
i++;
<?php } ?>
addInitMarker(new google.maps.LatLng(<?=$row['lat']?>, <?=$row['lng']?>), "<?=$row['name']?>", <?=$row['id']?>, tagarr, ratingarr);
<?php } ?>
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style type="text/css">
#map_canvas {
margin: 0;
padding: 0;
height: 400px;
width: 100%;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="./index.php">JamWalkr</a>
<ul class="nav">
<li><a href="./index.php"><i class="icon-home icon-white"></i></a></li>
<li><a href="./ajax.php"><i class="icon-music icon-white"></i></a></li>
<li><a href="./8tracks.php"><i class="icon-headphones icon-white"></i></a></li>
<li class="active"><a href="./map.php"><i class="icon-map-marker icon-white"></i></a></li>
</ul>
</div>
</div>
</div>
<div class="container-fluid" style="margin-top: 50px;">
<span id="msg"></span>
<video id="player" class="data"></video>
<div class="row-fluid">
<div class="span9">
<h1>Google Maps API</h1>
<div id="map_canvas"></div>
</div>
<div class="span3">
<?php
$sql = 'SELECT * FROM `Buildings` LIMIT 0, 30 ';
$rs = mysql_query($sql);
if (!$rs) { die("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Error: </strong>" . mysql_error() . "</strong></div>"); } ?>
<ul>
<?php while($row = mysql_fetch_array($rs)) { ?>
<li>
<strong><?=$row['name'];?></strong> (<?=$row['lat']?>,<?=$row['lng']?>)
<?php $sql2 = "SELECT * FROM `Tags` WHERE `building` = '".$row['id']."'";
$rs2 = mysql_query($sql2);
if (!$rs2) { die("<div class='alert alert-error'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Error: </strong>" . mysql_error() . "</strong></div>"); }
$first = false; ?>
<ul>
<?php while($row2 = mysql_fetch_array($rs2)) {
if (!$first) { $tags = $row2['tag']; $first = true; }
else { $tags .= "+".$row2['tag']; } ?>
<li><?=$row2['tag'];?></li>
<?php } ?>
<?php if ($first) { ?>
<li><form class="form-search" method="post" action="ajax.php">
<input type="text" name="tag" value="<?=$tags?>" style="display:none;"/>
<button type="submit" class="btn btn-jam btn-mini"><i class="icon-white icon-play"></i></button></form></li>
<?php } ?>
</ul>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</body>
</html>