Consistency with tile loading events.

Since loadstart is being fired here, it makes sense to fire loadend as well.  The isLoading flag also needs to be cleared.  Needs tests still.
This commit is contained in:
Tim Schaub
2012-02-25 20:45:18 -07:00
parent c18f6a23be
commit 12fa9b54ef

View File

@@ -95,6 +95,8 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
var ols = new OpenLayers.Protocol.Script({ var ols = new OpenLayers.Protocol.Script({
url: this.url, url: this.url,
callback: function(response) { callback: function(response) {
this.isLoading = false;
this.events.triggerEvent("loadend");
this.json = response.data; this.json = response.data;
}, },
scope: this scope: this
@@ -104,7 +106,13 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
// Use standard XHR // Use standard XHR
OpenLayers.Request.GET({ OpenLayers.Request.GET({
url: this.url, url: this.url,
callback: this.parseData, callback: function(response) {
this.isLoading = false;
this.events.triggerEvent("loadend");
if (response.status === 200) {
this.parseData(response);
}
},
scope: this scope: this
}); });
} }
@@ -122,12 +130,10 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
* {Object} parsed javascript data * {Object} parsed javascript data
*/ */
parseData: function(req) { parseData: function(req) {
if (req.status == 200) { if (!this.format) {
if (!this.format) { this.format = new OpenLayers.Format.JSON();
this.format = new OpenLayers.Format.JSON(); }
} this.json = this.format.read(req.responseText);
this.json = this.format.read(req.responseText);
}
}, },
/** /**