6 Replies Latest reply on Jul 1, 2014 9:57 AM by Zeydkas

    Styling rules in Javascript

    Zeydkas

      I am working with ThemBasedFOIs that contains different types of geometries. When I want to display points as markers and polygons as colored shapes so I need to define a complex styling.

       

      On the one hand I have a javascript theme query:

       

      var baseQuery = "SELECT value,annotation as label  FROM " + value;
      var theme = "<map_request><themes><theme name='JDBC_THEME'>"
      + "<jdbc_query asis='true' spatial_column='value' jdbc_srid='8307' label_column='label' "
      + "render_style='colorScheme' datasource='DSTest'>" + baseQuery
      + "</jdbc_query></theme></themes></map_request>";
      
      buffertheme = new MVThemeBasedFOI('buffertheme1', theme);
      buffertheme.addStyle(sc1);
      

       

      Where sc1 contains the render style 'colorScheme'. But I need 2 render styles one for the polygons and the other one for the points.

       

      On the other hand I have a styling rules:

       

      <?xml version="1.0" standalone="yes"?>

      <styling_rules key_column="ID" table_alias="t">

          <rule>

              <features style="M.POINTSTYLE"> t.geom_31466.get_gtype() = 1 </features>

        </rule>

          <rule>

              <features style="M.POLYGONSTYLE"> t.geom_31466.get_gtype() = 3 </features>

        </rule>

      </styling_rules>

       

      How can I add the styling_rules in the theme query instead using the render_style param? And anyone can my explain why is used 'geom_31466' to get the gtype?

       

      Thanks in advance.

        • 1. Re: Styling rules in Javascript
          grueningd

          I don't know how to archive this using jdbc-themes. But for your second question: "geom_31466" is just the name of a geometry column in the base table. It's just one way to determine the objects gtype...

          1 person found this helpful
          • 2. Re: Styling rules in Javascript
            Zeydkas

            Thanks for response, and are there any other way add this rules? for example creating them in map builder or something that I could use later in Javascript.

            • 3. Re: Styling rules in Javascript
              grueningd

              You can use a predefined themebased foi layer. Just create a geometry theme in mapbuilder and add two stying-rules similar to the upper sample.

              • 4. Re: Styling rules in Javascript
                grueningd

                Another way is to filter the geometries by their gtype. Doing so you can build two views - one for points and one for the polygons. Using that approach you can use jdbc as well...

                1 person found this helpful
                • 5. Re: Styling rules in Javascript
                  Zeydkas

                  I launch this resquest with 2 themes. First one for geometries 2001 and the secound one for the others. But only get the results for the first theme. Think there is something wrong, is possible that the request only allow one theme? so it wouldn't make any sense the <themes> tag.

                   

                  <map_request>

                  <themes>

                       <theme name='JDBC_THEME'>

                            <jdbc_query asis='true' spatial_column='value' jdbc_srid='8307' label_column='label' render_style='M.MARKER' datasource='DSTest'>

                            SELECT g.value,g.annotation as label FROM geometries g WHERE g.value.sdo_gtype = 2001</jdbc_query>

                       </theme>

                       <theme name='JDBC_THEME'>

                            <jdbc_query asis='true' spatial_column='value' jdbc_srid='8307' label_column='label' render_style='colorScheme' datasource='DSTest'>

                            SELECT g.value,g.annotation as label FROM geometries g WHERE g.value.sdo_gtype != 2001</jdbc_query>

                       </theme>

                  </themes>

                  </map_request>


                  Thanks again.

                  • 6. Re: Styling rules in Javascript
                    Zeydkas

                    This is the solution

                     

                    <AdvancedStyle>

                        <CollectionStyle>

                          <style name="M.SHAPES" shape="polygon"/>

                          <style name="M.MARKER" shape="point"/>

                          <style name="M.STREET" shape="line"/>

                      </CollectionStyle>

                    </AdvancedStyle