public static function getLngLat($lng,$lat) { echo $lng.'___'.$lat; echo "\n"; $ak = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; $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); echo "\n\n\n\n"; print_r($ret); echo "\n\n"; if($ret['status']==0){ $callback['cityCode']=$ret['result']['cityCode']; $callback['cityName']=$ret['result']['addressComponent']['city']; } return $callback; }
Array ( [status] => 0 [result] => Array ( [location] => Array ( [lng] => 116.45633588097 [lat] => 39.928965504131 ) [formatted_address] => 北京市朝陽區工體東路甲13 [business] => 朝外大街/朝外,東大橋,朝陽門 [addressComponent] => Array ( [country] => 中國 [country_code] => 0 [country_code_iso] => CHN [country_code_iso2] => CN [province] => 北京市 [city] => 北京市 [city_level] => 2 [district] => 朝陽區 [town] => [town_code] => [distance] => 5 [direction] => 附近 [adcode] => 110105 [street] => 工體東路 [street_number] => 甲13 ) [pois] => Array ( [0] => Array ( [addr] => 北京市朝陽區朝陽門外大街8號 [cp] => [direction] => 北 [distance] => 127 [name] => 藍島大廈(朝陽店) [poiType] => 購物 [point] => Array ( [x] => 116.45594002235 [y] => 39.928136947956 ) [tag] => 購物;購物中心 [tel] => [uid] => bba87388f48f50b9bca8224a [zip] => [parent_poi] => Array ( [name] => [tag] => [addr] => [point] => Array ( [x] => 0 [y] => 0 ) [direction] => [distance] => [uid] => ) ) [1] => Array ( [addr] => 北京市朝陽區三角路甲1 [cp] => [direction] => 西北 [distance] => 120 [name] => 東大橋(地鐵站) [poiType] => 公交設施 [point] => Array ( [x] => 116.45694612452 [y] => 39.928275273065 ) [tag] => 公交設施;地鐵站 [tel] => [uid] => ec0c6064cc9ab83e4657268a [zip] => [parent_poi] => Array ( [name] => [tag] => [addr] => [point] => Array ( [x] => 0 [y] => 0 ) [direction] => [distance] => [uid] => ) ) [2] => Array ( [addr] => 北京市朝陽區朝陽門外大街10號 [cp] => [direction] => 東北 [distance] => 173 [name] => 昆泰大廈 [poiType] => 房地產 [point] => Array ( [x] => 116.45513154739 [y] => 39.92819919429 ) [tag] => 房地產;寫字樓 [tel] => [uid] => 72e57fd7b3a35ab6f8dc850a [zip] => [parent_poi] => Array ( [name] => [tag] => [addr] => [point] => Array ( [x] => 0 [y] => 0 ) [direction] => [distance] => [uid] => ) ) [3] => Array ( [addr] => 北京市朝陽區工人體育場東路春平廣場 [cp] => [direction] => 西南 [distance] => 144 [name] => 交通銀行(北京東大橋支行) [poiType] => 金融 [point] => Array ( [x] => 116.45741324339 [y] => 39.92952710249 ) [tag] => 金融;銀行 [tel] => [uid] => a3e8341c868a79954afd3f4c [zip] => [parent_poi] => Array ( [name] => 百富國際大廈 [tag] => 房地產;寫字樓 [addr] => 北京市朝陽區工人體育場東路與朝陽門外大街交叉路口東北側(春平廣場) [point] => Array ( [x] => 116.45763781977 [y] => 39.930011229229 ) [direction] => 西南 [distance] => 209 [uid] => ebcc9ac6aad2942a85420e46 ) ) [4] => Array ( [addr] => 北京市朝陽區工人體育場東路壹家宜家 [cp] => [direction] => 南 [distance] => 136 [name] => 新生態國際公寓 [poiType] => 房地產 [point] => Array ( [x] => 116.45608375123 [y] => 39.929886739825 ) [tag] => 房地產;住宅區 [tel] => [uid] => a5a9a4a1935b03275fd4fe1c [zip] => [parent_poi] => Array ( [name] => [tag] => [addr] => [point] => Array ( [x] => 0 [y] => 0 ) [direction] => [distance] => [uid] => ) ) [5] => Array ( [addr] => 北京市朝陽門外大街1號金麒大廈1層 [cp] => [direction] => 東 [distance] => 161 [name] => 中國工商銀行(北京朝陽支行) [poiType] => 金融 [point] => Array ( [x] => 116.45489798796 [y] => 39.929132882453 ) [tag] => 金融;銀行 [tel] => [uid] => 08fc93dfd44dc3ef9b68b40d [zip] => [parent_poi] => Array ( [name] => 金麒大廈 [tag] => 房地產;寫字樓 [addr] => 北京市朝陽區朝陽門外大街1號 [point] => Array ( [x] => 116.45455663187 [y] => 39.929409528332 ) [direction] => 東 [distance] => 208 [uid] => 8fa14fc3e00fc86ef6eafc8f ) ) [6] => Array ( [addr] => 北京市朝陽區工人體育場東路20號 [cp] => [direction] => 西南 [distance] => 244 [name] => 北京市民政局 [poiType] => 政府機構 [point] => Array ( [x] => 116.45770070115 [y] => 39.93028787153 ) [tag] => 政府機構;行政單位 [tel] => [uid] => 0930a3b94a54585db11e36fb [zip] => [parent_poi] => Array ( [name] => 春平廣場 [tag] => 購物;購物中心 [addr] => 北京市朝陽區工人體育場東路20號 [point] => Array ( [x] => 116.4576917181 [y] => 39.929969732786 ) [direction] => 西南 [distance] => 209 [uid] => 74331d22ad6c34ed17948e10 ) ) [7] => Array ( [addr] => 朝外大街38號 [cp] => [direction] => 東北 [distance] => 268 [name] => 北京市陳經綸中學(東大橋高中部) [poiType] => 教育培訓 [point] => Array ( [x] => 116.45448476743 [y] => 39.927770385055 ) [tag] => 教育培訓;中學 [tel] => [uid] => 97e2499e4e26d35c6f3e1b35 [zip] => [parent_poi] => Array ( [name] => 保羅大廈 [tag] => 房地產;寫字樓 [addr] => 朝陽門外大街38號 [point] => Array ( [x] => 116.45415239439 [y] => 39.927715054634 ) [direction] => 東北 [distance] => 302 [uid] => dffd631cd742e8bc39221c8f ) ) [8] => Array ( [addr] => 北京市朝陽區東大橋路5號 [cp] => [direction] => 北 [distance] => 202 [name] => 北京東大肛腸醫院 [poiType] => 醫療 [point] => Array ( [x] => 116.45596697152 [y] => 39.927590561021 ) [tag] => 醫療;專科醫院 [tel] => [uid] => d3120b765ede1d831894c68f [zip] => [parent_poi] => Array ( [name] => [tag] => [addr] => [point] => Array ( [x] => 0 [y] => 0 ) [direction] => [distance] => [uid] => ) ) [9] => Array ( [addr] => 北京市朝陽區工人體育場東路20號 [cp] => [direction] => 西南 [distance] => 209 [name] => 春平廣場 [poiType] => 購物 [point] => Array ( [x] => 116.4576917181 [y] => 39.929969732786 ) [tag] => 購物;購物中心 [tel] => [uid] => 74331d22ad6c34ed17948e10 [zip] => [parent_poi] => Array ( [name] => [tag] => [addr] => [point] => Array ( [x] => 0 [y] => 0 ) [direction] => [distance] => [uid] => ) ) ) [roads] => Array ( ) [poiRegions] => Array ( ) [sematic_description] => 藍島大廈(朝陽店)北127米 [cityCode] => 131 ) )