OpenLayers OpenLayers

Ticket #968: vml.2.patch

File vml.2.patch, 2.8 kB (added by tschaub, 1 year ago)

cross-browser null geometry rendering consistency

  • lib/OpenLayers/Renderer/VML.js

    old new  
    264264    setNodeDimension: function(node, geometry) { 
    265265 
    266266        var bbox = geometry.getBounds(); 
    267  
    268         var resolution = this.getResolution(); 
     267        if(bbox) { 
     268            var resolution = this.getResolution(); 
     269         
     270            var scaledBox =  
     271                new OpenLayers.Bounds((bbox.left/resolution).toFixed(), 
     272                                      (bbox.bottom/resolution).toFixed(), 
     273                                      (bbox.right/resolution).toFixed(), 
     274                                      (bbox.top/resolution).toFixed()); 
     275             
     276            // Set the internal coordinate system to draw the path 
     277            node.style.left = scaledBox.left; 
     278            node.style.top = scaledBox.top; 
     279            node.style.width = scaledBox.getWidth(); 
     280            node.style.height = scaledBox.getHeight(); 
    269281     
    270         var scaledBox =  
    271             new OpenLayers.Bounds((bbox.left/resolution).toFixed(), 
    272                                   (bbox.bottom/resolution).toFixed(), 
    273                                   (bbox.right/resolution).toFixed(), 
    274                                   (bbox.top/resolution).toFixed()); 
    275          
    276         // Set the internal coordinate system to draw the path 
    277         node.style.left = scaledBox.left; 
    278         node.style.top = scaledBox.top; 
    279         node.style.width = scaledBox.getWidth(); 
    280         node.style.height = scaledBox.getHeight(); 
    281  
    282         node.coordorigin = scaledBox.left + " " + scaledBox.top; 
    283         node.coordsize = scaledBox.getWidth()+ " " + scaledBox.getHeight(); 
     282            node.coordorigin = scaledBox.left + " " + scaledBox.top; 
     283            node.coordsize = scaledBox.getWidth()+ " " + scaledBox.getHeight(); 
     284        } 
    284285    }, 
    285286 
    286287    /** 
     
    387388     * radius - {float} 
    388389     */ 
    389390    drawCircle: function(node, geometry, radius) { 
    390  
    391         var resolution = this.getResolution(); 
     391        if(!isNaN(geometry.x)&& !isNaN(geometry.y)) { 
     392            var resolution = this.getResolution(); 
     393         
     394            node.style.left = (geometry.x /resolution).toFixed() - radius; 
     395            node.style.top = (geometry.y /resolution).toFixed() - radius; 
    392396     
    393         node.style.left = (geometry.x /resolution).toFixed() - radius; 
    394         node.style.top = (geometry.y /resolution).toFixed() - radius; 
    395  
    396         var diameter = radius * 2; 
    397          
    398         node.style.width = diameter; 
    399         node.style.height = diameter; 
     397            var diameter = radius * 2; 
     398             
     399            node.style.width = diameter; 
     400            node.style.height = diameter; 
     401        } 
    400402    }, 
    401403 
    402404