Styles

Default Styles

For each type, GeoServer has default style that is used.

If we look at our Waterways layer, we see it is gray (the default polygon style).

We’d like to make this blue.

../../_images/1-new-style-gray.png

Create a Style

1. Click Styles on the left menu

../../_images/new-style-start.png

2. Click the “Add new style” link

../../_images/new-style-start-2.png ../../_images/spacer6.png

3. For name, enter ‘WaterStyle’. For Workspace, select postgis.

../../_images/new-style-water.png

4. In “Copy from existing style” dropdown, select green

../../_images/new-style-green.png ../../_images/spacer6.png

5. Click the “copy” link to the right of the dropdown

../../_images/new-style.png ../../_images/spacer6.png

6. As seen below, this loads the existing ‘green’ style into the style editor. We will use this to create our WaterStyle blue.

../../_images/new-style-2.png

Copy an Existing Style

Now that we have loaded the ‘green’ style to use as our template, we will update it to blue. To do so,

1. Update the required lines, as shown below:

../../_images/new-style-3.png ../../_images/spacer6.png

2. Click ‘Validate’ to check for errors. If no errors, click the Save button. Your new Style, “Waterways” should now appear in the Styles list.

../../_images/new-style-4.png ../../_images/spacer6.png ../../_images/spacer6.png

Apply Style

1. Click the Layers button in the left menu

../../_images/spacer6.png

2. Select the waterways layer

../../_images/new-style-5.png

3. In the Publishing tab, select postgis:WaterStyle from the Default Style dropsown

../../_images/new-style-6.png ../../_images/spacer6.png

4. On select, we should see the thumbnail reflect the blue color we chose above

../../_images/select-syle-1.png ../../_images/spacer6.png

5. Click the Save button.

If we now preview our layer in Layer Preview, our layer is now blue.

../../_images/select-syle-2.png ../../_images/spacer6.png ../../_images/spacer6.png