简体   繁体   中英

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. 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. However, I can't get it to work either. An alternative way is to use CSS, for example:

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM