added 'drawn' property to all tiles. removed redraw() and adapted all draw()s to auto handle redraw. remove getPosition() accessor that noone was using. set generic Tile's moveTo() to auto trigger the clear() and the redraw() (if desired). Update Image and WFS tile classes correspondingly. also update tests

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1198 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-08-12 15:54:51 +00:00
parent 0a04ee3d1b
commit 96c56e9d84
4 changed files with 105 additions and 93 deletions

View File

@@ -39,38 +39,31 @@ OpenLayers.Tile.WFS.prototype =
*
*/
destroy: function() {
this.clear();
this.urls = null;
OpenLayers.Tile.prototype.destroy.apply(this, arguments);
this.destroyAllFeatures();
this.features = null;
this.urls = null;
},
/** Clear the tile of any bounds/position-related data so that it can
* be reused in a new location.
*/
clear: function() {
while(this.features.length > 0) {
var feature = this.features.shift();
feature.destroy();
}
OpenLayers.Tile.prototype.clear.apply(this, arguments);
this.destroyAllFeatures();
},
/**
*/
*
*/
draw:function() {
if (this.drawn) {
this.clear();
}
OpenLayers.Tile.prototype.draw.apply(this, arguments);
this.loadFeaturesForRegion(this.requestSuccess);
},
/**
* @param {OpenLayers.Bounds}
* @param {OpenLayers.pixel} position
*/
moveTo: function (bounds, position) {
this.loaded = false;
OpenLayers.Tile.prototype.moveTo.apply(this, arguments);
},
/** get the full request string from the ds and the tile params
* and call the AJAX loadURL().
*
@@ -81,22 +74,13 @@ OpenLayers.Tile.WFS.prototype =
*/
loadFeaturesForRegion:function(success, failure) {
if (!this.loaded) {
if (this.urls != null) {
if (this.urls != null) {
// TODO: Hmmm, this stops multiple loads of the data when a
// result isn't immediately retrieved, but it's hacky.
// Do it better.
this.loaded = true;
for(var i=0; i < this.urls.length; i++) {
var params ={ BBOX:bounds.toBBOX() };
var url = this.urls[i] +
OpenLayers.Util.getParameterString(params);
OpenLayers.loadURL(url, null, this,
success, failure);
}
for(var i=0; i < this.urls.length; i++) {
var params = { BBOX:bounds.toBBOX() };
var url = this.urls[i] +
OpenLayers.Util.getParameterString(params);
OpenLayers.loadURL(url, null, this, success, failure);
}
}
},
@@ -121,16 +105,25 @@ OpenLayers.Tile.WFS.prototype =
* @param {Object} results
*/
addResults: function(results) {
for (var i=0; i < results.length; i++) {
var feature = new this.layer.featureClass(this.layer,
results[i]);
this.features.push(feature);
}
},
/** Iterate through and call destroy() on each feature, removing it from
* the local array
*
* @private
*/
destroyAllFeatures: function() {
while(this.features.length > 0) {
var feature = this.features.shift();
feature.destroy();
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Tile.WFS"
}