pbootcms模板如何增加百度地圖
首先找到你要增加的模板,模板路徑:template文件夾,比如要加到聯(lián)系contact.html上,找打合適的位置,加上如下代碼:
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=YQiwVrOyoN9C9ZMGkVL2a4jT"></script>
<style type="text/css">
#allmap {width: 100%;height: 400px;margin-top:20px;overflow: hidden;font-family:"微軟雅黑";}
#allmap b{color: #CC5522;font-size: 14px; }
#allmap img{max-width: none;}
</style>
<div id="allmap"></div>
<script type="text/javascript">
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point({label:map}), 18);
var marker1 = new BMap.Marker(new BMap.Point({label:map})); // 創(chuàng)建標注
map.addOverlay(marker1); // 將標注添加到地圖中
//marker1.setAnimation(BMAP_ANIMATION_BOUNCE); //跳動的動畫
//創(chuàng)建信息窗口
var infoWindow1 = new BMap.InfoWindow("<b>{pboot:companyname}</b><br>地址:{pboot:companyaddress}<br>電話:{pboot:companyphone}");
marker1.openInfoWindow(infoWindow1);
//marker1.addEventListener("click", function(){this.openInfoWindow(infoWindow1);});
//向地圖中添加縮放控件
var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
map.addControl(ctrl_nav);
//向地圖中添加縮略圖控件
var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
map.addControl(ctrl_ove);
//向地圖中添加比例尺控件
var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
map.addControl(ctrl_sca);
map.enableDragging();//啟用地圖拖拽事件,默認啟用(可不寫)
map.enableScrollWheelZoom();//啟用地圖滾輪放大縮小
map.enableDoubleClickZoom();//啟用鼠標雙擊放大,默認啟用(可不寫)
map.enableKeyboard();//啟用鍵盤上下左右鍵移動地
</script>
|
然后到后臺 按下圖設(shè)置:
設(shè)置后填寫坐標:
坐標獲取地址:http://api.map.baidu.com/lbsapi/getpoint/