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 UDig) handle the layer group and how we can change the way they see it.

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

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

  3. Now go to the GeoServer home page, where all the capabilities links are kept, take the WMS 1.1.1 one and drag&drop it into uDig “Catalog” tab to import the WMS as a uDig data source:

    ../_images/group8.png
  4. 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
  5. 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
  6. In our case, we need to make uDig aware of the change. Right click the root of the capabilities tree and choose the “Reset” command

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

    ../_images/group12.png