OpenLayers OpenLayers

Changeset 3112

Show
Ignore:
Timestamp:
05/02/07 10:06:41 (2 years ago)
Author:
crschmidt
Message:

Merge changes from trunk to 2.4:
svn merge trunk/openlayers/@3088 trunk/openlayers/@HEAD branches/openlayers/2.4/

Changes include:

  • Improved GML parsing to catch fid better
  • Letting panels pass mouseup through
  • Fixing small bug in panel example
  • Display of markers/layers when out of range on startup.
  • Fix to aspect ratio of Overview Map.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.4/examples/panel.html

    r2978 r3112  
    7070             
    7171            zb = new OpenLayers.Control.ZoomBox(); 
    72             panel = new OpenLayers.Control.Panel({defaultControl: zb}); 
     72            var panel = new OpenLayers.Control.Panel({defaultControl: zb}); 
    7373            panel.addControls([ 
    7474                new OpenLayers.Control.MouseDefaults(), 
  • branches/openlayers/2.4/lib/OpenLayers/Control/OverviewMap.js

    r3088 r3112  
    521521        this.extentRectangle.style.top = parseInt(top) + 'px'; 
    522522        this.extentRectangle.style.left = parseInt(left) + 'px'; 
    523         this.extentRectangle.style.height = parseInt(bottom - top)+ 'px'; 
    524         this.extentRectangle.style.width = parseInt(right - left) + 'px'; 
     523        this.extentRectangle.style.height = parseInt(Math.max(bottom - top, 0))+ 'px'; 
     524        this.extentRectangle.style.width = parseInt(Math.max(right - left, 0)) + 'px'; 
    525525    }, 
    526526 
  • branches/openlayers/2.4/lib/OpenLayers/Control/Panel.js

    r2978 r3112  
    130130        // Access to this div is via the panel_div attribute of the  
    131131        // control added to the panel. 
     132        // Also, stop mousedowns and clicks, but don't stop mouseup, 
     133        // since they need to pass through. 
    132134        for (var i = 0; i < controls.length; i++) { 
    133135            var element = document.createElement("div"); 
     
    138140            OpenLayers.Event.observe(controls[i].panel_div, "mousedown",  
    139141                              OpenLayers.Event.stop.bindAsEventListener()); 
    140             OpenLayers.Event.observe(controls[i].panel_div, "mouseup",  
    141                                   OpenLayers.Event.stop.bindAsEventListener()); 
    142142        }     
    143143 
  • branches/openlayers/2.4/lib/OpenLayers/Format/GML.js

    r3088 r3112  
    8585        var feature = new OpenLayers.Feature.Vector(); 
    8686 
    87         if (xmlNode.firstChild.attributes && xmlNode.firstChild.attributes['fid']) { 
    88             feature.fid = xmlNode.firstChild.attributes['fid'].nodeValue; 
    89         } 
    90          
    9187        // match MultiPolygon 
    9288        if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon").length != 0) { 
    9389            var multipolygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon")[0]; 
     90            feature.fid = multipolygon.parentNode.parentNode.getAttribute('fid'); 
     91 
    9492            geom = new OpenLayers.Geometry.MultiPolygon(); 
    9593            var polygons = OpenLayers.Ajax.getElementsByTagNameNS(multipolygon, 
     
    105103            var multilinestring = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 
    106104            this.gmlns, "gml", "MultiLineString")[0]; 
     105            feature.fid = multilinestring.parentNode.parentNode.getAttribute('fid'); 
    107106             
    108107            geom = new OpenLayers.Geometry.MultiLineString(); 
     
    123122            var multiPoint = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 
    124123                this.gmlns, "gml", "MultiPoint")[0]; 
     124            feature.fid = multiPoint.parentNode.parentNode.getAttribute('fid'); 
    125125                 
    126126            geom = new OpenLayers.Geometry.MultiPoint(); 
     
    139139            var polygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 
    140140                this.gmlns, "gml", "Polygon")[0]; 
     141            feature.fid = polygon.parentNode.parentNode.getAttribute('fid'); 
    141142             
    142143            geom = this.parsePolygonNode(polygon); 
     
    147148            var lineString = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 
    148149                this.gmlns, "gml", "LineString")[0]; 
     150            feature.fid = lineString.parentNode.parentNode.getAttribute('fid'); 
     151 
    149152            p = this.parseCoords(lineString); 
    150153            if (p.points) { 
     
    158161            var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, 
    159162                this.gmlns, "gml", "Point")[0]; 
     163            feature.fid = point.parentNode.parentNode.getAttribute('fid'); 
    160164             
    161165            p = this.parseCoords(point); 
  • branches/openlayers/2.4/lib/OpenLayers/Layer.js

    r3088 r3112  
    287287            if (!this.isBaseLayer) { 
    288288                this.inRange = this.calculateInRange(); 
     289                var show = ((this.visibility) && (this.inRange)); 
     290                this.div.style.display = show ? "" : "none"; 
    289291            } 
    290292             
  • branches/openlayers/2.4/lib/OpenLayers/Layer/Markers.js

    r1721 r3112  
    2222    * @type Array(OpenLayers.Marker) */ 
    2323    markers: null, 
     24 
     25 
     26    /** internal state of drawing. This is a workaround for the fact 
     27     *  that the map does not call moveTo with a zoomChanged when the 
     28     *  map is first starting up. This lets us catch the case where we 
     29     *  have *never* drawn the layer, and draw it even if the zoom hasn't 
     30     *  changed.  
     31     * @type Boolean */ 
     32    drawn: false, 
    2433     
    2534    /** 
     
    5261        OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 
    5362 
    54         if (zoomChanged) { 
     63        if (zoomChanged || !this.drawn) { 
    5564            this.redraw(); 
     65            this.drawn = true; 
    5666        } 
    5767    }, 
  • branches/openlayers/2.4/lib/OpenLayers/Layer/Vector.js

    r3088 r3112  
    249249 
    250250            this.renderer.eraseGeometry(feature.geometry); 
     251             
     252            //in the case that this feature is one of the selected features,  
     253            // remove it from that array as well. 
     254            if (OpenLayers.Util.indexOf(this.selectedFeatures, feature) != -1){ 
     255                OpenLayers.Util.removeItem(this.selectedFeatures, feature); 
     256            } 
    251257        } 
    252258    }, 
  • branches/openlayers/2.4/tests/Layer/test_Vector.html

    r3088 r3112  
    3030 
    3131    function test_03_Layer_Vector_removeFeatures(t) { 
    32         t.plan(2); 
     32        t.plan(3); 
    3333     
    3434        var layer = new OpenLayers.Layer.Vector(name); 
     
    4444        t.ok(layer.features.length == 1, "OpenLayers.Layer.Vector.removeFeatures removes a feature from the features array"); 
    4545        layer.addFeatures([pointFeature1.clone(), pointFeature2.clone()]); 
     46        layer.selectedFeatures.push(layer.features[0]);  
     47        layer.removeFeatures(layer.features[0]); 
     48        t.eq(layer.selectedFeatures, [], "Remove features removes selected features"); 
    4649        var features = layer.removeFeatures(layer.features); 
    4750         
     
    7073         
    7174        var f, s; 
     75         
     76        // Layer renderer needs a destroy, and draw, for functional tests.  
    7277        layer.renderer = { 
    7378            drawFeature: function(feature, style) { 
    7479                f = feature; 
    7580                s = style; 
    76             } 
     81            }, 
     82            destroy: function() { } 
    7783        }; 
     84         
    7885 
    7986        layer.drawFeature(feature); 
     
    113120            eraseFeatures: function(features) { 
    114121                f = features[0]; 
    115             } 
     122            }, 
     123            destroy: function() { } 
    116124        }; 
    117125 
  • branches/openlayers/2.4/tests/Marker/test_Box.html

    r3088 r3112  
    180180</body> 
    181181</html> 
    182 <html> 
    183 <head> 
    184   <script src="../../lib/OpenLayers.js"></script> 
    185   <script type="text/javascript"><!-- 
    186     var box;  
    187      
    188     function test_01_Box_constructor (t) { 
    189         t.plan( 7 ); 
    190  
    191         OpenLayers.Marker.Box.prototype._setBorder =  
    192             OpenLayers.Marker.Box.prototype.setBorder; 
    193         OpenLayers.Marker.Box.prototype.setBorder = function (x,y) { 
    194             g_Color = x; 
    195             g_Width = y; 
    196         }; 
    197  
    198         var bounds = new OpenLayers.Bounds(1,2,3,4); 
    199         var borderColor = "blue"; 
    200         var borderWidth = 55; 
    201  
    202  
    203         g_Color = g_Width = null; 
    204         box = new OpenLayers.Marker.Box(bounds, borderColor, borderWidth); 
    205  
    206         t.ok( box instanceof OpenLayers.Marker.Box, "new OpenLayers.Marker.Box returns Box object" ); 
    207         t.ok( box.bounds.equals(bounds), "bounds object correctly set"); 
    208         t.ok( box.div != null, "div created"); 
    209         t.eq( box.div.style.overflow, "hidden", "div style overflow hidden"); 
    210         t.ok( box.events != null, "events object created"); 
    211         t.eq( g_Color, borderColor, "setBorder called with correct border color");         
    212         t.eq( g_Width, borderWidth, "setBorder called with correct border width");         
    213          
    214  
    215         OpenLayers.Marker.Box.prototype.setBorder =  
    216             OpenLayers.Marker.Box.prototype._setBorder; 
    217     } 
    218  
    219  
    220     function test_02_Box_setBorder(t) { 
    221         t.plan( 2 ); 
    222  
    223         var box = { 
    224             div: { 
    225                 style: {} 
    226             } 
    227         }; 
    228  
    229       //defaults 
    230         var args = []; 
    231         OpenLayers.Marker.Box.prototype.setBorder.apply(box, args); 
    232         t.eq(box.div.style.border, "2px solid red", "style correctly set with no good values (defaults work)"); 
    233  
    234       //good vals 
    235         var borderColor = "blue"; 
    236         var borderWidth = 55; 
    237  
    238         args = [borderColor, borderWidth]; 
    239         OpenLayers.Marker.Box.prototype.setBorder.apply(box, args); 
    240         t.eq(box.div.style.border, borderWidth + "px solid " + borderColor, "style correctly set with both good values"); 
    241  
    242     } 
    243     function test_03_Box_draw(t) { 
    244         t.plan( 5 ); 
    245  
    246         OpenLayers.Util._modifyDOMElement =  
    247             OpenLayers.Util.modifyDOMElement; 
    248         OpenLayers.Util.modifyDOMElement =  
    249             function (element, id, px, sz) { 
    250                 g_Element = element; 
    251                 g_Id = id; 
    252                 g_Px = px; 
    253                 g_Sz = sz; 
    254             }; 
    255  
    256         var box = { 
    257             div: {} 
    258         }; 
    259  
    260          
    261         var px = {}; 
    262         var sz = {}; 
    263         var args = [px, sz]; 
    264  
    265         g_Element = g_Id = g_Px = g_Sz = null; 
    266         var retVal = OpenLayers.Marker.Box.prototype.draw.apply(box, args); 
    267  
    268         t.eq(g_Element, box.div, "modifyDOMElement passes box's div for element"); 
    269         t.eq(g_Id, null, "modifyDOMElement passes null for id"); 
    270         t.eq(g_Px, px, "modifyDOMElement passes new px value for px"); 
    271         t.eq(g_Sz, sz, "modifyDOMElement passes new sz value for sz"); 
    272         t.ok(retVal == box.div, "draw returns box's div"); 
    273  
    274         OpenLayers.Util.modifyDOMElement =  
    275             OpenLayers.Util._modifyDOMElement; 
    276  
    277     } 
    278  
    279     function test_04_Box_onScreen(t) { 
    280         t.plan( 2 ); 
    281  
    282         var map = new OpenLayers.Map("map"); 
    283  
    284         var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 
    285         layer = new OpenLayers.Layer.WMS(name, url); 
    286  
    287         map.addLayer(layer); 
    288          
    289         mlayer = new OpenLayers.Layer.Boxes('Test Layer'); 
    290         map.addLayer(mlayer); 
    291                 
    292         map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50)); 
    293  
    294         //onscreen box 
    295         var bounds = new OpenLayers.Bounds(-1,-1,1,1); 
    296         var box = new OpenLayers.Marker.Box(bounds); 
    297         mlayer.addMarker(box); 
    298          
    299         t.ok( box.onScreen(), "box knows it's onscreen" ); 
    300  
    301         //offscreen box 
    302         var bounds = new OpenLayers.Bounds(100,100,150,150); 
    303         var box2 = new OpenLayers.Marker.Box(bounds); 
    304         mlayer.addMarker(box2); 
    305  
    306         t.ok( !box2.onScreen(), "box knows it's offscreen" ); 
    307         map.destroy(); 
    308     } 
    309  
    310     function test_05_Box_display(t) { 
    311         t.plan( 2 ); 
    312  
    313         var box = { 
    314             div: { 
    315                 style: {} 
    316             } 
    317         }; 
    318  
    319       //display(true) 
    320         var args = [true]; 
    321         OpenLayers.Marker.Box.prototype.display.apply(box, args); 
    322         t.eq(box.div.style.display, "", "style.display correctly set to '' when display(true)"); 
    323  
    324       //display(false) 
    325         var args = [false]; 
    326         OpenLayers.Marker.Box.prototype.display.apply(box, args); 
    327         t.eq(box.div.style.display, "none", "style.display correctly set to 'none' when display(false)"); 
    328     } 
    329  
    330     function test_99_Box_destroy(t) { 
    331         t.plan(3); 
    332          
    333         OpenLayers.Marker.prototype._destroy =  
    334             OpenLayers.Marker.prototype.destroy; 
    335         OpenLayers.Marker.prototype.destroy = function() { 
    336             g_Destroy = true; 
    337         } 
    338                  
    339         var bounds = new OpenLayers.Bounds(1,2,3,4); 
    340         var borderColor = "blue"; 
    341         var borderWidth = 55; 
    342  
    343         g_Destroy = null; 
    344         box = new OpenLayers.Marker.Box(bounds, borderColor, borderWidth); 
    345         box.destroy(); 
    346  
    347         t.eq(box.bounds, null, "bounds nullified"); 
    348         t.eq(box.div, null, "div nullified"); 
    349         t.ok(g_Destroy == true, "OpenLayers.Marker.destroy() called"); 
    350  
    351  
    352         OpenLayers.Marker.prototype.destroy =  
    353             OpenLayers.Marker.prototype._destroy; 
    354     } 
    355      
    356   // --> 
    357   </script> 
    358 </head> 
    359 <body> 
    360     <div id="map" style="width:500px;height:550px"></div> 
    361 </body> 
    362 </html> 
  • branches/openlayers/2.4/tests/list-tests.html

    r3088 r3112  
    1818    <li>Geometry/test_Surface.html</li> 
    1919    <li>test_Format.html</li> 
     20    <li>Format/test_GML.html</li> 
    2021    <li>Format/test_WKT.html</li> 
    2122    <li>test_Icon.html</li>