On Wed, May 19, 2010 at 3:44 PM, Frank Broniewski <[email protected]> wrote: > Hello all, > > I am currently (virtually ;-))fighting to understand how I can make an > editable layer in OpenLayers. Especially the connection between the > save-strategy and the protocol is difficult to understand. I already > searched the docs and the mailing list, but was unable to find some kind > of definition what exactly a strategy or a protocol is and for what kind > of "behavoir" they are responsible. > > I managed to create a working example, where I could edit/create/modify > features and the changes were sent to my server but I really lack > understanding how things work together ... > > var points = new OpenLayers.Layer.Vector( > 'Viaah Points', > { > 'protocol' : new OpenLayers.Protocol.HTTP( > { > 'url' : '/my/layer.geojson', > 'format' : new OpenLayers.Format.GeoJSON() > } > ), > 'strategies' : [ > new OpenLayers.Strategy.BBOX(), > new OpenLayers.Strategy.Save({auto:true}) > ] > } > ); > > I added a standard editing toolbar, and with the auto:true save-strategy > I could see the requests sent to the server in firebug. > > From what I have guessed so far: Is it true that the save-strategy uses > the protocols methods for read/update/create/delete depending on the > edit-actions taken by the user?
The save strategy just calls protocol.commit(). See <http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Strategy/Save.js#L178>. The protocol's commit method looks at the states of the features and calls the appropriate method (update/create/delete). See <http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js#L519>. > And I presume it's somewhat hard-coded, > that updates are done by a HTTP PUT, create by HTTP POST etc. ? Yes. > In the > mailing lists post I often saw a callback function mentioned for the > protocol - does this function get called after the request has been sent > to the server? No, after the response is received. > > I am sure I have more questions, but these are the most basic ones > concerning editing of features. Any info on these internals is greatly > welcome The code is a great information source to know about the internals of OpenLayers :-) -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : [email protected] http://www.camptocamp.com _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
