fix bug where tiles with gutters are shifted (refs #441)
This commit is contained in:
@@ -399,6 +399,97 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A series of tests to verify the dimensions and positions
|
||||
* of the tile frame and img after draw.
|
||||
|
||||
* Written for https://github.com/openlayers/openlayers/issues/441
|
||||
*/
|
||||
function test_draw_without_gutter_without_frame(t) {
|
||||
t.plan(5);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS('blank',
|
||||
'../../img/blank.gif',
|
||||
{layers: 'fake'},
|
||||
{isBaseLayer: true});
|
||||
map.addLayer(layer);
|
||||
var tile = new OpenLayers.Tile.Image(
|
||||
layer,
|
||||
new OpenLayers.Pixel(6, 6),
|
||||
new OpenLayers.Bounds(5, 45, 6, 46),
|
||||
null,
|
||||
new OpenLayers.Size(256, 256));
|
||||
|
||||
tile.draw();
|
||||
t.eq(tile.frame, null, 'no frame');
|
||||
t.eq(parseInt(tile.imgDiv.style.left, 10), 6, 'correct tile img left');
|
||||
t.eq(parseInt(tile.imgDiv.style.top, 10), 6, 'correct tile img top');
|
||||
t.eq(parseInt(tile.imgDiv.style.width, 10), 256, 'correct tile img width');
|
||||
t.eq(parseInt(tile.imgDiv.style.height, 10), 256, 'correct tile img height');
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
function test_draw_without_gutter_with_frame(t) {
|
||||
t.plan(8);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS('blank',
|
||||
'../../img/blank.gif',
|
||||
{layers: 'fake'},
|
||||
{isBaseLayer: true});
|
||||
map.addLayer(layer);
|
||||
layer.gutter = 1; // this is just for a frame to be created for
|
||||
// the tile
|
||||
var tile = new OpenLayers.Tile.Image(
|
||||
layer,
|
||||
new OpenLayers.Pixel(6, 6),
|
||||
new OpenLayers.Bounds(5, 45, 6, 46),
|
||||
null,
|
||||
new OpenLayers.Size(256, 256));
|
||||
layer.gutter = null;
|
||||
|
||||
tile.draw();
|
||||
t.eq(parseInt(tile.frame.style.left, 10), 6, 'correct tile frame left');
|
||||
t.eq(parseInt(tile.frame.style.top, 10), 6, 'correct tile frame top');
|
||||
t.eq(parseInt(tile.frame.style.width, 10), 256, 'correct tile frame width');
|
||||
t.eq(parseInt(tile.frame.style.height, 10), 256, 'correct tile frame height');
|
||||
t.eq(parseInt(tile.imgDiv.style.left, 10), 0, 'correct tile img left');
|
||||
t.eq(parseInt(tile.imgDiv.style.top, 10), 0, 'correct tile img top');
|
||||
t.eq(parseInt(tile.imgDiv.style.width, 10), 100, 'correct tile img width');
|
||||
t.eq(parseInt(tile.imgDiv.style.height, 10), 100, 'correct tile img height');
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
function test_draw_with_gutter(t) {
|
||||
t.plan(8);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS('blank',
|
||||
'../../img/blank.gif',
|
||||
{layers: 'fake'},
|
||||
{isBaseLayer: true, gutter: 15});
|
||||
map.addLayer(layer);
|
||||
var tile = new OpenLayers.Tile.Image(
|
||||
layer,
|
||||
new OpenLayers.Pixel(6, 6),
|
||||
new OpenLayers.Bounds(5, 45, 6, 46),
|
||||
null,
|
||||
new OpenLayers.Size(256, 256));
|
||||
|
||||
tile.draw();
|
||||
t.eq(parseInt(tile.frame.style.left, 10), 6, 'correct tile frame left');
|
||||
t.eq(parseInt(tile.frame.style.top, 10), 6, 'correct tile frame top');
|
||||
t.eq(parseInt(tile.frame.style.width, 10), 256, 'correct tile frame width');
|
||||
t.eq(parseInt(tile.frame.style.height, 10), 256, 'correct tile frame height');
|
||||
t.eq(parseInt(tile.imgDiv.style.left, 10), -5, 'correct tile img left');
|
||||
t.eq(parseInt(tile.imgDiv.style.top, 10), -5, 'correct tile img top');
|
||||
t.eq(parseInt(tile.imgDiv.style.width, 10), 111, 'correct tile img width');
|
||||
t.eq(parseInt(tile.imgDiv.style.height, 10), 111, 'correct tile img height');
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user