$r = https_request(‘http://apis.map.qq.com/ws/geocoder/v1/?address=‘.$addr[‘addr‘].‘&key=F2GBZ-SREWQ-A3K56-GSLK5-ELOHS-PRB2X‘); if($r[‘status‘] == 0){ $lng = $r[‘result‘][‘location‘][‘lng‘]; $lat = $r[‘result‘][‘location‘][‘lat‘]; $r2 = https_request("http://apis.map.qq.com/ws/distance/v1/?mode=driving&from=22.560060,113.868490&to=$lat,$lng&key=F2GBZ-SREWQ-A3K56-GSLK5-ELOHS-PRB2X"); if($r2[‘status‘]==0){ if($r2[‘result‘][‘elements‘][‘distance‘]>5000){ exit( json_encode([‘check‘=>0,‘msg‘=>‘当前位置不在服务范围‘]) ); } }else{ exit( json_encode([‘check‘=>0,‘msg‘=>‘计算距离出错‘]) ); } }else{ exit( json_encode([‘check‘=>0,‘msg‘=>‘地理位置出错‘]) ); }
原文地址:https://www.cnblogs.com/shaoing/p/8902525.html
时间: 2024-10-10 17:51:49