-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratch.html
27 lines (27 loc) · 973 Bytes
/
scratch.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Geolocation</title>
</head>
<body>
<script>
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(position => {
let LAT = position.coords.latitude;
let LONG = position.coords.longitude;
let KEY = "AIzaSyA14yCmoAf85kOoAAEBdJbMkQ9orWVwktQ";
let url = `https://maps.googleapis.com/maps/api/geocode/json?latlng=${LAT},${LONG}&key=${KEY}`;
fetch(url)
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(err => console.warn(err.message));
});
}else{
console.log('Geolocation not available');
}
</script>
</body>
</html>