PHP根据城市名获取经纬度

/**

public function get_geo($city){

$url = "http://api.map.baidu.com/geocoder/v2/?ak=wfVfdMthZRL9vjaeyFKiBhLmUth60bbZ&output=json&address=$city";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
/* if(curl_errno($ch)){
 print_r(curl_error($ch));
} */
curl_close($ch);
return json_decode($result,TRUE);

}

Tags: 笔记

添加新评论