#

## OpenGeo Stack Workshop

# 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.

   Adding a new style

2. Click New

   Adding a new style

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

   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.

   Locating an SLD file

   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.

   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.

   Editing a feature type

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

   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.

> 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.

### Navigation

- index
- modules |
- next |
- previous |
- OpenGeo Stack Workshop »
- GeoServer Basics »
- Adding a Style