/*信息提示框*/ function comaplexcustomoverlay(point, text, mouseovertext){ this._point = point; this._text = text; this._overtext = mouseovertext; } comaplexcustomoverlay.prototype = new bmap.overlay(); comaplexcustomoverlay.prototype.initialize = function(map){ this._map = map; var div = this._div = document.createelement("div"); div.style.position = "absolute"; div.style.zindex = bmap.overlay.getzindex(this._point.lat); div.style.backgroundcolor = "#69aedb"; div.style.border = "1px solid #69aedb"; div.style.color = "white"; div.style.height = "18px"; div.style.padding = "2px"; div.style.lineheight = "18px"; div.style.whitespace = "nowrap"; div.style.mozuserselect = "none"; div.style.fontsize = "12px" var span = this._span = document.createelement("span"); div.appendchild(span); span.appendchild(document.createtextnode(this._text)); var that = this; var arrow = this._arrow = document.createelement("div"); arrow.style.background = "url(./images/contact/label.png) no-repeat"; arrow.style.position = "absolute"; arrow.style.width = "11px"; arrow.style.height = "10px"; arrow.style.top = "22px"; arrow.style.left = "10px"; arrow.style.overflow = "hidden"; div.appendchild(arrow); div.onmouseover = function(){ this.style.backgroundcolor = "#005bac"; this.style.bordercolor = "#005bac"; this.getelementsbytagname("span")[0].innerhtml = that._overtext; arrow.style.backgroundposition = "0px -20px"; } div.onmouseout = function(){ this.style.backgroundcolor = "#69aedb"; this.style.bordercolor = "#69aedb"; this.getelementsbytagname("span")[0].innerhtml = that._text; arrow.style.backgroundposition = "0px 0px"; } map.getpanes().labelpane.appendchild(div); return div; } comaplexcustomoverlay.prototype.draw = function(){ var map = this._map; var pixel = map.pointtooverlaypixel(this._point); this._div.style.left = pixel.x - parseint(this._arrow.style.left) + "px"; this._div.style.top = pixel.y - 50 + "px"; } function drawmsg(vo){ //alert(vo["mappointerx"]+","+vo["mappointery"]+","+vo["title"]); var txt = vo["title"], mouseovertxt = txt; var mycomapoverlay = new comaplexcustomoverlay(new bmap.point(parsefloat(vo["mappointerx"]),parsefloat(vo["mappointery"])),vo["title"],mouseovertxt); map.addoverlay(mycomapoverlay); } function drawpointer(markers,vo){ var pt = new bmap.point(parsefloat(vo["mappointerx"]),parsefloat(vo["mappointery"])); var marker=new bmap.marker(pt); markers.push(marker); } var map; var point; var markers; map = new bmap.map("map"); // 创建map实例 point = new bmap.point(113.328628,23.131031); map.centerandzoom(point, 18); // 初始化地图,设置中心点坐标和地图级别 map.addcontrol(new bmap.maptypecontrol()); //添加地图类型控件 map.setcurrentcity("广东"); // 设置地图显示的城市 此项是必须设置的 map.enablescrollwheelzoom(true); //开启鼠标滚轮缩放 var top_left_control = new bmap.scalecontrol({anchor: bmap_anchor_top_left});// 左上角,添加比例尺 var top_left_navigation = new bmap.navigationcontrol(); //左上角,添加默认缩放平移控件 map.addcontrol(top_left_control); map.addcontrol(top_left_navigation); markers = []; drawpointer(markers,{ "mappointerx":113.328628, "mappointery":23.131031, }); drawmsg({ "title":"中化广东有限公司", "mappointerx":113.328628, "mappointery":23.131031, }); var markerclusterer = new bmaplib.markerclusterer(map, {markers:markers});