Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: WFSLayer

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). WFSLayer requires using a proxy page. See the Using the proxy guide page for details about setting up a proxy. Note that WFSLayer was updated for 3.17 and the API Reference have changed to reflect the new WFSLayer.

Samples

Search for samples that use this class.

Class hierarchy

esri/layers/Layer
|_esri/layers/GraphicsLayer
  |_esri/layers/WFSLayer

Constructors

NameSummary
new WFSLayer(options)Creates a new WFSLayer object.

Properties

NameTypeSummary
classNameStringclass attribute of the layer's node.
customParametersObjectUse this to append custom parameters to WFS requests.
fieldsField[]An array of fields in the layer.
graphicsGraphic[]An array of features in the layer.
idStringID assigned to the layer.
infoTemplateInfoTemplateThe InfoTemplate for the layer.
loadErrorErrorSet if the layer failed to load.
loadedBooleanWhen the layer is loaded, the value becomes "true", and layer properties can be accessed.
maxScaleNumberMaximum visible scale for the layer.
minScaleNumberMinimum visible scale for the layer.
opacityNumberOpacity or transparency of layer.
rendererRendererThe renderer to apply to the layer.
showAttributionBooleanWhen true, the layer's attribution is displayed on the map.
suspendedBooleanWhen true, the layer is suspended.
urlStringURL to the ArcGIS Server REST resource that represents a map service.
visibleBooleanThe visibility of the layer.
visibleAtMapScaleBooleanWhen true, the layer is visible at the current map scale.

Methods

NameReturn typeSummary
clear()NoneClears all graphics.
disableMouseEvents()NoneDisables all mouse events on the graphics layer.
enableMouseEvents()NoneEnables all mouse events on the graphics layer.
fromJson(json)NoneCreates a WFSLayer using the provided JSON object.
getMap()MapReturns reference to the map control the layer is added to.
getNode()HTMLElementReturns the layer's DOM node.
hide()NoneSets the visibility of the layer to "false".
isVisibleAtScale(scale)BooleanReturns true if the layer is visible at the given scale.
redraw()NoneRedraws all the graphics in the layer.
refresh()NoneRefreshes the features in the WFS layer.
remove(graphic)GraphicRemoves a graphic.
resume()NoneResumes layer drawing.
setCustomParameters(customParameters)NoneSets the custom parameters used on the WFS layer.
setInfoTemplate(infoTemplate)NoneSpecify or change the info template for a layer.
setLineSymbol()NoneSets the default line symbol to be used if no renderer is specified.
setMaxScale(scale)NoneSet the maximum scale for the layer.
setMinScale(scale)NoneSet the minimum scale for the layer.
setOpacity(opacity)NoneInitial opacity or transparency of layer.
setPointSymbol()NoneSets the default point symbol to be used if no renderer is specified.
setPolygonSymbol()NoneSets the default polygon symbol to be used if no renderer is specified.
setRenderer(renderer)NoneSets the renderer for the graphics layer.
setScaleRange(minScale, maxScale)NoneSet the scale range for the layer.
setVisibility(isVisible)NoneSets the visibility of the layer.
show()NoneSets the visibility of the layer to "true".
suspend()NoneSuspends layer drawing.
toJson()ObjectConverts the WFSLayer instance to a JSON object.

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

NameEvent ObjectSummary
click
{
  event: <Object>
}
Fires when a graphic has been clicked.
dbl-clickFires 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-clearFires when all graphics in the GraphicsLayer are cleared.
mouse-down<MouseEvent> mouseEventFires when a mouse button is pressed down and the mouse cursor is on a graphic.
mouse-drag<MouseEvent> mouseEventFires while the mouse is being dragged until the mouse button is released.
mouse-move<MouseEvent> mouseEventFires as the mouse moves through a graphic on the GraphicsLayer.
mouse-out<MouseEvent> mouseEventFires as the mouse exits a graphic on the GraphicsLayer.
mouse-over<MouseEvent> mouseEventFires when the mouse first enters into a graphic on the GraphicsLayer.
mouse-up<MouseEvent> mouseEventFires 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.
resumeFires when a layer resumes drawing.
scale-range-changeFires when a layer's minScale and/or maxScale is changed.
scale-visibility-changeFires when a layer's scale visibility changes.
suspendFires when a layer suspends drawing.
updateFires any time a layer has finished loading or updating itself.
update-end
{
  error: <Error>
}
Fires when a layer has finished updating its content.
update-startFires 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

new WFSLayer(options)

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

<String> className

class attribute of the layer's node. (Added at v3.7)

<Object> customParameters

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"}

<Field[]> fields

An array of fields in the layer.

<Graphic[]> graphics

An array of features in the layer.

<String> id

ID assigned to the layer.
Known values: "WfsLayer"
Default value: "WfsLayer"

<InfoTemplate> infoTemplate

The InfoTemplate for the layer.

<Error> loadError

Set if the layer failed to load. (Added at v3.9)

<Boolean> loaded

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

<Number> maxScale

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

<Number> minScale

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

<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.
Known values: 0.0 - 1.0
Default value: 1.0

<Renderer> renderer

The renderer to apply to the layer.
Default value: null

<Boolean> showAttribution

When true, the layer's attribution is displayed on the map. (Added at v3.1)
Known values: true | false
Default value: true

<Boolean> suspended

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

<String> url

URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use Services Directory. An example URL for the Street Map service on ArcGIS Online is:
http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer. (Added at v1.2)

<Boolean> visible

The visibility of the layer.
Known values: true | false
Default value: true

<Boolean> visibleAtMapScale

When true, the layer is visible at the current map scale. (Added at v3.1)
Known values: true | false
Method Details

clear()

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();

disableMouseEvents()

Disables all mouse events on the graphics layer.

enableMouseEvents()

Enables all mouse events on the graphics layer.

fromJson(json)

Creates a WFSLayer using the provided JSON object. (Added at v3.17)
Parameters:
<Object> json Required The input JSON.

getMap()

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)
Return type: Map

getNode()

Returns the layer's DOM node. (Added at v3.7)
Return type: HTMLElement

hide()

Sets the visibility of the layer to "false". The layer is not removed, but it is hidden from view.

isVisibleAtScale(scale)

Returns true if the layer is visible at the given scale. (Added at v3.1)
Return type: Boolean
Parameters:
<Number> scale Required The scale at which to check if the layer is visible.

redraw()

Redraws all the graphics in the layer.

refresh()

Refreshes the features in the WFS layer.

remove(graphic)

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.
Return type: Graphic
Parameters:
<Graphic> graphic Required The graphic to remove.

resume()

Resumes layer drawing. (Added at v3.1)

setCustomParameters(customParameters)

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)
Parameters:
<Object> customParameters Required The customParameters object used append WFS requests.

setInfoTemplate(infoTemplate)

Specify or change the info template for a layer. (Added at v2.2)
Parameters:
<InfoTemplate> infoTemplate Required The new info template.
Sample:
require([
  "esri/layers/GraphicsLayer", "esri/InfoTemplate", ... 
], function(GraphicsLayer, InfoTemplate, ... ) {
  var cityLayer = new GraphicsLayer();

  var infoTemplate = new InfoTemplate("${CITY_NAME}","${*}");

  cityLayer.setInfoTemplate(infoTemplate);
  ...
});

setLineSymbol()

Sets the default line symbol to be used if no renderer is specified.

setMaxScale(scale)

Set the maximum scale for the layer. (Added at v3.1)
Parameters:
<Number> scale Required The maximum scale at which the layer is visible.

setMinScale(scale)

Set the minimum scale for the layer. (Added at v3.1)
Parameters:
<Number> scale Required The minimum scale at which the layer is visible.

setOpacity(opacity)

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.

setPointSymbol()

Sets the default point symbol to be used if no renderer is specified.

setPolygonSymbol()

Sets the default polygon symbol to be used if no renderer is specified.

setRenderer(renderer)

Sets the renderer for the graphics layer.
Parameters:
<Renderer> renderer Required The renderer used for the graphic.

setScaleRange(minScale, maxScale)

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.

setVisibility(isVisible)

Sets the visibility of the layer. When true, the layer is visible.
Parameters:
<Boolean> isVisible Required Set the visibility of the layer.

show()

Sets the visibility of the layer to "true".

suspend()

Suspends layer drawing. (Added at v3.1)

toJson()

Converts the WFSLayer instance to a JSON object. (Added at v3.17)
Return type: Object
Event Details
[ On Style Events | Connect Style Event ]

click

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.

dbl-click

Fires when a graphic has been double clicked. Should be used in favor of onDblClick. (Added at v3.5)

error

Fires when there is a problem retrieving a layer. Should be used in favor of onError. (Added at v3.5)
Event Object Properties:
<Error> error ArcGIS Server error message returned in a JavaScript error object.

graphic-add

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.

graphic-draw

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().

graphic-node-add

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:
<Graphic> graphic Graphic being drawn.
<HTMLElement> node Graphic's DOM node.

graphic-node-remove

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:
<Graphic> graphic Graphic being drawn.
<HTMLElement> node Graphic's DOM node.

graphic-remove

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.

graphics-clear

Fires when all graphics in the GraphicsLayer are cleared. Should be used in favor of onGraphicsClear. (Added at v3.5)

mouse-down

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)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-drag

Fires while the mouse is being dragged until the mouse button is released. Should be used in favor of onMouseDrag. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-move

Fires as the mouse moves through a graphic on the GraphicsLayer. Should be used in favor of onMouseMove. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-out

Fires as the mouse exits a graphic on the GraphicsLayer. Should be used in favor of onMouseOut. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-over

Fires when the mouse first enters into a graphic on the GraphicsLayer. Should be used in favor of onMouseOver. (Added at v3.5)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

mouse-up

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)
Event Object:
<MouseEvent> mouseEvent A standard DOM MouseEvent with additional properties mapPoint and screenPoint.

opacity-change

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.

resume

Fires when a layer resumes drawing. Should be used in favor of onResume. (Added at v3.5)

scale-range-change

Fires when a layer's minScale and/or maxScale is changed. Should be used in favor of onScaleRangeChange. (Added at v3.5)

scale-visibility-change

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)

suspend

Fires when a layer suspends drawing. Should be used in favor of onSuspend. (Added at v3.5)

update

Fires any time a layer has finished loading or updating itself. For an ArcGISTiledMapServiceLayer, the event fires when all required tiles have been retrieved and displayed. For an ArcGISDynamicMapServiceLayer or ArcGISImageServiceLayer, the event fires when the map image has been retrieved and displayed. For a GraphicsLayer, the event fires when all graphics have been redrawn after a pan or zoom. Deprecated at v2.0. Use update-start and update-end instead. (Added at v3.6)

update-end

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.

update-start

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)

visibility-change

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.
Show Modal