Two size/resize issues on singleTile layers, #886, with tests by Andreas.

Many thanks, Andreas!


git-svn-id: http://svn.openlayers.org/trunk/openlayers@3861 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-08-05 13:38:55 +00:00
parent 7361f32040
commit e3490e7aba
2 changed files with 32 additions and 4 deletions
+15 -2
View File
@@ -196,8 +196,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
setTileSize: function(size) { setTileSize: function(size) {
if (this.singleTile) { if (this.singleTile) {
var size = this.map.getSize().clone(); var size = this.map.getSize().clone();
size.h = size.h * this.ratio; size.h = parseInt(size.h * this.ratio);
size.w = size.w * this.ratio; size.w = parseInt(size.w * this.ratio);
} }
OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]); OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]);
}, },
@@ -651,5 +651,18 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
} }
}, },
/**
* Method: onMapResize
* For singleTile layers, this will replace the tile with the
* a new one with updated tileSize and extent.
*/
onMapResize: function() {
if (this.singleTile) {
this.clearGrid();
this.setTileSize();
this.initSingleTile(this.map.getExtent());
}
},
CLASS_NAME: "OpenLayers.Layer.Grid" CLASS_NAME: "OpenLayers.Layer.Grid"
}); });
+16 -1
View File
@@ -514,6 +514,21 @@
t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadEnd, "loadend correctly unregistered"); t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadEnd, "loadend correctly unregistered");
} }
function test_16_Layer_Grid_tileSizeIsInteger(t) {
t.plan(1);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.Grid(name, url, params, {
singleTile: true,
ratio: 1.5
});
map.addLayers([layer]);
width = layer.tileSize.w;
height = layer.tileSize.h;
t.ok(width == parseInt(width) && height == parseInt(height), "calculated tileSize width/height are integer values");
}
function test_99_Layer_Grid_destroy (t) { function test_99_Layer_Grid_destroy (t) {
t.plan( 5 ); t.plan( 5 );
@@ -547,6 +562,6 @@
</script> </script>
</head> </head>
<body> <body>
<div id="map" style="width:500px;height:550px;display:none"></div> <div id="map" style="width:499px;height:549px;display:none"></div>
</body> </body>
</html> </html>