Php 谷歌地图API Web服务参数
我正在尝试使用新的API在…进行地理编码 我有几个问题:Php 谷歌地图API Web服务参数,php,json,web-services,google-maps-api-3,coordinates,Php,Json,Web Services,Google Maps Api 3,Coordinates,我正在尝试使用新的API在…进行地理编码 我有几个问题: 我只对纬度和经度的信息感兴趣。 如何隔离此信息?(我需要将其添加到php中 (剧本) 是否有一种方法(web服务参数)只获取我需要的内容 使用此web服务,是否可以计算距离 2点不仅作为一条直线,而且作为一条道路 使用json\u decode($json\u string)将json字符串转换为变量 $json=file\u get\u contents('https://maps.googleapis.com/maps/api/ge
json\u decode($json\u string)
将json字符串转换为变量
$json=file\u get\u contents('https://maps.googleapis.com/maps/api/geocode/json?address=Apple%20inc&key=');
$data=json_decode($json);
foreach($data->results as$result){
打印“”。$result->格式化的_地址。“;
打印“纬度:”.$result->geometry->location->Lat.”,“.$result->geometry->location->lng.”
;
}
打印“”;
打印(数据);
打印“”;
为js找到了这个函数--for(i=0;i”;打印($xml);-它适用于90%的请求。。。但有时它不起作用,也不明白为什么。。。如果我传递(例如)url。。。Peziè,11832043 CORTINA D'AMPEZZO,Italia&key=结果无效。。。如果我在浏览器中复制和粘贴,它会正常工作…为什么?顺便说一句,解决了上一个问题。。。这个问题是由于意大利语中的特殊字符造成的
$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>';