1

May I set variable in CSS, like as

<ogc:Function name="env">

I have this:

* {
  fill: [recode(strTrim(name),
         'Akmola Region', '#6495ED',
         'Aktobe Region', '#B0C4DE')];
  fill-opacity:0.4;
  stroke: lightgrey;
}

but I want set variables for Fill and Stroke-width parameters. Like this:

<Rule>
          <Title>Akmola Region</Title>
           <ogc:Filter>
            <ogc:PropertyIsEqualTo>
             <ogc:PropertyName>name</ogc:PropertyName>
             <ogc:Literal>Akmola Region</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
            <PolygonSymbolizer>
                  <Fill>                 
                  <CssParameter name="fill">
                  #<ogc:Function name="env">
                 <ogc:Literal>Akmola_fill_color</ogc:Literal> 
                   <ogc:Literal>6495ED</ogc:Literal>  
                  </ogc:Function>                   
                   </CssParameter>
                  <CssParameter name="fill-opacity">0.4</CssParameter>
                  </Fill>
              <Stroke>
                <CssParameter name="stroke">#605f5f</CssParameter>
                <CssParameter name="stroke-width">
                <ogc:Function name="env">
                <ogc:Literal>Akmola_stroke_width</ogc:Literal>
                <ogc:Literal>0.1</ogc:Literal> 
                </ogc:Function>
                </CssParameter>                 
              </Stroke>
          </PolygonSymbolizer>
        </Rule>

        <Rule>
          <Title>Aktobe Region</Title>
           <ogc:Filter>
            <ogc:PropertyIsEqualTo>
             <ogc:PropertyName>name</ogc:PropertyName>
             <ogc:Literal>Aktobe Region</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
            <PolygonSymbolizer>
                  <Fill>
                  <CssParameter name="fill">
                  #<ogc:Function name="env">
                 <ogc:Literal>Aktobe_fill_color</ogc:Literal> 
                   <ogc:Literal>B0C4DE</ogc:Literal>  
                  </ogc:Function>                   
                   </CssParameter>
                    <CssParameter name="fill-opacity">0.4</CssParameter>
                  </Fill>
              <Stroke>
                <CssParameter name="stroke">#605f5f</CssParameter>
                <CssParameter name="stroke-width">
                <ogc:Function name="env">
                <ogc:Literal>Aktobe_stroke_width</ogc:Literal>
                <ogc:Literal>0.1</ogc:Literal> 
                </ogc:Function>
                </CssParameter>                 
              </Stroke>
          </PolygonSymbolizer>
        </Rule>

I want emulate hover event when mouse hover on map object. Maybe it is possible with css capabilities?

5
  • Have you tried doing that? If so, what happened?
    – PolyGeo
    May 22, 2019 at 2:53
  • In SLD style it is worke fine! In CSS I didn't try this. Im not shoure that it compatible .
    – Cold Pol
    May 22, 2019 at 3:22
  • Please use the edit button beneath your question to revise it with any requested clarifications.
    – PolyGeo
    May 22, 2019 at 3:46
  • possible duplicate of gis.stackexchange.com/questions/154935/…
    – Ian Turton
    May 22, 2019 at 7:28
  • I don't understand anything. May you get me link to doc?
    – Cold Pol
    May 22, 2019 at 10:59

1 Answer 1

1
   * {
      fill: [recode(strTrim(name),
             'Akmola Region', env('color_Akmola','#6495ED'),
             'Aktobe Region', env('color_Aktobe','#B0C4DE'))];
      fill-opacity:0.4;
      stroke: lightgrey;
    }
    /* &env=color_Akmola:%23ff0000 */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.