45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<html>
|
|
<head>
|
|
<title>Test av alt</title>
|
|
<head>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
|
<script>
|
|
$(document).ready(function(){
|
|
if(navigator.geolocation){
|
|
navigator.geolocation.getCurrentPosition(showLocation);
|
|
}else{
|
|
$('#location').html('Geolocation is not supported by this browser.');
|
|
}
|
|
});
|
|
|
|
function showLocation(position){
|
|
var latitude = position.coords.latitude;
|
|
var longitude = position.coords.longitude;
|
|
$.ajax({
|
|
type:'POST',
|
|
url:'getLocation.php',
|
|
data:'latitude='+latitude+'&longitude='+longitude,
|
|
success:function(msg){
|
|
if(msg){
|
|
$("#location").html(msg);
|
|
}else{
|
|
$("#location").html('Not Available');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<body>
|
|
<p>Your Location: <span id="location"></span></p>
|
|
<p>Lat: <span id="lat"></span></p>
|
|
<p>Lon: <span id="lon"></span></p>
|
|
|
|
<?php
|
|
|
|
echo $latlon;
|
|
?>
|
|
|
|
</body>
|
|
</html>
|