OpenGeo

OpenGeo Stack Workshop

Previous topic

Using the Map Preview

Next topic

Working With PostGIS

Adding a Style

The most important function of a web map server is the ability to style and render data. This section covers the task of adding a new style to GeoServer and configuring the default style for a particular layer.

  1. From the GeoServer Welcome Page navigate to Config ‣ Data ‣ Style.

    ../_images/style_add1.jpg

    Adding a new style

  2. Click New

    ../_images/style_add2.jpg

    Adding a new style

  3. Enter “coastline_style” in the text field and click New.

    ../_images/style_add3.jpg

    Specifying style name

  4. Scroll to the bottom of the Style Editor page and click Browse.

  5. Navigate to the workshop data/bayarea directory, select the bay_area_coastline.sld file, and click Upload.

    ../_images/style_add4.jpg

    Locating an SLD file

    ../_images/style_add5.jpg

    Uploading a new style

    Note

    In GeoServer, styles are represented via SLD (Styled Layer Descriptor) documents. SLD is an XML format for specifying the symbolization of a layer.

    ../_images/style_add6.jpg

    SLD editor

    Note

    When an SLD document is uploaded the contents are shown in the text editor. The editor can be used to edit the contents of the SLD directly.

  6. Add the new style by clicking Submit, followed by Apply, and finally Save.

  7. From the Config page navigate to Data ‣ FeatureTypes. Select bay_area_coastline_shp:bay_area_coastline` from the drop down and click Edit.

    ../_images/style_add7.jpg

    Editing a feature type

  8. On the Feature Type Editor page set the Style by selecting coastline_style from the drop down.

    ../_images/style_add8.jpg

    Changing a feature type style

    Note

    Setting the default style allows that style to be used implicitly when no style is specified in a map request.

  9. Scroll to the bottom of the page. Submit, Apply, and Save.

  10. Repeat steps 1 through 3 from the previous module to view the bay_area_coastline layer in the Map Preview.

../_images/style_add9.jpg

Previewing a style change

That concludes the basics module. At this point the tasks of adding and styling data have been successfully completed. In the next modules these core skills will be built upon to add more data and perform more complex styling.