-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestlocation.html
executable file
·74 lines (53 loc) · 1.85 KB
/
testlocation.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Location</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var locationArray = []
window.initMap = function(){
}
var geocoder = new google.maps.Geocoder;
var literalAddress;
var finalLocation;
function getLocation(callbackFn) {
navigator.geolocation.getCurrentPosition(function () {}, function () {}, {});
//The working next statement.
navigator.geolocation.getCurrentPosition(function (position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
finalLocation = {latitude: lat, longitude: lng};
callbackFn(finalLocation);
}, function (e) {
}, {
enableHighAccuracy: true
});
}
console.log(getLocation(printLOC));
function printLOC(finalLocation){
return finalLocation;
}
function geocodeLatLng(geocoder, map, infowindow) {
var latlng = printLOC(finalLocation)
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === 'OK') {
if (results[1]) {
literalAddress = (results[1].formatted_address);
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
return literalAddress;
});
}
console.log(geocodeLatLng());
</script>
<!-- <script src="locationStatus.js"></script> -->
</head>
<body>
</body>
</html>