[OpenLayers-Commits] r11043 - in trunk/openlayers: lib/OpenLayers/Control lib/OpenLayers/Layer tests/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Jan 19 11:44:39 EST 2011


Author: ahocevar
Date: 2011-01-19 08:44:39 -0800 (Wed, 19 Jan 2011)
New Revision: 11043

Modified:
   trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js
   trunk/openlayers/lib/OpenLayers/Layer/Vector.js
   trunk/openlayers/tests/Control/ModifyFeature.html
Log:
give Layer.Vector a vertexremoved event, to be fired e.g. by the ModifyFeature control. r=bartvde (closes #3017)


Modified: trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js	2011-01-19 12:01:28 UTC (rev 11042)
+++ trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js	2011-01-19 16:44:39 UTC (rev 11043)
@@ -608,6 +608,11 @@
                vertex.geometry.parent) {
                 // remove the vertex
                 vertex.geometry.parent.removeComponent(vertex.geometry);
+                this.layer.events.triggerEvent("vertexremoved", {
+                    vertex: vertex.geometry,
+                    feature: this.feature,
+                    pixel: evt.xy
+                });
                 this.layer.drawFeature(this.feature, this.standalone ?
                                        undefined :
                                        this.selectControl.renderIntent);

Modified: trunk/openlayers/lib/OpenLayers/Layer/Vector.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Vector.js	2011-01-19 12:01:28 UTC (rev 11042)
+++ trunk/openlayers/lib/OpenLayers/Layer/Vector.js	2011-01-19 16:44:39 UTC (rev 11043)
@@ -90,6 +90,12 @@
      *      property referencing the vertex modified (always a point geometry),
      *      and a *pixel* property referencing the pixel location of the
      *      modification.
+     * vertexremoved - Triggered when a vertex within any feature geometry
+     *      has been deleted.  Listeners will receive an object with a
+     *      *feature* property referencing the modified feature, a *vertex*
+     *      property referencing the vertex modified (always a point geometry),
+     *      and a *pixel* property referencing the pixel location of the
+     *      removal.
      * sketchstarted - Triggered when a feature sketch bound for this layer
      *      is started.  Listeners will receive an object with a *feature*
      *      property referencing the new sketch feature and a *vertex* property
@@ -110,8 +116,8 @@
                   "beforefeaturesremoved", "featureremoved", "featuresremoved",
                   "beforefeatureselected", "featureselected", "featureunselected", 
                   "beforefeaturemodified", "featuremodified", "afterfeaturemodified",
-                  "vertexmodified", "sketchstarted", "sketchmodified",
-                  "sketchcomplete", "refresh"],
+                  "vertexmodified", "vertexremoved", "sketchstarted",
+                  "sketchmodified", "sketchcomplete", "refresh"],
 
     /**
      * APIProperty: isBaseLayer

Modified: trunk/openlayers/tests/Control/ModifyFeature.html
===================================================================
--- trunk/openlayers/tests/Control/ModifyFeature.html	2011-01-19 12:01:28 UTC (rev 11042)
+++ trunk/openlayers/tests/Control/ModifyFeature.html	2011-01-19 16:44:39 UTC (rev 11043)
@@ -74,7 +74,7 @@
     }
     
     function test_handleKeypress(t) {
-        t.plan(11);
+        t.plan(14);
 
         /**
          * There are two things that we want to test here
@@ -108,9 +108,17 @@
                      "vertex deletion: removeComponent called on parent with proper geometry");
             }
         };
-        layer.events.on({"featuremodified": function(event) {
-            t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
-        }});
+        layer.events.on({
+            "featuremodified": function(event) {
+                t.eq(event.feature.id, poly.id, "vertex deletion: featuremodifed triggered");
+            },
+            "vertexremoved": function(evt) {
+                layer.events.unregister("vertexremoved", this, arguments.callee);
+                t.eq(evt.feature.id, poly.id, "vertexremoved triggered with correct feature");
+                t.eq(evt.vertex.id, point.geometry.id, "vertexremoved triggered with correct vertex");
+                t.eq(evt.pixel, "foo", "vertexremoved triggered with correct pixel");
+            }
+        });
         layer.drawFeature = function(feature) {
             t.eq(feature.id, poly.id,
                  "vertex deletion: drawFeature called with the proper feature");
@@ -123,7 +131,7 @@
                  "vertex deletion: onModification called with the proper feature");
         };
         // run the above four tests twice
-        control.handleKeypress({keyCode:delKey});
+        control.handleKeypress({keyCode:delKey, xy: "foo"});
         control.handleKeypress({keyCode:dKey});
         t.eq(control.feature.state, OpenLayers.State.UPDATE, "feature state set to update");
 



More information about the Commits mailing list