将CSS规则应用于OpenLayers矢量功能 [英] Apply CSS rules to OpenLayers vector feature
本文介绍了将CSS规则应用于OpenLayers矢量功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过在SVG饼图和OpenLayers矢量层上使用相同的CSS样式来简化代码.这样,如果我将某一种要素类型的css更改为具有不同的颜色,则只能在一个地方进行修改. 但是,我找不到在矢量层上设置要素的CSS类的方法.有可能吗?尽管我可以在创建每个功能时设置类,但我可能不得不使用样式图和上下文.
I'd like to simplify my code by using the same css styles on my SVG piechart and on my OpenLayers vector layer. This way if I ever change the css to have a different colour for one feature type I only have one place to modify. However, I can't find a way of setting the css class of a feature on a vector layer. Is is possible? I'd probably have to use a style map and context though I could set the class as I create each feature.
推荐答案
可以在CSS文件中尝试这样做吗?
Can you try to do like this in your css file:
svg[id *= "_something"]
{
stylexyz1: valuexyz1;
stylexyz2: valuexyz2;
stylexyz3: valuexyz3;
stylexyz4: valuexyz4;
stylexyz5: valuexyz5;
}
这篇关于将CSS规则应用于OpenLayers矢量功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文