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 navigate to Style.
Click New
Enter “manird” in the Name field and notice the file upload dialogue SLD file.
Navigate to the workshop
data/user_data/
directory, select thefoss4g_mainrd.sld
file, and click Upload.Note
In GeoServer, styles are represented via SLD (Styled Layer Descriptor) documents. SLD is an XML format for specifying the symbolization of a layer. 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 Submit. Once it’s save, you should see something like this:
After having created the style, it’s time to apply it to a vector layer. Click on the Layers link.
Select the “Mainrd” on the Layers page.
Select the Publish tab.
Assign the new created style “mainrd” as the default style.
Warning
Many new users mistake the Available Styles for the Default Style, please take into account that they are different, the default one allows that style to be used implicitly when no style is specified in a map request, while the available ones are just optional compatible styles.
Note
Geoserver 2.x assigns a default style depending on the geometry of the objects and the type, for example: line, poly, raster, point.
Scroll to the bottom of the page and hit Save.
Use the map preview to show how the style, zoom in an notice the scale dependencies