require(["esri/layers/WFSLayer"], function(WFSLayer) { /* code goes here */ });
Description
(Added at v3.14)
(Currently in beta)
A layer for OGC Web Feature Services (WFS).
Samples
Search for
samples that use this class.
Class hierarchy
esri/layers/Layer
|_esri/layers/GraphicsLayer
|_esri/layers/WFSLayer
Constructors
Properties
Methods
Events
[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
Events
click | {
event: <Object >
} | Fires when a graphic has been clicked. |
dbl-click | | Fires when a graphic has been double clicked. |
error | {
error: <Error >
} | Fires when there is a problem retrieving a layer. |
graphic-add | {
graphic: <Graphic >
} | Fires when a graphic is added to the GraphicsLayer. |
graphic-draw | {
graphic: <Graphic >
} | Fires when a graphic is drawn. |
graphic-node-add | {
graphic: <Graphic >,
node: <HTMLElement >
} | Fires when a graphic's DOM node is created and added to the layer. |
graphic-node-remove | {
graphic: <Graphic >,
node: <HTMLElement >
} | This event is fired when a graphic's DOM node is removed (consider the node destroyed). |
graphic-remove | {
graphic: <Graphic >
} | Fires when a graphic is removed from the GraphicsLayer. |
graphics-clear | | Fires when all graphics in the GraphicsLayer are cleared. |
mouse-down | <MouseEvent > mouseEvent | Fires when a mouse button is pressed down and the mouse cursor is on a graphic. |
mouse-drag | <MouseEvent > mouseEvent | Fires while the mouse is being dragged until the mouse button is released. |
mouse-move | <MouseEvent > mouseEvent | Fires as the mouse moves through a graphic on the GraphicsLayer. |
mouse-out | <MouseEvent > mouseEvent | Fires as the mouse exits a graphic on the GraphicsLayer. |
mouse-over | <MouseEvent > mouseEvent | Fires when the mouse first enters into a graphic on the GraphicsLayer. |
mouse-up | <MouseEvent > mouseEvent | Fires when a mouse button is released and the mouse cursor is on a graphic. |
opacity-change | {
opacity: <Number >
} | Fires when the layer opacity has been changed, and returns an object with the opacity value. |
resume | | Fires when a layer resumes drawing. |
scale-range-change | | Fires when a layer's minScale and/or maxScale is changed. |
scale-visibility-change | | Fires when a layer's scale visibility changes. |
suspend | | Fires when a layer suspends drawing. |
update | | Fires any time a layer has finished loading or updating itself. |
update-end | {
error: <Error >
} | Fires when a layer has finished updating its content. |
update-start | | Fires when a layer begins to update its content. |
visibility-change | {
visible: <Boolean >
} | Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer. |
Constructor Details
Creates a new WFSLayer object
Parameters:
<Object > options |
Required |
See options table below for full descriptions of the properties needed for this object. |
options
properties:
<Object > customParameters |
Optional |
Use this to append custom parameters to WFS requests. For example, if the service requires an access key, the key can be included as a custom parameter for all the requests.
"customParameters" : {"key": "1R-ADNF-6NCD"}
The custom parameters are applied to GetCapabilities , DescribeFeatureInfo , and GetFeature
|
<InfoTemplate > infoTemplate |
Optional |
The template that defines the content to display in the map info window when the user clicks on a feature. If not specified, the info window will not be displayed. |
<Number > maxFeatures |
Optional |
Specifies the maximum number of features to return in one response. The recommended value depends on the effect the WFS server implementation and data size has on performance. The default value is 100 .
The suggested value range for "ondemand" mode is 1 - 100 . The suggested range for "snapshot" mode is 100 - 1000 . |
<String > mode |
Optional |
The query mode for the WFS layer. Each mode determines when and how many features are sent to the client. The default mode is "snapshot" .
Known values: "snapshot" | "ondemand" . |
<String > name |
Optional |
The simple layer name (excluding the namespace). Use the | character as a deliminator. The default is the first layer in the service.
Example: "name": "citylimits" |
<String > url |
Required |
URL to the WFS server. |
<String > version |
Optional |
OGC WFS version number. The default is "1.1.0".
Known values: "1.0.0" | "1.1.0" | "2.0.0" . |
<String > wkid |
Optional |
The well-known ID of the spatial reference used by the WFSLayer. The default is 3857 .
Supported WKIDs: 3857 | 4326 | 3785 . |
Property Details
class attribute of the layer's node.
(Added at v3.7)
Use this to append custom parameters to WFS requests. For example, if the service requires an access key, the key can be included as a custom parameter for all the requests. The custom parameters are applied to GetCapabilities
, DescribeFeatureInfo
, and GetFeature
. (Added at v3.18)
Sample:
"customParameters" : {"key": "1R-ADNF-6NCD"}
An array of fields in the layer.
An array of features in the layer.
ID assigned to the layer.
Known values: "WfsLayer"
Default value: "WfsLayer"
The InfoTemplate for the layer.
Set if the layer failed to load. (Added at v3.9)
When the layer is loaded, the value becomes "true", and layer properties can be accessed. The
onLoad event is also fired.
Known values: true | false
Maximum visible scale for the layer. If the map is zoomed in beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a maximum scale. (Added at v3.1)
Default value: 0
Minimum visible scale for the layer. If the map is zoomed out beyond this scale, the layer will not be visible. A value of 0 means the layer does not have a visible scale. (Added at v3.1)
Default value: 0
Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency.
Known values: 0.0 - 1.0
Default value: 1.0
The renderer to apply to the layer.
Default value: null
When true, the layer's attribution is displayed on the map. (Added at v3.1)
Known values: true | false
Default value: true
When true, the layer is suspended. A layer is considered to be suspended when one of the following is true:
- The layer is hidden.
- The layer is not visible at the current map scale.
- The layer is explicitly suspended by calling the
Layer.suspend
method.
(Added at v3.1) Known values: true | false
The visibility of the layer.
Known values: true | false
Default value: true
When true, the layer is visible at the current map scale. (Added at v3.1)
Known values: true | false
Method Details
Clears all graphics. It is not recommended to call
clear()
on a
FeatureLayer as the layer automatically manages fetching (from the service) and clearing graphics based on its
mode. Explicitly calling
clear()
to clear the graphics will interfere with the integrity of this process. For feature layers, we recommend using
applyedits() to add, delete, and update features.
Sample:
graphicsLayer.clear();
Disables all mouse events on the graphics layer.
Enables all mouse events on the graphics layer.
Initializes a WFSLayer using the provided JSON object. (Added at v3.17)
Parameters:
<Object > json |
Required |
The input JSON. This should include the required url property. |
<Function > callback |
Optional |
The function to call when the method has completed. The argument in the function is an array of objects representing all layers in the WFS service. |
Returns reference to the map control the layer is added to. Returns null
or undefined
if it is not added to a map. (Added at v3.7)
Returns the layer's DOM node. (Added at v3.7)
Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.
Returns true if the layer is visible at the given scale. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The scale at which to check if the layer is visible. |
Redraws all the graphics in the layer.
Refreshes the features in the WFS layer.
Removes a graphic. It is not recommended to call
remove()
on a
FeatureLayer as the layer automatically manages fetching (from the service) and clearing graphics based on its
mode. Explicitly calling
remove()
to remove the graphics will interfere with the integrity of this process. For feature layers, we recommend using
applyedits() to add, delete, and update features.
Parameters:
<Graphic > graphic |
Required |
The graphic to remove. |
Resumes layer drawing. (Added at v3.1)
Sets the custom parameters used on the WFS layer. It applies to GetCapabilities
, DescribeFeatureType
, and GetFeature
methods.
NOTE: This will update the properties and refresh the layer.
(Added at v3.18)
Specify or change the info template for a layer. (Added at v2.2)
Sample:
require([
"esri/layers/GraphicsLayer", "esri/InfoTemplate", ...
], function(GraphicsLayer, InfoTemplate, ... ) {
var cityLayer = new GraphicsLayer();
var infoTemplate = new InfoTemplate("${CITY_NAME}","${*}");
cityLayer.setInfoTemplate(infoTemplate);
...
});
Sets the default line symbol to be used if no renderer is specified.
Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The maximum scale at which the layer is visible. |
Set the minimum scale for the layer. (Added at v3.1)
Parameters:
<Number > scale |
Required |
The minimum scale at which the layer is visible. |
Initial opacity or transparency of layer. Not supported in Internet Explorer.
Parameters:
<Number > opacity |
Required |
Value from 0 to 1, where 0 is 100% transparent and 1 has no transparency. The default value is 1. |
Sets the default point symbol to be used if no renderer is specified.
Sets the default polygon symbol to be used if no renderer is specified.
Sets the renderer for the graphics layer.
Parameters:
<Renderer > renderer |
Required |
The renderer used for the graphic. |
Set the scale range for the layer. If minScale
and maxScale
are set to 0 then the layer will be visible at all scales. (Added at v3.1)
Parameters:
<Number > minScale |
Required |
The minimum scale at which the layer is visible. |
<Number > maxScale |
Required |
The maximum scale at which the layer is visible. |
Sets the visibility of the layer. When true, the layer is visible.
Parameters:
<Boolean > isVisible |
Required |
Set the visibility of the layer. |
Sets the visibility of the layer to "true".
Suspends layer drawing. (Added at v3.1)
Converts the WFSLayer instance to a JSON object. (Added at v3.17)
Event Details
[ On Style Events | Connect Style Event ]
Fires when a graphic has been clicked. Should be used in favor of onClick. (Added at v3.5)
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when a graphic has been double clicked. Should be used in favor of onDblClick. (Added at v3.5)
Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
Fires when a graphic is added to the GraphicsLayer. Should be used in favor of onGraphicAdd. (Added at v3.5)
Event Object Properties:
<Graphic > graphic |
The added graphic. |
Fires when a graphic is drawn. A graphic is drawn or redrawn when:
- When it is added to the layer.
- When Geometry or Symbol is modified.
- When it enters the viewport and intersects the map extent.
- When the layer is redrawn.
(Added at v3.7) Event Object Properties:
<Graphic > graphic |
Graphic being drawn. When the layer surfaceType is "svg" or "vml" , the graphic's DOM node is accessible with graphic.getNode(). |
Fires when a graphic's DOM node is created and added to the layer. Fires only when the layer surfaceType is "svg"
or "vml"
. (Added at v3.7)
This event is fired when a graphic's DOM node is removed (consider the node destroyed). The DOM node of a graphic is removed when:
- Graphic is removed from the layer.
- Graphic exits the viewport on map navigation.
- When a symbol change cannot be applied to the Graphic without replacing the current node with a new one. For example: when a marker symbol is changed from SimpleMarkerSymbol to PictureMarkerSymbol, onGraphicNodeRemove will be fired for the node that is being replaced (SVG Circle) and onGraphicNodeAdd will be fired for the new node (SVG Image).
Fires only when the layer surfaceType is
"svg"
or
"vml"
.
(Added at v3.7)
Fires when a graphic is removed from the GraphicsLayer. Should be used in favor of onGraphicRemove. (Added at v3.5)
Event Object Properties:
<Graphic > graphic |
The removed graphic. |
Fires when all graphics in the GraphicsLayer are cleared. Should be used in favor of onGraphicsClear. (Added at v3.5)
Fires when a mouse button is pressed down and the mouse cursor is on a graphic. Should be used in favor of onMouseDown. (Added at v3.5)
Fires while the mouse is being dragged until the mouse button is released. Should be used in favor of onMouseDrag. (Added at v3.5)
Fires as the mouse moves through a graphic on the GraphicsLayer. Should be used in favor of onMouseMove. (Added at v3.5)
Fires as the mouse exits a graphic on the GraphicsLayer. Should be used in favor of onMouseOut. (Added at v3.5)
Fires when the mouse first enters into a graphic on the GraphicsLayer. Should be used in favor of onMouseOver. (Added at v3.5)
Fires when a mouse button is released and the mouse cursor is on a graphic. Should be used in favor of onMouseUp. (Added at v3.5)
Fires when the layer opacity has been changed, and returns an object with the opacity value. Should be used in favor of onOpacityChange. (Added at v3.5)
Event Object Properties:
<Number > opacity |
Fires when the layer opacity (transparency) changes. A number property named opacity that indicates the new opacity. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency. |
Fires when a layer resumes drawing. Should be used in favor of onResume. (Added at v3.5)
Fires when a layer's minScale and/or maxScale is changed. Should be used in favor of onScaleRangeChange. (Added at v3.5)
Fires when a layer's scale visibility changes. The scale visibility changes when a layer is initially visible and becomes invisible because the map scale does not intersect the layer's scale range or vice versa. Should be used in favor of onScaleVisibilityChange. (Added at v3.5)
Fires when a layer suspends drawing. Should be used in favor of onSuspend. (Added at v3.5)
Fires when a layer has finished updating its content. It is the responsibility of the subclass to determine when this event is fired. Should be used in favor of onUpdateEnd. (Added at v3.5)
Event Object Properties:
<Error > error |
Optional argument. The error object is available when an error occurs during the update. |
Fires when a layer begins to update its content. It is the responsibility of the subclass to determine when this event is fired. Should be used in favor of onUpdateStart. (Added at v3.5)
Fires when the layer visibility has been changed, and returns an object with a Boolean visible property containing the new visibility value of the layer. Should be used in favor of onVisibilityChange. (Added at v3.5)
Event Object Properties:
<Boolean > visible |
Fires when the layer visibility changes. A boolean property named visible indicates whether or not the layer is visible after visibility changed. |
Fires when a graphic has been clicked.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when a graphic has been double clicked. (Added at v2.0)
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and graphic. |
Fires when there is a problem retrieving a layer. (Added at v1.3)
Fires when a graphic is added to the GraphicsLayer.
Event Object Properties:
<Graphic > graphic |
The added graphic. |
Fires when a graphic is drawn. A graphic is drawn or redrawn when:
- When it is added to the layer.
- When Geometry or Symbol is modified.
- When it enters the viewport and intersects the map extent.
- When the layer is redrawn.
(Added at v3.7) Event Object Properties:
<Object > evt |
The < Graphic > graphic being drawn. When the layer surfaceType is "svg" or "vml" , the graphic's DOM node is accessible with graphic.getNode() . |
Fires when a graphic's DOM node is created and added to the layer. Fires only when the layer surfaceType is "svg"
or "vml"
. (Added at v3.7)
Event Object Properties:
<Object > evt |
An object with the following properties:
- < Graphic > graphic:Graphic being drawn.
- < DOM Node > node: Graphic's DOM Node.
|
This event is fired when a graphic's DOM node is removed (consider the node destroyed). The DOM node of a graphic is removed when:
- Graphic is removed from the layer.
- Graphic exits the viewport on map navigation.
- When a symbol change cannot be applied to the Graphic without replacing the current node with a new one. For example: when a marker symbol is changed from SimpleMarkerSymbol to PictureMarkerSymbol, onGraphicNodeRemove will be fired for the node that is being replaced (SVG Circle) and onGraphicNodeAdd will be fired for the new node (SVG Image).
Fires only when the layer surfaceType is
"svg"
or
"vml"
.
(Added at v3.7) Event Object Properties:
<Object > evt |
An object with the following properties:<Graphic> graphic | Graphic being drawn. | <DOM Node> node | Graphic's DOM node. |
|
Fires when a graphic is removed from the GraphicsLayer.
Event Object Properties:
<Graphic > graphic |
The removed graphic. |
Fires when all graphics in the GraphicsLayer are cleared.
Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map.
In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the onLoad event:
Event Object Properties:
<Layer > layer |
The loaded layer. |
Sample: function init() {
//setting initial extent in constructor
var map = new esri.Map("mapDiv", { extent: new esri.geometry.Extent(...) });
//or use set extent method
var map = new esri.Map("mapDiv");
map.setExtent(new esri.geometry.Extent(...));
//add first layer
map.addLayer(...);
}
Fires when a mouse button is pressed down and the mouse cursor is on a graphic.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires while the mouse is being dragged until the mouse button is released.
Event Object Properties:
<Object > event |
The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires as the mouse moves through a graphic on the GraphicsLayer.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires as the mouse exits a graphic on the GraphicsLayer.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when the mouse first enters into a graphic on the GraphicsLayer.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when a mouse button is released and the mouse cursor is on a graphic.
Event Object Properties:
<Object > event |
The returned object contains screenPoint, mapPoint, and Graphic. |
Fires when the layer opacity has been changed, and returns the opacity value.
Event Object Properties:
<Number > opacity |
Opacity or transparency of layer. Values range from 0.0 to 1.0, where 0.0 is 100% transparent and 1.0 has no transparency. |
This event is fired when the layer's refreshInterval
is modified. (Added at v3.7)
Fires when a layer resumes drawing. (Added at v3.1)
Fires when a layer's minScale and/or maxScale is changed. (Added at v3.1)
Fires when a layer's scale visibility changes. The scale visibility changes when a layer is initially visible and becomes invisible because the map scale does not intersect the layer's scale range or vice versa. (Added at v3.1)
Fires when a layer suspends drawing. (Added at v3.1)
Fires when a layer has finished updating its content. It is the responsibility of the subclass to determine when this event is fired.
Event Object Properties:
<Error > error |
Optional argument. The error object is available when an error occurs during the update. |
Sample: dojo.connect(layer, "onUpdateEnd", layerUpdateCompleted);
function layerUpdateCompleted(error) {
if (error) {
console.log("Update completed with error: ", error);
}
else {
console.log("Update completed");
}
}
Fires when a layer begins to update its content. It is the responsibility of the subclass to determine when this event is fired.
Sample:
dojo.connect(layer, "onUpdateStart", layerUpdateStarted);
function layerUpdateStarted() {
console.log("Update started...");
}
Fires when the layer visibility has been changed, and returns the new visibility.
Event Object Properties:
<Boolean > visbility |
Determines whether the layer is visible on the map. |