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:
@@ -196,8 +196,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
setTileSize: function(size) {
|
||||
if (this.singleTile) {
|
||||
var size = this.map.getSize().clone();
|
||||
size.h = size.h * this.ratio;
|
||||
size.w = size.w * this.ratio;
|
||||
size.h = parseInt(size.h * this.ratio);
|
||||
size.w = parseInt(size.w * this.ratio);
|
||||
}
|
||||
OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]);
|
||||
},
|
||||
@@ -268,7 +268,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
|
||||
var ul = new OpenLayers.LonLat(tileBounds.left, tileBounds.top);
|
||||
var px = this.map.getLayerPxFromLonLat(ul);
|
||||
|
||||
|
||||
if (!this.grid.length) {
|
||||
this.grid[0] = [];
|
||||
}
|
||||
@@ -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"
|
||||
});
|
||||
|
||||
@@ -513,6 +513,21 @@
|
||||
entry = g_unregistered["loadend"];
|
||||
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) {
|
||||
|
||||
@@ -547,6 +562,6 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px;display:none"></div>
|
||||
<div id="map" style="width:499px;height:549px;display:none"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user