From 551f509b490234e637ea6d1507d8744b7db0d6f1 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 19 Apr 2012 15:26:16 +0200 Subject: [PATCH] Make sure tiles are loaded for Bing overlays. Previously, Bing overlays that were added to an existing map had empty tiles, because tiles are added before the layer url is set in initLayer. This change makes sure tiles are only rendered when the layer url is available, by not processing the tile queue before the layer url is set. --- lib/OpenLayers/Layer/Bing.js | 16 ++++++++++++---- tests/Layer/Bing.html | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Bing.js b/lib/OpenLayers/Layer/Bing.js index 30bb412550..162edf98a5 100644 --- a/lib/OpenLayers/Layer/Bing.js +++ b/lib/OpenLayers/Layer/Bing.js @@ -176,6 +176,18 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { res.zoomMax + 1 - res.zoomMin, this.numZoomLevels ) }, true); + this.updateAttribution(); + }, + + /** + * Method: drawTileFromQueue + * Draws the first tile from the tileQueue, and unqueues that tile + */ + drawTileFromQueue: function() { + // don't start working on the queue before we have a url from initLayer + if (this.url) { + OpenLayers.Layer.XYZ.prototype.drawTileFromQueue.apply(this, arguments); + } }, /** @@ -185,9 +197,6 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { * bounds - {} */ getURL: function(bounds) { - if (!this.url) { - return; - } var xyz = this.getXYZ(bounds), x = xyz.x, y = xyz.y, z = xyz.z; var quadDigits = []; for (var i = z; i > 0; --i) { @@ -253,7 +262,6 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { */ setMap: function() { OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments); - this.updateAttribution(); this.map.events.register("moveend", this, this.updateAttribution); }, diff --git a/tests/Layer/Bing.html b/tests/Layer/Bing.html index a55d2ebb24..b37de906fd 100644 --- a/tests/Layer/Bing.html +++ b/tests/Layer/Bing.html @@ -1,5 +1,19 @@ +