PHP根据经纬度查询地理位置 function getCity($longitude, $latitude){ //调取百度接口,其中ak为百度帐号key,注意location纬度在前,经度在后 $api = "http://api.map.baidu.com/geocoder/v2/ak=ZmliRk1lEOigtcPGcDeGSimRNkVdX64H&location=".$latitude.",".$longitude."&output=json&pois=1"; $content = file_get_contents($api); $arr = json_decode($content,true); return $arr;}