Month: July 2012

Annotation layers in GeoServer.

Posted by – Saturday 2012-07-21

Currently I am working in a project that requires switching from MapServer to GeoServer. As a newcomer to the latter, one of the things I miss is MapServer’s annotation layers. An annotation layer is one that just shows labels, like names of towns or countries. In this post we will see how annotation layers can be implemented using GeoServer.

1. The arena.

In our example there is already an existing WMS layer named ‘municipalities’, that contains the borders of some municipalities of Galicia and whose geometry type is multipolygon. The data source is a shapefile. The following screenshot – taken from GeoServer’s administration application – shows the attributes the municipalities have.

GeoServer screenshot

Our goal is showing the municipalities names in a different WMS layer, so an user of the WMS service can toggle the visibility of this annotation layer, that is, being able to show or hide, in every moment, the municipalities’ names. The names of the municipalities are stored in the attribute ‘NOMBRE’.


Styling OpenLayers NavigationHistory control.

Posted by – Tuesday 2012-07-10

In this post we will see how to style the default OpenLayers NavigationHistory control, that is, changing the icons shown by the two buttons created by this control.

1. The arena.

First, the Javascript code used to create this control and to add it to the map is the shown below:

var map 
   = new'map'));


var navHistory 
   = new OpenLayers.Controls.NavigationHistory();


var element
   = document.getElementById('navigation-history');
var navHistoryPanel 
   = new OpenLayers.Control.Panel({div: element});


Custom legend icons in MapServer.

Posted by – Thursday 2012-07-05

As seen in a recent post in this blog, MapServer implements the optional WMS request GetLegendGraphic.

You can find that the generated icons do not fit your needs, and prefer that MapServer returns custom legend icons provided by you. Let’s see how can it be accomplished.

First, is convenient that in your LEGEND object you supply the icons size; in our example, it will be 20×20 pixels.

    KEYSIZE 20 20
END # end of legend object