JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.githubusercontent.com/estebanav/javascript-mobile-desktop-geolocation/master/js/geoPosition.js"></script>
<a href="http://www.stronia.com/2014/07/geolocation-for-unsupported-browsers.html">Back to geoPosition tutorial.</a>
<br>
<a href="http://jsfiddle.net/anshudwibhashi/tK4YJ/1">View Source</a><br><br>
<div id="result">Determining your location...<br>Please be patient it might take a few seconds</div>
JavaScript
// Don't forget to load the geoPosition.js library from the CDN URL
if(geoPosition.init()){
geoPosition.getCurrentPosition(success, failure);
}
function success(pos){
var lat = pos.coords.latitude;
var lon = pos.coords.longitude;
document.getElementById('result').innerHTML=lat+', '+lon;
}
function failure(){
alert("We can't determine your location!");
}