map api code nearbysearch

时间:2014-02-11 07:02:18

标签: php json google-maps map

我有错误是什么问题?我怎么得到echo getAddress?我试过时间来解决这个问题吗?

function getAddress($la, $lo){
  $ur= "http://maps.googleapis.com/maps/api/place/nearbysearch/json?location=".$la.",".$lo."&radius=10&sensor=true&key=AIzaSyA0JD_Z2Uo2AfnDTejQFWHAXOIaRRpjF8c"
   $json = file_get_contents($ur);

   $data = json_decode($json);
   $status = $data->status;
   $name= '';
     if($status == "OK"){
      $addr = $data->results[0]->formatted_address;
     }
   return $addr;
  } 
          echo getAddress("6.154841","80.700845");

1 个答案:

答案 0 :(得分:0)

您忘记了$ur

末尾的半冒号;

$ur= "http://maps.googleapis.com/maps/api/place/nearbysearch/json? location=".$la.",".$lo."&radius=10&sensor=true&key=AIzaSyA0JD_Z2Uo2AfnDTejQFWHAXOIaRRpjF8c";