Ticket #429 (closed bug: duplicate)
tile.getBoundsFromBaseLayer doesn't return what you'd expect for odd size viewport
| Reported by: | tschaub | Owned by: | tschaub |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.5 Release |
| Component: | Tile | Version: | |
| Keywords: | Cc: | ||
| State: |
Description
The following example shows a case where tile.getBoundsFromBaseLayer doesn't return the same as tile.bounds despite the overlay having all the same properties as the base layer. Note that if you change the viewport size to something even (like 512, 300) it works well.
This causes problems if you are trying to use something like tilecache - denying tile requests because the bounds aren't within the threshold.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 511px;
height: 299px;
border: 1px solid gray;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
var map;
function init(){
map = new OpenLayers.Map('map');
var l0 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
var l1 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
{isBaseLayer: false});
map.addLayers([l0, l1]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
// When tiles are drawn, overlay tile bounds are re-calculated
// in tile.getBoundsFromBaseLayer.
// For odd viewport sizes (odd width or height) - the calculation
// doesn't return what you'd expect it to.
alert(l0.grid[0][0].bounds + "\n" + l1.grid[0][0].bounds);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Example</h1>
<div id="map"></div>
</body>
</html>
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

