日期:2014-05-17 浏览次数:20435 次
function searchByArea(cps, cpa, cpn, areaMapAddress) { var companys = cps; var companysaddress = cpa; var companyname = cpn; var map = new BMap.Map("milkMap"); // 创建地图实例 var point = new BMap.Point(areaMapAddress.split(",")[0].toString(), areaMapAddress.split(",")[1].toString()); // 创建点坐标 map.centerAndZoom(point, 13); // 初始化地图,设置中心点坐标和地图级别 //map.addControl(new BMap.OverviewMapControl({ isOpen: 1, anchor: BMAP_ANCHOR_TOP_RIGHT })); //为地图添加鹰眼 map.addControl(new BMap.NavigationControl(opts)); //为地图添加鱼骨 //给地图添加自定义的控件; ZoomControl.prototype.initialize = initSearch(map); var myZoomCtrl = new ZoomControl(); map.addControl(myZoomCtrl); map.enableScrollWheelZoom(); //启动鼠标滚轮缩放地图 map.enableKeyboard(); //启动键盘操作地图 if (companys != "") { var c = companys.split("|"); var caddress = companysaddress.split("|"); var cname = companyname.split("|"); if (c.length > 0) { for (var i = 0; i < c.length; i++) { var cc = c[i].split(","); //------------开始标注一个地点---------- var pointMarker = new BMap.Point(cc[0], cc[1]); // 创建标注的坐标 var marker = new BMap.Marker(pointMarker); // 创建标注 map.addOverlay(marker); // 将标注添加到地图中 [color=#FF0000] var infowindow = new BMap.InfoWindow(cname[i].toString() + "<br /> <span style='font-size:10px;'>公司地址:" + caddress[i].toString() + "</span><br /><img src='../../images/telephone.ico' /><a href='#' style='line-height:3em;color:#005EAC;font-size:10px;text-decoration:none;'>88888888>></a>"); // 创建信息窗口对象 marker.addEventListener("click", function () { //给标注添加点击事件 this.openInfoWindow(infowindow); });[/color] var label = new BMap.Label(cname[i].toString(), { point: pointMarker, offset: new BMap.Size(3, -6) }); //定义一个文字标签 map.addOverlay(label); } } } }