Decorating a MapΒΆ

WMS Decorations provide a framework for visually annotating images from WMS with absolute, rather than spatial, positioning. This example of decoration include scaleline, legends, and image.

  1. Go to $geoserver_data and create a new directory named layouts and create a new file named boulder_ly.xml inside it.

  2. Inside the boulder_ly.xml file enter the following XML (replace ${geoserver_data} with your actual path, e.g., file://C:/training/geoserver_data ):

    <layout>
            <decoration type="image" affinity="top,left" offset="45,8"
                            size="64,60">
                <option name="url"
                            value="${geoserver_data}/geosolutions-logo-tx.png" />
            </decoration>
    
            <decoration type="text" affinity="bottom,right" offset="3,3">
                    <option name="message" value="Boulder City" />
                    <option name="font-size" value="14" />
                    <option name="font-color" value="#FFFFFF" />
                    <option name="halo-radius" value="1" />
                    <option name="halo-color" value="#000000" />
            </decoration>
    
            <decoration type="scaleline" affinity="bottom,left" offset="3,3" />
    
            <decoration type="legend" affinity="top,right"
                                    offset="6,6" size="auto" />
    </layout>
    
  3. Save and close the file.

  4. Go to the Layer Preview to preview the new map decoration on geosolutions:Mainrd layer. Once the layout boulder_ly.xml is defined, request it by adding format_options=layout:boulder_ly to the request parameters.

    ../_images/decoration2.png

    Map decoration

    The request:

    http://localhost:8083/geoserver/geosolutions/wms?service=WMS&version=1.1.0&request=GetMap&layers=geosolutions:Mainrd&styles=&bbox=3048474.661,1226045.092,3095249.0,1279080.5&width=451&height=512&srs=EPSG:2876&format=application/openlayers&format_options=layout:boulder_ly
    

Note

Zoom-in until the layer and legend appears since for this layer we have scale_denominator based rules. Also you can apply this format_layout to any layer, but be careful with the overalys since you will have all the legends printed out on the right-top side of the map.