[fusion-commits] r2544 - in trunk: . lib lib/OpenLayers

svn_fusion at osgeo.org svn_fusion at osgeo.org
Sat Jul 7 05:08:15 PDT 2012


Author: jng
Date: 2012-07-07 05:08:15 -0700 (Sat, 07 Jul 2012)
New Revision: 2544

Added:
   trunk/lib/OpenLayers/OpenLayersGMapsPatch.js
Modified:
   trunk/build.xml
   trunk/lib/fusion.js
Log:
#529: Patch our internal copy of OpenLayers to remove the "Map Data" popup on every move in a TOS-compliant manner (source: http://trac.osgeo.org/openlayers/wiki/Release/2.11/GoogleMaps37)

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2012-07-07 11:51:06 UTC (rev 2543)
+++ trunk/build.xml	2012-07-07 12:08:15 UTC (rev 2544)
@@ -214,6 +214,7 @@
                           fusion.js
                           Proj4js/proj4js-compressed.js
                           OpenLayers/OpenLayers.js
+                          OpenLayers/OpenLayersGMapsPatch.js
                           OLpatch.js
                           jxLib/jxlib.uncompressed.js
                           IE9patch.js

Added: trunk/lib/OpenLayers/OpenLayersGMapsPatch.js
===================================================================
--- trunk/lib/OpenLayers/OpenLayersGMapsPatch.js	                        (rev 0)
+++ trunk/lib/OpenLayers/OpenLayersGMapsPatch.js	2012-07-07 12:08:15 UTC (rev 2544)
@@ -0,0 +1,54 @@
+/**
+ * OpenLayersGMapsPatch.js
+ *
+ * This is a TOS-compliant patch to remove the "Map Data" popup that gets displayed on each map move.
+ *
+ * Source: http://trac.osgeo.org/openlayers/wiki/Release/2.11/GoogleMaps37
+ * TODO: When we move to OpenLayers 2.12, the patch is built in and this file will no longer be needed
+ */
+
+OpenLayers.Layer.Google.v3.repositionMapElements = function() {
+    // This is the first time any Google layer in this mapObject has been
+    // made visible.  The mapObject needs to know the container size.
+    google.maps.event.trigger(this.mapObject, "resize");
+    
+    var div = this.mapObject.getDiv().firstChild;
+    if (!div || div.childNodes.length < 3) {
+        this.repositionTimer = window.setTimeout(
+            OpenLayers.Function.bind(this.repositionMapElements, this),
+            250
+        );
+        return false;
+    }
+
+    var cache = OpenLayers.Layer.Google.cache[this.map.id];
+    var container = this.map.viewPortDiv;
+    
+    // move the ToS and branding stuff up to the container div
+    // depends on value of zIndex, which is not robust
+    for (var i=div.children.length-1; i>=0; --i) {
+        if (div.children[i].style.zIndex == 1000001) {
+            var termsOfUse = div.children[i];
+            container.appendChild(termsOfUse);
+            termsOfUse.style.zIndex = "1100";
+            termsOfUse.style.bottom = "";
+            termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
+            termsOfUse.style.display = "";
+            cache.termsOfUse = termsOfUse;
+        }
+        if (div.children[i].style.zIndex == 1000000) {
+            var poweredBy = div.children[i];
+            container.appendChild(poweredBy);
+            poweredBy.style.zIndex = "1100";
+            poweredBy.style.bottom = "";
+            poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
+            poweredBy.style.display = "";
+            cache.poweredBy = poweredBy;
+        }
+        if (div.children[i].style.zIndex == 10000002) {
+            container.appendChild(div.children[i]);
+        }
+    }
+
+    this.setGMapVisibility(this.visibility);
+};
\ No newline at end of file

Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js	2012-07-07 11:51:06 UTC (rev 2543)
+++ trunk/lib/fusion.js	2012-07-07 12:08:15 UTC (rev 2544)
@@ -1398,6 +1398,7 @@
     
     if (!Fusion._singleFile) {
         var coreScripts = ['lib/OpenLayers/OpenLayers.js',
+                           'lib/OpenLayers/OpenLayersGMapsPatch.js', /* Remove when we base off of OL 2.12 */
                             'lib/OLpatch.js',
                             'lib/jxLib/jxlib.uncompressed.js',
                             'lib/IE9patch.js',



More information about the fusion-commits mailing list