From 797c57586ad2f52a05255fca685cce639ac442c3 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 2 Apr 2008 14:08:01 +0000 Subject: [PATCH] The FramedCloud popup throws an error if you attempt to call setContentHTML before you add the popup to the map. To prevent this, don't call construct or updateBlocks if relativePosition is null, to prevent this error message. r=elemoine, (Pullup #1479) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6765 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Popup/Framed.js | 17 ++++++++++++++--- tests/Popup/FramedCloud.html | 18 ++++++++++++++++++ tests/list-tests.html | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/Popup/FramedCloud.html diff --git a/lib/OpenLayers/Popup/Framed.js b/lib/OpenLayers/Popup/Framed.js index ebd017f6a1..4b864b6f7e 100644 --- a/lib/OpenLayers/Popup/Framed.js +++ b/lib/OpenLayers/Popup/Framed.js @@ -248,6 +248,12 @@ OpenLayers.Popup.Framed = * Method: createBlocks */ createBlocks: function() { + if (!this.relativePosition) { + // this.relativePosition can't be set until we have a map + // set: if it's not set, we can't create blocks. (See #1479) + return false; + } + this.blocks = []; var position = this.positionBlocks[this.relativePosition]; @@ -274,6 +280,8 @@ OpenLayers.Popup.Framed = block.div.appendChild(block.image); this.groupDiv.appendChild(block.div); } + + return true; }, /** @@ -283,11 +291,14 @@ OpenLayers.Popup.Framed = * the popup's blocks in their appropropriate places. */ updateBlocks: function() { - if (!this.blocks) { - this.createBlocks(); + var cont = this.createBlocks(); + if (!cont) { + return false; + } } - + + var position = this.positionBlocks[this.relativePosition]; for (var i = 0; i < position.blocks.length; i++) { diff --git a/tests/Popup/FramedCloud.html b/tests/Popup/FramedCloud.html new file mode 100644 index 0000000000..b7f33257a5 --- /dev/null +++ b/tests/Popup/FramedCloud.html @@ -0,0 +1,18 @@ + + + + + + +
+ + diff --git a/tests/list-tests.html b/tests/list-tests.html index 94ba67900c..209fb506d8 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -40,6 +40,7 @@
  • Popup.html
  • Popup/Anchored.html
  • Popup/AnchoredBubble.html
  • +
  • Popup/FramedCloud.html
  • Feature.html
  • Feature/Vector.html
  • Style.html