diff --git a/examples/spherical-mercator.html b/examples/spherical-mercator.html index 409a8e232f..fc1bf681a5 100644 --- a/examples/spherical-mercator.html +++ b/examples/spherical-mercator.html @@ -91,16 +91,11 @@

OpenLayers Spherical Mercator Example

// create OSM layers var mapnik = new OpenLayers.Layer.OSM(); - var osmarender = new OpenLayers.Layer.OSM( - "OpenStreetMap (Tiles@Home)", - "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png" - ); - // create a vector layer for drawing var vector = new OpenLayers.Layer.Vector("Editable Vectors"); map.addLayers([ - gphy, gmap, gsat, ghyb, veroad, veaer, vehyb, mapnik, osmarender, vector + gphy, gmap, gsat, ghyb, veroad, veaer, vehyb, mapnik, vector ]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.EditingToolbar(vector)); diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 4af8ec8423..1e3598bd04 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -138,6 +138,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { */ tileQueue: null, + /** + * Property: loading + * {Boolean} Indicates if tiles are being loaded. + */ + loading: false, + /** * Property: backBuffer * {DOMElement} The back buffer. @@ -1050,7 +1056,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { tile.onLoadStart = function() { //if that was first tile then trigger a 'loadstart' on the layer - if (this.numLoadingTiles == 0) { + if (this.loading === false) { + this.loading = true; this.events.triggerEvent("loadstart"); } this.events.triggerEvent("tileloadstart", {tile: tile}); @@ -1061,7 +1068,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { this.numLoadingTiles--; this.events.triggerEvent("tileloaded", {tile: tile}); //if that was the last tile, then trigger a 'loadend' on the layer - if (this.numLoadingTiles === 0) { + if (this.tileQueue.length === 0 && this.numLoadingTiles === 0) { + this.loading = false; this.events.triggerEvent("loadend"); if(this.backBuffer) { // the removal of the back buffer is delayed to prevent flash