-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.php
75 lines (61 loc) · 2.46 KB
/
map.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pineapple Store</title>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<script src="js/jquery2.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="main.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script src='https://maps.google.com/maps/api/js?sensor=false'></script>
<!--<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCfF9SGOWz8YdGZHE_6hzfzgoHGx2BlK7Q&callback=initMap"
type="text/javascript"></script>-->
<script type="text/javascript">
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
// x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
$('#demo').html("Your location : " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude);
longi = position.coords.longitude;
latit = position.coords.latitude;
setterlocation(latit, longi);
}
getLocation();
// When the window has finished loading create our google map below
function setterlocation(latit, longi) {
var latlng = new google.maps.LatLng(latit, longi); //Set the default location of map
var map = new google.maps.Map(document.getElementById('map'), {
center: latlng,
zoom: 11, //The zoom value for map
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: 'Place the marker for your location!', //The title on hover to display
draggable: true //this makes it drag and drop
});
google.maps.event.addListener(marker, 'dragend', function (a) {
console.log(a);
document.getElementById('loc').value = a.latLng.lat().toFixed(4) + ', ' + a.latLng.lng().toFixed(4); //Place the value in input box
});
}
</script>
<style>
#map {
height: 500px;
border: 1px solid #000;
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>