Creating a Base Map with a Layer Group

The best way to easily set-up a map with more than one layer for consumption is to create a Layer Group, that is what we are going to do in this section.

  1. Locate the Layer Group link and click it.

    ../_images/group1.png

    Layer Group link

  2. Click the Add new layer group link.

    ../_images/group2.png

    Add new layer group link

  3. Name it test.

    ../_images/group3-1.png
  4. Click the Add layer link:

    ../_images/group3-2.png

    Add new layer

  5. Select the “Mainrd” layer in the popup window.

    ../_images/group4.png

    Select a layer

  6. Add also “BoulderCityLimits” and “bplandmarks”, the final list should look like this:.

    ../_images/group5.png

    List of layers for the group

    Note

    You can use the green arrows to adjust the ordering of the layers until it looks like the above figure.

  7. Click the generate bounds button to have GeoServer compute the group bounds from the layers inside of it.

  8. Scroll to the bottom of the page and then click Save.

  9. If all went well, you should see something like this:

    ../_images/group7.png

    After a successful save.

    Note

    The autogenerated bounds may be too large and you may experience a bad feeling when previewing the map. You can optionally reduce the layer group bounds by inserting manually the bbox values. Good values are the following: minx = 3.057.566,8646; maxx = 3.079.500,65246; miny = 1.241.929,35617; maxy = 1.257.467,5777

The layer group is now ready to be consumed:

  1. Go to the Layer Preview link at the bottom of the lefthand menu.

    ../_images/preview1.png

    Layer Preview

  2. Find the test layer group and click on the OpenLayers link to preview it.

    ../_images/preview3.png

    OpenLayers view

    Note

    Check the browser’s address bar for an interesting sample WMS request for the layer.

  3. As you might have noticed before, a larger, more realistic group has already been configured for you. It is named boulder. Have a look at its definition and add to this the Mainrd layer. Then using the green arrows move the layer at the following position (see the screenshot).

    ../_images/preview3b.png

    A new layer inside the existing layer group.

  4. Then use the Map Preview to display it.

  5. Try clicking in the middle of the map. A couple of tables with more information about the vector features that have been clicked should appear at the bottom.

    ../_images/preview4.png

    Feature info

  6. Try to zoom in more and more. New layers should start to appear. This is scale dependent styling.

Now let’s see how a desktop client (for our case, we use QGIS) handle the layer group and how we can change the way they see it.

Note

QGIS is an Open Source widely used GIS desktop client. Setup packages, for Linux or Windows, can be found from QGIS download.

  1. Ensure that your Geoserver is up, and open a desktop client (our case, QGIS).

  2. Once both GeoServer and QGIS are up, organize their windows so that you can see GeoServer and QGIS ones at the same time.

  3. Now go to the GeoServer home page, where all the capabilities links are kept, right click on the WMS 1.3.0 one and select Copy Link Address from the context menu:

    ../_images/group8.png
  4. From the QGIS menu select Layer>Add Layer>Add WMs/WMTS Layer.. option.

    ../_images/group8-1.png
  5. In the Data Source Manager window press the New button and fill the Connection Details field. Insert the WMS capabilities link you copied from the GeoServer main interface as URL and GeoServer Training as Name. Press OK to save the new connection.

    ../_images/group8-2.png
  6. Press the Connect button, a list of available layers is retrieved and shown. Look at the layer tree. The boulder group is visible as a simple layer and all the layers it contains are actually shown at the same level as the group.

    ../_images/group9.png
  7. Let’s change it so that the layer group internal structure is shown. Go back to the boulder layer group page and change its mode to Named tree, then press the Save button.

    ../_images/group10.png
  8. In our case, we need to make QGIS aware of the change. Go to the browser window, on the left side of QGIS interface, the right click the GeoServer Training item and select Refresh option from context menu.

    ../_images/group11.png
  9. Now most of the layers are contained inside the “boulder” group

    ../_images/group12.png