<!--地图开始--> <script type="text/javascript" src="/js/map.js"></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(116.418687,39.9516), 18);//括号内数字113.266875,23.135834 请改为你公司的百度地图坐标,坐标获取地址:http://api.map.baidu.com/lbsapi/getpoint/index.html var marker1 = new BMap.Marker(new BMap.Point(116.419137,39.951879)); //括号内数字113.266875,23.135834 请改为你公司的百度地图坐标,坐标获取地址:http://api.map.baidu.com/lbsapi/getpoint/index.html map.addOverlay(marker1); // 将标注添加到地图中 //marker1.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画 //创建信息窗口 var infoWindow1 = new BMap.InfoWindow("<b>大都宴会</b><br>地址:北京市xxxxx88号<br>电话:13988888888"); 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> <!--地图结束-->
map.js中的代码如下,自己替换一下ak和应用
(function(){ window.BMap_loadScriptTime = (new Date).getTime(); document.write('<script type="text/javascript" src="https://api.map.baidu.com/getscript?v=2.0&ak=ozXc8STBTO6ySOWE6PpmkGSN1gjyTcf0&services=&t=91725354"></script>');})();