[英]Change color of graticule label
I'm trying to change the color of graticule labels on my openlayers map but I cant make it work. 我正在尝试更改openlayers地图上的经纬网标签的颜色,但我不能让它工作。 Here is what I'm doing:
这是我正在做的事情:
this.Graticule = new OpenLayers.Control.Graticule({
numPoints: 2,
labelled: true,
lineSymbolizer:{strokeColor: "#ffffff", strokeWidth: 1, strokeOpacity: 0.2},
labelSymbolizer:{strokeColor: "#ffffff", strokeWidth: 1, strokeOpacity: 0.7}
});
The color lines is changing but I always get black labels. 颜色线正在变化,但我总是得到黑色标签。
Can someone help me here? 有人可以帮我吗?
Thanks. 谢谢。
In order to change the text labels you need to define font attributes: 要更改文本标签,您需要定义字体属性:
labelSymbolizer: {
fontColor: "#ffffff",
fontSize: "12px"
}
I have no experience with OpenLayers, but from what I've seen that should work. 我没有使用OpenLayers的经验,但是从我看到的应该有效。 However, I can't get it to work either.
但是,我也无法让它工作。 An alternative way is to use CSS, for example:
另一种方法是使用CSS,例如:
tspan{
stroke: green;
}
However this will have all labels to be green which probably isn't intended. 然而,这将使所有标签都是绿色的,这可能不是预期的。 As I said I have no experience with OpenLayers, but maybe there is some way to lock down the CSS rule to only graticule text?
正如我所说,我没有使用OpenLayers的经验,但也许有一些方法可以将CSS规则锁定为只有刻度文本?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.