Ticket #808: loadevents.patch
| File loadevents.patch, 6.0 kB (added by crschmidt, 1 year ago) |
|---|
-
lib/OpenLayers/Layer/GML.js
old new 83 83 // loaded after the GML is paited. 84 84 // See http://trac.openlayers.org/ticket/404 85 85 if(this.visibility && !this.loaded){ 86 this.events.triggerEvent("loadstart"); 86 87 this.loadGML(); 87 88 } 88 89 }, … … 115 116 116 117 var gml = this.format ? new this.format() : new OpenLayers.Format.GML(); 117 118 this.addFeatures(gml.read(doc)); 119 this.events.triggerEvent("loadend"); 118 120 }, 119 121 120 122 /** … … 127 129 */ 128 130 requestFailure: function(request) { 129 131 alert("Error in loading GML file "+this.url); 132 this.events.triggerEvent("loadend"); 130 133 }, 131 134 132 135 /** @final @type String */ -
lib/OpenLayers/Layer/Text.js
old new 48 48 OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); 49 49 this.features = new Array(); 50 50 if (this.location != null) { 51 this.events.triggerEvent("loadstart"); 51 52 OpenLayers.loadURL(this.location, null, this, this.parseData); 52 53 } 53 54 }, … … 151 152 } 152 153 } 153 154 } 155 this.events.triggerEvent("loadend"); 154 156 }, 155 157 156 158 /** -
lib/OpenLayers/Layer/WFS.js
old new 31 31 */ 32 32 ratio: 2, 33 33 34 /** 35 * Property: numLoadingTiles 36 * {Int} The number of tiles outstanding. 37 */ 38 numLoadingTiles: 0, 39 34 40 /** 35 41 * Property: DEFAULT_PARAMS 36 42 * {Object} Hashtable of default key/value parameters … … 204 210 if (!this.tile) { 205 211 this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds, 206 212 url, tileSize); 213 this.addTileMonitoringHooks(this.tile); 207 214 this.tile.draw(); 208 215 } else { 209 216 if (this.vectorMode) { … … 213 220 this.clearMarkers(); 214 221 } 215 222 this.tile.destroy(); 223 this.removeTileMonitoringHooks(this.tile); 216 224 217 225 this.tile = null; 218 226 this.tile = new OpenLayers.Tile.WFS(this, pos, tileBounds, … … 222 230 } 223 231 }, 224 232 233 /** 234 * Method: addTileMonitoringHooks 235 * This function takes a tile as input and adds the appropriate hooks to 236 * the tile so that the layer can keep track of the loading tiles. 237 * 238 * Parameters: 239 * tile - {<OpenLayers.Tile>} 240 */ 241 addTileMonitoringHooks: function(tile) { 242 tile.onLoadStart = function() { 243 //if that was first tile then trigger a 'loadstart' on the layer 244 if (this.numLoadingTiles == 0) { 245 this.events.triggerEvent("loadstart"); 246 } 247 this.numLoadingTiles++; 248 }; 249 tile.events.register("loadstart", this, tile.onLoadStart); 250 251 tile.onLoadEnd = function() { 252 this.numLoadingTiles--; 253 this.events.triggerEvent("tileloaded"); 254 //if that was the last tile, then trigger a 'loadend' on the layer 255 if (this.numLoadingTiles == 0) { 256 this.events.triggerEvent("loadend"); 257 } 258 }; 259 tile.events.register("loadend", this, tile.onLoadEnd); 260 }, 261 262 /** 263 * Method: removeTileMonitoringHooks 264 * This function takes a tile as input and removes the tile hooks 265 * that were added in addTileMonitoringHooks() 266 * 267 * Parameters: 268 * tile - {<OpenLayers.Tile>} 269 */ 270 removeTileMonitoringHooks: function(tile) { 271 tile.events.unregister("loadstart", this, tile.onLoadStart); 272 tile.events.unregister("loadend", this, tile.onLoadEnd); 273 }, 274 225 275 /** 226 276 * Method: onMapResize 227 277 * Call the onMapResize method of the appropriate parent class. -
lib/OpenLayers/Layer/GeoRSS.js
old new 55 61 OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name, options]); 56 62 this.location = location; 57 63 this.features = new Array(); 64 this.events.triggerEvent("loadstart"); 58 65 OpenLayers.loadURL(location, null, this, this.parseData); 59 66 }, 60 67 … … 191 203 marker.events.register('click', feature, this.markerClick); 192 204 this.addMarker(marker); 193 205 } 206 this.events.triggerEvent("loadend"); 194 207 }, 195 208 196 209 /** -
lib/OpenLayers/Tile/WFS.js
old new 77 77 */ 78 78 draw:function() { 79 79 if (OpenLayers.Tile.prototype.draw.apply(this, arguments)) { 80 if (this.isLoading) { 81 //if we're already loading, send 'reload' instead of 'loadstart'. 82 this.events.triggerEvent("reload"); 83 } else { 84 this.isLoading = true; 85 this.events.triggerEvent("loadstart"); 86 } 80 87 this.loadFeaturesForRegion(this.requestSuccess); 81 88 } 82 89 }, … … 117 124 var resultFeatures = OpenLayers.Ajax.getElementsByTagNameNS(doc, "http://www.opengis.net/gml","gml", "featureMember"); 118 125 this.addResults(resultFeatures); 119 126 } 127 if (this.isLoading) { 128 this.isLoading = false; 129 this.events.triggerEvent("loadend"); 130 } 120 131 }, 121 132 122 133 /**
