ALKMaps.Strategy.Save

A strategy that commits newly created or modified features.  By default the strategy waits for a call to save before persisting changes.  By configuring the strategy with the auto option, changes can be saved automatically.

Inherits from

Summary
ALKMaps.Strategy.SaveA strategy that commits newly created or modified features.
Properties
events{ALKMaps.Events} An events object that handles all events on the strategy object.
events{ALKMaps.Events} Events instance for triggering this protocol events.
auto{Boolean | Number} Auto-save.
timer{Number} The id of the timer.
Constructor
ALKMaps.Strategy.SaveCreate a new Save strategy.
Functions
activateActivate the strategy.
deactivateDeactivate the strategy.
triggerSaveRegistered as a listener.
saveTell the layer protocol to commit unsaved features.
onCommitCalled after protocol commit.

Properties

events

{ALKMaps.Events} An events object that handles all events on the strategy object.

Register a listener for a particular event with the following syntax

strategy.events.register(type, obj, listener);

Supported event types

startTriggered before saving
successTriggered after a successful transaction
failTriggered after a failed transaction

events

{ALKMaps.Events} Events instance for triggering this protocol events.

auto

{Boolean | Number} Auto-save.  Default is false.  If true, features will be saved immediately after being added to the layer and with each modification or deletion.  If auto is a number, features will be saved on an interval provided by the value (in seconds).

timer

{Number} The id of the timer.

Constructor

ALKMaps.Strategy.Save

Create a new Save strategy.

Parameters

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

Functions

activate

activate: function()

Activate the strategy.  Register any listeners, do appropriate setup.

Returns

{Boolean} The strategy was successfully activated.

deactivate

deactivate: function()

Deactivate the strategy.  Unregister any listeners, do appropriate tear-down.

Returns

{Boolean} The strategy was successfully deactivated.

triggerSave

triggerSave: function(event)

Registered as a listener.  Calls save if a feature has insert, update, or delete state.

Parameters

event{Object} The event this function is listening for.

save

save: function(features)

Tell the layer protocol to commit unsaved features.  If the layer projection differs from the map projection, features will be transformed into the layer projection before being committed.

Parameters

features{Array} Features to be saved.  If null, then default is all features in the layer.  Features are assumed to be in the map projection.

onCommit

onCommit: function(response)

Called after protocol commit.

Parameters

response{ALKMaps.Protocol.Response} A response object.
activate: function()
Activate the strategy.
deactivate: function()
Deactivate the strategy.
triggerSave: function(event)
Registered as a listener.
save: function(features)
Tell the layer protocol to commit unsaved features.
onCommit: function(response)
Called after protocol commit.
{Boolean | Number} Auto-save.
Abstract vector layer strategy class.
Protocols return Response objects to their users.
Close