Skip to content

Commit 99f116e

Browse files
committed
With tileQueue, we need a different way of handling loadstart/loadend.
1 parent de97165 commit 99f116e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/OpenLayers/Layer/Grid.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
138138
*/
139139
tileQueue: null,
140140

141+
/**
142+
* Property: loading
143+
* {Boolean} Indicates if tiles are being loaded.
144+
*/
145+
loading: false,
146+
141147
/**
142148
* Property: backBuffer
143149
* {DOMElement} The back buffer.
@@ -1050,7 +1056,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
10501056

10511057
tile.onLoadStart = function() {
10521058
//if that was first tile then trigger a 'loadstart' on the layer
1053-
if (this.numLoadingTiles == 0) {
1059+
if (this.loading === false) {
1060+
this.loading = true;
10541061
this.events.triggerEvent("loadstart");
10551062
}
10561063
this.events.triggerEvent("tileloadstart", {tile: tile});
@@ -1061,7 +1068,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
10611068
this.numLoadingTiles--;
10621069
this.events.triggerEvent("tileloaded", {tile: tile});
10631070
//if that was the last tile, then trigger a 'loadend' on the layer
1064-
if (this.numLoadingTiles === 0) {
1071+
if (this.tileQueue.length === 0 && this.numLoadingTiles === 0) {
1072+
this.loading = false;
10651073
this.events.triggerEvent("loadend");
10661074
if(this.backBuffer) {
10671075
// the removal of the back buffer is delayed to prevent flash

0 commit comments

Comments
 (0)