");
$q = urlencode($q);
$tmp = get_lat_long($q); //$tmp will be a 2 member array containing latitude and longitude
print ("Latitude: " . $tmp['latitude']);
print ("
Longitude: " . $tmp['longitude']);
}
function get_lat_long($q) {
$gm = fopen('https://maps.google.com/maps?q=' . str_replace(' ','+',$q) . '&output=js','r');
$tmp = @fread($gm,30000);
fclose($gm);
//print ($tmp);
$x = preg_replace ('/.*center:\{lat:([^,]*),lng:([^,]*)},.*/', "|$1|$2|", nl2br(trim($tmp)));
//print ($x);
list ($dmy,$lat_value, $lng_value) = explode ("|",$x );
return(array('latitude'=>$lat_value,'longitude'=>$lng_value));
}
?>