document.write("\n") document.write("
Loading...
\n") document.write("\n") var map_icon = new Image(); map_icon.src = '/images/Map_Marker.png'; var icon_w = map_icon.width; var icon_h = map_icon.height; if (icon_w == 0) {icon_w = icon_h = 20;} //创建和初始化地图函数: function initMap(){ createMap();//创建地图 setMapEvent();//设置地图事件 addMapControl();//向地图添加控件 addMarker();//向地图中添加marker } //创建地图函数: function createMap(){ var Map_Ditu_map = new BMap.Map("Map_Ditu");//在百度地图容器中创建一个地图 var Map_Ditu_point = new BMap.Point(113.782238,22.969143);//定义一个中心点坐标 Map_Ditu_map.centerAndZoom(Map_Ditu_point,16);//设定地图的中心点和坐标并将地图显示在地图容器中 window.Map_Ditu_map = Map_Ditu_map;//将map变量存储在全局 } //地图事件设置函数: function setMapEvent(){ Map_Ditu_map.enableDragging();//启用地图拖拽事件,默认启用(可不写) Map_Ditu_map.disableScrollWheelZoom();//禁用地图滚轮放大缩小,默认禁用(可不写) //Map_Ditu_map.enableScrollWheelZoom();//启用地图滚轮放大缩小 Map_Ditu_map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写) Map_Ditu_map.enableKeyboard();//启用键盘上下左右键移动地图 } //地图控件添加函数: function addMapControl(){ //向地图中添加缩放控件 var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}); Map_Ditu_map.addControl(ctrl_nav); //向地图中添加缩略图控件 var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1}); Map_Ditu_map.addControl(ctrl_ove); //向地图中添加比例尺控件 var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}); Map_Ditu_map.addControl(ctrl_sca); } //标注点数组 var Map_Ditu_markerArr = [{title:"广东粤辉环保工程有限公司",content:"电话:0769-22993002 传真:0769-22423158
地址:东莞市东城区莞长路牛山创富工业园4楼",point:"113.782238|22.969143",isOpen:1,icon:{w:icon_w,h:icon_h,l:0,t:0,x:icon_w/2,lb:icon_w/2}}]; //创建marker function addMarker(mapinfo){ for(var i=0;i"+json.title.substr(json.title.length/2),{"offset":new BMap.Size(json.icon.lb-json.icon.x+icon_w/2+5,-18)}); marker.setLabel(label); //向地图中添加文字信息 Map_Ditu_map.addOverlay(marker); label.setStyle({ borderColor:"#666666", color:"#666666", cursor:"pointer" }); (function(){ var index = i; var _iw = createInfoWindow(i); var _marker = marker; _marker.addEventListener("click",function(){ this.openInfoWindow(_iw); }); _iw.addEventListener("open",function(){ _marker.getLabel().hide(); }) _iw.addEventListener("close",function(){ _marker.getLabel().show(); }) label.addEventListener("click",function(){ _marker.openInfoWindow(_iw); }) if(!!json.isOpen){ label.hide(); _marker.openInfoWindow(_iw); } })() } } //创建InfoWindow function createInfoWindow(i){ var json = Map_Ditu_markerArr[i]; var iw = new BMap.InfoWindow("" + json.title + "
"+json.content+"
"); return iw; } //创建一个Icon function createIcon(json){ var icon = new BMap.Icon("/images/Map_Marker.png", new BMap.Size(json.w,json.h),{imageOffset: new BMap.Size(-json.l,-json.t),infoWindowOffset:new BMap.Size(json.lb+0,-2),offset:new BMap.Size(json.x,json.h-icon_h/2)}) return icon; } //initMap();//创建和初始化地图 if(window.attachEvent){window.attachEvent("onload",initMap);} //ie if(window.addEventListener){window.addEventListener("load",initMap,false);} //FF