来客旗下网站:来客网站设计
服务热线:18106308119(微信)联系我们支付方式

威海网站建设,威海网络公司

帝国CMS

帝国CMS百度地图自动标注方法

DATE:2013-08-01 08:46:00
1.先在系统模版新建字段 diduan 地段 后面该打的全部打勾2.到管理模板变量 增加模板变量 变量名:[!---temp.ditu--] 变量标识:百度地图标注3.变量值加入以下代码
标签:

1.先在系统模版新建字段   diduan  地段    后面该打的全部打勾
2.到管理模板变量  增加模板变量  变量名:[!--temp.ditu--]  变量标识:百度地图标注
3.变量值加入以下代码

 

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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!doctype html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=uft-8">
        <title>采集坐标 </title>
        <!--[if IE 6]>
            <script type="text/javascript" src="http://dev.baidu.com/wiki/static/map/tuan/js/DD_belatedPNG_0.0.8a-min.js"></script>
            <script>DD_belatedPNG.fix("#float_search_bar");</script>
       <![endif]-->
       <style>
            #preview{
                border: 1px solid #bfd2e1;
                width: 250px;
                height: 250px;
                font-family: Arial, Helvetica, sans-serif,"宋体";
            }
            #map_container{
                height: 250px;
            }
            #float_search_bar{
                z-index: 2012;
                position: absolute;
                width: 180px;
                height: 31px;
                background: url("http://dev.baidu.com/wiki/static/map/tuan/images/search_bar.png") repeat-x;
                background-position: 0 -21px;
                padding: 3px 0 0 10px;
            }
            #float_search_bar label, #float_search_bar span{
                color: #0787cb;
                font-size: 14px;
            }
            #float_search_bar input{
                width: 180px;
                height: 16px;
                margin-top: 1px;
            }
            #float_search_bar input:focus{
                outline: none;
            }
            #float_search_bar button{
                border: 0;
                color: white;
                width: 77px;
                height: 20px;
                background: url("http://dev.baidu.com/wiki/static/map/tuan/images/search_bar.png") no-repeat;
                background-position: 0 0;
                margin-right: 5px;
                cursor: pointer;
            }
        </style>
   </head>
     
   <body>
   <div id="preview">
        <div id="float_search_bar">
            <label>区域:</label>
            <input type="text" id="keyword" />
            <button id="search_button">查找</button>
            <span>点击地图或标注获取坐标</span>
        </div>
        <div id="map_container"></div>
    </div>
    <div id="result" style="margin-top: 4px;"></div>
      
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
    <script type="text/javascript">
        function getUrlParas(){
            var hash = location.hash,
                para = {},
                tParas = hash.substr(1).split("&");
            for(var p in tParas){
                if(tParas.hasOwnProperty(p)){
                    var obj = tParas[p].split("=");
                    para[obj[0]] = obj[1];
                }
            }
            return para;
        }
        var para = getUrlParas(),
            center = para.address?decodeURIComponent(para.address) : "[!--diduan--]",
            city = para.city?decodeURIComponent(para.city) : "[!--diqu--]";
      
        document.getElementById("keyword").value = center;
      
        var marker_trick = false;
        var map = new BMap.Map("map_container");
        map.enableScrollWheelZoom();
      
        var marker = new BMap.Marker(new BMap.Point(116.404, 39.915), {
            enableMassClear: false,
            raiseOnDrag: true
                 });
        marker.enableDragging();
        map.addOverlay(marker);
      
        map.addEventListener("click", function(e){
            if(!(e.overlay)){
                map.clearOverlays();
                marker.show();
                marker.setPosition(e.point);
                setResult(e.point.lng, e.point.lat);
            }
        });
        marker.addEventListener("dragend", function(e){
            setResult(e.point.lng, e.point.lat);
        });
      
        var local = new BMap.LocalSearch(map, {
            renderOptions:{map: map},
                         pageCapacity: 1
        });
        local.setSearchCompleteCallback(function(results){
            if(local.getStatus() !== BMAP_STATUS_SUCCESS){
                alert("无结果");
            } else {
                             marker.hide();
                         }
        });
        local.setMarkersSetCallback(function(pois){
            for(var i=pois.length; i--; ){
                var marker = pois[i].marker;
                marker.addEventListener("click", function(e){
                    marker_trick = true;
                    var pos = this.getPosition();
                    setResult(pos.lng, pos.lat);
                });
            }
        });
      
        window.onload = function(){
            local.search(center);
            document.getElementById("search_button").onclick = function(){
                local.search(document.getElementById("keyword").value);
            };
            document.getElementById("keyword").onkeyup = function(e){
                var me = this;
                e = e || window.event;
                var keycode = e.keyCode;
                if(keycode === 9){
                    local.search(document.getElementById("keyword").value);
                }
            };
        };
        function a(){
            document.getElementById("float_search_bar").style.display = "none";
        }
        a();
        /*
         * setResult : 定义得到标注经纬度后的操作
         * 请修改此函数以满足您的需求
         * lng: 标注的经度
         * lat: 标注的纬度
         */
        function setResult(lng, lat){
            document.getElementById("result").innerHTML = lng + ", " + lat;
        }
   </script>
    </body>
</html>



4.到需要加入地图的内容模版加入代码:[!--temp.ditu--]

效果:

提交需求告诉我们您的求,我们会在24小时内与您联得联系,资料会保密!

服务项目
高端网页设计定制
移动应用设计开发
网络营销推广
成功案例
最新案例
网站建设
移动营销
网络营销
网店装修
客户名录
关于来客
公司简介
公司新闻
联系我们
在线问答
解决方案
网站建设
电商运营
移动营销
网络营销
站长博客
网页设计
手机网站
网站优化
天猫装修

电话:18106308119  邮箱:19767526@qq.com

© Copyright 2010-2015来客网站设计工作室保留所有权利    鲁ICP备13009554号-4

站点地图|