Skip to content
This repository
Browse code

Merge pull request #472 from probins/goopop

Fix Google terms/poweredby/popup. Thanks @probins for the quick fix.
  • Loading branch information...
commit 92f04a7a4277a6c818ef2d40a2856910ed72d3d6 2 parents 2624ea0 + f435a98
Andreas Hocevar authored May 17, 2012

Showing 1 changed file with 24 additions and 20 deletions. Show diff stats Hide diff stats

  1. 44  lib/OpenLayers/Layer/Google/v3.js
44  lib/OpenLayers/Layer/Google/v3.js
@@ -137,27 +137,31 @@ OpenLayers.Layer.Google.v3 = {
137 137
         var cache = OpenLayers.Layer.Google.cache[this.map.id];
138 138
         var container = this.map.viewPortDiv;
139 139
         
140  
-        // move the Map Data popup to the container, if any
141  
-        while (div.lastChild.style.display == "none") {
142  
-            container.appendChild(div.lastChild);
143  
-        }
144  
-
145 140
         // move the ToS and branding stuff up to the container div
146  
-        var termsOfUse = div.lastChild;
147  
-        container.appendChild(termsOfUse);
148  
-        termsOfUse.style.zIndex = "1100";
149  
-        termsOfUse.style.bottom = "";
150  
-        termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
151  
-        termsOfUse.style.display = "";
152  
-        cache.termsOfUse = termsOfUse;
153  
-
154  
-        var poweredBy = div.lastChild;
155  
-        container.appendChild(poweredBy);
156  
-        poweredBy.style.zIndex = "1100";
157  
-        poweredBy.style.bottom = "";
158  
-        poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
159  
-        poweredBy.style.display = "";
160  
-        cache.poweredBy = poweredBy;
  141
+        // depends on value of zIndex, which is not robust
  142
+        for (var i=div.children.length-1; i>=0; --i) {
  143
+            if (div.children[i].style.zIndex == 1000001) {
  144
+                var termsOfUse = div.children[i];
  145
+                container.appendChild(termsOfUse);
  146
+                termsOfUse.style.zIndex = "1100";
  147
+                termsOfUse.style.bottom = "";
  148
+                termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
  149
+                termsOfUse.style.display = "";
  150
+                cache.termsOfUse = termsOfUse;
  151
+            }
  152
+            if (div.children[i].style.zIndex == 1000000) {
  153
+                var poweredBy = div.children[i];
  154
+                container.appendChild(poweredBy);
  155
+                poweredBy.style.zIndex = "1100";
  156
+                poweredBy.style.bottom = "";
  157
+                poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
  158
+                poweredBy.style.display = "";
  159
+                cache.poweredBy = poweredBy;
  160
+            }
  161
+            if (div.children[i].style.zIndex == 10000002) {
  162
+                container.appendChild(div.children[i]);
  163
+            }
  164
+        }
161 165
 
162 166
         this.setGMapVisibility(this.visibility);
163 167
 

0 notes on commit 92f04a7

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