OpenLayers v4.0.1 API - Class: WFS

# Class: WFS

This documentation is for OpenLayers v4.0.1. The latest is v.

## ol.format.WFS

Feature format for reading and writing data in the WFS format. By default, supports WFS version 1.1.0. You can pass a GML format as option if you want to read a WFS that contains GML2 (WFS 1.0.0). Also see `ol.format.GMLBase` which is used by this format.

#### new ol.format.WFS(opt_options)

src/ol/format/wfs.js, line 29

  Name | Type | Description
  --- | --- | ---

  `options`

  Optional configuration object.

  Name | Type | Description
  --- | --- | ---
  `featureNS` | Object.<string, string> | string | undefined | The namespace URI used for features.
  `featureType` | Array.<string> | string | undefined | The feature type to parse. Only used for read operations.
  `gmlFormat` | ol.format.GMLBase | undefined | The GML format to use to parse the response. Default is `ol.format.GML3`.
  `schemaLocation` | string | undefined | Optional schemaLocation to use for serialization, this will override the default.

### Extends

- ol.format.XMLFeature

### Methods

#### readFeatureCollectionMetadata(source){ol.WFSFeatureCollectionMetadata|undefined}

src/ol/format/wfs.js, line 165

  Read feature collection metadata of the source.

  Name | Type | Description
  --- | --- | ---
  `source` | Document | Node | Object | string | Source.

  ##### Returns:

  FeatureCollection metadata.

#### readFeatures(source, opt_options){Array.<ol.Feature>}

src/ol/format/wfs.js, line 108

  Read all features from a WFS FeatureCollection.

  Name | Type | Description
  --- | --- | ---
  `source` | Document | Node | Object | string | Source.

  `options`

  Read options.

  Name | Type | Description
  --- | --- | ---
  `dataProjection` | ol.ProjectionLike | Projection of the data we are reading. If not provided, the projection will be derived from the data (where possible) or the `defaultDataProjection` of the format is assigned (where set). If the projection can not be derived from the data and if no `defaultDataProjection` is set for a format, the features will not be reprojected.
  `featureProjection` | ol.ProjectionLike | Projection of the feature geometries created by the format reader. If not provided, features will be returned in the `dataProjection`.

  ##### Returns:

  Features.

#### readProjection(source){ol.proj.Projection}

src/ol/format/wfs.js, line 915

  Read the projection from a WFS source.

  Name | Type | Description
  --- | --- | ---
  `source` | Document | Node | Object | string | Source.

  ##### Returns:

  Projection.

#### readTransactionResponse(source){ol.WFSTransactionResponse|undefined}

src/ol/format/wfs.js, line 142

  Read transaction response of the source.

  Name | Type | Description
  --- | --- | ---
  `source` | Document | Node | Object | string | Source.

  ##### Returns:

  Transaction response.

#### writeGetFeature(options){Node}

src/ol/format/wfs.js, line 783

  Encode format as WFS `GetFeature` and return the Node.

  Name | Type | Description
  --- | --- | ---

  `options`

  Options.

  Name | Type | Description
  --- | --- | ---
  `featureNS` | string | The namespace URI used for features. Required.
  `featurePrefix` | string | The prefix for the feature namespace. Required.
  `featureTypes` | Array.<string> | The feature type names. Required.
  `srsName` | string | undefined | SRS name. No srsName attribute will be set on geometries when this is not provided.
  `handle` | string | undefined | Handle.
  `outputFormat` | string | undefined | Output format.
  `maxFeatures` | number | undefined | Maximum number of features to fetch.
  `geometryName` | string | undefined | Geometry name to use in a BBOX filter.
  `propertyNames` | Array.<string> | undefined | Optional list of property names to serialize.
  `startIndex` | number | undefined | Start index to use for WFS paging. This is a WFS 2.0 feature backported to WFS 1.1.0 by some Web Feature Services.
  `count` | number | undefined | Number of features to retrieve when paging. This is a WFS 2.0 feature backported to WFS 1.1.0 by some Web Feature Services. Please note that some Web Feature Services have repurposed `maxfeatures` instead.
  `bbox` | ol.Extent | undefined | Extent to use for the BBOX filter.
  `filter` | ol.format.filter.Filter | undefined | Filter condition. See `ol.format.filter` for more information.
  `resultType` | string | undefined | Indicates what response should be returned, E.g. `hits` only includes the `numberOfFeatures` attribute in the response and no features.

  ##### Returns:

  Result.

#### writeTransaction(inserts, updates, deletes, options){Node}

src/ol/format/wfs.js, line 850

  Encode format as WFS `Transaction` and return the Node.

  Name | Type | Description
  --- | --- | ---
  `inserts` | Array.<ol.Feature> | The features to insert.
  `updates` | Array.<ol.Feature> | The features to update.
  `deletes` | Array.<ol.Feature> | The features to delete.

  `options`

  Write options.

  Name | Type | Description
  --- | --- | ---
  `featureNS` | string | The namespace URI used for features. Required.
  `featurePrefix` | string | The prefix for the feature namespace. Required.
  `featureType` | string | The feature type name. Required.
  `srsName` | string | undefined | SRS name. No srsName attribute will be set on geometries when this is not provided.
  `handle` | string | undefined | Handle.
  `nativeElements` | Array.<Object> | Native elements. Currently not supported. Required.
  `gmlOptions` | olx.format.GMLOptions | undefined | GML options for the WFS transaction writer.

  ##### Returns:

  Result.