-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.php
More file actions
72 lines (64 loc) · 1.87 KB
/
map.php
File metadata and controls
72 lines (64 loc) · 1.87 KB
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
<?php
include 'mapconnect.php';
$apikey = "AIzaSyDU8XFtp3Qe0QDPzJIaT50CgPfkau1LKsk ";
$id = $_GET['id'];
$lat = 0;
$long = 0;
$zoom = 8;
$findmap = "SELECT centerLat, centerLong, zoom FROM maps WHERE ID = $id";
if(!$result = $con->query($findmap)){
die('There was an error running the query [' . $con->error . ']');
} else {
$row = $result->fetch_assoc();
$lat = $row['centerLat'];
$long = $row['centerLong'];
$zoom = $row['zoom'];
}
?><!DOCTYPE html>
<html>
<head>
<meta name="viewport"
content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=
<?php echo $apikey; ?>&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(<?php echo $lat.', '.$long; ?>),
zoom: <?php echo $zoom; ?>
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
<?php
$getpoints = "SELECT pointLat, pointLong, pointText
FROM mappoints WHERE mapID = $id";
if(!$result = $con->query($getpoints)){
die('There was an error running the query
[' . $con->error . ']');
} else {
while ($row = $result->fetch_assoc()) {
echo ' var myLatlng1 = new google.maps.LatLng('.
$row[pointLat].', '.$row[pointLong].');
var marker1 = new google.maps.Marker({
position: myLatlng1,
map: map,
title:"'.$row[pointText].'"
});';
}
}
?>
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"/>
</body>
</html>