OpenLayers OpenLayers

Changeset 2293

Show
Ignore:
Timestamp:
03/01/07 12:06:20 (2 years ago)
Author:
emanuel
Message:

standard zoomlevel animation with +/-key

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/KeyboardDefaults.js

    r2292 r2293  
    1414 
    1515    /** @type int */ 
    16     slideFactor: 100
     16    slideFactor: 75
    1717 
    1818    /** 
     
    2727     */ 
    2828    draw: function() { 
    29 //keypress 
    3029        OpenLayers.Event.observe(document,  
    3130                      'keypress',  
    3231                      this.defaultKeyDown.bindAsEventListener(this)); 
    33         OpenLayers.Event.observe(document,  
    34                       'keyup',  
    35                       this.defaultKeyUp.bindAsEventListener(this)); 
    3632    }, 
    3733     
     
    4238        switch(evt.keyCode) { 
    4339            case OpenLayers.Event.KEY_LEFT: 
    44                 this.map.pan(-75, 0); 
     40                this.map.pan(-this.slideFactor, 0); 
    4541                break; 
    4642            case OpenLayers.Event.KEY_RIGHT:  
    47                 this.map.pan(75, 0); 
     43                this.map.pan(this.slideFactor, 0); 
    4844                break; 
    4945            case OpenLayers.Event.KEY_UP: 
    50                 this.map.pan(0, -75); 
     46                this.map.pan(0, -this.slideFactor); 
    5147                break; 
    5248            case OpenLayers.Event.KEY_DOWN: 
    53                 this.map.pan(0, 75); 
     49                this.map.pan(0, this.slideFactor); 
    5450                break; 
    5551            case 33: // Page Up   
     
    7268        switch(evt.charCode) {  
    7369            case 43: // +  
    74                 // get and set some settings for zoom animation  
    75                 this.map.prepareZoomAnimation(); 
    76                 this.map.zoomlevel_scale += 0.2; 
    77                 // run zoom animation -> scale tile(s) 
    78                 this.map.runZoomAnimation(); 
     70                this.map.zoomIn(); 
    7971                break;  
    8072            case 45: // -  
    81                 // get and set some settings for zoom animation  
    82                 this.map.prepareZoomAnimation(); 
    83                 this.map.zoomlevel_scale -= 0.2; 
    84                 // run zoom animation -> scale tile(s) 
    85                 this.map.runZoomAnimation(); 
     73                this.map.zoomOut(); 
    8674                break;  
    8775        }      
    8876    }, 
    8977     
    90     defaultKeyUp: function (evt) { 
    91         switch(evt.keyCode) { 
    92             case 107: 
    93                 if((this.map.zoomlevel_scale-this.map.zoomlevel_startScale) < 1) 
    94                 { 
    95                     //this.map.zoomlevel_scale = Math.ceil(this.map.zoomlevel_scale); 
    96                     //this.map.runZoomAnimation(); 
    97                     this.map.zoomTo(this.map.zoomlevel_startScale+1); 
    98                 } 
    99                 //this.map.finishZoomAnimation(Math.round(this.map.zoomlevel_scale)); 
    100  
    101             case 109: 
    102                 if((this.map.zoomlevel_scale-this.map.zoomlevel_startScale) < 1) 
    103                 { 
    104                     Math.floor(this.map.zoomlevel_scale); 
    105                     this.map.runZoomAnimation(); 
    106                 } 
    107                 // finish zoom animation 
    108                 this.map.finishZoomAnimation(Math.round(this.map.zoomlevel_scale)); 
    109                 break; 
    110  
    111         } 
    112  
    113  
    114  
    115     }, 
    11678 
    11779