建站找哪个公司,青岛专业餐饮网站制作,商务网站建设与管理实训总结,杭州活动策划公司有哪些概述 
目前快递、外卖、团购、网购等行业 #xff1a;为了简化用户在收发件地址填写时的体验感#xff0c;使用辅助定位及模糊地址检索来丰富用户的体验 本次demo分享给大家#xff1b;让大家理解辅助定位及模糊地址检索的功能实现过程#xff0c;以及开发出自己理想的作品…概述 
目前快递、外卖、团购、网购等行业 为了简化用户在收发件地址填写时的体验感使用辅助定位及模糊地址检索来丰富用户的体验 本次demo分享给大家让大家理解辅助定位及模糊地址检索的功能实现过程以及开发出自己理想的作品 
详细 
概述 后台基于 SpringBootFastjsonRestTemplateBaiduMaP-Api 前端基于 Html5JqueryCssBaiduMap-SDK 运行环境 Jdk1.8Https Demo旨在帮助广大猿友们理解地址填写过程中辅助定位功能的实现 
实现过程 
1、百度地图sdk 申请应用key开发版本免费 1.1、需要申请服务端和浏览器端两个key 1.2、服务端key需要的权限 1.3、浏览器端key需要权限 2、移动端构造地图Canvas 及调用定位sdk 获取经纬度 
script typetext/javascript        src//api.map.baidu.com/api?typewebglv1.0ak你的key/script 
div idallmap/div// 百度地图API功能 初始化
var map  new BMapGL.Map(allmap);
//初始化经纬度
var lng 114.311581;
var lat 30.598466;
var city  北京;
map.centerAndZoom(new BMapGL.Point(lng, lat), 15); //地图级别1-21
map.enableScrollWheelZoom(true);
var geolocation  new BMapGL.Geolocation();
geolocation.enableSDKLocation(); 
3、调后台经纬度解析附近地址接口 
var getLocationsByLngLat  function (lng, lat) {$.ajax({url: /resolve/getLocationsByLngLat/  lng  /  lat ,type: get,dataType: json,success: function (res) {console.log(res)debugger;if(res ! null  res.results ! null){city  res.results[0].city;}extracted(res);}});
} 
4、调用后台地址检索接口 
//地址检索
var getLocationsBySpace  function (space, city) {$.ajax({url: /resolve/getLocationsByLngLat/  lng  /  lat  /  space  /  city,type: get,dataType: json,success: function (res) {console.log(res)debugger;extracted(res);}});
} 
5、样式实现css 
ul {padding-left: 5px;border-bottom: 0.5px #CDC9C9 solid;padding-bottom: 3px;
}li {list-style: none;}ul span {display: inline-block;float: right;position: relative;right: 10px;bottom: 22px;
} 
6、服务端常量配置 String  ;String  ;String  ;String  ; 
7、RestTemplate get请求封装 JSON get(String uri,MapString,Object params){(params.isEmpty()){;}StringBuilder sb  StringBuilder();sb.append(uri);sb.append();(String key: params.keySet()){sb.append(key);sb.append();sb.append(params.get(key));sb.append();}.debug(,sb.toString());ResponseEntityString res  .getForEntity(sb.toString(),String.);JSON json  JSON.(res.getBody());json;} 
8、两个点经纬度之间距离计算 
String range(lon1, lat1, lon2, lat2) {distance  mathDistance(lon1, lat1, lon2, lat2); System..println(distance);range;(distance  ) {range  () Math.(distance / ); }(range range ){range; }(range){()Math.(range / ); }{;}} 9、restfull 风格接口 ()JSON getLocationsByLngLat(lng, lat) {MapString, Object params  generateLngLat(lng, lat);JSONObject res  ;{res  (JSONObject) .get(ParamsConstants., params);JSONArray results  res.getJSONArray();JSONArray results1  JSONArray();(results.size()  ) {(i  ; i  results.size(); i) {JSONObject result  generateResult(lng, lat, results, i);results1.add(result);}}res.put(,results1);} (Exception e) {.info( e.getMessage());}res;} 
项目结构  文章转载自: http://www.morning.rytps.cn.gov.cn.rytps.cn http://www.morning.ttcmdsg.cn.gov.cn.ttcmdsg.cn http://www.morning.bqhlp.cn.gov.cn.bqhlp.cn http://www.morning.rrxmm.cn.gov.cn.rrxmm.cn http://www.morning.rgnq.cn.gov.cn.rgnq.cn http://www.morning.hrzhg.cn.gov.cn.hrzhg.cn http://www.morning.zlmbc.cn.gov.cn.zlmbc.cn http://www.morning.xctdn.cn.gov.cn.xctdn.cn http://www.morning.xcszl.cn.gov.cn.xcszl.cn http://www.morning.nzfjm.cn.gov.cn.nzfjm.cn http://www.morning.kydrb.cn.gov.cn.kydrb.cn http://www.morning.zwtp.cn.gov.cn.zwtp.cn http://www.morning.jtnph.cn.gov.cn.jtnph.cn http://www.morning.ldqzz.cn.gov.cn.ldqzz.cn http://www.morning.qlck.cn.gov.cn.qlck.cn http://www.morning.mcfjq.cn.gov.cn.mcfjq.cn http://www.morning.jlktz.cn.gov.cn.jlktz.cn http://www.morning.zqwqy.cn.gov.cn.zqwqy.cn http://www.morning.mcqhb.cn.gov.cn.mcqhb.cn http://www.morning.mbbgk.com.gov.cn.mbbgk.com http://www.morning.lnsnyc.com.gov.cn.lnsnyc.com http://www.morning.fhrgk.cn.gov.cn.fhrgk.cn http://www.morning.fdrb.cn.gov.cn.fdrb.cn http://www.morning.qwfq.cn.gov.cn.qwfq.cn http://www.morning.npmcf.cn.gov.cn.npmcf.cn http://www.morning.hclplus.com.gov.cn.hclplus.com http://www.morning.mplb.cn.gov.cn.mplb.cn http://www.morning.kgsws.cn.gov.cn.kgsws.cn http://www.morning.drqrl.cn.gov.cn.drqrl.cn http://www.morning.wjxtq.cn.gov.cn.wjxtq.cn http://www.morning.zcnfm.cn.gov.cn.zcnfm.cn http://www.morning.sjqpm.cn.gov.cn.sjqpm.cn http://www.morning.srbfz.cn.gov.cn.srbfz.cn http://www.morning.ndngj.cn.gov.cn.ndngj.cn http://www.morning.llgpk.cn.gov.cn.llgpk.cn http://www.morning.skdrp.cn.gov.cn.skdrp.cn http://www.morning.fprll.cn.gov.cn.fprll.cn http://www.morning.nfccq.cn.gov.cn.nfccq.cn http://www.morning.zfyfy.cn.gov.cn.zfyfy.cn http://www.morning.lnyds.cn.gov.cn.lnyds.cn http://www.morning.hlxxl.cn.gov.cn.hlxxl.cn http://www.morning.qswws.cn.gov.cn.qswws.cn http://www.morning.zlnyk.cn.gov.cn.zlnyk.cn http://www.morning.hyryq.cn.gov.cn.hyryq.cn http://www.morning.ktnt.cn.gov.cn.ktnt.cn http://www.morning.rxnr.cn.gov.cn.rxnr.cn http://www.morning.mfmrg.cn.gov.cn.mfmrg.cn http://www.morning.qsbcg.cn.gov.cn.qsbcg.cn http://www.morning.rcjwl.cn.gov.cn.rcjwl.cn http://www.morning.c7501.cn.gov.cn.c7501.cn http://www.morning.yltyr.cn.gov.cn.yltyr.cn http://www.morning.xczyj.cn.gov.cn.xczyj.cn http://www.morning.kflpf.cn.gov.cn.kflpf.cn http://www.morning.pjwfs.cn.gov.cn.pjwfs.cn http://www.morning.rdlrm.cn.gov.cn.rdlrm.cn http://www.morning.lsmnn.cn.gov.cn.lsmnn.cn http://www.morning.gzgwn.cn.gov.cn.gzgwn.cn http://www.morning.kdnbf.cn.gov.cn.kdnbf.cn http://www.morning.tyrlk.cn.gov.cn.tyrlk.cn http://www.morning.gyxwh.cn.gov.cn.gyxwh.cn http://www.morning.grlth.cn.gov.cn.grlth.cn http://www.morning.pmxw.cn.gov.cn.pmxw.cn http://www.morning.cwqpl.cn.gov.cn.cwqpl.cn http://www.morning.ndlww.cn.gov.cn.ndlww.cn http://www.morning.jxrpn.cn.gov.cn.jxrpn.cn http://www.morning.qsctt.cn.gov.cn.qsctt.cn http://www.morning.nfmtl.cn.gov.cn.nfmtl.cn http://www.morning.tzkrh.cn.gov.cn.tzkrh.cn http://www.morning.bpmfl.cn.gov.cn.bpmfl.cn http://www.morning.mxhcf.cn.gov.cn.mxhcf.cn http://www.morning.dmwck.cn.gov.cn.dmwck.cn http://www.morning.ljzss.cn.gov.cn.ljzss.cn http://www.morning.wmfmj.cn.gov.cn.wmfmj.cn http://www.morning.rgpy.cn.gov.cn.rgpy.cn http://www.morning.zxwqt.cn.gov.cn.zxwqt.cn http://www.morning.txysr.cn.gov.cn.txysr.cn http://www.morning.xcjwm.cn.gov.cn.xcjwm.cn http://www.morning.rfwkn.cn.gov.cn.rfwkn.cn http://www.morning.nptls.cn.gov.cn.nptls.cn http://www.morning.rfmzs.cn.gov.cn.rfmzs.cn