OpenLayers.Protocol.SQL.Gears

This Protocol stores feature in the browser via the Gears Database module http://code.google.com/apis/gears/api_database.html.

The main advantage is that all the read, create, update and delete operations can be done offline.

Inherits from

Summary
OpenLayers.Protocol.SQL.GearsThis Protocol stores feature in the browser via the Gears Database module http://code.google.com/apis/gears/api_database.html.
Properties
FID_PREFIX{String}
NULL_GEOMETRY{String}
NULL_FEATURE_STATE{String}
jsonParser{OpenLayers.Format.JSON}
wktParser{OpenLayers.Format.WKT}
fidRegExp{RegExp} Regular expression to know whether a feature was created in offline mode.
saveFeatureState{Boolean} Whether to save the feature state (<OpenLayers.State>) into the database, defaults to true.
typeOfFid{String} The type of the feature identifier, either “number” or “string”, defaults to “string”.
db{GearsDatabase}
Constructor
OpenLayers.Protocol.SQL.Gears
Functions
initializeDatabase
destroyClean up the protocol.
supportedDetermine whether a browser supports Gears
readRead all features from the database and return a OpenLayers.Protocol.Response instance.
unfreezeFeature
extractFidFromField
createCreate new features into the database.
updateConstruct a request updating modified feature.
createOrUpdateConstruct a request for updating or creating features in the database.
freezeFeature
getFeatureStateForFreezeGet the state of the feature to store into the database.
deleteDelete features from the database.
createdOfflineReturns true if the feature had a feature id when it was created in the Gears database, false otherwise; this is determined by checking the form of the feature’s fid value.
commitGo over the features and for each take action based on the feature state.
clearRemoves all rows of the table.
callUserCallbackThis method is called from within commit each time a request is made to the database, it is responsible for calling the user-supplied callbacks.

Properties

FID_PREFIX

{String}

NULL_GEOMETRY

{String}

NULL_FEATURE_STATE

{String}

fidRegExp

{RegExp} Regular expression to know whether a feature was created in offline mode.

saveFeatureState

{Boolean} Whether to save the feature state (<OpenLayers.State>) into the database, defaults to true.

typeOfFid

{String} The type of the feature identifier, either “number” or “string”, defaults to “string”.

db

{GearsDatabase}

Constructor

OpenLayers.Protocol.SQL.Gears

Functions

initializeDatabase

initializeDatabase: function()

destroy

destroy: function()

Clean up the protocol.

supported

supported: function()

Determine whether a browser supports Gears

Returns

{Boolean} The browser supports Gears

read

read: function(options)

Read all features from the database and return a OpenLayers.Protocol.Response instance.  If the options parameter contains a callback attribute, the function is called with the response as a parameter.

Parameters

options{Object} Optional object for configuring the request; it can have the {Boolean} property “noFeatureStateReset” which specifies if the state of features read from the Gears database must be reset to null, if “noFeatureStateReset” is undefined or false then each feature’s state is reset to null, if “noFeatureStateReset” is true the feature state is preserved.

Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.

unfreezeFeature

unfreezeFeature: function(row)

Parameters

row{ResultSet}

Returns

{OpenLayers.Feature.Vector}

extractFidFromField

extractFidFromField: function(field)

Parameters

field{String}

Returns {String} or {Number} The fid.

create

create: function(features,
options)

Create new features into the database.

Parameters

features{Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} The features to create in the database.
options{Object} Optional object for configuring the request.

Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.

update

update: function(features,
options)

Construct a request updating modified feature.

Parameters

features{Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} The features to update in the database.
options{Object} Optional object for configuring the request.

Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.

createOrUpdate

createOrUpdate: function(features)

Construct a request for updating or creating features in the database.

Parameters

features{Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} The feature to create or update in the database.

Returns

{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.

freezeFeature

freezeFeature: function(feature)

Parameters

feature{OpenLayers.Feature.Vector}
state{String} The feature state to store in the database.

Returns

{Array}

getFeatureStateForFreeze

getFeatureStateForFreeze: function(feature)

Get the state of the feature to store into the database.

Parameters

feature{OpenLayers.Feature.Vector} The feature.

Returns {String} The state

delete

"delete": function(features,
options)

Delete features from the database.

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.

createdOffline

createdOffline: function(feature)

Returns true if the feature had a feature id when it was created in the Gears database, false otherwise; this is determined by checking the form of the feature’s fid value.

Parameters

feature{OpenLayers.Feature.Vector}

Returns

{Boolean}

commit

commit: function(features,
options)

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

Parameters

features{Array({OpenLayers.Feature.Vector})}
options{Object} Object whose possible keys are “create”, “update”, “delete”, “callback” and “scope”, the values referenced by the first three are objects as passed to the “create”, “update”, and “delete” methods, the value referenced by the “callback” key is a function which is called when the commit operation is complete using the scope referenced by the “scope” key.

Returns

{Array({OpenLayers.Protocol.Response})} An array of OpenLayers.Protocol.Response objects, one per request made to the database.

clear

clear: function()

Removes all rows of the table.

callUserCallback

callUserCallback: function(options,
resp)

This method is called from within commit each time a request is made to the database, it is responsible for calling the user-supplied callbacks.

Parameters

options{Object} The map of options passed to the commit call.
resp{OpenLayers.Protocol.Response}
A parser to read/write JSON safely.
Class for reading and writing Well-Known Text.
initializeDatabase: function()
destroy: function()
Clean up the protocol.
supported: function()
Determine whether a browser supports Gears
read: function(options)
Read all features from the database and return a OpenLayers.Protocol.Response instance.
Protocols return Response objects to their users.
unfreezeFeature: function(row)
extractFidFromField: function(field)
create: function(features,
options)
Create new features into the database.
update: function(features,
options)
Construct a request updating modified feature.
createOrUpdate: function(features)
Construct a request for updating or creating features in the database.
freezeFeature: function(feature)
getFeatureStateForFreeze: function(feature)
Get the state of the feature to store into the database.
"delete": function(features,
options)
Delete features from the database.
createdOffline: function(feature)
Returns true if the feature had a feature id when it was created in the Gears database, false otherwise; this is determined by checking the form of the feature’s fid value.
commit: function(features,
options)
Go over the features and for each take action based on the feature state.
clear: function()
Removes all rows of the table.
callUserCallback: function(options,
resp)
This method is called from within commit each time a request is made to the database, it is responsible for calling the user-supplied callbacks.
Abstract SQL protocol class.
Vector features use the OpenLayers.Geometry classes as geometry description.
Close