.. _geoserver.basics.style_add:

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.

#. From the GeoServer `Welcome Page <http://localhost:8080/geoserver>`_ navigate to :menuselection:`Config --> Data --> Style`.

   .. figure:: style_add1.jpg

     Adding a new style
     
#. Click :guilabel:`New`

   .. figure:: style_add2.jpg

     Adding a new style

#. Enter "coastline_style" in the text field and click :guilabel:`New`.

   .. figure:: style_add3.jpg

      Specifying style name

#. Scroll to the bottom of the :guilabel:`Style Editor` page and click :guilabel:`Browse`.

#. Navigate to the workshop :file:`data/bayarea` directory, select the :file:`bay_area_coastline.sld` file, and click :guilabel:`Upload`.

   .. figure:: style_add4.jpg
 
      Locating an SLD file

   .. figure:: style_add5.jpg
      :width: 650

      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.

   .. figure:: style_add6.jpg
      :width: 650

      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.

#. Add the new style by clicking :guilabel:`Submit`, followed by :guilabel:`Apply`, and finally :guilabel:`Save`.

#. From the `Config <http://localhost:8080/geoserver/config/index.do>`_ page navigate to :menuselection:`Data --> FeatureTypes`. Select :guilabel:`bay_area_coastline_shp:bay_area_coastline`` from the drop down and click :guilabel:`Edit`.

   .. figure:: style_add7.jpg

     Editing a feature type

#. On the :guilabel:`Feature Type Editor` page set the :guilabel:`Style` by selecting **coastline_style** from the drop down.

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

#. Scroll to the bottom of the page. :guilabel:`Submit`, :guilabel:`Apply`, and :guilabel:`Save`.

#. Repeat steps 1 through 3 from the :ref:`previous <geoserver.basics.map_preview>` module to view the **bay_area_coastline** layer in the **Map Preview**.

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