[OpenLayers-Trac] [OpenLayers] #1018: Remove 'drawn' property from tile altogether
OpenLayers
trac at openlayers.org
Thu Sep 27 02:15:18 EDT 2007
#1018: Remove 'drawn' property from tile altogether
--------------------+-------------------------------------------------------
Reporter: euzuro | Owner: euzuro
Type: task | Status: new
Priority: minor | Milestone: 2.6 Release
Component: Tile | Version: 2.5 RC3
Keywords: |
--------------------+-------------------------------------------------------
The 'drawn' property as we know it is only used in one case:
the case where you have a gridded layer with buffer set to 0 and where a
new grid is initialized (initGriddedTiles) and it just so happens that
there is an extra row/col of tiles to the right or bottom of the displayed
map. Since the buffer is set to 0 we are instructed to *not* load any
tiles which are off the grid, so this extra row/col's tiles do not get
loaded.
However! in the case where the user then drags the map just a tiny bit up
or left, that extra row of tiles is brought into view. They then need to
be drawn, and this is the entire reason for the 'drawn' property and the
following code snippet, at the end of the moveGriddedTiles() function:
{{{
if (this.buffer == 0) {
for (var r=0, rl=this.grid.length; r<rl; r++) {
var row = this.grid[r];
for (var c=0, cl=row.length; c<cl; c++) {
var tile = row[c];
if (!tile.drawn && H
tile.bounds.intersectsBounds(bounds, false)) {
tile.draw();
}
}
}
}
}}}
This border case I believe can be avoided by simply changing one line of
the tile.draw() function:
{{{
var withinMapExtent = (mapExtent &&
this.bounds.intersectsBounds(mapExtent,
false));
}}}
to
{{{
var withinMapExtent = (mapExtent &&
this.bounds.intersectsBounds(mapExtent, true));
}}}
which makes the bounds test *inclusive* and therefore yes will draw the
last col/row of tiles. OK, the user said NO BUFFER, but we're only
buffering one little tiny row/column and the whole point of OpenLayers in
the first place is to be slippy and so it doesn't seem unreasonable to
expect/hope the user to slip around.
And of course the bonus of this is that by changing that one line, we can
eliminate a property that results in confusing code that noone can
understand. To me, this seems like a win.
--
Ticket URL: <http://trac.openlayers.org/ticket/1018>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list