<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
</head>
<body>
<button onclick="startGeolocation()">위치 정보 시작</button>
<button onclick="stopGeolocation()">위치 정보 중지</button>
<div id="target"></div>
<script>
let id;
let myDiv = document.getElementById("target");
function startGeolocation() {
if (navigator.geolocation) {
id = navigator.geolocation.watchPosition(showGeolocation)
}
function showGeolocation(location) {
myDiv.innerHTML = "(위도: " + location.coords.latitude + ", 경도: " + location.coords.longitude + ")";
}
function stopGeolocation() {
if (navigator.geolocation) {
navigator.geolocation.clearWatch(id);
}
}
}
</script>
</body>
</html>
실시간 정보를 표시합니다.
화면 확대 축소 zoom + - (0) | 2022.10.28 |
---|---|
제이쿼리 div 드래그 (0) | 2022.10.28 |
핸드폰에서 홈페이지 접속시 모바일로 자동접속하기 (0) | 2022.04.13 |
jQuery로 파일 업로드시 file upload loading bar (0) | 2021.08.20 |
다른 서버에 파일올리기 (0) | 2021.08.05 |