gxp.plugins.FeatureManager

Extends
ptype
gxp_featuremanager
class gxp.plugins.FeatureManager(config)

Plugin for a shared feature manager that other tools can reference. Works on layers added by the gxp.plugins.WMSSource plugin, if there is a WFS resource advertized in the layer’s DescribeLayer document.

The FeatureManager handles WFS feature loading, filtering, paging and transactions.

Config Options

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

actions

Array Custom actions for tools that do not provide their own. Array elements are expected to be valid Ext config objects or strings referencing a valid Ext component. Actions provided here may have additional menuText and buttonText properties. The former will be used as text when the action is used in a menu. The latter will be conditionally used on buttons, only if showButtonText is set to true. The native text property will unconditionally be used for buttons. Optional, only needed to create custom actions.

actionTarget

Object or String or Array Where to place the tool’s actions (e.g. buttons or menus)?

In case of a string, this can be any string that references an Ext.Container property on the portal, or a unique id configured on a component.

In case of an object, the object has a “target” and an “index” property, so that the tool can be inserted at a specified index in the target.

actionTarget can also be an array of strings or objects, if the action is to be put in more than one place (e.g. a button and a context menu item).

To reference one of the toolbars of an Ext.Panel, ”.tbar”, ”.bbar” or ”.fbar” has to be appended. The default is “map.tbar”. The viewer’s main MapPanel can always be accessed with “map” as actionTarget. Set to null if no actions should be created.

Some tools provide a context menu. To reference this context menu as actionTarget for other tools, configure an id in the tool’s outputConfig, and use the id with ”.contextMenu” appended. In the snippet below, a layer tree is created, with a “Remove layer” action as button on the tree’s top toolbar, and as menu item in its context menu:

{
    xtype: "gxp_layertree",
    outputConfig: {
        id: "tree",
        tbar: []
    }
}, {
    xtype: "gxp_removelayer",
    actionTarget: ["tree.tbar", "tree.contextMenu"]
}

If a tool has both actions and output, and you want to force it to immediately output to a container, set actionTarget to null. If you want to hide the actions, set actionTarget to false. In this case, you should configure a defaultAction to make sure that an action is active.

autoActivate

Boolean Set to false if the tool should be initialized without activating it. Default is true.

autoLoadFeatures

Boolean Automatically load features after a new layer has been set? Default is false.

autoSetLayer

Boolean When no layer is configured, listen to the viewer’s layerselectionchange event to automatically set the layer. Default is true unless layer is configured.

autoZoomPage

Boolean Set to true to always zoom the map to the currently selected page. Default is false.

controlOptions

Object If this tool is associated with an OpenLayers.Control then this is an optional object to pass to the constructor of the associated OpenLayers.Control.

defaultAction

Number Optional index of an action that should be active by default. Only works for actions that are a GeoExt.Action instance.

format

String Optional response format to use for WFS GetFeature requests. Valid values are “GML2”, “GML3” and “JSON”. By default this is not set, which means that GML3 will be used.

layer

Object with source and name properties. The layer referenced here will be set as soon as it is added to the target’s map. When this option is configured, autoSetLayer will be set to false.

maxFeatures

Number Default is 100

multi

Boolean If set to true, geometries will be casted to Multi geometries before writing. No casting will be done for reading.

outputAction

Number The actions array index of the action that should trigger this tool’s output. Only valid if actions is configured. Leave this unconfigured if none of the actions should trigger this tool’s output.

outputConfig

Object Optional configuration for the output container. This may be useful to override the xtype (e.g. “window” instead of “gx_popup”), or to provide layout configurations when rendering to an outputTarget.

outputTarget

String Where to add the tool’s output container? This can be any string that references an Ext.Container property on the portal, or “map” to access the viewer’s main map. If not provided, a window will be created. To reference one of the toolbars of an Ext.Panel, ”.tbar”, ”.bbar” or ”.fbar” has to be appended.

paging

Boolean Should paging be enabled? Default is true.

pagingType

Integer Paging type to use, one of: gxp.plugins.FeatureManager.QUADTREE_PAGING (0) or gxp.plugins.FeatureManager.WFS_PAGING (1)

selectStyle

Object Style properties that override the default style for selected features.

showButtonText

Show the buttonText an action is configured with, if used as a button. Default is false.

symbolizer

Object An object with “Point”, “Line” and “Polygon” properties, each with a valid symbolizer object for OpenLayers. Will be used to render features.

toggleGroup

String If this tool should be radio-button style toggled with other tools, this string is to identify the toggle group.

Public Properties

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

FeatureManager.active

Boolean Is the tool currently active?

FeatureManager.featureLayer

OpenLayers.Layer.Vector The layer associated with this tool’s featureStore.

FeatureManager.featureStore

gxp.data.WFSFeatureStore The FeatureStore that this tool manages.

FeatureManager.geometryType

String The geometry type of the featureLayer

FeatureManager.layerRecord

GeoExt.data.LayerRecord The currently selected layer for this FeatureManager

FeatureManager.schema
GeoExt.data.AttributeStore or false if the featureLayer has no
associated WFS FeatureType, or null if no layer is currently selected.

Public Methods

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

FeatureManager.activate()
Returns:Boolean true when this tool was activated

Activates this tool. When active, this tool loads the features for the configured layer, or listens to layer changes on the application and loads features for the selected layer.

FeatureManager.addActions()
Parameters:actionsArray Optional actions to add. If not provided, this.actions will be added.
Returns:Array The actions added.
FeatureManager.addOutput()
Parameters:configObject configuration for the Ext.Component to be added to the outputTarget. Properties of this configuration will be overridden by the applications outputConfig for the tool instance. Tool plugins that want to reuse their output (after being closed by a window or crumb panel) can also provide an Ext.Component instance here, if it was previously created with addOutput.
Returns:Ext.Component The component added to the outputTarget.

Adds output to the tool’s outputTarget. This method is meant to be called and/or overridden by subclasses.

FeatureManager.clearFeatures()

Unload all features.

FeatureManager.deactivate()
Returns:Boolean true when this tool was deactivated

Dectivates this tool. When deactivated, this tool won’t listen to layer changes on the application and load features for the selected layer. The current featureLayer will be cleared.

FeatureManager.getPageExtent()
Returns:OpenLayers.Bounds the bounds of the current page

Get the extent of the current page.

FeatureManager.getState()

:return {Object} Gets the configured tool state. Overwrite in subclasses to return anything other than a copy of the initialConfig property.

FeatureManager.hideLayer()
Parameters:idString id of a tool that no longer needs to show this tool’s featureLayer. The layer will be hidden if no more tools need to show it.
FeatureManager.loadFeatures()
Parameters:
  • filterOpenLayers.Filter Optional filter for the GetFeature request.
  • callbackFunction Optional callback to call when the features are loaded. This function will be called with the array of the laoded features (OpenLayers.Feature.Vector) as argument.
  • scopeObject Optional scope for the callback function.
FeatureManager.nextPage()
Parameters:
  • callbackFunction Optional callback to call when the page is available. The callback will receive the page as 1st argument.
  • scopeObject Optional scope for the callback.

Load the next page.

FeatureManager.previousPage()
Parameters:
  • callbackFunction Optional callback to call when the page is available. The callback will receive the page as 1st argument.
  • scopeObject Optional scope for the callback.

Load the previous page.

FeatureManager.removeOutput()

Removes all output created by this tool

FeatureManager.setLayer()
Parameters:layerRecordGeoExt.data.LayerRecord. If not provided, the current layer will be unset.
Returns:Boolean The layer was changed.

Sets the layer for this tool

FeatureManager.setPage()
Parameters:
  • conditionObject Object to tell the method which page to set. If “lonLat” (OpenLayers.LonLat) is provided, the page containing the provided location will be loaded. If only an “index” property (pointing to a page in this tool’s pages array) is provided, the method will load the according page if it has less then maxFeatures features. If it does not, leaves will be created until the top-left page has less than maxFeatures, and this top-left page will be loaded. If index is “last”, the last page of the quad-tree will be loaded. If an additional “next” property is provided (a page object is expected here), the page that would be loaded with previousPage called from the provided page will be set. This is the bottom-right page of the page pointed to with “index”. If the resulting page would be empty, and “allowEmpty” is false, the next matching page will be loaded.
  • callbackFunction Optional callback to call when the page is available. The callback will receive the page as 1st argument.
  • scopeObject Optional scope for the callback.

Sets and loads the page specified by the condition argument. This is usually used to load a page for a specific location, or to load the first or last page of the quad tree.

Sample code to load the page that contains the (0, 0) location:

featureManager.setPage({lonLat: new OpenLayers.LonLat(0, 0)});

Sample code to load the first page of the quad-tree:

featureManager.setPage({index: 0});

Sample code to load the last page of the quad-tree:

featureManager.setPage({index: "last"});

Sample code to load the first page that contains features:

featureManager.setPage();
FeatureManager.showLayer()
Parameters:
  • idString id of a tool that needs to show this tool’s featureLayer.
  • displayString “all” or “selected”. Optional, default is “all”
FeatureManager.visible()
Returns:mixed “all”, “selected” or false

Are we currently showing all features, selected features only or no features?

Events

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

activate

Fired when the tool is activated.

Listener arguments: * tool - gxp.plugins.Tool the activated tool

beforeclearfeatures

Fired when the clearFeatures method is called, before clearing the features. This event can be used to abort clearFeatures before any action is performed, by having a listener return false.

Listener arguments:

beforelayerchange

Fired before a layer change results in destruction of the current featureStore, and creation of a new one. This event can be used to abort the setLayer method before any action is performed, by having a listener return false.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • layer - GeoExt.data.LayerRecord the layerRecord argument passed to the setLayer method
beforequery

Fired before a WFS GetFeature request is issued. This event can be used to abort the loadFeatures method before any action is performed, by having a listener return false.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • filter - OpenLayers.Filter the filter argument passed to the loadFeatures method
  • callback - Function the callback argument passed to the loadFeatures method
  • scope - Object the scope argument passed to the loadFeatures method
beforesave

Fired before a transaction is saved.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • store - gxp.data.WFSFeatureStore
  • params - Object The params object which can be used to manipulate a transaction request.
beforsetpage

Fired if paging is on, before a different page is requested. This event can be used to abort the setPage method before any action is performed, by having a listener return false.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • condition - Object the condition passed to the setPage method
  • callback - Function the callback argument passed to the setPage method
  • scope - Object the scope argument passed to the setPage method
clearfeatures

Fired when features have been cleared by the clearFeatures method.

Listener arguments:

deactivate

Fired when the tool is deactivated.

Listener arguments: * tool - gxp.plugins.Tool the deactivated tool

exception

Fired when an exception occurs.

Listener arguments:

  • tool - gxp.plugins.FeatureManager` this tool
  • exceptionReport - Object The exceptionReport object
  • msg - String The exception message
  • records - Array of GeoExt.data.FeatureRecord The features involved in the failing transaction.
layerchange

Fired after a layer change, as soon as the layer’s schema is available and a featureStore has been created.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • layer - GeoExt.data.LayerRecord the new layer
  • schema - GeoExt.data.AttributeStore or false if the layer has no associated WFS FeatureType, or null if no layer is currently selected.
query

Fired after a WFS GetFeature query, when the results are available.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • store - gxp.data.WFSFeatureStore
  • filter - OpenLayers.Filter the filter argument passed to the loadFeatures method
setpage

Fired if paging is on, when a different page is set, but before its features are loaded.

Listener arguments:

  • tool - gxp.plugins.FeatureManager this tool
  • condition - Object the condition passed to the setPage method
  • callback - Function the callback argument passed to the setPage method
  • scope - Object the scope argument passed to the setPage method
  • pageIndex - Integer the index of the page
  • numPages - Integer the number of pages