-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeoMap2.shtml
executable file
·34 lines (31 loc) · 1.07 KB
/
geoMap2.shtml
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML GeoLocation Test</title>
<script type="text/javascript">
function findMyCurrentLocation(){
var geoService = navigator.geolocation;
if (geoService) {
alert("Your Browser supports GeoLocation");
navigator.geolocation.getCurrentPosition(showCurrentLocation,errorHandler,{enableHighAccuracy: true});
} else {
alert("Your Browser does not support GeoLocation.");
}
}
function showCurrentLocation(position){
document.getElementById("mycurrentlocation").innerHTML = "Your location details --> Current Latitude : " + position.coords.latitude + " , Longitude : " + position.coords.longitude;
}
function errorHandler(error){
alert("Error while retrieving current position. Error code: " + error.code + ",Message: " + error.message);
}
</script>
</head>
<body>
<div id="main">
<div id="mycurrentlocation"></div>
<input type="button" value="Find My Location" onclick="findMyCurrentLocation()"/>
</div>
</body>
</html>