Concordo ma in realtà mi basterebbe risolvere il passaggio dei dati da dove vengono calcolati in javascript alla parte di php.
Il file php che mi da questi problemi è questo :
codice:
<!DOCTYPE html>
<?php
include "comuni/utility.php";
session_start();
?>
<html>
<head>
<title></title>
<!--
Richiede l'uso di HTML5.
Prende la posizione geografica (lat, long) da GPS o utilizzando l'indirizzo IP
ed effettuando dei lookup per trovare il punto geografico.
Visualizza una mappa con google maps e il punto in cui si trova la locazione
geografica (vera o del server nat)
Scrive l'indirizzo corrispondente usando un reverse geocoder
-->
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<!--
Browsers will fallback on other options for geolocation (IP address, WiFi networks in your area) if you do not have a GPS device installed.-->
<script type="text/javascript">
function disp_confirm()
{
var r=confirm("Vuoi che venga rilevata la tua posizione?")
if (r==true)
{
geof();
}
else
{
alert("La geolocalizzazione non verra' effettuata")
}
}
function geof() {
//if (navigator.geolocation)
navigator.geolocation.getCurrentPosition(
function (position) {
// Did we get the position correctly?
alert (position.coords.latitude+" "+position.coords.longitude);
var PosX=position.coords.latitude;
var PosY=position.coords.longitude;
window.alert("X="+PosX+" Y="+PosY);
document.getElementById('latitude').innerHTML=PosX;
document.getElementById('longitude').innerHTML=PosY;
// To see everything available in the position.coords array:
// for (key in position.coords) {alert(key)}
//mapThisGoogle(position.coords.latitude,position.coords.longitude);
var page = "getuserposition.php";
window.opener.document.location = page+"?px="+PosX+"&py="+PosY;
//window.location.href = page+"?px="+PosX+"&py="+PosY;
},
// next function is the error callback
function (error)
{
switch(error.code)
{
case error.TIMEOUT:
alert ('Timeout');
break;
case error.POSITION_UNAVAILABLE:
alert ('Position unavailable');
break;
case error.PERMISSION_DENIED:
alert ('Permission denied');
break;
case error.UNKNOWN_ERROR:
alert ('Unknown error');
break;
}
}
);
//else alert("la georeferenziazione non e' possibile");
}
</script>
</head>
<body onload="disp_confirm(); ">
<form id="myform" method="get">
<input type="hidden" id="latitude" name="latitude" value="">
<input type="hidden" id="longitude "name="longitude" value="">
</form>
<div style="width:100%; height:90%" id="map"></div>
</body>
</html>
<?php
error_reporting(E_ALL & ~E_DEPRECATED);
$email=null;
if(isset($_SESSION["useremail"])) $email=$_SESSION["useremail"];
$lat;$lat;
if(isset($_GET["px"]) && isset($_GET["py"]))
{
$lat = $_GET["px"];
$lon = $_GET["py"];
// $arrayPos=geof();
echo "Latitudine : ".$_GET['px']."
";
echo "Longitudine: ".$_GET['py']."
";
}
else
{
}
if( isset($_GET['email'] ))
{
$file=fopen("posizione.txt","w");
if($file)
{
fputs($file,$lat."\r\n");
fputs($file,$lon."\r\n");
}
echo '
<?xml version="1.0" encoding="utf-8"?>
<position>
<lon>'.$lon.'</lon>
<lat>'.$lat.'</lat>
</position>
';
}
?>