OpenLayers.Protocol.HTTP - OpenLayers

# OpenLayers. Protocol.HTTP

A basic HTTP protocol for vector layers. Create a new instance with the OpenLayers.Protocol.HTTP constructor.

#### Inherits from

- OpenLayers.Protocol

Summary

OpenLayers. Protocol.HTTP | A basic HTTP protocol for vector layers.
Properties |
url | {String} Service URL, read-only, set through the options passed to constructor.
headers | {Object} HTTP request headers, read-only, set through the options passed to the constructor, Example: {‘Content-Type’: ‘plain/text’}
params | {Object} Parameters of GET requests, read-only, set through the options passed to the constructor, Example: {‘bbox’: ‘5,5,5,5’}
callback | {Object} Function to be called when the read, create, update, delete or commit operation completes, read-only, set through the options passed to the constructor.
scope | {Object} Callback execution scope, read-only, set through the options passed to the constructor.
Constructor |
OpenLayers. Protocol.HTTP | A class for giving layers generic HTTP protocol.
Functions |
destroy | Clean up the protocol.
createCallback | Returns a function that applies the given public method with resp and options arguments.
read | Construct a request for reading new features.
handleRead | Individual callbacks are created for read, create and update, should a subclass need to override each one separately.
create | Construct a request for writing newly created features.
handleCreate | Called the the request issued by create is complete.
update | Construct a request updating modified feature.
handleUpdate | Called the the request issued by update is complete.
delete | Construct a request deleting a removed feature.
handleDelete | Called the the request issued by delete is complete.
handleResponse | Called by CRUD specific handlers.
parseFeatures | Read HTTP response body and return features.
commit | Iterate over each feature and take action based on the feature state.
callUserCallback | This method is used from within the commit method each time an an HTTP response is received from the server, it is responsible for calling the user-supplied callbacks.

### Properties

### url

{String} Service URL, read-only, set through the options passed to constructor.

### headers

{Object} HTTP request headers, read-only, set through the options passed to the constructor, Example: {‘Content-Type’: ‘plain/text’}

### params

{Object} Parameters of GET requests, read-only, set through the options passed to the constructor, Example: {‘bbox’: ‘5,5,5,5’}

### callback

{Object} Function to be called when the read, create, update, delete or commit operation completes, read-only, set through the options passed to the constructor.

### scope

{Object} Callback execution scope, read-only, set through the options passed to the constructor.

### Constructor

### OpenLayers. Protocol.HTTP

A class for giving layers generic HTTP protocol.

#### Parameters

options | {Object} Optional object whose properties will be set on the instance.

#### Valid options include

url | {String}
headers | {Object}
params | {Object}
format | {OpenLayers.Format}
callback | {Function}
scope | {Object}

### Functions

### destroy

> destroy: function()

Clean up the protocol.

### createCallback

> createCallback: function( | method,
> | response,
> | options | )

Returns a function that applies the given public method with resp and options arguments.

#### Parameters

method | {Function} The method to be applied by the callback.
response | {OpenLayers.Protocol.Response} The protocol response object.
options | {Object} Options sent to the protocol method (read, create, update, or delete).

### read

> read: function( | options | )

Construct a request for reading new features.

#### Parameters

options | {Object} Optional object for configuring the request. This object is modified and should not be reused.

#### Valid options

url | {String} Url for the request.
params | {Object} Parameters to get serialized as a query string.
headers | {Object} Headers to be set on the request.
filter | {<OpenLayers.Filter.BBOX>} If a bbox filter is sent, it will be serialized according to the OpenSearch Geo extension (bbox=minx,miny,maxx,maxy). Note that a BBOX filter as the child of a logical filter will not be serialized.

#### Returns

{OpenLayers.Protocol.Response} A response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes, its “features” property is then populated with the the features received from the server.

### handleRead

> handleRead: function( | resp,
> | options | )

Individual callbacks are created for read, create and update, should a subclass need to override each one separately.

#### Parameters

resp | {OpenLayers.Protocol.Response} The response object to pass to the user callback.
options | {Object} The user options passed to the read call.

### create

> create: function( | features,
> | options | )

Construct a request for writing newly created features.

#### Parameters

features | {Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector}
options | {Object} Optional object for configuring the request. This object is modified and should not be reused.

#### Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes, its “features” property is then populated with the the features received from the server.

### handleCreate

> handleCreate: function( | resp,
> | options | )

Called the the request issued by create is complete. May be overridden by subclasses.

#### Parameters

resp | {OpenLayers.Protocol.Response} The response object to pass to any user callback.
options | {Object} The user options passed to the create call.

### update

> update: function( | feature,
> | options | )

Construct a request updating modified feature.

#### Parameters

feature | {OpenLayers.Feature.Vector}
options | {Object} Optional object for configuring the request. This object is modified and should not be reused.

#### Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes, its “features” property is then populated with the the feature received from the server.

### handleUpdate

> handleUpdate: function( | resp,
> | options | )

Called the the request issued by update is complete. May be overridden by subclasses.

#### Parameters

resp | {OpenLayers.Protocol.Response} The response object to pass to any user callback.
options | {Object} The user options passed to the update call.

### delete

> "delete": function( | feature,
> | options | )

Construct a request deleting a removed feature.

#### Parameters

feature | {OpenLayers.Feature.Vector}
options | {Object} Optional object for configuring the request. This object is modified and should not be reused.

#### Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes.

### handleDelete

> handleDelete: function( | resp,
> | options | )

Called the the request issued by delete is complete. May be overridden by subclasses.

#### Parameters

resp | {OpenLayers.Protocol.Response} The response object to pass to any user callback.
options | {Object} The user options passed to the delete call.

### handleResponse

> handleResponse: function( | resp,
> | options | )

Called by CRUD specific handlers.

#### Parameters

resp | {OpenLayers.Protocol.Response} The response object to pass to any user callback.
options | {Object} The user options passed to the create, read, update, or delete call.

### parseFeatures

> parseFeatures: function( | request | )

Read HTTP response body and return features.

#### Parameters

request | {XMLHttpRequest} The request object

#### Returns

{Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} Array of features or a single feature.

### commit

> commit: function( | features,
> | options | )

Iterate over each feature and take action based on the feature state. Possible actions are create, update and delete.

#### Parameters

features | {Array({OpenLayers.Feature.Vector})}
options | {Object} Optional object for setting up intermediate commit callbacks.

#### Valid options

create | {Object} Optional object to be passed to the create method.
update | {Object} Optional object to be passed to the update method.
delete | {Object} Optional object to be passed to the delete method.
callback | {Function} Optional function to be called when the commit is complete.
scope | {Object} Optional object to be set as the scope of the callback.

#### Returns

{Array(OpenLayers.Protocol.Response)} An array of response objects, one per request made to the server, each object’s “priv” property references the corresponding HTTP request.

### callUserCallback

> callUserCallback: function( | resp,
> | options | )

This method is used from within the commit method each time an an HTTP response is received from the server, it is responsible for calling the user-supplied callbacks.

#### Parameters

resp | {OpenLayers.Protocol.Response}
options | {Object} The map of options passed to the commit call.

> read: function( | options | )

Construct a request for reading new features.

> create: function( | features,
> | options | )

Construct a request for writing newly created features.

> update: function( | feature,
> | options | )

Construct a request updating modified feature.

> "delete": function( | feature,
> | options | )

Construct a request deleting a removed feature.

> commit: function( | features,
> | options | )

Iterate over each feature and take action based on the feature state.

> destroy: function()

Clean up the protocol.

> createCallback: function( | method,
> | response,
> | options | )

Returns a function that applies the given public method with resp and options arguments.

> handleRead: function( | resp,
> | options | )

Individual callbacks are created for read, create and update, should a subclass need to override each one separately.

> handleCreate: function( | resp,
> | options | )

Called the the request issued by create is complete.

> handleUpdate: function( | resp,
> | options | )

Called the the request issued by update is complete.

> handleDelete: function( | resp,
> | options | )

Called the the request issued by delete is complete.

> handleResponse: function( | resp,
> | options | )

Called by CRUD specific handlers.

> parseFeatures: function( | request | )

Read HTTP response body and return features.

> callUserCallback: function( | resp,
> | options | )

This method is used from within the commit method each time an an HTTP response is received from the server, it is responsible for calling the user-supplied callbacks.
A class for giving layers generic HTTP protocol.
Abstract vector layer protocol class.
Base class for format reading/writing a variety of formats.
Protocols return Response objects to their users.
Vector features use the OpenLayers.Geometry classes as geometry description.
Close