gxp.plugins.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.WMSSourceplugin, 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 ArrayCustom 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 additionalmenuTextandbuttonTextproperties. The former will be used as text when the action is used in a menu. The latter will be conditionally used on buttons, only ifshowButtonTextis set to true. The nativetextproperty will unconditionally be used for buttons. Optional, only needed to create custom actions.
-
actionTarget ObjectorStringorArrayWhere 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.Containerproperty 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 BooleanSet to false if the tool should be initialized without activating it. Default is true.
-
autoLoadFeatures BooleanAutomatically load features after a new layer has been set? Default is false.
-
autoSetLayer BooleanWhen nolayeris configured, listen to the viewer’s layerselectionchange event to automatically set the layer. Default is true unlesslayeris configured.
-
autoZoomPage BooleanSet to true to always zoom the map to the currently selected page. Default is false.
-
controlOptions ObjectIf this tool is associated with anOpenLayers.Controlthen this is an optional object to pass to the constructor of the associatedOpenLayers.Control.
-
defaultAction NumberOptional index of an action that should be active by default. Only works for actions that are aGeoExt.Actioninstance.
-
format StringOptional 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 Objectwith 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,autoSetLayerwill be set to false.
-
maxFeatures NumberDefault is 100
-
multi BooleanIf set to true, geometries will be casted to Multi geometries before writing. No casting will be done for reading.
-
outputAction NumberTheactionsarray index of the action that should trigger this tool’s output. Only valid ifactionsis configured. Leave this unconfigured if none of theactionsshould trigger this tool’s output.
-
outputConfig ObjectOptional 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 anoutputTarget.
-
outputTarget StringWhere to add the tool’s output container? This can be any string that references anExt.Containerproperty 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 anExt.Panel, ”.tbar”, ”.bbar” or ”.fbar” has to be appended.
-
paging BooleanShould paging be enabled? Default is true.
-
pagingType IntegerPaging type to use, one of: gxp.plugins.FeatureManager.QUADTREE_PAGING (0) or gxp.plugins.FeatureManager.WFS_PAGING (1)
-
selectStyle ObjectStyle properties that override the default style for selected features.
-
showButtonText Show the
buttonTextan action is configured with, if used as a button. Default is false.
-
symbolizer ObjectAn object with “Point”, “Line” and “Polygon” properties, each with a valid symbolizer object for OpenLayers. Will be used to render features.
-
toggleGroup StringIf 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¶ BooleanIs the tool currently active?
-
FeatureManager.featureLayer¶ OpenLayers.Layer.VectorThe layer associated with this tool’s featureStore.
-
FeatureManager.featureStore¶ gxp.data.WFSFeatureStoreThe FeatureStore that this tool manages.
-
FeatureManager.geometryType¶ StringThe geometry type of the featureLayer
-
FeatureManager.layerRecord¶ GeoExt.data.LayerRecordThe currently selected layer for this FeatureManager
-
FeatureManager.schema¶ GeoExt.data.AttributeStoreor false if thefeatureLayerhas 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: Booleantrue when this tool was activatedActivates 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: actions – ArrayOptional actions to add. If not provided, this.actions will be added.Returns: ArrayThe actions added.
-
FeatureManager.addOutput()¶ Parameters: config – Objectconfiguration for theExt.Componentto be added to theoutputTarget. Properties of this configuration will be overridden by the applicationsoutputConfigfor the tool instance. Tool plugins that want to reuse their output (after being closed by a window or crumb panel) can also provide anExt.Componentinstance here, if it was previously created withaddOutput.Returns: Ext.ComponentThe component added to theoutputTarget.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: Booleantrue when this tool was deactivatedDectivates 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.Boundsthe bounds of the current pageGet 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: id – Stringid 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: - filter –
OpenLayers.FilterOptional filter for the GetFeature request. - callback –
FunctionOptional 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. - scope –
ObjectOptional scope for the callback function.
- filter –
-
FeatureManager.nextPage()¶ Parameters: - callback –
FunctionOptional callback to call when the page is available. The callback will receive the page as 1st argument. - scope –
ObjectOptional scope for the callback.
Load the next page.
- callback –
-
FeatureManager.previousPage()¶ Parameters: - callback –
FunctionOptional callback to call when the page is available. The callback will receive the page as 1st argument. - scope –
ObjectOptional scope for the callback.
Load the previous page.
- callback –
-
FeatureManager.removeOutput()¶ Removes all output created by this tool
-
FeatureManager.setLayer()¶ Parameters: layerRecord – GeoExt.data.LayerRecord. If not provided, the current layer will be unset.Returns: BooleanThe layer was changed.Sets the layer for this tool
-
FeatureManager.setPage()¶ Parameters: - condition –
ObjectObject 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 thenmaxFeaturesfeatures. If it does not, leaves will be created until the top-left page has less thanmaxFeatures, 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 withpreviousPagecalled 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. - callback –
FunctionOptional callback to call when the page is available. The callback will receive the page as 1st argument. - scope –
ObjectOptional 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();
- condition –
-
FeatureManager.showLayer()¶ Parameters: - id –
Stringid of a tool that needs to show this tool’s featureLayer. - display –
String“all” or “selected”. Optional, default is “all”
- id –
-
FeatureManager.visible()¶ Returns: mixed“all”, “selected” or falseAre 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.Toolthe 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:
- tool -
gxp.plugins.FeatureManagerthis tool
- tool -
-
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.FeatureManagerthis tool - layer -
GeoExt.data.LayerRecordthe layerRecord argument passed to the setLayer method
- tool -
-
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.FeatureManagerthis tool - filter -
OpenLayers.Filterthe filter argument passed to the loadFeatures method - callback -
Functionthe callback argument passed to the loadFeatures method - scope -
Objectthe scope argument passed to the loadFeatures method
- tool -
-
beforesave Fired before a transaction is saved.
Listener arguments:
- tool -
gxp.plugins.FeatureManagerthis tool - store -
gxp.data.WFSFeatureStore - params -
ObjectThe params object which can be used to manipulate a transaction request.
- tool -
-
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.FeatureManagerthis tool - condition -
Objectthe condition passed to the setPage method - callback -
Functionthe callback argument passed to the setPage method - scope -
Objectthe scope argument passed to the setPage method
- tool -
-
clearfeatures Fired when features have been cleared by the clearFeatures method.
Listener arguments:
- tool -
gxp.plugins.FeatureManagerthis tool
- tool -
-
deactivate Fired when the tool is deactivated.
Listener arguments: * tool -
gxp.plugins.Toolthe deactivated tool
-
exception Fired when an exception occurs.
Listener arguments:
- tool -
gxp.plugins.FeatureManager`this tool - exceptionReport -
ObjectThe exceptionReport object - msg -
StringThe exception message - records -
ArrayofGeoExt.data.FeatureRecordThe features involved in the failing transaction.
- tool -
-
layerchange Fired after a layer change, as soon as the layer’s schema is available and a
featureStorehas been created.Listener arguments:
- tool -
gxp.plugins.FeatureManagerthis tool - layer -
GeoExt.data.LayerRecordthe new layer - schema -
GeoExt.data.AttributeStoreor false if the layer has no associated WFS FeatureType, or null if no layer is currently selected.
- tool -
-
query Fired after a WFS GetFeature query, when the results are available.
Listener arguments:
- tool -
gxp.plugins.FeatureManagerthis tool - store -
gxp.data.WFSFeatureStore - filter -
OpenLayers.Filterthe filter argument passed to the loadFeatures method
- tool -
-
setpage Fired if paging is on, when a different page is set, but before its features are loaded.
Listener arguments:
- tool -
gxp.plugins.FeatureManagerthis tool - condition -
Objectthe condition passed to the setPage method - callback -
Functionthe callback argument passed to the setPage method - scope -
Objectthe scope argument passed to the setPage method - pageIndex -
Integerthe index of the page - numPages -
Integerthe number of pages
- tool -