JSFiddle - React, Tailwind, and code Playground

by mcotton

HTML

<div id="msg">Nothing to see here</div>

JavaScript

if (navigator.geolocation)  {
    navigator.geolocation.getCurrentPosition(show_map, handle_error, {enableHighAccuracy: true});
    //$('#msg').html('I can haz geo');
}
else {
    $('#msg').html('Y U NO HAVE GEO');
}

function show_map(position) {
    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var altitude = position.coords.altitude;
    $('#msg').html('Current lat and long: ' + latitude + ' ' + longitude);
}

function handle_error(err) {
    if(err.code == 1) {
        // user said 'No'
    }
}