chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{yun:}include file="$wapstyle/member/cheader.htm"{/yun}
<script type="text/javascript">
    var weburl='{yun:}$config_wapdomain{/yun}'; 
</script>
 
<section class="wap_member">
    <div class="yun_wap_addresume_box" style="background:none;">
        <form action="" method="post">
            <div class="yun_wap_mapsetadd">
                <input type="text" name="address" id='address' value="{yun:}$row.address{/yun}"  placeholder="请填写详细地址" class="yun_wap_mapset_text">
            </div>
     
            <div class="yun_wap_mapset_ts_wz "> 
                <span class="yun_wap_mapset_ts">点击搜索即可获得地址的相应位置 </span>
                <input type="button" value="搜索" onclick="localsearch('全国');" class="yun_wap_mapsetadd_bth">
            </div>
            
            <div class="yun_wap_mapsetadd ">
                <div class="yun_wap_mapset">
                    <div class=""> 设置地图 
                        <span class="resume-cont_wate_bj">*</span> 
                        <span class="yun_wap_mapset_ts">( 在地图上点击所在位置即可 )</span>
                    </div>
 
                    <div class="yun_wap_mapset_mapbox ">
                        <div id="map_container" style="width:100%;height:200px; left:0;"></div>
                        <div class="yun_wap_mapset_mapbox_wz">
                            <div class="yun_wap_mapset_mapbox_wz_c"> 
                                <span class="yun_wap_mapset_mapbox_wz_c_s">X轴:</span>
                                <input name="xvalue" id="map_x" type="text" value="{yun:}$row.x{/yun}" readonly="readonly" class="yun_wap_mapset_text" />  
                            </div>
                        </div>
 
                        <div class="yun_wap_mapset_mapbox_wz">
                            <div class="yun_wap_mapset_mapbox_wz_c"> 
                                <span class="yun_wap_mapset_mapbox_wz_c_s"> Y轴:</span>
                                <input name="yvalue" id="map_y" type="text" value="{yun:}$row.y{/yun}" readonly="readonly" class="yun_wap_mapset_text" />
                            </div> 
                        </div>
                    </div>       
                </div>
            </div>
 
            <div class="yun_wap_mapset_mapbox_bth mt10" style="background: transparent; border: none;">
                <input type="submit" name="submit" value="提交操作" class="reinputText2">
            </div>
        </form>
    </div> 
</section>
 
<script type="text/javascript" src="{yun:}$config.mapurl{/yun}"></script> 
<script>
    var map=new BMap.Map("map_container");
    setLocation('map_container',116.404, 39.915,"map_x","map_y");
    $(document).ready(function() {
        {yun:}if ($row.x=="" || $row.y=="") && $row.address!=""{/yun}
            localsearch();
        {yun:}elseif $row.x!="" && $row.y!=""{/yun}
            setLocation('map_container',{yun:}$row.x{/yun},{yun:}$row.y{/yun},"map_x","map_y");
        {yun:}else{/yun}
            var geolocation = new BMap.Geolocation();
            geolocation.getCurrentPosition(function (r) {
            
            if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                location_r = r;
                setLocation('map_container',r.point.lng,r.point.lat,"map_x","map_y"); 
            }
        }, { enableHighAccuracy: true });
        {yun:}/if{/yun}
    });
 
    function localsearch(){
        if($("#address").val()==""){
            layermsg('请输入地址!', 2);return false;
        }
        // 创建地址解析器实例
        var myGeo = new BMap.Geocoder();
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint('{yun:}$city_name[$row.provinceid]{/yun}{yun:}$city_name[$row.cityid]{/yun}{yun:}$city_name[$row.three_cityid]{/yun}'+$("#address").val().replace(/\s+/g,""), function(point){
            if(point){
                $("#map_x").val(point.lng);
                $("#map_y").val(point.lat);
                map.centerAndZoom(point, 16);
                map.addOverlay(new BMap.Marker(point));
            }
        }, "北京市");
    }
    function setLocation(id,x,y,xid,yid){
        
        var rating,map_control_type,map_control_anchor;
        if(!x && !y){x='116.404';y='39.915';}
        var point = new BMap.Point(x,y);
        var marker = new BMap.Marker(point);
        var opts = {type:BMAP_NAVIGATION_CONTROL_LARGE}
        map.enableScrollWheelZoom(true);
        map.addControl(new BMap.NavigationControl(opts));
        map.centerAndZoom(point, 15);
        map.addOverlay(marker);
        // 解决移动端 click事件点击无效
        map.addEventListener("touchmove", function (e) {
            map.enableDragging();
        });
        //  触摸结束时触发次此事件  此时开启禁止拖动
        map.addEventListener("touchend", function (e) {
            map.disableDragging();
        });
        // 初始化地图 禁止拖动   注:虽禁止拖动,但是可以出发拖动事件
        map.disableDragging();
    
        map.addEventListener("click",function(e){
            var info = new BMap.InfoWindow('', {width: 260});
            var projection = this.getMapType().getProjection();
            var lngLat = e.point;
            document.getElementById(xid).value=lngLat.lng;
            document.getElementById(yid).value=lngLat.lat;
            map.clearOverlays();
            var point = new BMap.Point(lngLat.lng,lngLat.lat);
            var marker = new BMap.Marker(point);
            map.addOverlay(marker);
        });
    }  
    
</script>
{yun:}include file="$wapstyle/footer.htm"{/yun}