OpenLayers OpenLayers

Changeset 5972

Show
Ignore:
Timestamp:
02/02/08 11:32:19 (1 year ago)
Author:
tcoulter
Message:

If you don't move the mouse, and get to a point where the code hits finalize() or cancel(), the handler will pass a null point to the renderer. Fixed this to suppress errors.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/topp/nymap/lib/OpenLayers/Handler/Point.js

    r5956 r5972  
    112112            this.map.addLayer(this.layer); 
    113113        } 
     114         
     115        this.createFeature(); 
    114116 
    115117        return true; 
     
    160162     */ 
    161163    finalize: function() { 
     164        this.cleanup("done"); 
     165    }, 
     166 
     167    /** 
     168     * APIMethod: cancel 
     169     * Finish the geometry and call the "cancel" callback. 
     170     */ 
     171    cancel: function() { 
     172        this.cleanup("cancel"); 
     173    }, 
     174     
     175    cleanup: function(callback) { 
    162176        this.layer.eraseFeatures(this.point); 
    163177        this.mouseDown = false; 
    164178        this.lastDown = null; 
    165179        this.lastUp = null; 
    166         this.callback("done", [this.geometryClone()]); 
    167         this.destroyFeature(); 
    168     }, 
    169  
    170     /** 
    171      * APIMethod: cancel 
    172      * Finish the geometry and call the "cancel" callback. 
    173      */ 
    174     cancel: function() { 
    175         this.layer.eraseFeatures(this.point); 
    176         this.mouseDown = false; 
    177         this.lastDown = null; 
    178         this.lastUp = null; 
    179         this.callback("cancel", [this.geometryClone()]); 
     180        this.callback(callback, [this.geometryClone()]); 
    180181        this.destroyFeature(); 
    181182    }, 
     
    258259     */ 
    259260    mousemove: function (evt) { 
    260         if (this.point == null) { 
    261             this.createFeature(); 
    262         } 
    263          
    264261        var lonlat = this.map.getLonLatFromPixel(evt.xy); 
    265262        this.point.geometry.x = lonlat.lon;