prepare("$sql"); $res->execute(); list($comune) = $res->fetch(PDO::FETCH_NUM); $sql="SELECT indirizzo from ".$prefix."_ele_sede where id_sede='$id_sede' "; $res = $dbi->prepare("$sql"); $res->execute(); list($indirizzo) = $res->fetch(PDO::FETCH_NUM); $address=rawurlencode("$indirizzo,$comune,58047"); $resultGeoCode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false'); $output= json_decode($resultGeoCode); if($output->status == 'OK'){ $latitude = $output->results[0]->geometry->location->lat; //Returns Latitude $longitude = $output->results[0]->geometry->location->lng; // Returns Longitude $location = $output->results[0]->formatted_address; }else{ $latitude=0; $longitude=0; $location=''; } $coords['lat'] = $latitude; $coords['long'] = $longitude; /* $url = sprintf('http://maps.google.com/maps?output=js&q=%s',rawurlencode($address)); $result = false; if($result = file_get_contents($url)) { $coords = array(); if(strpos($result,'errortips') > 1 || strpos($result,'Did you mean:') !== false) { return false; } preg_match('!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U', $result, $matches); $coords['lat'] = $matches[1]; $coords['long'] = $matches[2]; } */ # type="text/javascript" echo ' '; } ?>