OpenLayers OpenLayers

Changeset 4262

Show
Ignore:
Timestamp:
09/13/07 12:31:35 (1 year ago)
Author:
tschaub
Message:

fixing up feature modification - addressing 3 of 4 points from http://openlayers.org/pipermail/dev/2007-September/001333.html - no feature dragging still, and you can't delete entire non-point features

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/tschaub/feature/examples/modify-feature.html

    r4117 r4262  
    1818        } 
    1919    </style> 
     20    <script src="../lib/Firebug/firebug.js"></script> 
    2021    <script src="../lib/OpenLayers.js"></script> 
    2122    <script type="text/javascript"> 
     
    3233            map.addControl(new OpenLayers.Control.MousePosition()); 
    3334             
     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            }; 
    3449            controls = { 
    3550                point: new OpenLayers.Control.DrawFeature(vectors, 
     
    3954                polygon: new OpenLayers.Control.DrawFeature(vectors, 
    4055                            OpenLayers.Handler.Polygon), 
    41                 modify: new OpenLayers.Control.ModifyFeature(vectors) 
     56                modify: new OpenLayers.Control.ModifyFeature(vectors, 
     57                                                             modifyOptions) 
    4258            }; 
    4359             
     
    4965            document.getElementById('noneToggle').checked = true; 
    5066        } 
     67         
    5168 
    5269        function toggleControl(element) { 
  • sandbox/tschaub/feature/lib/OpenLayers/Control/ModifyFeature.js

    r4171 r4262  
    112112    onModificationEnd: function() {}, 
    113113     
     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 
    114122    /** 
    115123     * Constructor: OpenLayers.Control.ModifyFeature 
     
    361369            this.virtualVertices = []; 
    362370        } 
    363         if(this.feature.geometry.CLASS_NAME != "OpenLayers.Geometry.Point") { 
     371        if(this.feature && 
     372           this.feature.geometry.CLASS_NAME != "OpenLayers.Geometry.Point") { 
    364373            this.collectVertices(this.feature.geometry); 
    365374            this.layer.addFeatures(this.vertices); 
     
    385394                if(this.feature.geometry.CLASS_NAME == 
    386395                   "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                    } 
    389402                } else { 
    390403                    if(OpenLayers.Util.indexOf(this.vertices, vertex) != -1) { 
     
    394407                                               this.selectControl.selectStyle); 
    395408                        this.resetVertices(); 
     409                        this.onModification(this.feature); 
    396410                    } 
    397411                }