根据地址获取经纬度
//根据地址获取经纬度接口 function addresstolatlag($address){ $url='http://api.map.baidu.com/geocoder/v2/?address='.$address.'&output=json&ak=hKSq4jsczk9n4qGZHdRbjaWmacgIZefl'; if($result=file_get_contents($url)) { $data = array(); $res= json_decode($result,true); if ($res['status'] == 0) { # code... $results = $res['result']; $data['lng'] = $results['location']['lng']; $data['lat'] = $results['location']['lat']; } return $data; } } 返回结果为数组Array ( [lng] => 121.39841516679303 [lat] => 31.24016808 )