地址栏url不识别地图坐标为字符串型的X,Y.必须转换成数值型才识别

来源:互联网 发布:麒麟655支持5g网络 编辑:程序博客网 时间:2024/05/17 00:51
if(in_array($diqu,$map)){                        $server=substr($keyword,6,6);//服务                        $area=substr($keyword,12,6);//地区                        $str=file_get_contents("lo.log");                        $arr=explode(',',$str);                        $x=floatval($arr[0]);//必须转换为数字型否则url地址栏不识别                        $y=floatval($arr[1]);                        $key="vNT0rv0ofwpsOmq0Mhl7BCPPizA2za0u";//                        $map=file_get_contents("http://api.map.baidu.com/place/v2/search?q=".$server."&region=".$area."&output=json&ak=".$key);                        $map=file_get_contents("http://api.map.baidu.com/place/v2/search?query=".$server."&scope=2&output=json&location=$x,$y&radius=2000&filter=sort_name:distance|sort_rule:1&ak={$key}");                        file_put_contents('ditu.txt',$map);                        $resMap=json_decode($map,true);                        $table="";                        foreach($resMap['results'] as $key=>$val){                            if(empty($val['telephone'])){                                $val['telephone']='';                            }                            $table .=$val['name'].$val['address'].$val['telephone']."距离:".$val['detail_info']['distance'].''."\n";                        }                        $contentStr = $table;
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);echo $resultStr;

}
阅读全文
0 0
原创粉丝点击