forked from harshit-paneri/Web-Location
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
65 lines (59 loc) · 2.34 KB
/
main.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My Google Map on web page</title>
<!-- Google fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="main-cont">
<div class="user-inputs">
<h1 class="title">Google Map</h1>
<h3 class="title">Enter longitude</h3>
<input type="text" id="myNumber1">
<h3 class="title">Enter latitude</h3>
<input type="text" id="myNumber2">
<button class="btn btn-primary mt-2 rainbow-5" onclick="myFunction1()">Find Location..</button>
</div>
<div class="map-widget">
<div id="map"></div>
</div>
</div>
<script>
function myFunction1() {
//var m1 = -25.344
if (document.getElementById("myNumber1") && document.getElementById("myNumber1").value) {
var m1 = document.getElementById('myNumber1').value;
} else {
alert("Please enter value of longitude");
return;
}
//var m2 = 131.036
if (document.getElementById("myNumber2") && document.getElementById("myNumber2").value) {
var m2 = document.getElementById('myNumber2').value;
} else {
alert("Please enter value of latitude");
return;
}
const uluru = { lat: parseFloat(m1), lng: parseFloat(m2) };
const map = new google.maps.Map(document.getElementById("map"), {
zoom: 4,
center: uluru,
});
const marker = new google.maps.Marker({
position: uluru,
map: map,
});
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC-OXJ1L0k4641pTKBPUoCgzSKPcZukNkw">
</script>
</body>
</html>