[OpenLayers-Commits] r10855 - sandbox/sonxurxo/editfeature/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Oct 21 04:36:46 EDT 2010


Author: sonxurxo
Date: 2010-10-21 01:36:46 -0700 (Thu, 21 Oct 2010)
New Revision: 10855

Modified:
   sandbox/sonxurxo/editfeature/examples/edit-feature.html
Log:
First Commit - removing trash

Modified: sandbox/sonxurxo/editfeature/examples/edit-feature.html
===================================================================
--- sandbox/sonxurxo/editfeature/examples/edit-feature.html	2010-10-21 08:30:32 UTC (rev 10854)
+++ sandbox/sonxurxo/editfeature/examples/edit-feature.html	2010-10-21 08:36:46 UTC (rev 10855)
@@ -66,6 +66,10 @@
         <script>
             var map;
             
+            /*
+             * This class inherits DrawFeature control. It adds a keyboard handler to manage ESCAPE
+             * and DELETE key press.
+             */
             OpenLayers.Control.DrawFeatureOpt = OpenLayers.Class(OpenLayers.Control.DrawFeature, {
                 handlers: null,
                 initialize: function(layer, handler, options) {
@@ -81,12 +85,18 @@
                 handleKeypress: function(evt) {
                     var code = evt.keyCode;
                     if (this.handler.drawing) {
+                        /*
+                         * ESCAPE pressed. Remove second last vertix and finalize the drawing
+                         */
                         if (code === 27) {
-                            var index = this.handler.line.geometry.components.length -2;
+                            var index = this.handler.line.geometry.components.length - 2;
                             this.handler.line.geometry.removeComponent(this.handler.line.geometry.components[index]);
-                            this.handler.drawFeature();
                             this.handler.finalize();
                         }
+                        /*
+                         * DELETE pressed. Remove third last vertix (actually the last drawn one) 
+                         * and redraw the feature
+                         */
                         if (code === 46) {
                             var index = this.handler.line.geometry.components.length - 3;        
                             this.handler.line.geometry.removeComponent(this.handler.line.geometry.components[index]);
@@ -111,8 +121,6 @@
                 
                 CLASS_NAME: "OpenLayers.Control.DrawFeatureOpt"
             });
-            //OpenLayers.ProxyHost= "/cgi-bin/proxy.cgi?url=";
-            OpenLayers.ProxyHost = "proxy.cgi?url=";
 
             function init() {
                 map = new OpenLayers.Map("the_map", {
@@ -121,12 +129,7 @@
                 var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                         "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
 
-                /*
-                 * Layer that point to the WFS-T service. It will not load any features from the
-                 * remote WFS server by itself, the GetFeature control will do that and place features
-                 * (actually only one) in this layer. We set the WFS protocol just to be able to 
-                 * save the modified feature through WFS-T
-                 */
+                
                 var wfs = new OpenLayers.Layer.Vector("WFS");
                     
                 map.addLayers([wms, wfs]);
@@ -140,10 +143,9 @@
                     }
                 );
                 
-                drawControl.events.register("activate", this, function() {
-                    modifyFeatureControl.deactivate();
-                });
-                
+                /*
+                 * After adding a feature, select it to modify
+                 */
                 drawControl.events.register("featureadded", this, function(e) {
                     modifyFeatureControl.selectFeature(e.feature);
                     modifyFeatureControl.selectControl.select(e.feature);
@@ -174,16 +176,11 @@
                         deleteFeatureControl.unselect(e.feature);
                     }
                 });
-                /*
-                 * Controls
-                 */
+                
                 var panel = new OpenLayers.Control.Panel({
                     displayClass: 'olControlEditingToolbar'
                 });
                 
-                /*
-                 * Only the getFeature control is visible at first.
-                 */
                 panel.addControls([drawControl, modifyFeatureControl, deleteFeatureControl]);
                 
                 map.addControls([
@@ -191,36 +188,6 @@
                 ]);
                 
                 map.setCenter(new OpenLayers.LonLat(-8, 43), 7);
-                
-                /*****************************
-                 * Helper functions
-                 *****************************/
-                /*
-                 * Sets a temporary message in a div with id 'confirmationMessage'
-                 */
-                var setTemporaryMessage = function(message, time) {
-                    document.getElementById("confirmationMessage").innerHTML = message;
-                    setTimeout("document.getElementById('confirmationMessage').innerHTML = ''", time);
-                }
-                /*
-                 * Sets the controls 'save' and 'cancel' in the panel, removing 
-                 * 'getFeatureControlToModify' and 'getFeatureControlToDelete' ones
-                 */
-                var setModifyingPanel = function() {
-                    OpenLayers.Util.removeItem(panel.controls, saveControl);
-                    OpenLayers.Util.removeItem(panel.controls, cancelControl);
-                    panel.addControls([getFeatureControlToModify, getFeatureControlToDelete]);
-                    panel.redraw();
-                }
-                /*
-                 * Sets the 'getFeatureControlToModify' and 'getFeatureControlToDelete' in the panel,
-                 * removing 'save' and 'cancel' ones
-                 */
-                var setInitPanel = function() {
-                    OpenLayers.Util.removeItem(panel.controls, getFeatureControlToModify);
-                    OpenLayers.Util.removeItem(panel.controls, getFeatureControlToDelete);
-                    panel.addControls([saveControl, cancelControl]);
-                }
             }
 
         </script>



More information about the Commits mailing list