JSFiddle - React, Tailwind, and code Playground
HTML
<p id="location"></p>
JavaScript
if(typeof navigator.geolocation.watchPosition == "function"){
var erfolgsCallback = function(position) {
var msg = 'Zeit: ' + position.timestamp + '<br>' +
'Geographische Breite: ' + position.coords.latitude + '<br>' +
'Geographische Länge: ' + position.coords.longitude + '<br>';
document.getElementById('location').innerHTML = msg;
navigator.geolocation.getCurrentPosition(erfolgsCallback);
}
}
else{
alert("Dein Browser ist zu schlecht :(");
}
var erfolgsCallback = function(position) {
var msg = 'Zeit: ' + position.timestamp + '<br>' +
'Geographische Breite: ' + position.coords.latitude + '<br>' +
'Geographische Länge: ' + position.coords.longitude + '<br>';
document.getElementById('location').innerHTML = msg;
}