From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../api/geolocation/getcurrentposition/index.html | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 files/ko/web/api/geolocation/getcurrentposition/index.html (limited to 'files/ko/web/api/geolocation/getcurrentposition') 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 +--- +
{{securecontext_header}}{{ APIRef("Geolocation API") }}
+ +

Geolocation.getCurrentPosition() 메서드는 장치의 현재 위치를 가져옵니다.

+ +

구문

+ +
navigator.geolocation.getCurrentPosition(success[, error[, [options]])
+ +

매개변수

+ +
+
success
+
{{domxref("GeolocationPosition")}} 객체를 유일한 매개변수로 받는 콜백 함수.
+
error {{optional_inline}}
+
{{domxref("GeolocationPositionError")}} 객체를 유일한 매개변수로 받는 콜백 함수.
+
options {{optional_inline}}
+
{{domxref("PositionOptions")}} 객체.
+
+ +

예제

+ +
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);
+
+ +

명세

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}Initial specification.
+ +

브라우저 호환성

+ + + +

{{Compat("api.Geolocation.getCurrentPosition")}}

+ +

같이 보기

+ + -- cgit v1.2.3-54-g00ecf