diff options
Diffstat (limited to 'files/ko/web/api/geolocation/getcurrentposition')
-rw-r--r-- | files/ko/web/api/geolocation/getcurrentposition/index.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/files/ko/web/api/geolocation/getcurrentposition/index.html b/files/ko/web/api/geolocation/getcurrentposition/index.html new file mode 100644 index 0000000000..ffe4aeae2f --- /dev/null +++ b/files/ko/web/api/geolocation/getcurrentposition/index.html @@ -0,0 +1,88 @@ +--- +title: Geolocation.getCurrentPosition() +slug: Web/API/Geolocation/getCurrentPosition +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context + - 위치 + - 위치정보 +translation_of: Web/API/Geolocation/getCurrentPosition +--- +<div>{{securecontext_header}}{{ APIRef("Geolocation API") }}</div> + +<p><strong><code>Geolocation.getCurrentPosition()</code></strong> 메서드는 장치의 현재 위치를 가져옵니다.</p> + +<h2 id="구문">구문</h2> + +<pre class="syntaxbox">navigator.geolocation.getCurrentPosition(<em>success</em>[, <em>error</em>[, [<em>options</em>]])</pre> + +<h3 id="매개변수">매개변수</h3> + +<dl> + <dt><code>success</code></dt> + <dd>{{domxref("GeolocationPosition")}} 객체를 유일한 매개변수로 받는 콜백 함수.</dd> + <dt><code>error</code> {{optional_inline}}</dt> + <dd>{{domxref("GeolocationPositionError")}} 객체를 유일한 매개변수로 받는 콜백 함수.</dd> + <dt><code>options</code> {{optional_inline}}</dt> + <dd>{{domxref("PositionOptions")}} 객체.</dd> +</dl> + +<h2 id="예제">예제</h2> + +<pre class="brush: js">var options = { + enableHighAccuracy: true, + timeout: 5000, + maximumAge: 0 +}; + +function success(pos) { + var crd = pos.coords; + + console.log('Your current position is:'); + console.log('Latitude : ' + crd.latitude); + console.log('Longitude: ' + crd.longitude); + console.log('More or less ' + crd.accuracy + ' meters.'); +}; + +function error(err) { + console.warn('ERROR(' + err.code + '): ' + err.message); +}; + +navigator.geolocation.getCurrentPosition(success, error, options); +</pre> + +<h2 id="명세">명세</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('Geolocation')}}</td> + <td>{{Spec2('Geolocation')}}</td> + <td>Initial specification.</td> + </tr> + </tbody> +</table> + +<h2 id="브라우저_호환성">브라우저 호환성</h2> + + + +<p>{{Compat("api.Geolocation.getCurrentPosition")}}</p> + +<h2 id="같이_보기">같이 보기</h2> + +<ul> + <li><a href="/ko/docs/Web/API/Geolocation_API/Using_the_Geolocation_API">Geolocation API 사용하기</a></li> + <li>{{domxref("Navigator.geolocation")}}</li> +</ul> |