Changeset 4262
- Timestamp:
- 09/13/07 12:31:35 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/tschaub/feature/examples/modify-feature.html
r4117 r4262 18 18 } 19 19 </style> 20 <script src="../lib/Firebug/firebug.js"></script> 20 21 <script src="../lib/OpenLayers.js"></script> 21 22 <script type="text/javascript"> … … 32 33 map.addControl(new OpenLayers.Control.MousePosition()); 33 34 35 var modifyOptions = { 36 onModificationStart: function(feature) { 37 OpenLayers.Console.log("start modifying", feature.id); 38 }, 39 onModification: function(feature) { 40 OpenLayers.Console.log("modified", feature.id); 41 }, 42 onModificationEnd: function(feature) { 43 OpenLayers.Console.log("end modifying", feature.id); 44 }, 45 onDelete: function(feature) { 46 OpenLayers.Console.log("delete", feature.id); 47 } 48 }; 34 49 controls = { 35 50 point: new OpenLayers.Control.DrawFeature(vectors, … … 39 54 polygon: new OpenLayers.Control.DrawFeature(vectors, 40 55 OpenLayers.Handler.Polygon), 41 modify: new OpenLayers.Control.ModifyFeature(vectors) 56 modify: new OpenLayers.Control.ModifyFeature(vectors, 57 modifyOptions) 42 58 }; 43 59 … … 49 65 document.getElementById('noneToggle').checked = true; 50 66 } 67 51 68 52 69 function toggleControl(element) { sandbox/tschaub/feature/lib/OpenLayers/Control/ModifyFeature.js
r4171 r4262 112 112 onModificationEnd: function() {}, 113 113 114 /** 115 * APIProperty: onDelete 116 * {Function} Optional function to be called when a feature is finished 117 * deleted. The function should expect to be called with a 118 * feature. 119 */ 120 onDelete: function() {}, 121 114 122 /** 115 123 * Constructor: OpenLayers.Control.ModifyFeature … … 361 369 this.virtualVertices = []; 362 370 } 363 if(this.feature.geometry.CLASS_NAME != "OpenLayers.Geometry.Point") { 371 if(this.feature && 372 this.feature.geometry.CLASS_NAME != "OpenLayers.Geometry.Point") { 364 373 this.collectVertices(this.feature.geometry); 365 374 this.layer.addFeatures(this.vertices); … … 385 394 if(this.feature.geometry.CLASS_NAME == 386 395 "OpenLayers.Geometry.Point") { 387 // delete the point 388 this.layer.removeFeatures([vertex]); 396 if(this.feature == vertex) { 397 // delete the point only if it is modifiable 398 this.unselectFeature(vertex); 399 this.layer.removeFeatures([vertex]); 400 this.onDelete(vertex); 401 } 389 402 } else { 390 403 if(OpenLayers.Util.indexOf(this.vertices, vertex) != -1) { … … 394 407 this.selectControl.selectStyle); 395 408 this.resetVertices(); 409 this.onModification(this.feature); 396 410 } 397 411 }
