Custom Wms Layer Class

THL Toolbox > Developers' Zone > Gis Development > Custom Wms Layer Class

Custom WMS Layer Class

Contributor(s): Tom Benner

The THL uses OpenLayers and GeoServer to create maps on multiple pages on both the main THL site and on its RoR apps. To keep the rendering of features on these maps consistent, a custom WMS was written. This class consolidates all of the SLD-related logic and makes THL-specific WMS layer methods available (e.g. showPlaceNames, setLanguage). The current code is at:

external link: http://thlib.org/places/maps/interactive/scripts/THLWMS.js

The initialize() function is overwritten to add additional WMS parameters that will be used in all instances of this class. Consequently, most WMS layers using this class can be initialized with only one option, a CQL filter, since all the other options are defined in the class. Here's an example of how to use the class to create a layer:

var layer = new OpenLayers.Layer.THLWMS("Nations", {
	CQL_FILTER: "object_type=29"			
});
layer.showPlaceNames();
layer.setLanguage('roman.popular');
map.addLayer(new_layer);

Provided for unrestricted use by the external link: Tibetan and Himalayan Library