-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogleMaps.html
75 lines (65 loc) · 1.77 KB
/
googleMaps.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
75
<html>
<head>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAtQLxQ7YVodxMugi0DMPBk2QxShYR9blE&libraries=geometry&callback=initMap"
async defer>
</script>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script>
/**
*Settings used to load Goodgle Maps
*/
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -27.480253, lng: 153.035431},
disableDefaultUI: true,
zoom: 14
});
/**
* Geolocation
* Finding location
*/
var pos;
var infoWindow = new google.maps.InfoWindow({map: map});
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
/**
* Placing a marker
* @type {google.maps.Marker}
*/
var marker = new google.maps.Marker({
position: pos,
map: map,
icon: 'marker_man.png',
});
map.setCenter(pos);
}, function () {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
</script>
</body>
</html>