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.
Locate the Layer Group link and click it.
Click the Add new layer group link.
Name it
test
.Click the Add layer link:
Select the “Mainrd” layer in the popup window.
Add also “BoulderCityLimits” and “bplandmarks”, the final list should look like this:.
Note
You can use the green arrows to adjust the ordering of the layers until it looks like the above figure.
Click the generate bounds button to have GeoServer compute the group bounds from the layers inside of it.
Scroll to the bottom of the page and then click Save.
If all went well, you should see something like this:
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:
Go to the Layer Preview link at the bottom of the lefthand menu.
Find the test layer group and click on the OpenLayers link to preview it.
Note
Check the browser’s address bar for an interesting sample WMS request for the layer.
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).Then use the Map Preview to display it.
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.
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.
Ensure that your Geoserver is up, and open a desktop client (our case, Udig).
Once both GeoServer and uDig are up, organize their windows so that you can see GeoServer and uDig ones at the same time.
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:
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.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
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
Now most of the layers are contained inside the “boulder” group