"; } if (qq != '') { contentText += "QQ:847498783
"; } if (email != '') { contentText += "邮箱:847498783@qq.com
"; } if (address != '') { contentText += "地址:广州市花都区花城街花卉之都南北大道A区26号
"; } if (fullCustomerName != '') { CustomerName = fullCustomerName; } var markerArr = [{ title: CustomerName, content: contentText, point: "113.221286|23.454791", /*特别提醒需要修改经纬度*/ isOpen: 0, icon: { w: 21, h: 21, l: 0, t: 0, x: 6, lb: 5 } }]; function addMarker() { for (var i = 0; i < markerArr.length; i++) { var json = markerArr[i]; var p0 = json.point.split("|")[0]; var p1 = json.point.split("|")[1]; var point = new BMap.Point(p0, p1); var iconImg = createIcon(json.icon); var marker = new BMap.Marker(point, { icon: iconImg }); var iw = createInfoWindow(i); var label = new BMap.Label(json.title, { "offset": new BMap.Size(json.icon.lb - json.icon.x + 10, -20) }); marker.setLabel(label); map.addOverlay(marker); label.setStyle({ borderColor: "#808080", color: "#333", 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); } })(); } } function createInfoWindow(i) { var json = markerArr[i]; var iw = new BMap.InfoWindow("" + json.title + "
" + json.content + "
"); return iw; } function createIcon(json) { var icon = new BMap.Icon("http://api.map.sdprint.cn/lbsapi/creatmap/images/us_mk_icon.png", new BMap.Size(json.w, json.h), { imageOffset: new BMap.Size(-json.l, -json.t), infoWindowOffset: new BMap.Size(json.lb + 5, 1), offset: new BMap.Size(json.x, json.h) }); return icon; } initMap();
|