-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
92 lines (83 loc) · 2.64 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
<html>
<head>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0; font-family: sans-serif; }
#map_canvas { height: 100% }
div.title { font-weight: bold; }
div.type { }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBb3MwPLAaHBqroCJrcEH-Fh5hfjYT7KfA&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
infowindow = new google.maps.InfoWindow({ size: new google.maps.Size(10,10) });
var myOptions = {
center: new google.maps.LatLng(61.164437,-149.655762),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
for(var i in pointArray)
{
var marker = new google.maps.Marker({
position: pointArray[i].position,
map: map,
title: pointArray[i].title,
clickable: true
});
(function(marker, info){
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<div class="title">' + info.title + '</div><div class="type">' + info.type + '</div>');
infowindow.open(map, marker);
});
})(marker, pointArray[i]);
}
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function(results)
{
var center = new google.maps.LatLng(
results.coords.latitude,
results.coords.longitude
);
new google.maps.Marker({
position: center,
map: map,
icon: 'star.png',
title: "You are here"
});
map.setCenter(center);
map.setZoom(12);
});
}
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
<script type="text/javascript">
pointArray = [];
<?
$link = mysql_connect('localhost', 'root', 'root');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('ak_beer_finder', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
$result = mysql_query("SELECT * FROM bars limit 20");
while ($row = mysql_fetch_assoc($result))
echo 'pointArray.push({
position: new google.maps.LatLng(' . $row['lat'] . ', ' . $row['long'] . '),
title: "' . $row['name'] . '",
type: "' . $row['type'] . '"});'."\n";
?>
</script>
</body>
</head>
</html>