谷歌地图API Web服务参数


Google Maps API Web Service Parameters

我正在尝试使用新的API在https://maps.googleapis.com/maps/api/geocode/json?address=Chiavari+Via+Preli+30&key=....进行地理编码

我有几个问题:

  1. 我只对经纬度的信息感兴趣。我如何隔离这些信息?(我需要将其添加到php脚本)
  2. 是否有一种方法(web服务参数)只得到我需要什么?
  3. 使用此web服务,是否可以计算距离2点不仅作为一条线,还作为一条路的路径?

使用json_decode($json_string)将json字符串转换为变量

http://php.net/manual/en/function.json-decode.php

$json = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=Apple%20inc&key=');
$data = json_decode($json);
foreach($data->results as $result) {
    print '<h4>' . $result->formatted_address . '</h4>';
    print 'Lat: ' . $result->geometry->location->lat . ', ' . $result->geometry->location->lng . '<hr>';
}
print '<pre>';
print_r($data);
print '</pre>';