From 175423b3ba27e3c49000384cf9272adea18e72ea Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Wed, 28 Mar 2012 11:40:14 -0400 Subject: [PATCH 1/4] In the case of an overview map rendered into a user-provided div, the minimize and maximize divs are not created so we need to test for existence of them in the showToggle method. --- lib/OpenLayers/Control/OverviewMap.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index c572451495..e683c0f0b5 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -398,8 +398,12 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * minimize - {Boolean} */ showToggle: function(minimize) { - this.maximizeDiv.style.display = minimize ? '' : 'none'; - this.minimizeDiv.style.display = minimize ? 'none' : ''; + if (this.maximizeDiv) { + this.maximizeDiv.style.display = minimize ? '' : 'none'; + } + if (this.minimizeDiv) { + this.minimizeDiv.style.display = minimize ? 'none' : ''; + } }, /** From 9e31fb6e9a9b76c6c80bea05fab4d4fbe136f38f Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Wed, 28 Mar 2012 14:06:51 -0400 Subject: [PATCH 2/4] Update OverviewMap to test if calling minimizeControl or maximizeControl causes an exception. --- tests/Control/OverviewMap.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index 30cac5dff0..7e6a8f2e3d 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -209,6 +209,37 @@ map.destroy(); } + + function test_custom_div(t) { + t.plan(3); + var div = document.createElement('div'); + + control = new OpenLayers.Control.OverviewMap({ + div: div + }); + + map = new OpenLayers.Map('map', { + layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})], + controls: [control] + }); + + t.eq(control.maximizeDiv, null, + "OverviewMap does not create maximize div"); + t.eq(control.minimizeDiv, null, + "OverviewMap does not create minimize div"); + + var exc; + try { + control.maximizeControl(); + control.minimizeControl(); + } catch(e) { + exc = e; + } + + t.ok(exc != undefined, 'maximize and minimize do not trigger an exception'); + + map.destroy(); + } From d4e6253447523427bc249e8e8fd7fed55a622473 Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Thu, 29 Mar 2012 07:32:25 -0400 Subject: [PATCH 3/4] indent 4. --- tests/Control/OverviewMap.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index 7e6a8f2e3d..b9ae5b6fca 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -230,8 +230,8 @@ var exc; try { - control.maximizeControl(); - control.minimizeControl(); + control.maximizeControl(); + control.minimizeControl(); } catch(e) { exc = e; } From 30af95d034fda584bfc9a6931b10f1b0b9dd9cca Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Fri, 30 Mar 2012 07:59:22 -0400 Subject: [PATCH 4/4] a working test thanks to Marc. --- tests/Control/OverviewMap.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Control/OverviewMap.html b/tests/Control/OverviewMap.html index b9ae5b6fca..6548e21e59 100644 --- a/tests/Control/OverviewMap.html +++ b/tests/Control/OverviewMap.html @@ -236,7 +236,7 @@ exc = e; } - t.ok(exc != undefined, 'maximize and minimize do not trigger an exception'); + t.eq(exc, undefined, 'maximize and minimize do not trigger an exception'); map.destroy(); }