{TametheBots}

Geolocation Api

The Result:

Geolocation API? No

Get Current Location?: It fails

Testing how geolocation API is handled.

<script>
window.onload = function() {
if (navigator.geolocation) {
document.getElementById("supported").innerText = 'Yes';
document.getElementById("result").innerText = 'Getting position';
let startPos;
const geoSuccess = function(position) {
startPos = position;
let output = "Lat: " + startPos.coords.latitude.toFixed(4) + ", Lng: " + startPos.coords.longitude.toFixed(4);
document.getElementById("result").innerText = output;
};
const geoError = function(error) {
let output = "Error code: " + error.code + ", " + error.message;
document.getElementById("result").innerText = output;
};
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
};
}
</script>

< Back