Posisi geolokasi Properti
Contoh
Dapatkan garis lintang dan garis bujur dari posisi pengguna:
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;
}
Definisi dan Penggunaan
Properti posisi mengembalikan posisi dan ketinggian perangkat di Bumi.
Sifat Koordinat
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 |
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
position | 5.0 | 9.0 | 3.5 | 5.0 | 16.0 |
Objek Geolokasi