Skip to content
This repository
Browse code

Merge pull request #370 from pagameba/overviewmap

OverviewMap custom div bug.
  • Loading branch information...
commit 943efd66b00d553995f9af76c022c1d2cf2b9494 2 parents e35dfe1 + 30af95d
Paul Spencer authored
8  lib/OpenLayers/Control/OverviewMap.js
@@ -398,8 +398,12 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
398 398
      * minimize - {Boolean} 
399 399
      */
400 400
     showToggle: function(minimize) {
401  
-        this.maximizeDiv.style.display = minimize ? '' : 'none';
402  
-        this.minimizeDiv.style.display = minimize ? 'none' : '';
  401
+        if (this.maximizeDiv) {
  402
+            this.maximizeDiv.style.display = minimize ? '' : 'none';
  403
+        }
  404
+        if (this.minimizeDiv) {
  405
+            this.minimizeDiv.style.display = minimize ? 'none' : '';
  406
+        }
403 407
     },
404 408
 
405 409
     /**
31  tests/Control/OverviewMap.html
@@ -209,6 +209,37 @@
209 209
 
210 210
         map.destroy();
211 211
     }
  212
+    
  213
+    function test_custom_div(t) {
  214
+        t.plan(3);
  215
+        var div = document.createElement('div');
  216
+        
  217
+        control = new OpenLayers.Control.OverviewMap({
  218
+          div: div
  219
+        });
  220
+        
  221
+        map = new OpenLayers.Map('map', {
  222
+            layers  : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
  223
+            controls: [control]
  224
+        });
  225
+        
  226
+        t.eq(control.maximizeDiv, null, 
  227
+            "OverviewMap does not create maximize div");
  228
+        t.eq(control.minimizeDiv, null, 
  229
+            "OverviewMap does not create minimize div");
  230
+        
  231
+        var exc;
  232
+        try {
  233
+            control.maximizeControl();
  234
+            control.minimizeControl();
  235
+        } catch(e) {
  236
+            exc = e;
  237
+        }
  238
+
  239
+        t.eq(exc, undefined, 'maximize and minimize do not trigger an exception');
  240
+        
  241
+        map.destroy();
  242
+    }
212 243
 
213 244
   </script>
214 245
 </head>

0 notes on commit 943efd6

Please sign in to comment.
Something went wrong with that request. Please try again.