Geo- ligging posisie Eiendom
Voorbeeld
Kry die breedte- en lengtegraad van die gebruiker se posisie:
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;
}
Definisie en gebruik
Die posisie-eienskap gee die posisie en hoogte van die toestel op Aarde terug.
Koördineer eienskappe
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 |
Blaaierondersteuning
Property | |||||
---|---|---|---|---|---|
position | 5.0 | 9.0 | 3.5 | 5.0 | 16.0 |
❮ Geolocation Object