/** * # +======================================================================== * # | - @name 获取位置 * # | - @author cq <just_leaf@foxmail.com> * # | - @copyright zmtek 2018-11-07 * # +------------------------------------------------------------------------ * # | - 1首页 * # +======================================================================== */ function getaddr($lng,$lat) { // http://www.gpsspg.com/maps.htm $result = file_get_contents('https://apis.map.qq.com/jsapi?qt=rgeoc&lnglat='.$lng.'%2C'.$lat.'&key=FBOBZ-VODWU-C7SVF-B2BDI-UK3JE-YBFUS&output=jsonp&pf=jsapi&ref=jsapi&cb=qq.maps._svcb3.geocoder0'); $str = explode('qq.maps._svcb3.geocoder0&&qq.maps._svcb3.geocoder0(',$result)[1]; $text = substr($str,0,strlen($str)-1); $pat = '#"addr"(?<data>.*)","addr_info"#'; preg_match($pat,$text,$mat); $str = substr($mat[0],8,100); $addr = explode('","addr_info":',$str)[0]; $addr = characet($addr); return $addr; } /** * # +======================================================================== * # | - @name 转码utf8 * # | - @author cq <just_leaf@foxmail.com> * # | - @copyright zmtek 2018-11-07 * # +------------------------------------------------------------------------ * # | - 1首页 * # +======================================================================== */ function characet($data){ if( !empty($data) ){ $fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ; if( $fileType != 'UTF-8'){ $data = mb_convert_encoding($data ,'utf-8' , $fileType); } } return $data; }