gxp.plugins.WMSSource

Extends
ptype
gxp_wmssource
class gxp.plugins.WMSSource(config)

Plugin for using WMS layers with gxp.Viewer instances. The plugin issues a GetCapabilities request to create a store of the WMS’s layers.

Example Use

Configuration in the gxp.Viewer:

defaultSourceType: "gxp_wmssource",
sources: {
    "opengeo": {
        url: "http://suite.opengeo.org/geoserver/wms"
    }
}

A typical configuration for a layer from this source (in the layers array of the viewer’s map config option would look like this:

{
    source: "opengeo",
    name: "world",
    group: "background"
}

n optional ‘getFeatureInfo’ property can also be passed to ustomize the sort order, visibility, & labels for layer attributes.

sample ‘getFeatureInfo’ configuration would look like this:
{
    fields: ["twn_name","pop1990"]
    propertyNames: {"pop1990": "1990 Population",  "twn_name": "Town"}
}

Within the ‘getFeatureInfo’ configuration, the ‘fields’ property determines sort order & visibility (any attributes not included are not displayed) and ‘propertyNames’ specifies the labels for the attributes.

For initial programmatic layer configurations, to leverage lazy loading of the Capabilities document, it is recommended to configure layers with the fields listed in requiredProperties.

Config Options

Configuration properties in addition to those listed for Ext.util.Observable.

baseParams

Object Base parameters to use on the WMS GetCapabilities request.

requiredProperties

Array(String) List of config properties that are required for each layer from this source to allow lazy loading, in addition to name. Default is ["title", "bbox"]. When the source loads layers from a WMS that does not provide layers in all projections, srs should be included in this list. Fallback values are available for title (the WMS layer name), bbox (the map’s maxExtent as array), and srs (the map’s projection, e.g. “EPSG:4326”).

url

String WMS service URL for this source

version

String If specified, the version string will be included in WMS GetCapabilities requests. By default, no version is set.

Public Properties

Public properties in addition to those listed for Ext.util.Observable.

WMSSource.hidden

Boolean Set to true if you don’t want this LayerSource to show up in the AddLayers dialog. Defaults to false.

WMSSource.lazy

Boolean. true when the source is ready, but its store hasn’t been loaded yet (i.e. lazy source). Read-only.

WMSSource.requiredProperties

Array(String) List of config properties that are required for a complete layer configuration, in addition to name.

WMSSource.store

GeoExt.data.LayerStore

WMSSource.title

String A descriptive title for this layer source.

Public Methods

Public methods in addition to those listed for Ext.util.Observable.

WMSSource.createLayerRecord()
Parameters:configObject The application config for this layer.
Returns:GeoExt.data.LayerRecord or null when the source is lazy.

Create a layer record given the config. Applications should check that the source is not lazy` or that the config is complete (i.e. configured with all fields listed in requiredProperties before using this method. Otherwise, it is recommended to use the asynchronous gxp.Viewer.createLayerRecord() method on the target viewer instead, which will load the source’s store to complete the configuration if necessary.

WMSSource.createStore()

Creates a store of layer records. Fires “ready” when store is loaded.

WMSSource.describeLayer()
Parameters:
  • recGeoExt.data.LayerRecord the layer to issue a WMS DescribeLayer request for
  • callbackFunction Callback function. Will be called with an Ext.data.Record from a GeoExt.data.DescribeLayerStore as first argument, or false if the WMS does not support DescribeLayer.
  • scopeObject Optional scope for the callback.

Get a DescribeLayer response from this source’s WMS.

WMSSource.getConfigForRecord()
Parameters:recordGeoExt.data.LayerRecord
Returns:Object

Create a config object that can be used to recreate the given record.

WMSSource.getProjection()
Parameters:layerRecordGeoExt.data.LayerRecord a record from this source’s store
Returns:OpenLayers.Projection A suitable projection for the layerRecord. If the layer is available in the map projection, the map projection will be returned. Otherwise an equal projection, or null if none is available.

Get the projection that the source will use for the layer created in createLayerRecord. If the layer is not available in a projection that fits the map projection, null will be returned.

WMSSource.getSchema()
Parameters:
  • recGeoExt.data.LayerRecord the WMS layer to issue a WFS DescribeFeatureType request for
  • callbackFunction Callback function. Will be called with a GeoExt.data.AttributeStore containing the schema as first argument, or false if the WMS does not support DescribeLayer or the layer is not associated with a WFS feature type.
  • scopeObject Optional scope for the callback.

Gets the schema for a layer of this source, if the layer is a feature layer.

WMSSource.getState()
Returns:Object

Gets the configured source state.

WMSSource.getWFSProtocol()
Parameters:
  • recordGeoExt.data.LayerRecord
  • callbackFunction
  • scopeObject
Returns:

OpenLayers.Protocol.WFS

Creates a WFS protocol for the given WMS layer record.

WMSSource.init()
Parameters:targetObject The object initializing this plugin.

Events

Events in addition to those listed for Ext.util.Observable.

failure

Fires if the layer source fails to load.

ready

Fires when the layer source is ready for action.