1
當我嘗試通過谷歌服務將地址轉換成經度和緯度時遇到問題。我的地址是1456 sok。否:10/1 kat:8 Alsancak。問題是,當我寫這個地址到url,返回正確的結果,但是當我使用下面的php代碼,我得到零結果。PHP谷歌地理編碼服務返回零結果
沒有問題,結果是:
問題用PHP:
<?php
header('Content-Type: text/html; charset=utf-8');
getGoogleAddressCoordinates("1456 sok. no: 10/1 kat:8 Alsancak");
function getGoogleAddressCoordinates($address)
{
//$address = urlencode($address);
$address = str_replace(" ", "%20", $address);
$request = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $address . '&sensor=true');
$json = json_decode($request, true);
print_r ($json);
}
>
你究竟得到什麼從請求回來? ('$ request'包含什麼?)如果它是'false',那麼這個調用本身出了問題。您是否打開了錯誤報告? –
該鏈接不適用於我..我得到'ZERO_RESULTS' – bitWorking