pbootcms模板如何增加百度地圖
pbootcms模板如何增加百度地圖
首先找到你要增加的模板,模板路徑:template文件夾,比如要加到聯(lián)系contact.html上,找到合適的位置,加上如下代碼:
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=IZ4JODRg1DVV7YiJL9FtxJo6js4DeG7e&s=1"></script> <style> #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)建標(biāo)注 map.addOverlay(marker1); // 將標(biāo)注添加到地圖中 //marker1.setAnimation(BMAP_ANIMATION_BOUNCE); //跳動(dòng)的動(dòng)畫 //創(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();//啟用地圖拖拽事件,默認(rèn)啟用(可不寫) map.enableScrollWheelZoom(); //啟用地圖滾輪放大縮小 map.enableDoubleClickZoom(); //啟用鼠標(biāo)雙擊放大,默認(rèn)啟用(可不寫) map.enableKeyboard(); //啟用鍵盤上下左右鍵移動(dòng)地 </script>