This Protocol stores feature in the browser via the Gears Database module http://code.google.com
The main advantage is that all the read, create, update and delete operations can be done offline.
OpenLayers. | This Protocol stores feature in the browser via the Gears Database module http://code.google.com |
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. | |
Functions | |
initializeDatabase | |
destroy | Clean up the protocol. |
supported | Determine whether a browser supports Gears |
read | Read all features from the database and return a OpenLayers.Protocol.Response instance. |
unfreezeFeature | |
extractFidFromField | |
create | Create new features into the database. |
update | Construct a request updating modified feature. |
createOrUpdate | Construct a request for updating or creating features in the database. |
freezeFeature | |
getFeatureStateForFreeze | Get the state of the feature to store into the database. |
delete | Delete features from the database. |
createdOffline | 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 | Go over the features and for each take action based on the feature state. |
clear | Removes all rows of the table. |
callUserCallback | 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. |
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.
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. |
{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.
create: function( features, options )
Create new features into the database.
features | {Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} The features to create in the database. |
options | {Object} Optional object for configuring the request. |
{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.
update: function( features, options )
Construct a request updating modified feature.
features | {Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} The features to update in the database. |
options | {Object} Optional object for configuring the request. |
{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.
createOrUpdate: function( features )
Construct a request for updating or creating features in the database.
features | {Array({OpenLayers.Feature.Vector})} or {OpenLayers.Feature.Vector} The feature to create or update in the database. |
{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.
freezeFeature: function( feature )
feature | {OpenLayers.Feature.Vector} |
state | {String} The feature state to store in the database. |
{Array}
getFeatureStateForFreeze: function( feature )
Get the state of the feature to store into the database.
feature | {OpenLayers.Feature.Vector} The feature. |
Returns {String} The state
"delete": function( features, options )
Delete features from the database.
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. |
{OpenLayers.Protocol.Response} An OpenLayers.Protocol.Response object.
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.
feature | {OpenLayers.Feature.Vector} |
{Boolean}
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.
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. |
{Array({OpenLayers.Protocol.Response})} An array of OpenLayers.Protocol.Response objects, one per request made to the database.
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.
options | {Object} The map of options passed to the commit call. |
resp | {OpenLayers.Protocol.Response} |
initializeDatabase: function()
Clean up the protocol.
destroy: function()
Determine whether a browser supports Gears
supported: function()
Read all features from the database and return a OpenLayers.Protocol.Response instance.
read: function( options )
unfreezeFeature: function( row )
extractFidFromField: function( field )
Create new features into the database.
create: function( features, options )
Construct a request updating modified feature.
update: function( features, options )
Construct a request for updating or creating features in the database.
createOrUpdate: function( features )
freezeFeature: function( feature )
Get the state of the feature to store into the database.
getFeatureStateForFreeze: function( feature )
Delete features from the database.
"delete": function( features, options )
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.
createdOffline: function( feature )
Go over the features and for each take action based on the feature state.
commit: function( features, options )
Removes all rows of the table.
clear: function()
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.
callUserCallback: function( options, resp )