OpenLayers OpenLayers

Changeset 5374

Show
Ignore:
Timestamp:
12/11/07 13:31:42 (1 year ago)
Author:
enjahova
Message:

Added ZoomToLastExtent, ZoomOut and Identify tools to be used with Panel. also started work on a new theme

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/enjahova/openlayers/lib/OpenLayers.js

    r5027 r5374  
    128128            "OpenLayers/Control/Attribution.js", 
    129129            "OpenLayers/Control/ZoomBox.js", 
     130            "OpenLayers/Control/Identify.js", 
     131            "OpenLayers/Control/ZoomOut.js", 
    130132            "OpenLayers/Control/ZoomToMaxExtent.js", 
     133            "OpenLayers/Control/ZoomToLastExtent.js", 
    131134            "OpenLayers/Control/DragPan.js", 
    132135            "OpenLayers/Control/Navigation.js", 
  • sandbox/enjahova/openlayers/lib/OpenLayers/Map.js

    r5361 r5374  
    135135     */ 
    136136    viewRequestID: 0, 
     137     
     138    /** 
     139     * Property extents 
     140     * {Array} Used to store a history of the extents 
     141     */ 
     142    extents: [], 
    137143 
    138144  // Options 
     
    247253     */ 
    248254    fallThrough: false, 
     255     
     256     
    249257 
    250258    /** 
     
    359367            this.addControlToMap(this.controls[i]); 
    360368        } 
     369         
     370        //keep track of previous extents so we can "undo" them Used by ZoomToLastExtent 
     371        var func = function () {  
     372            //console.log(this.getExtent()); 
     373            //console.log(this.getScale()); 
     374            this.extents.push(this.getExtent()); 
     375        } 
     376        this.events.register("moveend", map, func ); 
    361377 
    362378        this.popups = []; 
     
    449465         return this.tileSize; 
    450466     }, 
    451  
    452  
    453     /** 
    454      * APIMethod: getBy 
    455      * Get a list of objects given a property and a match item. 
    456      * 
    457      * Parameters: 
    458      * array - {String} A property on the map whose value is an array. 
    459      * property - {String} A property on each item of the given array. 
    460      * match - {String | Object} A string to match.  Can also be a regular 
    461      *     expression literal or object.  In addition, it can be any object 
    462      *     with a method named test.  For reqular expressions or other, if 
    463      *     match.test(map[array][i][property]) evaluates to true, the item will 
    464      *     be included in the array returned.  If no items are found, an empty 
    465      *     array is returned. 
    466      * 
    467      * Returns: 
    468      * {Array} An array of items where the given property matches the given 
    469      *     criteria. 
    470      */ 
    471     getBy: function(array, property, match) { 
    472         var found = []; 
    473         var item; 
    474         var list = this[array]; 
    475         var test = (typeof match.test == "function"); 
    476         if(list instanceof Array) { 
    477             for(var i=0; i<list.length; ++i) { 
    478                 item = list[i]; 
    479                 if(item[property] == match || 
    480                    (test && match.test(item[property]))) { 
    481                     found.push(item); 
    482                 } 
    483             } 
    484         } 
    485         return found; 
    486     }, 
    487  
    488     /** 
    489      * APIMethod: getLayersBy 
    490      * Get a list of layers with properties matching the given criteria. 
    491      * 
    492      * Parameter: 
    493      * property - {String} A layer property to be matched. 
    494      * match - {String | Object} A string to match.  Can also be a regular 
    495      *     expression literal or object.  In addition, it can be any object 
    496      *     with a method named test.  For reqular expressions or other, if 
    497      *     match.test(layer[property]) evaluates to true, the layer will be 
    498      *     included in the array returned.  If no layers are found, an empty 
    499      *     array is returned. 
    500      * 
    501      * Returns: 
    502      * {Array(<OpenLayers.Layer>)} A list of layers matching the given criteria. 
    503      *     An empty array is returned if no matches are found. 
    504      */ 
    505     getLayersBy: function(property, match) { 
    506         return this.getBy("layers", property, match); 
    507     }, 
    508  
    509     /** 
    510      * APIMethod: getLayersByName 
    511      * Get a list of layers with names matching the given name. 
    512      * 
    513      * Parameter: 
    514      * match - {String | Object} A layer name.  The name can also be a regular 
    515      *     expression literal or object.  In addition, it can be any object 
    516      *     with a method named test.  For reqular expressions or other, if 
    517      *     name.test(layer.name) evaluates to true, the layer will be included 
    518      *     in the list of layers returned.  If no layers are found, an empty 
    519      *     array is returned. 
    520      * 
    521      * Returns: 
    522      * {Array(<OpenLayers.Layer>)} A list of layers matching the given name. 
    523      *     An empty array is returned if no matches are found. 
    524      */ 
    525     getLayersByName: function(match) { 
    526         return this.getLayersBy("name", match); 
    527     }, 
    528  
    529     /** 
    530      * APIMethod: getLayersByType 
    531      * Get a list of layers of a given type (CLASS_NAME). 
    532      * 
    533      * Parameter: 
    534      * match - {String | Object} A layer class name.  The type can also be a 
    535      *     regular expression literal or object.  In addition, it can be any 
    536      *     object with a method named test.  For reqular expressions or other, 
    537      *     if type.test(layer.CLASS_NAME) evaluates to true, the layer will 
    538      *     be included in the list of layers returned.  If no layers are 
    539      *     found, an empty array is returned. 
    540      * 
    541      * Returns: 
    542      * {Array(<OpenLayers.Layer>)} A list of layers matching the given type. 
    543      *     An empty array is returned if no matches are found. 
    544      */ 
    545     getLayersByType: function(match) { 
    546         return this.getLayersBy("CLASS_NAME", match); 
    547     }, 
    548  
    549     /** 
    550      * APIMethod: getControlsBy 
    551      * Get a list of controls with properties matching the given criteria. 
    552      * 
    553      * Parameter: 
    554      * property - {String} A control property to be matched. 
    555      * match - {String | Object} A string to match.  Can also be a regular 
    556      *     expression literal or object.  In addition, it can be any object 
    557      *     with a method named test.  For reqular expressions or other, if 
    558      *     match.test(layer[property]) evaluates to true, the layer will be 
    559      *     included in the array returned.  If no layers are found, an empty 
    560      *     array is returned. 
    561      * 
    562      * Returns: 
    563      * {Array(<OpenLayers.Control>)} A list of controls matching the given 
    564      *     criteria.  An empty array is returned if no matches are found. 
    565      */ 
    566     getControlsBy: function(property, match) { 
    567         return this.getBy("controls", property, match); 
    568     }, 
    569  
    570     /** 
    571      * APIMethod: getControlsByType 
    572      * Get a list of controls of a given type (CLASS_NAME). 
    573      * 
    574      * Parameter: 
    575      * match - {String | Object} A control class name.  The type can also be a 
    576      *     regular expression literal or object.  In addition, it can be any 
    577      *     object with a method named test.  For reqular expressions or other, 
    578      *     if type.test(control.CLASS_NAME) evaluates to true, the control will 
    579      *     be included in the list of controls returned.  If no controls are 
    580      *     found, an empty array is returned. 
    581      * 
    582      * Returns: 
    583      * {Array(<OpenLayers.Control>)} A list of controls matching the given type. 
    584      *     An empty array is returned if no matches are found. 
    585      */ 
    586     getControlsByType: function(match) { 
    587         return this.getControlsBy("CLASS_NAME", match); 
    588     }, 
    589467 
    590468  /********************************************************/ 
     
    16381516        this.zoomToExtent(this.getMaxExtent()); 
    16391517    }, 
     1518     
     1519    /**  
     1520     * APIMethod: zoomToLastExtent 
     1521     * Zoom to the full extent and recenter. 
     1522     */ 
     1523    zoomToLastExtent: function() { 
     1524        if(this.extents.length > 1) 
     1525        { 
     1526            var tmp = this.extents.pop(); 
     1527            var last_extent = this.extents.pop(); 
     1528            this.zoomToExtent(last_extent); 
     1529        } 
     1530        else 
     1531        { 
     1532            this.zoomToMaxExtent(); 
     1533            this.extents.pop();this.extents.pop();//original extent should leave extents empty 
     1534        } 
     1535    }, 
    16401536 
    16411537    /**