Tile.Image improvements and partial rewrite. Thanks erilem for the excellent collaboration during the review phase. p=me,erilem r=erilem (closes #3419)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12241 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+24
-62
@@ -77,7 +77,7 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
* {<OpenLayers.Pixel>} Top Left pixel of the tile
|
||||
*/
|
||||
position: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: isLoading
|
||||
* {Boolean} Is the tile loading?
|
||||
@@ -143,54 +143,38 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
this.events = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: clone
|
||||
*
|
||||
* Parameters:
|
||||
* obj - {<OpenLayers.Tile>} The tile to be cloned
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Tile>} An exact clone of this <OpenLayers.Tile>
|
||||
*/
|
||||
clone: function (obj) {
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Tile(this.layer,
|
||||
this.position,
|
||||
this.bounds,
|
||||
this.url,
|
||||
this.size);
|
||||
}
|
||||
|
||||
// catch any randomly tagged-on properties
|
||||
OpenLayers.Util.applyDefaults(obj, this);
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
* Clear whatever is currently in the tile, then return whether or not
|
||||
* it should actually be re-drawn.
|
||||
* it should actually be re-drawn. This is an example implementation
|
||||
* that can be overridden by subclasses. The minimum thing to do here
|
||||
* is to call <clear> and return the result from <shouldDraw>.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Whether or not the tile should actually be drawn. Note that
|
||||
* this is not really the best way of doing things, but such is
|
||||
* the way the code has been developed. Subclasses call this and
|
||||
* depend on the return to know if they should draw or not.
|
||||
* {Boolean} Whether or not the tile should actually be drawn.
|
||||
*/
|
||||
draw: function() {
|
||||
var maxExtent = this.layer.maxExtent;
|
||||
var withinMaxExtent = (maxExtent &&
|
||||
this.bounds.intersectsBounds(maxExtent, false));
|
||||
|
||||
// The only case where we *wouldn't* want to draw the tile is if the
|
||||
// tile is outside its layer's maxExtent.
|
||||
this.shouldDraw = (withinMaxExtent || this.layer.displayOutsideMaxExtent);
|
||||
|
||||
//clear tile's contents and mark as not drawn
|
||||
this.clear();
|
||||
|
||||
return this.shouldDraw;
|
||||
return this.shouldDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: shouldDraw
|
||||
* Return whether or not the tile should actually be (re-)drawn. The only
|
||||
* case where we *wouldn't* want to draw the tile is if the tile is outside
|
||||
* its layer's maxExtent
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Whether or not the tile should actually be drawn.
|
||||
*/
|
||||
shouldDraw: function() {
|
||||
var maxExtent = this.layer.maxExtent;
|
||||
var withinMaxExtent = (maxExtent &&
|
||||
this.bounds.intersectsBounds(maxExtent, false));
|
||||
|
||||
return withinMaxExtent || this.layer.displayOutsideMaxExtent;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -220,7 +204,7 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
* Clear the tile of any bounds/position-related data so that it can
|
||||
* be reused in a new location. To be implemented by subclasses.
|
||||
*/
|
||||
clear: function() {
|
||||
clear: function(draw) {
|
||||
// to be implemented by subclasses
|
||||
},
|
||||
|
||||
@@ -260,29 +244,7 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
bottomRight.lon,
|
||||
topLeft.lat);
|
||||
return bounds;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: showTile
|
||||
* Show the tile only if it should be drawn.
|
||||
*/
|
||||
showTile: function() {
|
||||
if (this.shouldDraw) {
|
||||
this.show();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: show
|
||||
* Show the tile. To be implemented by subclasses.
|
||||
*/
|
||||
show: function() { },
|
||||
|
||||
/**
|
||||
* Method: hide
|
||||
* Hide the tile. To be implemented by subclasses.
|
||||
*/
|
||||
hide: function() { },
|
||||
|
||||
CLASS_NAME: "OpenLayers.Tile"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user