forked from yulunyao/INFS3202
-
Notifications
You must be signed in to change notification settings - Fork 0
/
location.php
123 lines (102 loc) · 3.07 KB
/
location.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
<?php
session_start();
$con = mysqli_connect('au-cdbr-azure-east-a.cloudapp.net:3306', "b622a8e03ec7ba", "6e32c3d6", "sik");
echo "Welcome " . $_SESSION['username'];
$query = "SELECT random FROM signup WHERE username = '".$_SESSION['username']."'";
$result = mysqli_query($con,$query);
while($row = mysqli_fetch_assoc($result)) {
print_r(" with UID: ");
print_r($row["random"]);
}
echo "<a href='logout.php'> [logout]</a>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SiK</title>
<link rel="stylesheet" type="text/css" href="css/styleTask.css">
</head>
<body>
<!--
Or key is:
AIzaSyDG4jMSOZattisRWE3f96RaJcV5S9nQHr0
-->
<div id="wrapper">
<div class="logo"><img src="img/SiKd.png" alt="Logo" width="70px" height="32px"></div>
<p id="demo"></p>
<div style="width: 50%; height: 100%; float:left;">
<div id="googleMap" style="width:80%;height:400px;"></div>
</div>
<div id=right style="width: 50%; height: 100%; float:right ">
<h3>You are now in the location:</h2>
<img src="img/blue.png" width="50%" height="50%"></img>
<h2 id=addressA></h2>
<button id=locationBtn>Send Location</button>
</div>
<p></p>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDG4jMSOZattisRWE3f96RaJcV5S9nQHr0"></script>
<script>
var x = document.getElementById("demo");
var lat = 0;
var longi = 0;
var map;
var geocoder;
var infowindow;
window.addEventListener("load", function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
});
function getLocation() {
}
function showPosition(position) {
/*x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;*/
lat = position.coords.latitude;
longi = position.coords.longitude;
console.log(lat);
console.log(longi);
mapInit();
}
function mapInit() {
var mapProp= {
center:new google.maps.LatLng(lat,longi),
zoom:15,
};
map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
geocoder = new google.maps.Geocoder;
infowindow = new google.maps.InfoWindow;
geoLookup();
}
function geoLookup(){
var latlng = {lat: parseFloat(lat), lng: parseFloat(longi)};
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === 'OK') {
if (results[1]) {
map.setZoom(15);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
document.getElementById("addressA").innerHTML = results[1].formatted_address;
//textString
//infowindow.open(map, marker);
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
});
}
//var json = https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=AIzaSyDG4jMSOZattisRWE3f96RaJcV5S9nQHr0
</script>
</div>
<div id="footer" >
Designed By Team.
</div>
</body>
</html>