JSFiddle - React, Tailwind, and code Playground
by cdeutsch
HTML
<h1>Getting Basic GeoLocation Data</h1>
<div>
<input type="button" id="go" value="Click Me To View Your Location" />
</div>
JavaScript
$(document).ready(function () {
//wire up button click.
$('#go').click(function () {
//test for pressence of geolocation.
if (navigator && navigator.geolocation) {
//the getCurrentPosition isn't instant so show a busy indicator.
$('#busy').show();
//make the request for the user's position.
navigator.geolocation.getCurrentPosition(geo_success, geo_error);
} else {
error('GeoLocation is not supported.');
}
});
//add busy indicator which uses an embedded animated gif to indicate an ajax call is in progress.
$('<div id="busy" style="display:none;position:fixed;right:50%;top:10px;z-index:100;"><img alt="Working..." width="32" height="32"...