OpenLayers OpenLayers

Changeset 3090

Show
Ignore:
Timestamp:
04/22/07 12:46:38 (2 years ago)
Author:
tschaub
Message:

merge recent changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/tschaub/tc/lib/OpenLayers/Control/DrawFeature.js

    r2978 r3090  
    2323     * @type {Object} The functions that are sent to the handler for callback 
    2424     */ 
    25     callbacks: {}
     25    callbacks: null
    2626     
    2727    /** 
  • sandbox/tschaub/tc/lib/OpenLayers/Control/LayerSwitcher.js

    r2934 r3090  
    337337        //configure main div 
    338338        this.div.style.position = "absolute"; 
    339         this.div.style.top = "10px"; 
     339        this.div.style.top = "25px"; 
    340340        this.div.style.right = "0px"; 
    341341        this.div.style.left = ""; 
  • sandbox/tschaub/tc/lib/OpenLayers/Control/OverviewMap.js

    r2964 r3090  
    4747     * @type Array(OpenLayers.Layer) 
    4848     */ 
    49     layers: []
     49    layers: null
    5050 
    5151    /** 
     
    6969     * @type: Object 
    7070     */ 
    71     mapOptions: {}
     71    mapOptions: null
    7272 
    7373    /** 
     
    7676     */ 
    7777    initialize: function(options) { 
     78        this.layers = new Array(); 
    7879        OpenLayers.Control.prototype.initialize.apply(this, [options]); 
    7980    }, 
  • sandbox/tschaub/tc/lib/OpenLayers/Control/SelectFeature.js

    r3043 r3090  
    4646     * @type {Object} The functions that are sent to the handler for callback 
    4747     */ 
    48     callbacks: {}
     48    callbacks: null
    4949     
    5050    /** 
  • sandbox/tschaub/tc/lib/OpenLayers/Feature/Vector.js

    r3043 r3090  
    2828    geometry:null, 
    2929 
    30     /** @type array */ 
    31     attributes: {}
    32  
    33     /** @type strinng */ 
     30    /** @type Object */ 
     31    attributes: null
     32 
     33    /** @type String */ 
    3434    state: null, 
    3535     
     
    4949        this.geometry = geometry; 
    5050        this.state = null; 
     51        this.attributes = new Object(); 
    5152        if (data) { 
    52             OpenLayers.Util.extend(this.attributes, data); 
    53         }     
     53            this.attributes = OpenLayers.Util.extend(this.attributes, data); 
     54        } 
    5455        this.style = style ? style : null;  
    5556    }, 
  • sandbox/tschaub/tc/lib/OpenLayers/Handler/Drag.js

    r3042 r3090  
    9494        if (this.started) { 
    9595            this.started = false; 
    96             this.dragging = false; 
    9796            // TBD replace with CSS classes 
    9897            this.map.div.style.cursor = ""; 
     
    133132    click: function (evt) { 
    134133        // throw away the first left click event that happens after a mouse up 
    135         if (OpenLayers.Event.isLeftClick(evt) && this.dragging) { 
    136             this.dragging = true; 
     134        if (this.dragging) { 
     135            this.dragging = false; 
    137136            return false;  
    138137        } 
  • sandbox/tschaub/tc/lib/OpenLayers/Layer/KaMap.js

    r2240 r3090  
    146146 
    147147    }, 
     148     
     149    /** 
     150     * @param {Object} obj 
     151     *  
     152     * @returns An exact clone of this OpenLayers.Layer.Grid 
     153     * @type OpenLayers.Layer.Grid 
     154     */ 
     155    clone: function (obj) { 
     156         
     157        if (obj == null) { 
     158            obj = new OpenLayers.Layer.KaMap(this.name, 
     159                                            this.url, 
     160                                            this.params, 
     161                                            this.options); 
     162        } 
     163 
     164        //get all additions from superclasses 
     165        obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]); 
     166 
     167        // copy/set any non-init, non-simple values here 
     168        if (this.tileSize != null) { 
     169            obj.tileSize = this.tileSize.clone(); 
     170        } 
     171         
     172        // we do not want to copy reference to grid, so we make a new array 
     173        obj.grid = new Array(); 
     174 
     175        return obj; 
     176    },     
     177 
    148178 
    149179    /** @final @type String */ 
  • sandbox/tschaub/tc/lib/OpenLayers/Layer/Vector.js

    r3045 r3090  
    2727     
    2828    /** @type Array(OpenLayers.Feature.Vector) */ 
    29     selectedFeatures: []
     29    selectedFeatures: null
    3030 
    3131    /** @type {Boolean} */ 
     
    253253 
    254254    /** 
     255     * Destroy all features on the layer and empty the selected features array. 
    255256     */ 
    256257    destroyFeatures: function () { 
     258        this.selectedFeatures = new Array(); 
    257259        for (var i = this.features.length - 1; i >= 0; i--) { 
    258260            this.features[i].destroy(); 
  • sandbox/tschaub/tc/lib/OpenLayers/Layer/WFS.js

    r2996 r3090  
    203203        } 
    204204    }, 
    205          
     205 
     206    /** 
     207     * Call the onMapResize method of the appropriate parent class.  
     208     */ 
     209    onMapResize: function() { 
     210        if(this.vectorMode) { 
     211            OpenLayers.Layer.Vector.prototype.onMapResize.apply(this, arguments); 
     212        } else { 
     213            OpenLayers.Layer.Markers.prototype.onMapResize.apply(this, arguments); 
     214        } 
     215    }, 
     216 
    206217    /** 
    207218     * @param {Object} obj 
  • sandbox/tschaub/tc/lib/OpenLayers/Popup.js

    r2994 r3090  
    105105            this.div.appendChild(closeImg); 
    106106 
    107             var closeEvents = new OpenLayers.Events(this, closeImg); 
    108             closeEvents.register("mousedown", this, this.hide); 
     107            var closePopup = function(e) { 
     108                this.hide(); 
     109                OpenLayers.Event.stop(e); 
     110            } 
     111            OpenLayers.Event.observe(closeImg, "click",  
     112                                     closePopup.bindAsEventListener(this)); 
    109113 
    110114        } 
  • sandbox/tschaub/tc/lib/OpenLayers/Renderer.js

    r3043 r3090  
    110110     * Draw the feature.  The optional style argument can be used 
    111111     * to override the feature's own style.  This method should only 
    112      * be called from layer.drawFeature().  Implemented by a renderer 
    113      * subclass. 
     112     * be called from layer.drawFeature(). 
    114113     * 
    115114     * @param {OpenLayers.Feature.Vector} feature  
    116115     * @param {Object} style 
     116     * @private 
    117117     */ 
    118     drawFeature: function(feature, style) {}, 
     118    drawFeature: function(feature, style) { 
     119        if(style == null) { 
     120            style = feature.style; 
     121        } 
     122        this.drawGeometry(feature.geometry, style, feature.id); 
     123    }, 
     124 
    119125 
    120126    /**  
     
    126132     * @param geometry {OpenLayers.Geometry} 
    127133     * @param style {Object} 
     134     * @param {String} featureId 
    128135     * @private 
    129136     */ 
    130     drawGeometry: function(geometry, style) {}, 
     137    drawGeometry: function(geometry, style, featureId) {}, 
    131138         
    132139    /** 
     
    134141     * 
    135142     * Clear all vectors from the renderer 
    136      * 
     143     * @private 
    137144     */     
    138145    clear: function() {}, 
     
    154161     
    155162    /** 
     163     * This is called by the layer to erase features 
     164     * @param {Array(OpenLayers.Feature.Vector)} features 
     165     * @private 
     166     */ 
     167    eraseFeatures: function(features) { 
     168        if(!(features instanceof Array)) { 
     169            features = [features]; 
     170        } 
     171        for(var i=0; i<features.length; ++i) { 
     172            this.eraseGeometry(features[i].geometry); 
     173        } 
     174    }, 
     175     
     176    /** 
    156177     * virtual function 
    157178     *  
     
    159180     *  
    160181     * @param geometry {OpenLayers.Geometry} 
     182     * @private 
    161183     */ 
    162184    eraseGeometry: function(geometry) {}, 
  • sandbox/tschaub/tc/lib/OpenLayers/Renderer/Elements.js

    r3043 r3090  
    207207     * @returns A geometry from an event that happened on a layer 
    208208     * @type OpenLayers.Geometry 
     209     * @private 
    209210     */ 
    210211    getFeatureIdFromEvent: function(evt) { 
     
    219220     *  
    220221     * @param {OpenLayers.Geometry} geometry 
     222     * @private 
    221223     */ 
    222224    eraseGeometry: function(geometry) { 
     
    253255     * @returns A new node of the given type and id 
    254256     * @type DOMElement 
     257     * @private 
    255258     */ 
    256259    nodeFactory: function(id, type, geometry) { 
  • sandbox/tschaub/tc/lib/OpenLayers/Renderer/SVG.js

    r3043 r3090  
    1414    /** @type String */ 
    1515    xmlns: "http://www.w3.org/2000/svg", 
    16      
     16 
     17    // Firefox has a limitation where values larger or smaller than about 
     18    // 15000 in an SVG document lock the browser up. This works around it. 
     19    /** @type Integer */ 
     20    maxPixel: 15000, 
     21     
     22 
     23    /** @type Float  
     24        @private */ 
     25    localResolution: null, 
     26 
    1727    /** 
    1828     * @constructor 
     
    5565        var resolution = this.getResolution(); 
    5666         
    57         var extentString = extent.left / resolution + " " + -extent.top / resolution + " " +  
     67 
     68        // If the resolution has changed, start over changing the corner, because 
     69        // the features will redraw. 
     70        if (!this.localResolution || resolution != this.localResolution) { 
     71            this.left = -extent.left / resolution; 
     72            this.top = extent.top / resolution; 
     73        } 
     74 
     75         
     76        var left = 0; 
     77        var top = 0; 
     78 
     79        // If the resolution has not changed, we already have features, and we need 
     80        // to adjust the viewbox to fit them. 
     81        if (this.localResolution && resolution == this.localResolution) { 
     82            left = (this.left) - (-extent.left / resolution); 
     83            top  = (this.top) - (extent.top / resolution); 
     84        }     
     85         
     86        // Store resolution for use later. 
     87        this.localResolution = resolution; 
     88         
     89        // Set the viewbox -- the left/top will be pixels-dragged-since-res change, 
     90        // the width/height will be pixels. 
     91        var extentString = left + " " + top + " " +  
    5892                             extent.getWidth() / resolution + " " + extent.getHeight() / resolution; 
     93        //var extentString = extent.left / resolution + " " + -extent.top / resolution + " " +  
    5994        this.rendererRoot.setAttributeNS(null, "viewBox", extentString); 
    6095    }, 
     
    237272    drawCircle: function(node, geometry, radius) { 
    238273        var resolution = this.getResolution(); 
    239         node.setAttributeNS(null, "cx", geometry.x / resolution); 
    240         node.setAttributeNS(null, "cy", geometry.y / resolution); 
    241         node.setAttributeNS(null, "r", radius); 
     274        var x = (geometry.x / resolution + this.left); 
     275        var y = (geometry.y / resolution - this.top); 
     276        var draw = true; 
     277        if (x < -this.maxPixel || x > this.maxPixel) { draw = false; } 
     278        if (y < -this.maxPixel || y > this.maxPixel) { draw = false; } 
     279 
     280        if (draw) {  
     281            node.setAttributeNS(null, "cx", x); 
     282            node.setAttributeNS(null, "cy", y); 
     283            node.setAttributeNS(null, "r", radius); 
     284        } else { 
     285            node.setAttributeNS(null, "cx", ""); 
     286            node.setAttributeNS(null, "cy", ""); 
     287            node.setAttributeNS(null, "r", 0); 
     288        }     
     289             
    242290    }, 
    243291     
     
    267315    drawPolygon: function(node, geometry) { 
    268316        var d = ""; 
     317        var draw = true; 
    269318        for (var j = 0; j < geometry.components.length; j++) { 
    270319            var linearRing = geometry.components[j]; 
    271320            d += " M"; 
    272321            for (var i = 0; i < linearRing.components.length; i++) { 
    273                 d += " " + this.getShortString(linearRing.components[i]); 
     322                var component = this.getShortString(linearRing.components[i]) 
     323                if (component) { 
     324                    d += " " + component; 
     325                } else { 
     326                    draw = false; 
     327                }     
    274328            } 
    275329        } 
    276330        d += " z"; 
    277          
    278         node.setAttributeNS(null, "d", d); 
    279         node.setAttributeNS(null, "fill-rule", "evenodd"); 
     331        if (draw) { 
     332            node.setAttributeNS(null, "d", d); 
     333            node.setAttributeNS(null, "fill-rule", "evenodd"); 
     334        } else { 
     335            node.setAttributeNS(null, "d", ""); 
     336        }     
    280337    }, 
    281338     
     
    286343     */ 
    287344    drawRectangle: function(node, geometry) { 
    288         node.setAttributeNS(null, "x", geometry.x / resolution); 
    289         node.setAttributeNS(null, "y", geometry.y / resolution); 
    290         node.setAttributeNS(null, "width", geometry.width); 
    291         node.setAttributeNS(null, "height", geometry.height); 
     345        // This needs to be reworked  
     346        var x = (geometry.x / resolution + this.left); 
     347        var y = (geometry.y / resolution - this.top); 
     348        var draw = true; 
     349        if (x < -this.maxPixel || x > this.maxPixel) { draw = false; } 
     350        if (y < -this.maxPixel || y > this.maxPixel) { draw = false; } 
     351        if (draw) { 
     352            node.setAttributeNS(null, "x", x); 
     353            node.setAttributeNS(null, "y", y); 
     354            node.setAttributeNS(null, "width", geometry.width); 
     355            node.setAttributeNS(null, "height", geometry.height); 
     356        } else { 
     357            node.setAttributeNS(null, "x", ""); 
     358            node.setAttributeNS(null, "y", ""); 
     359            node.setAttributeNS(null, "width", 0); 
     360            node.setAttributeNS(null, "height", 0); 
     361        }     
     362 
    292363    }, 
    293364     
     
    300371    drawCurve: function(node, geometry) { 
    301372        var d = null; 
     373        var draw = true; 
    302374        for (var i = 0; i < geometry.components.length; i++) { 
    303375            if ((i%3) == 0 && (i/3) == 0) { 
    304                 d = "M " + this.getShortString(geometry.components[i]); 
     376                var component = this.getShortString(geometry.components[i]); 
     377                if (!component) { draw = false; } 
     378                d = "M " + component; 
    305379            } else if ((i%3) == 1) { 
    306                 d += " C " + this.getShortString(geometry.components[i]); 
     380                var component = this.getShortString(geometry.components[i]); 
     381                if (!component) { draw = false; } 
     382                d += " C " + component; 
    307383            } else { 
    308                 d += " " + this.getShortString(geometry.components[i]); 
     384                var component = this.getShortString(geometry.components[i]); 
     385                if (!component) { draw = false; } 
     386                d += " " + component; 
    309387            } 
    310388        } 
    311         node.setAttributeNS(null, "d", d); 
     389        if (draw) { 
     390            node.setAttributeNS(null, "d", d); 
     391        } else { 
     392            node.setAttributeNS(null, "d", ""); 
     393        }     
    312394    }, 
    313395     
     
    321403        // create the svg path string representation 
    322404        var d = null; 
     405        var draw = true; 
    323406        for (var i = 0; i < geometry.components.length; i++) { 
    324407            if ((i%3) == 0 && (i/3) == 0) { 
    325                 d = "M " + this.getShortString(geometry.components[i]); 
     408                var component = this.getShortString(geometry.components[i]); 
     409                if (!component) { draw = false; } 
     410                d = "M " + component; 
    326411            } else if ((i%3) == 1) { 
    327                 d += " C " + this.getShortString(geometry.components[i]); 
     412                var component = this.getShortString(geometry.components[i]); 
     413                if (!component) { draw = false; } 
     414                d += " C " + component; 
    328415            } else { 
    329                 d += " " + this.getShortString(geometry.components[i]); 
     416                var component = this.getShortString(geometry.components[i]); 
     417                if (!component) { draw = false; } 
     418                d += " " + component; 
    330419            } 
    331420        } 
    332421        d += " Z"; 
    333         node.setAttributeNS(null, "d", d); 
     422        if (draw) { 
     423            node.setAttributeNS(null, "d", d); 
     424        } else { 
     425            node.setAttributeNS(null, "d", ""); 
     426        }     
    334427    }, 
    335428 
     
    341434        var strings = []; 
    342435        for(var i = 0; i < components.length; i++) { 
    343             strings.push(this.getShortString(components[i])); 
     436            var component = this.getShortString(components[i]); 
     437            if (!component) { return false; } 
     438            strings.push(component); 
    344439        } 
    345440        return strings.join(","); 
     
    353448    getShortString: function(point) { 
    354449        var resolution = this.getResolution(); 
    355         return point.x / resolution + "," + point.y / resolution;   
     450        var x = (point.x / resolution + this.left); 
     451        var y = (point.y / resolution - this.top); 
     452        if (x < -this.maxPixel || x > this.maxPixel) { return false; } 
     453        if (y < -this.maxPixel || y > this.maxPixel) { return false; } 
     454        var string =  x + "," + y;   
     455        return string; 
    356456         
    357457    }, 
  • sandbox/tschaub/tc/lib/OpenLayers/Util.js

    r2994 r3090  
    174174                                       opacity, delayDisplay) { 
    175175 
    176     image = document.createElement("img"); 
     176    var image = document.createElement("img"); 
    177177 
    178178    //set generic properties 
  • sandbox/tschaub/tc/tests/Layer/test_KaMap.html

    r2803 r3090  
    148148 
    149149    function test_10_Layer_KaMap_clone(t) { 
    150         t.plan(4); 
     150        t.plan(5); 
    151151         
    152152        var options = {tileSize: new OpenLayers.Size(500,50)}; 
     
    169169 
    170170        t.eq( clone.alpha, layer.alpha, "alpha copied correctly"); 
     171         
     172        t.eq( clone.CLASS_NAME, "OpenLayers.Layer.KaMap", "Clone is a ka-map layer"); 
    171173 
    172174        layer.grid = null; 
  • sandbox/tschaub/tc/tests/Layer/test_Vector.html

    r3043 r3090  
    102102 
    103103    function test_Layer_Vector_destroyFeatures (t) { 
    104         t.plan(2);  
     104        t.plan(3);  
    105105        layer = new OpenLayers.Layer.Vector(name); 
    106106        var map = new OpenLayers.Map('map'); 
     
    113113        layer.addFeatures(features); 
    114114        t.eq(layer.features.length, 5, "addFeatures adds 5 features"); 
     115        layer.selectedFeatures.push(features[0]);  
    115116        layer.destroyFeatures(); 
    116117        t.eq(layer.features.length, 0, "destroyFeatures triggers removal"); 
     118        t.eq(layer.selectedFeatures, [], "Destroy features removes selected features"); 
    117119    } 
    118120 
  • sandbox/tschaub/tc/tests/list-tests.html

    r3026 r3090  
    4343    <li>Layer/test_Text.html</li> 
    4444    <li>Layer/test_WMS.html</li> 
     45    <li>Layer/test_WFS.html</li> 
    4546    <li>Layer/test_TMS.html</li> 
    4647    <li>Layer/test_Vector.html</li> 
  • sandbox/tschaub/tc/theme/default/style.css

    r2978 r3090  
    9090.olControlNavToolbar .olControlNavigationItemActive {  
    9191  background-image: url("img/panning-hand-on.png"); 
     92  background-repeat: no-repeat; 
    9293} 
    9394.olControlNavToolbar .olControlNavigationItemInactive {  
    9495  background-image: url("img/panning-hand-off.png"); 
     96  background-repeat: no-repeat; 
    9597} 
    9698.olControlNavToolbar .olControlZoomBoxItemActive {  
    9799  background-image: url("img/drag-rectangle-on.png"); 
    98100  background-color: orange; 
     101  background-repeat: no-repeat; 
    99102} 
    100103.olControlNavToolbar .olControlZoomBoxItemInactive {  
    101104  background-image: url("img/drag-rectangle-off.png"); 
     105  background-repeat: no-repeat; 
    102106} 
    103107.olControlEditingToolbar  { 
     
    115119.olControlEditingToolbar .olControlNavigationItemActive {  
    116120  background-image: url("img/pan_on.png"); 
     121  background-repeat: no-repeat; 
    117122} 
    118123.olControlEditingToolbar .olControlNavigationItemInactive {  
    119124  background-image: url("img/pan_off.png"); 
     125  background-repeat: no-repeat; 
    120126} 
    121127.olControlEditingToolbar .olControlDrawFeaturePointItemActive {  
    122128  background-image: url("img/draw_point_on.png"); 
     129  background-repeat: no-repeat; 
    123130} 
    124131.olControlEditingToolbar .olControlDrawFeaturePointItemInactive {  
    125132  background-image: url("img/draw_point_off.png"); 
     133  background-repeat: no-repeat; 
    126134} 
    127135.olControlEditingToolbar .olControlDrawFeaturePathItemInactive {  
    128136  background-image: url("img/draw_line_off.png"); 
     137  background-repeat: no-repeat; 
    129138} 
    130139.olControlEditingToolbar .olControlDrawFeaturePathItemActive {  
    131140  background-image: url("img/draw_line_on.png"); 
     141  background-repeat: no-repeat; 
    132142} 
    133143.olControlEditingToolbar .olControlDrawFeaturePolygonItemInactive {  
    134144  background-image: url("img/draw_polygon_off.png"); 
     145  background-repeat: no-repeat; 
    135146} 
    136147.olControlEditingToolbar .olControlDrawFeaturePolygonItemActive {  
    137148  background-image: url("img/draw_polygon_on.png"); 
     149  background-repeat: no-repeat; 
    138150}