지리적 위치 속성
예시
사용자 위치의 위도와 경도를 가져옵니다.
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
정의 및 사용
position 속성은 지구에서 장치의 위치와 고도를 반환합니다.
좌표 속성
Property | Description |
---|---|
position.coords | Returns a Coordinates object that defines the current location |
position.timestamp | Returns a DOMTimeStamp representing the time at which the location was retrieved |
브라우저 지원
Property | |||||
---|---|---|---|---|---|
position | 5.0 | 9.0 | 3.5 | 5.0 | 16.0 |
❮ 지리적 위치 개체