|
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <title>提交订单</title>
- <link rel="stylesheet" type="text/css" href="public/css/main.css"/>
- <link rel="stylesheet" type="text/css" href="public/css/master.css"/>
- <link rel="stylesheet" type="text/css" href="public/css/ui-base.css"/>
- <link rel="stylesheet" type="text/css" href="public/css/ui-box.css"/>
- <link rel="stylesheet" type="text/css" href="public/css/ui-color.css"/>
- <link rel="stylesheet" type="text/css" href="public/css/baidu.css"/>
- <style type="text/css">
- .r-result{
- margin: 0.15rem;
- background-color: #d6d8dd;
- }
- .r-result_img{
- width: 0.14rem;
- margin-left: 0.05rem;
- margin-right: 0.05rem;
- position: relative;
- top: 0.02rem;
- }
- </style>
- </head>
- <body class="bg_color">
- <div style="display: none;" id="l-map"></div>
- <div class="ub ui_p_a10 r-result ub-ae ui_radiu_all">
- <img class="r-result_img" src="public/images/ic_search.png"/>
- <div class="ub-f1" id="r-result"><input class="ulev1" style="width: 90%;" placeholder="请输入" type="text" id="suggestId" size="20" value="" /></div>
- <span style="color: #0076ff;" class="ulev1">取消</span>
- </div>
-
- <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
- <script src="public/js/jquery-2.2.4.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="public/js/main.js" type="text/javascript" charset="utf-8"></script>
- <script src="public/js/rem.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=qnG9Q2oSgfGlwLUBeYBp7gTvFUCk31me"></script>
- <script type="text/javascript">
- //自动获取焦点
- $(document).ready(function(){
- $("#suggestId").focus();
- });
-
- // 百度地图API功能
- function G(id) {
- return document.getElementById(id);
- }
-
- var map = new BMap.Map("l-map");
- map.centerAndZoom("江苏",12); // 初始化地图,设置城市和地图级别。
-
- var ac = new BMap.Autocomplete( //建立一个自动完成的对象
- {"input" : "suggestId"
- ,"location" : map
- });
-
- ac.addEventListener("onhighlight", function(e) { //鼠标放在下拉列表上的事件
- var str = "";
- var _value = e.fromitem.value;
- var value = "";
- if (e.fromitem.index > -1) {
- value = _value.province + _value.city + _value.district + _value.street + _value.business;
- }
- str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
-
- value = "";
- if (e.toitem.index > -1) {
- _value = e.toitem.value;
- value = _value.province + _value.city + _value.district + _value.street + _value.business;
- }
- str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
- G("searchResultPanel").innerHTML = str;
-
- });
-
- var myValue;
- ac.addEventListener("onconfirm", function(e) { //鼠标点击下拉列表后的事件
- var _value = e.item.value;
- myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
- G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
-
- setPlace();
- var add_name = $("#suggestId").val();
- var myGeo = new BMap.Geocoder();
- var get_bus = getStorage("get_bus");
-
- myGeo.getPoint(add_name, function(point){
- if (point) {
- map.centerAndZoom(point, 16);
- map.addOverlay(new BMap.Marker(point));
- if(get_bus == "0"){
- setStorage("geton_name",add_name);
- setStorage("geton_point",point.lat +","+point.lng);
- window.location.href="submit_order.html";
- }else if(get_bus == "1"){
- setStorage("getoff_name",add_name);
- setStorage("getoff_point",point.lat +","+point.lng);
- window.location.href="submit_order.html";
- }
-
- }else{
- alert("您选择地址没有解析到结果!");
- }
- }, "北京市");
-
- });
-
- function setPlace(){
- map.clearOverlays(); //清除地图上所有覆盖物
- function myFun(){
- var pp = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果
- map.centerAndZoom(pp, 18);
- map.addOverlay(new BMap.Marker(pp)); //添加标注
- }
- var local = new BMap.LocalSearch(map, { //智能搜索
- onSearchComplete: myFun
- });
- local.search(myValue);
- }
-
- </script>
- </body>
- </html>
|