JSFiddle - React, Tailwind, and code Playground
by sperske
JavaScript
var getLocation = function () {
var suc = function (p) {
alert("geolocation success:"+p.coords.latitude);
if (p.coords.latitude != undefined) {
currentLatitude = p.coords.latitude;
currentLongitude = p.coords.longitude;
}
};
var fail = function () {
alert("geolocation failed");
getLocation();
};
navigator.geolocation.getCurrentPosition(suc, fail);
}
getLocation();