Remove cargo culted image tile bits.

This commit is contained in:
Tim Schaub
2012-02-25 20:03:40 -07:00
parent 65233dd0bc
commit 73e6973ab5

View File

@@ -15,9 +15,8 @@
* rendered image; only a 'hit grid' that can be used to * rendered image; only a 'hit grid' that can be used to
* look up feature attributes. * look up feature attributes.
* *
* IMPORTANT - remove all traces of IMAGES * See the <OpenLayers.Tile.UTFGrid> constructor for details on constructing a
* * new instance.
* <OpenLayers.Tile.UTFGrid> constructor.
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Tile> * - <OpenLayers.Tile>
@@ -26,37 +25,22 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
/** /**
* Property: url * Property: url
* {String} The URL of the image being requested. No default. Filled in by * {String}
* layer.getURL() function. * The URL of the UTFGrid file being requested. Provided by the <getURL>
* method.
*/ */
url: null, url: null,
/** /**
* Property: json * Property: json
* {Object}
* Stores the parsed JSON tile data structure. * Stores the parsed JSON tile data structure.
* {Object} The image for this tile.
*/ */
json: null, json: null,
/** /**
* Property: imageReloadAttempts * Constructor: OpenLayers.Tile.UTFGrid
* {Integer} Attempts to load the image. * Constructor for a new <OpenLayers.Tile.UTFGrid> instance.
*/
imageReloadAttempts: null,
/**
* Property: asyncRequestId
* {Integer} ID of an request to see if request is still valid. This is a
* number which increments by 1 for each asynchronous request.
*/
asyncRequestId: null,
/** TBD 3.0 - reorder the parameters to the init function to remove
* URL. the getUrl() function on the layer gets called on
* each draw(), so no need to specify it here.
*
* Constructor: OpenLayers.Tile.Image
* Constructor for a new <OpenLayers.Tile.Image> instance.
* *
* Parameters: * Parameters:
* layer - {<OpenLayers.Layer>} layer that the tile will go in. * layer - {<OpenLayers.Layer>} layer that the tile will go in.
@@ -65,24 +49,14 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
* url - {<String>} Deprecated. Remove me in 3.0. * url - {<String>} Deprecated. Remove me in 3.0.
* size - {<OpenLayers.Size>} * size - {<OpenLayers.Size>}
* options - {Object} * options - {Object}
*/ */
initialize: function(layer, position, bounds, url, size, options) {
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
this.url = url; //deprecated remove me
},
/** /**
* APIMethod: destroy * APIMethod: destroy
* nullify references to prevent circular references and memory leaks * nullify references to prevent circular references and memory leaks
*/ */
destroy: function() { destroy: function() {
if (this.imgDiv) { this.clear();
this.clear();
this.imgDiv = null;
this.frame = null;
}
// don't handle async requests any more
this.asyncRequestId = null;
OpenLayers.Tile.prototype.destroy.apply(this, arguments); OpenLayers.Tile.prototype.destroy.apply(this, arguments);
}, },
@@ -120,16 +94,13 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
}); });
ols.read(); ols.read();
} else { } else {
// Use standard AJAX call // Use standard XHR
var resp = new OpenLayers.Protocol.Response({requestType: "read"}); OpenLayers.Request.GET({
resp.priv = OpenLayers.Request.GET({
url: this.url, url: this.url,
callback: this.parseData, callback: this.parseData,
scope: this scope: this
}); });
} }
this.positionTile();
} else { } else {
this.unload(); this.unload();
} }
@@ -150,67 +121,14 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
} }
}, },
/**
* Method: positionTile
* Using the properties currenty set on the layer, position the tile correctly.
* This method is used both by the async and non-async versions of the Tile.Image
* code.
*/
positionTile: function() {
var style = this.getTile().style;
style.left = this.position.x + "%";
style.top = this.position.y + "%";
style.width = this.size.w + "%";
style.height = this.size.h + "%";
},
/** /**
* Method: clear * Method: clear
* Remove the tile from the DOM, clear it of any image related data so that * Delete data stored with this tile.
* it can be reused in a new location.
*/ */
clear: function() { clear: function() {
this.json = null; this.json = null;
var tile = this.getTile();
if (tile.parentNode === this.layer.div) {
this.layer.div.removeChild(tile);
}
}, },
/**
* Method: getImage
* Returns or creates and returns the tile image.
*/
getImage: function() {
if (!this.imgDiv) {
// MP TODO do we NEED to create an image here?
this.imgDiv = document.createElement("img");
this.imgDiv.className = "olTileImage";
var style = this.imgDiv.style;
style.width = "100%";
style.height = "100%";
style.visibility = "hidden";
style.opacity = 0;
style.position = "absolute";
if (this.frame) {
this.frame.appendChild(this.imgDiv);
}
}
return this.imgDiv;
},
/**
* Method: getTile
* Get the tile's markup.
*
* Returns:
* {DOMElement} The tile's markup
*/
getTile: function() {
return this.frame ? this.frame : this.getImage();
},
CLASS_NAME: "OpenLayers.Tile.UTFGrid" CLASS_NAME: "OpenLayers.Tile.UTFGrid"
}); });