//经纬度转城市名称(返回城市id,城市名称)
//$ak百度开发密钥,$lat纬度,$lng经度,$type返回数据类型
public function getCityName($ak,$lat,$lng)
{
$callback=array('cityCode'=>0,'cityName'=>'');
$apiUrl='http://api.map.baidu.com/geocoder/v2/?location='.$lat.','.$lng.'&output=json&coordtype=wgs84ll&pois=1&ak='.$ak;
$ret=json_decode(file_get_contents($apiUrl),true);
if($ret['status']==0){
$callback['cityCode']=$ret['result']['cityCode'];
$callback['cityName']=$ret['result']['addressComponent']['city'];
}
return $callback;
}