Openlayers Label添加背景
来源:互联网 发布:电脑声控软件 编辑:程序博客网 时间:2024/04/26 08:06
Openlayers的2.11的 Label是没有添加背景色的,需要使用label需要添加如下代码
//修改文件: openlayers/lib/OpenLayers/Renderer/Elements.js//行号范围@@ -838,6 +838,10 @@ if (label) { this.textRoot.removeChild(label); }//添加start var labelBackground = document.getElementById(featureId + this.LABEL_ID_SUFFIX + "_bg"); if (labelBackground) { this.textRoot.removeChild(labelBackground); }//添加结束 }, //===================================================================//修改文件: openlayers/lib/OpenLayers/Renderer/VML.js//行号范围 -807,6 +807,15 @@ textbox.innerText = style.label; //添加start if (style.labelBackgroundColor) { textbox.style.backgroundColor = style.labelBackgroundColor; } if (style.labelBorderColor || style.labelBorderSize) { textbox.style.border = "solid " + (style.labelBorderSize ? style.labelBorderSize : "1px") + " " + (style.labelBorderColor ? style.labelBorderColor : "#000000"); } //添加结束 if (style.fillColor) { textbox.style.color = style.fontColor; }//===================================================================//修改文件: openlayers/lib/OpenLayers/Renderer/SVG.js//行号范围 -713,6 +713,38 @@ label.appendChild(tspan); this.textRoot.appendChild(label); } //添加start if (style.labelBackgroundColor || style.labelBorderColor || style.labelBorderSize) { var bg = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX + "_bg", "rect"); if (style.labelBackgroundColor) { bg.setAttributeNS(null, "fill", style.labelBackgroundColor); } if (style.labelBorderColor || style.labelBorderSize) { bg.setAttributeNS(null, "stroke", (style.labelBorderColor ? style.labelBorderColor : "#000000")); bg.setAttributeNS(null, "stroke-width", (style.labelBorderSize ? style.labelBorderSize : "0.5")); } var bbox = label.getBBox(); var labelWidth = bbox.width; var labelHeight = bbox.height; var padding = 2; if (style.labelPadding) { var pos = style.labelPadding.indexOf("px"); if (pos == -1) { padding = style.labelPadding; } else { padding = parseInt(style.labelPadding.substr(0, pos)); } } bg.setAttributeNS(null, "x", bbox.x-padding); bg.setAttributeNS(null, "y", bbox.y-padding); bg.setAttributeNS(null, "height", (labelHeight+padding*2)+"px"); bg.setAttributeNS(null, "width", (labelWidth+padding*2)+"px"); this.textRoot.insertBefore(bg, label); } //添加结束 }, //===================================================================//使用示例: openlayers/examples/vector-features-with-text.html//行号范围@@ -33,6 +33,10 @@ fontSize: "12px", fontFamily: "Courier New, monospace", fontWeight: "bold",//添加结束 labelPadding: "3px", labelBackgroundColor: "#efefef", labelBorderColor: "#cfcfcf", labelBorderSize: "1px",//添加结束 labelAlign: "${align}", labelXOffset: "${xOffset}", labelYOffset: "${yOffset}"
0 0
- Openlayers Label添加背景
- OpenLayers添加右键菜单
- OpenLayers开发:添加地标
- openlayers select-feature show polygon dimension label
- OpenLayers上添加Highcharts统计表
- openlayers添加标记信息框
- WinFrom 中 label背景透明
- 如何使label背景透明
- 绝对背景透明的Label
- WINCE 5.0 label背景透明
- 创建背景,精灵,label等
- WinFrom 中 label背景透明
- IOS 设置label背景颜色
- delphi label 背景颜色设置!
- OpenLayers 学习(二)基于OpenLayers添加地图控件
- label添加图片
- label添加删除线
- label文字添加超链接
- 项目优化经验分享(五)站在全局看问题
- leetcode 第一题 two sum
- 项目优化经验分享(六)SVN冲突和处理
- poj 2299
- Linux crontab命令
- Openlayers Label添加背景
- 通过简单Dump能获得的基本信息
- gridcontrol中添加checkbox复选框
- Linux下history命令用法
- Linux下TCP参数配置
- 让Visual Studio 也支持JS代码折叠 [ Visual Studio | #region | #endregion ]
- oracle导出excel 方法总结
- Linux学习:第三章-Linux常用命令-2
- HAL层开发基础