您的位置:首页 > 其它

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

2017-09-12 08:53 260 查看
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."®ion=".$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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: