<?php /* Smarty version Smarty-3.1.8, created on 2015-11-21 16:20:06
         compiled from "D:\wwwroot\o2o\htdocs\themes\default\xiche\ucenter\addr\location.html" */ ?>
<?php /*%%SmartyHeaderCode:921565029299ee6d8-71319859%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'fa08611c19731793f71c23d94c50611e20cc6ba9' => 
    array (
      0 => 'D:\\wwwroot\\o2o\\htdocs\\themes\\default\\xiche\\ucenter\\addr\\location.html',
      1 => 1448094003,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '921565029299ee6d8-71319859',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.8',
  'unifunc' => 'content_56502929c8e578_27319110',
  'variables' => 
  array (
    'url' => 0,
    'CONFIG' => 0,
    'city' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56502929c8e578_27319110')) {function content_56502929c8e578_27319110($_smarty_tpl) {?><?php if (!is_callable('smarty_function_link')) include 'D:\\wwwroot\\o2o\\htdocs\\system\\plugins/smarty\\function.link.php';
?><?php $_smarty_tpl->tpl_vars['tpl_title'] = new Smarty_variable('地址管理', null, 0);?>
<!DOCTYPE HTML>
<html>
    <head>
        <?php echo $_smarty_tpl->getSubTemplate ("xiche/block/sheader.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>

    </head>
    <body>
        <header> <i class="left"><a id="icon_goback" href="<?php echo smarty_function_link(array('ctl'=>'xiche/ucenter/addr/add'),$_smarty_tpl);?>
"></a></i>
            <div class="title">服务地址</div>
            <form method="post" action="<?php echo smarty_function_link(array('ctl'=>'xiche/ucenter/addr/add'),$_smarty_tpl);?>
">
                <input type="hidden" id="addr" name="addr" value="">
                <input type="hidden" name="lat" id="lat" value="">
                <input type="hidden" name="lng" id="lng" value="">
                <input type="hidden" name="url" id="url" value="<?php echo $_smarty_tpl->tpl_vars['url']->value;?>
">
                <i class="right"><input class="road_sub" type="submit" value="确认"  /></i> 
            </form>
        </header>
        <section class="page_center_box" style="height:100%">
            <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=7b92b3afff29988b6d4dbf9a00698ed8"></script>
            
            
            <div class="tf_search">
                    <div class="tf_search_box">
                            <i class="searchIco"></i><input  id="suggestId" name="name" type="text" placeholder="请点击地图或输入关键字进行定位" onblur="if (!value) {
                            value = defaultValue;
                            this.style.color = '#999'
                        }" onclick="if (value == defaultValue) {
                                    value = '';
                                    this.style.color = '#000'
                                }" >
                    </div>
            </div>
            



            <div id="allmap" style="width: 100%; height:100%;overflow-y:scroll;"></div>
            <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:100%;height:auto; display:none;"></div>
            <script type="text/javascript">
                // 百度地图API功能
                require(["zepto", "underscore", "frozen"], function ($, _, fz) {
                    var map = new BMap.Map("allmap");
                    var addr = null;
                    var lng = "<?php echo $_smarty_tpl->tpl_vars['CONFIG']->value['site']['lng'];?>
";
                    var lat = "<?php echo $_smarty_tpl->tpl_vars['CONFIG']->value['site']['lat'];?>
";
                    if (!lng && !lat) {
                        map.centerAndZoom("<?php echo $_smarty_tpl->tpl_vars['city']->value;?>
");
                        var point = new BMap.Point(117.260852, 31.825717);
                    } else {
                        map.centerAndZoom(new BMap.Point(lng, lat), 15);
                        var point = new BMap.Point(lng, lat);
                    }
                    map.centerAndZoom(point, 15);
                    var marker = new BMap.Marker(point);  // 创建标注
                    map.clearOverlays();
                    //map.addOverlay(marker);              // 将标注添加到地图中
                    //marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                    function showPoint(e) {
                        var p = new BMap.Point(e.point.lng, e.point.lat);
                        $('#lat').val(e.point.lat);
                        $('#lng').val(e.point.lng);
                        var mk = new BMap.Marker(p);
                        map.clearOverlays();
                        //removeOverlay(overlay:Overlay);
                        map.addOverlay(mk);
                        //mk.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                        var geoc = new BMap.Geocoder();
                        geoc.getLocation(p, function (rs) {
                            var addComp = rs.addressComponents;
                            addr = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;
                            //alert(addr);
                            $("#suggestId").val(addr);
                        });
                    }
                    map.enableScrollWheelZoom(true);
                    map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
                    map.addEventListener("click", showPoint);
                    function G(id) {
                        return document.getElementById(id);
                    }
                    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();
                    });
                    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>
            <script type="text/javascript">

                require(["zepto", "underscore", "frozen"], function ($, _, fz) {
                    $('.right').click(function () {
                        var road = $("#suggestId").val();
                        $("#addr").val(road);
                    })
                    $('.btn_long').click(function(){
                        $('.road_sub').click();
                    })
                    
                    $('#list3').addClass('on');
                });
            </script>
        </section>
        
        <footer>
            <div class="btn_long_box"><a href="javascript:void(0);" class="btn_long" style="text-align:center;line-height:0.4rem;font-weight:bold;">保存</a></div>
        </footer>

    </body>
</html><?php }} ?>