以下代码应返回该地点的坐标,但它仅以逗号返回....
<?php
function getCoordinates($address){
$address = str_replace(" ", "+", $address);
$url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address=$address";
$response = file_get_contents($url);
$json = json_decode($response,TRUE);
return ($json['results'][0]['geometry']['location']['lat'].",".$json['results'][0]['geometry']['location']['lng']);
}
echo getCoordinates('740 Story Rd San Jose CA 95122');
?>