Day2_geolocation

Tutorials of (Day2_geolocation) by Linweihan

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>Day2_geolocation</title>
  
  
  
  
  
</head>

<body>
  
<html>
<head>
	<title>geolocation</title>
	<meta charset="utf-8">
</head>
<body>
	<div id="position"></div>
</body>
</html>

<script type="text/javascript" src="E:\Google 雲端硬碟\Html5\geolocation API\2_new.js"></script>
  
    <script  src="js/index.js"></script>

</body>
</html>
/* Downloaded from https://www.codeseek.co/ */
/* Downloaded from https://www.codeseek.co/ */
function doFirst() {
	if(navigator.geolocation){
		alert('Support');
		navigator.geolocation.getCurrentPosition(succCallback,errorCallback,{
			enableHighAccuracy:true,
			timeout:10000,
			maximumAge:0
		});
	
	}else{
		alert('NO Support')
	}
}
function succCallback(e) {
	var lati = e.coords.latitude;
	var longi = e.coords.longitude;
	var accuracy = e.coords.accuracy;

	document.getElementById('position').innerHTML = '緯度 : '+lati+'<br>經度 : '+longi+'<br>準確度 : '+accuracy;
}

function errorCallback(e) {
	alert('Code: ' + e.code + '\nMessage:' + e.message);
}
window.addEventListener('load',doFirst,false);

This awesome code ( Day2_geolocation ) is write by LinWeiHan, you can se more from this user in the personal repository

You can find the original code on Codepen.io

2018 © LinWeiHan