0
我想將地址轉換爲geocoordiantes.when我稱這個函數並打印latlong值系統給我下面的錯誤。將地址轉換爲地理座標
警告:的file_get_contents(http://maps.googleapis.com/maps/api/geocode/json?latlng=Raiwind路,拉合爾,巴基斯坦,74.2306 &傳感器= FALSE)[function.file-GET-內容]:未能打開流:HTTP請求失敗! HTTP/1.0 400用C錯誤的請求:\ WAMP \ WWW \上線TEMP \ yy.php 137
代碼如下:懇請解決它
function getlatlong($address)
{
$Address = urlencode($address);
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$Address."&sensor=true";
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->status;
if ($status=="OK") {
$Lat = $xml->result->geometry->location->lat;
$Lon = $xml->result->geometry->location->lng;
$LatLng = "$Lat,$Lon";
}
return $LatLng;
}
$coord=getlatlong($source1);
print $coord;