OpenLayers OpenLayers

Changeset 605

Show
Ignore:
Timestamp:
06/15/06 15:02:21 (3 years ago)
Author:
euzuro
Message:

fix for #77. alpha png transparency. and tests. yay.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Tile/Image.js

    r522 r605  
    88     
    99    /** @type DOMElement img */ 
    10     img:null, 
     10    imgDiv:null, 
    1111 
    1212    /**  
     
    2424 
    2525    destroy: function() { 
    26         if ((this.img != null) && (this.img.parentNode == this.layer.div)) { 
    27             this.layer.div.removeChild(this.img); 
     26        if ((this.imgDiv != null) && (this.imgDiv.parentNode == this.layer.div)) { 
     27            this.layer.div.removeChild(this.imgDiv); 
    2828        } 
    29         this.img = null; 
     29        this.imgDiv = null; 
    3030        OpenLayers.Tile.prototype.destroy.apply(this, arguments); 
    3131    }, 
     
    3434    */ 
    3535    draw:function() { 
    36         this.img = OpenLayers.Util.createImage(null, 
    37                                                this.position, 
    38                                                this.size, 
    39                                                this.url, 
    40                                                "absolute"); 
    41         this.layer.div.appendChild(this.img); 
     36        this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null, 
     37                                                       this.position, 
     38                                                       this.size, 
     39                                                       this.url, 
     40                                                       "absolute"); 
     41        this.layer.div.appendChild(this.imgDiv); 
    4242    }, 
    4343 
  • trunk/openlayers/tests/test_Layer_WMS.html

    r601 r605  
    2626        var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); 
    2727        tile.draw(); 
    28         t.eq( tile.img.src, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "image src is created correctly via addtile" ); 
    29         t.eq( tile.img.style.top, "6px", "image top is set correctly via addtile" ); 
    30         t.eq( tile.img.style.left, "5px", "image top is set correctly via addtile" ); 
     28 
     29        var img = tile.imgDiv.childNodes[0]; 
     30 
     31        t.eq( img.src, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "image src is created correctly via addtile" ); 
     32        t.eq( tile.imgDiv.style.top, "6px", "image top is set correctly via addtile" ); 
     33        t.eq( tile.imgDiv.style.left, "5px", "image top is set correctly via addtile" ); 
     34 
     35        var firstChild = layer.div.firstChild; 
    3136        if (!isMozilla) 
    3237            t.ok( true, "skipping element test outside of Mozilla"); 
    3338        else 
    34             t.ok( layer.div.firstChild instanceof HTMLImageElement, "div first child is an image object" ); 
    35         t.eq( layer.div.firstChild.src, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "div first child is correct image object" ); 
     39            t.ok( firstChild instanceof HTMLElement, "div first child is an image object" ); 
     40        t.eq( firstChild.childNodes[0].src, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326&BBOX=1,2,3,4&WIDTH=256&HEIGHT=256", "div first child is correct image object" ); 
    3641        var pos = tile.getPosition(); 
    3742        t.eq( pos.toString(), "x=5,y=6", "Position of tile is set correctly." ); 
  • trunk/openlayers/tests/test_Tile_Image.html

    r512 r605  
    2424    } 
    2525    function test_02_Tile_Image_draw (t) { 
    26         t.plan( 4 ); 
     26        t.plan( 5 ); 
    2727 
    2828        var layer = new Object(); //bogus layer 
     
    3535         
    3636        tile.draw(); 
     37         
     38        var img = tile.imgDiv.childNodes[0]; 
     39         
    3740        if (!isMozilla) 
    3841            t.ok( true, "skipping element test outside of Mozilla"); 
    3942        else 
    40             t.ok( tile.img instanceof HTMLImageElement, "tile.draw creates an image"); 
    41         t.eq( tile.img.src, "http://www.openlayers.org/dev/tests/tileimage", "tile.draw creates an image"); 
    42         t.eq( tile.img.style.width, "5px", "Image width is correct" ); 
    43         t.eq( tile.img.style.height, "6px", "Image height is correct" ); 
     43            t.ok( tile.imgDiv instanceof HTMLElement, "tile.draw creates an image"); 
     44        if (!isMozilla) 
     45            t.ok( true, "skipping element test outside of Mozilla"); 
     46        else 
     47            t.ok( img instanceof HTMLImageElement, "tile.draw creates an image"); 
     48        t.eq( img.src, "http://www.openlayers.org/dev/tests/tileimage", "tile.draw creates an image"); 
     49        t.eq( tile.imgDiv.style.width, "5px", "Image width is correct" ); 
     50        t.eq( tile.imgDiv.style.height, "6px", "Image height is correct" ); 
    4451    } 
    4552