I'm a newbie so thanks in advance for any help. I am setting up a simple geolocation page. Currently when I click a button, an alert popup box states the geolocation settings.
The problem - instead of the result popping up in a box, I need the geolocation info to display on the page itself.
I was told I need to use the appendTo element and I've tried many different ways but nothing happens.
Here is the current script:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Geolocation</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.
js"</script>
<section>
<script>
$(document).ready(function() {
$('#startGeo').click(checkLocation);
function checkLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getLocation,
locationFail);
}
else {
document.write('You do not have geolocation');
}
}
function getLocation(position) {
var latitude = position.coords.latitute;
var longitude = position.coords.longitude;
var accuracy = position.coords.accuracy;
var timestamp = position.coords.timestamp;
alert('latitude: ' + latitude + 'longitude: ' + longitude +
'accuracy: ' + accuracy + 'timestamp: ' + timestamp);
}
function locationFail() {
document.write('We did not get your location. Please check your
settings.')
}
});
</script>
</head>
<body>
<button id="startGeo">Click here to check your geolocation
abilities</button>
</body>
</html>