Geolocation

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Geolocation 인터페이스는 장치의 위치를 가져오는 방법을 나타냅니다. Geolocation을 사용하면 웹 사이트나 웹 앱이 위치 정보를 활용해, 현재 위치에 대해 맞춤 콘텐츠를 제공할 수 있습니다.

Navigator 객체의 geolocation 속성으로 이 인터페이스를 구현하는 객체에 접근할 수 있습니다.

참고: 보안 상의 문제로, 웹 페이지가 위치 정보에 접근을 시도하면 사용자에게 알림을 보내고 권한을 허용할지 묻습니다. 각 브라우저는 자신만의 권한 정책과 요청 방식을 가지고 있으므로 주의해야 합니다.

속성

Geolocation 인터페이스는 어떤 속성도 구현하거나 상속하지 않습니다.

메서드

Geolocation 인터페이스는 어떤 메서드도 상속하지 않습니다.

Geolocation.getCurrentPosition() Secure context
장치의 현재 위치를 조사한 후 Position 객체로 반환합니다.
Geolocation.watchPosition() Secure context
장치의 위치가 변경될 때마다 호출하는 콜백을 등록합니다. 반환값은 콜백의 식별자로 쓸 수 있는 long 값입니다.
Geolocation.clearWatch() Secure context
watchPosition()을 이용해 등록한 특정 콜백을 삭제합니다.

명세

Specification Status Comment
Geolocation API Recommendation 초기 명세.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
GeolocationChrome Full support 5Edge Full support 12Firefox Full support 3.5
Notes
Full support 3.5
Notes
Notes GPSD (GPS daemon) support added in Firefox 3.6. WiFi-based location is provided by Google (privacy) or a custom provider (MLS instructions).
IE Full support 9Opera Full support 16
Full support 16
No support 10.6 — 15
Safari Full support 5WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support 16
Full support 16
No support 11 — 14
Safari iOS Full support YesSamsung Internet Android Full support Yes
clearWatchChrome Full support 5Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 16
Full support 16
No support 10.6 — 15
Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support 16
Full support 16
No support 11 — 14
Safari iOS Full support YesSamsung Internet Android Full support Yes
getCurrentPositionChrome Full support 5Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 16
Full support 16
No support 10.6 — 15
Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support 16
Full support 16
No support 11 — 14
Safari iOS Full support YesSamsung Internet Android Full support Yes
Secure context requiredChrome Full support 50Edge ? Firefox Full support 55IE No support NoOpera Full support 37Safari Full support YesWebView Android Full support 51
Notes
Full support 51
Notes
Notes Secure context is only required for applications targeting Android Nougat (7) and higher. See bug 603574.
Chrome Android Full support 50Firefox Android Full support 55Opera Android Full support 37Safari iOS Full support YesSamsung Internet Android ?
watchPositionChrome Full support 5Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support 16
Full support 16
No support 10.6 — 15
Safari Full support YesWebView Android Full support YesChrome Android Full support 18Firefox Android Full support 4Opera Android Full support 16
Full support 16
No support 11 — 14
Safari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

같이 보기