티스토리 뷰

컴퓨팅/HTML5

GPS 이용

에어버스 2014. 10. 13. 13:42

모든 브리우저에서 되는지 모름.
Geolocation API 이용, GPS기능이 없으면 IP주소로 대략적인 위치 추측. 

navigator.seolocation.getCurrentPosition(성공시 호출함수명, 실패시 호출함수명, 옵션);

function 성공함수명(position)
{
  document.getElementById("output").innerHTML="위도" + position.coords.lattude + " 경도" + position.coords.longitude;
}

coords
    latitude : 위도
    longitude : 경도
    altitude : 고도(표고)
    accuracy : 위도 경도의 정밀도 (m)
    altitudeAccuracy : 고도(표고)의 정밀도 (m)
    heading : 방위(북쪽이 0도 로 시계방향)
    speed : 진행속도 (m/s)

timestampPosition : 취득시간

var 계속감시ID = navigator.geolocation.watchPosition(성공시호출함수, 실패시호출함수, 옵션);
var 계속감시ID = navigator.geolocation.clearWatch(계속감시ID); // watchPosition()로 얻은 ID

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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