HTML5 Geolocation API를 사용하면 즐겨찾는 웹사이트와 위치를 공유할 수 있습니다. JavaScript는 위도와 경도를 캡처하고 백엔드 웹 서버로 보내어 지역 비즈니스를 찾거나 지도에 위치를 표시하는 것과 같은 멋진 위치 인식 작업을 수행할 수 있습니다.
지오로케이션 API는 글로벌 내비게이터 개체의 새 속성, 즉. 지리적 위치 개체.

예시
다음 코드를 실행하여 위도 및 경도 좌표와 함께 Geolocation API를 사용하여 현재 위치를 찾을 수 있습니다.
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function showLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
alert("Latitude : " + latitude + " Longitude: " + longitude);
}
function errorHandler(err) {
if(err.code == 1) {
alert("Error: Access is denied!");
} else if( err.code == 2) {
alert("Error: Position is unavailable!");
}
}
function getLocation(){
if(navigator.geolocation){
// timeout at 60000 milliseconds (60 seconds)
var options = {timeout:60000};
navigator.geolocation.getCurrentPosition
(showLocation, errorHandler, options);
} else{
alert("Sorry, browser does not support geolocation!");
}
}
</script>
</head>
<body>
<form>
<input type="button" onclick="getLocation();" value="Get Location"/>
</form>
</body>
</html>