fix for #77. alpha png transparency. and tests. yay.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@605 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -7,7 +7,7 @@ OpenLayers.Tile.Image.prototype =
|
||||
Object.extend( new OpenLayers.Tile(), {
|
||||
|
||||
/** @type DOMElement img */
|
||||
img:null,
|
||||
imgDiv:null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -23,22 +23,22 @@ OpenLayers.Tile.Image.prototype =
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if ((this.img != null) && (this.img.parentNode == this.layer.div)) {
|
||||
this.layer.div.removeChild(this.img);
|
||||
if ((this.imgDiv != null) && (this.imgDiv.parentNode == this.layer.div)) {
|
||||
this.layer.div.removeChild(this.imgDiv);
|
||||
}
|
||||
this.img = null;
|
||||
this.imgDiv = null;
|
||||
OpenLayers.Tile.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
*/
|
||||
draw:function() {
|
||||
this.img = OpenLayers.Util.createImage(null,
|
||||
this.position,
|
||||
this.size,
|
||||
this.url,
|
||||
"absolute");
|
||||
this.layer.div.appendChild(this.img);
|
||||
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
|
||||
this.position,
|
||||
this.size,
|
||||
this.url,
|
||||
"absolute");
|
||||
this.layer.div.appendChild(this.imgDiv);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
@@ -25,14 +25,19 @@
|
||||
var pixel = new OpenLayers.Pixel(5,6);
|
||||
var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel);
|
||||
tile.draw();
|
||||
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" );
|
||||
t.eq( tile.img.style.top, "6px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.img.style.left, "5px", "image top is set correctly via addtile" );
|
||||
|
||||
var img = tile.imgDiv.childNodes[0];
|
||||
|
||||
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" );
|
||||
t.eq( tile.imgDiv.style.top, "6px", "image top is set correctly via addtile" );
|
||||
t.eq( tile.imgDiv.style.left, "5px", "image top is set correctly via addtile" );
|
||||
|
||||
var firstChild = layer.div.firstChild;
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
t.ok( layer.div.firstChild instanceof HTMLImageElement, "div first child is an image object" );
|
||||
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" );
|
||||
t.ok( firstChild instanceof HTMLElement, "div first child is an image object" );
|
||||
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" );
|
||||
var pos = tile.getPosition();
|
||||
t.eq( pos.toString(), "x=5,y=6", "Position of tile is set correctly." );
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
t.ok( tile.size.equals(size), "tile.size is set correctly");
|
||||
}
|
||||
function test_02_Tile_Image_draw (t) {
|
||||
t.plan( 4 );
|
||||
t.plan( 5 );
|
||||
|
||||
var layer = new Object(); //bogus layer
|
||||
layer.div = document.createElement("div");
|
||||
@@ -34,13 +34,20 @@
|
||||
tile = new OpenLayers.Tile.Image(layer, position, bounds, url, size);
|
||||
|
||||
tile.draw();
|
||||
|
||||
var img = tile.imgDiv.childNodes[0];
|
||||
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
t.ok( tile.img instanceof HTMLImageElement, "tile.draw creates an image");
|
||||
t.eq( tile.img.src, "http://www.openlayers.org/dev/tests/tileimage", "tile.draw creates an image");
|
||||
t.eq( tile.img.style.width, "5px", "Image width is correct" );
|
||||
t.eq( tile.img.style.height, "6px", "Image height is correct" );
|
||||
t.ok( tile.imgDiv instanceof HTMLElement, "tile.draw creates an image");
|
||||
if (!isMozilla)
|
||||
t.ok( true, "skipping element test outside of Mozilla");
|
||||
else
|
||||
t.ok( img instanceof HTMLImageElement, "tile.draw creates an image");
|
||||
t.eq( img.src, "http://www.openlayers.org/dev/tests/tileimage", "tile.draw creates an image");
|
||||
t.eq( tile.imgDiv.style.width, "5px", "Image width is correct" );
|
||||
t.eq( tile.imgDiv.style.height, "6px", "Image height is correct" );
|
||||
}
|
||||
|
||||
// -->
|
||||
|
||||
Reference in New Issue
Block a user