diff --git a/lib/OpenLayers/Tile/UTFGrid.js b/lib/OpenLayers/Tile/UTFGrid.js index 17ecd3ee19..6572e08293 100644 --- a/lib/OpenLayers/Tile/UTFGrid.js +++ b/lib/OpenLayers/Tile/UTFGrid.js @@ -15,9 +15,8 @@ * rendered image; only a 'hit grid' that can be used to * look up feature attributes. * - * IMPORTANT - remove all traces of IMAGES - * - * constructor. + * See the constructor for details on constructing a + * new instance. * * Inherits from: * - @@ -26,37 +25,22 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, { /** * Property: url - * {String} The URL of the image being requested. No default. Filled in by - * layer.getURL() function. + * {String} + * The URL of the UTFGrid file being requested. Provided by the + * method. */ url: null, /** * Property: json + * {Object} * Stores the parsed JSON tile data structure. - * {Object} The image for this tile. */ json: null, /** - * Property: imageReloadAttempts - * {Integer} Attempts to load the image. - */ - 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 instance. + * Constructor: OpenLayers.Tile.UTFGrid + * Constructor for a new instance. * * Parameters: * layer - {} layer that the tile will go in. @@ -65,24 +49,14 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, { * url - {} Deprecated. Remove me in 3.0. * size - {} * 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 * nullify references to prevent circular references and memory leaks */ destroy: function() { - if (this.imgDiv) { - this.clear(); - this.imgDiv = null; - this.frame = null; - } - // don't handle async requests any more - this.asyncRequestId = null; + this.clear(); OpenLayers.Tile.prototype.destroy.apply(this, arguments); }, @@ -120,16 +94,13 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, { }); ols.read(); } else { - // Use standard AJAX call - var resp = new OpenLayers.Protocol.Response({requestType: "read"}); - resp.priv = OpenLayers.Request.GET({ + // Use standard XHR + OpenLayers.Request.GET({ url: this.url, callback: this.parseData, scope: this }); } - - this.positionTile(); } else { 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 - * Remove the tile from the DOM, clear it of any image related data so that - * it can be reused in a new location. + * Delete data stored with this tile. */ clear: function() { 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" });