[OpenLayers-Commits] r11047 - in trunk/openlayers: examples lib/OpenLayers/Layer/Google

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Jan 20 08:31:30 EST 2011


Author: ahocevar
Date: 2011-01-20 05:31:30 -0800 (Thu, 20 Jan 2011)
New Revision: 11047

Modified:
   trunk/openlayers/examples/google-v3.html
   trunk/openlayers/examples/google-v3.js
   trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js
Log:
giving Layer.Google.v3 an animationEnabled option, like the one we already have for Layer.VirtualEarth. r=bartvde (closes #3020)


Modified: trunk/openlayers/examples/google-v3.html
===================================================================
--- trunk/openlayers/examples/google-v3.html	2011-01-20 13:20:03 UTC (rev 11046)
+++ trunk/openlayers/examples/google-v3.html	2011-01-20 13:31:30 UTC (rev 11047)
@@ -19,6 +19,8 @@
         </p>
         <div id="map" class="smallmap"></div>
         <div id="docs">
+            <p><input id="animate" type="checkbox" checked="checked">Animated
+                zoom (if supported by GMaps on your device)</input></p>
             <p>
                 If you use the Google Maps v3 API with a Google layer, you don't
                 need to include an API key.  This layer only works in the 

Modified: trunk/openlayers/examples/google-v3.js
===================================================================
--- trunk/openlayers/examples/google-v3.js	2011-01-20 13:20:03 UTC (rev 11046)
+++ trunk/openlayers/examples/google-v3.js	2011-01-20 13:31:30 UTC (rev 11047)
@@ -29,4 +29,12 @@
         new OpenLayers.Projection("EPSG:4326"),
         map.getProjectionObject()
     ), 5);
+    
+    // add behavior to html
+    var animate = document.getElementById("animate");
+    animate.onclick = function() {
+        for (var i=map.layers.length-1; i>=0; --i) {
+            map.layers[i].animationEnabled = this.checked;
+        }
+    };
 }

Modified: trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js	2011-01-20 13:20:03 UTC (rev 11046)
+++ trunk/openlayers/lib/OpenLayers/Layer/Google/v3.js	2011-01-20 13:31:30 UTC (rev 11047)
@@ -51,6 +51,19 @@
         projection: "EPSG:900913"
     },
 
+    /**
+     * APIProperty: animationEnabled
+     * {Boolean} If set to true, the transition between zoom levels will be
+     *     animated (if supported by the GMaps API for the device used). Set to
+     *     false to match the zooming experience of other layer types. Default
+     *     is true. Note that the GMaps API does not give us control over zoom
+     *     animation, so if set to false, when zooming, this will make the
+     *     layer temporarily invisible, wait until GMaps reports the map being
+     *     idle, and make it visible again. The result will be a blank layer
+     *     for a few moments while zooming.
+     */
+    animationEnabled: true, 
+
     /** 
      * Method: loadMapObject
      * Load the GMap and register appropriate event listeners. If we can't 
@@ -340,6 +353,17 @@
      * zoom - {int} MapObject zoom format
      */
     setMapObjectCenter: function(center, zoom) {
+        if (this.animationEnabled === false && zoom != this.mapObject.zoom) {
+            var mapContainer = this.getMapContainer();
+            google.maps.event.addListenerOnce(
+                this.mapObject, 
+                "idle", 
+                function() {
+                    mapContainer.style.visibility = "";
+                }
+            );
+            mapContainer.style.visibility = "hidden";
+        }
         this.mapObject.setOptions({
             center: center,
             zoom: zoom



More information about the Commits mailing list