Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Html5/geolocation: Difference between revisions

From ZeroWiki
imported>pkccr1
No edit summary
(Repair batch-0008 pages from live compare)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[pagelist(html5)]]
<!-- MONIWIKI PageList(html5) -->
* [[html5]]
* [[html5/VA]]
* [[html5/canvas]]
* [[html5/communicationAPI]]
* [[html5/drag-and-drop]]
* [[html5/form]]
* [[html5/geolocation]]
* [[html5/offline-web-application]]
* [[html5/others-api]]
* [[html5/outline]]
* [[html5/overview]]
* [[html5/richtext-edit]]
* [[html5/section]]
* [[html5/video&audio]]
* [[html5/web-storage]]
* [[html5/web-workers]]
* [[html5/webSqlDatabase]]
* [[html5/websocket]]
* [[html5/문제점]]
* [[html5practice]]
* [[html5practice/roundRect]]
* [[html5practice/계층형자료구조그리기]]
* [[html5practice/즐겨찾기목록만들기]]
__TOC__
__TOC__


Line 20: Line 43:
{| class="wikitable"
{| class="wikitable"
|-
|-
| ///coords 속성///
| '''coords 속성'''
| ///설명///
| '''설명'''
|-
|-
| latitude
| latitude
Line 50: Line 73:


= 추가 기능 =
= 추가 기능 =
* 윤곽이 있는 사각형을 그릴 수 있다.
{| class="wikitable"
* 색으로 채운 사각형을 그릴 수 있다.
|-
* 사각형을 지울 수 있다.
| '''속성'''
| '''설명'''
|-
| enableHighAccuracy
| 정확도가 높은 위치 정보 요청
|-
| timeout
| 위치 정보 확인에 시간제한 설정
|-
| maximumAge
| 유효 기간 설정
|}


= 예제 =
* http://html5demos.com/

Latest revision as of 01:40, 27 March 2026

Geolocation API?

  • 프로그램을 실행하는 디바이스의 위치 정보를 얻기 위한 API
  • 모바일 애플리케이션과 연동하여 사용
  • 고급 레벨의 API - GPS를 이용하는지 네트워크 정보를 이용하는지는 알수 없으나
                     디바이스나 네트워크의 종류에 관계없이 동작!

사용 방법

  • Geolocation API 관련 메서드는 모두 window.navigator 객체에 정의

getCurrentPosition()

  • 현재 위치를 한번만 받는 메서드
   namigator.geolocation.getCurrentPosition(function(position){
     alert("위도:" + position.coords.latitude +
        "경도 :" + position.coords.longitude);
   });
  • 위치 정보 객체의 속성
coords 속성 설명
latitude 위도
longitude 경도
altitude 표고
accuracy 위도와 경도의 오차
altitudeAccuracy 표고의 오차
heading 진행방향
speed 진행 속도

watchPosition()

    • 현재 위치를 계속 추적
    • clearWatch()가 호출되면 종료

추가 기능

속성 설명
enableHighAccuracy 정확도가 높은 위치 정보 요청
timeout 위치 정보 확인에 시간제한 설정
maximumAge 유효 기간 설정

예제