[OpenLayers-Commits] r11408 - in sandbox/ahocevar/layercontainer/lib/OpenLayers: . Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Feb 24 06:43:41 EST 2011


Author: erilem
Date: 2011-02-24 03:43:41 -0800 (Thu, 24 Feb 2011)
New Revision: 11408

Modified:
   sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer.js
   sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/Grid.js
   sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js
Log:
call moveByPx on every layer

Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/Grid.js	2011-02-24 11:43:13 UTC (rev 11407)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer/Grid.js	2011-02-24 11:43:41 UTC (rev 11408)
@@ -126,19 +126,6 @@
         this._moveGriddedTiles = OpenLayers.Function.bind(
             this.moveGriddedTiles, this
         );
-        
-        this.events.register("move", this, function() {
-            if (!this._forceReTile) {
-                if (this.timerId != null) {
-                    window.clearTimeout(this.timerId);
-                }
-                this.timerId = window.setTimeout(
-                    this._moveGriddedTiles,
-                    this.tileLoadingDelay
-                );
-            }
-            delete this._forceReTile;
-        });
     },
 
     /**
@@ -245,12 +232,29 @@
                 //  then we want to reTile (thus, partial true).  
                 //
                 if (forceReTile || !tilesBounds.containsBounds(bounds, true)) {
-                    this._forceReTile = true;
                     this.initGriddedTiles(bounds);
                 }
             }
         }
     },
+
+    /**
+     * Method: moveByPx
+     * Move the layer based on pixel vector.
+     *
+     * Parameters:
+     * dx - {Number}
+     * dy - {Number}
+     */
+    moveByPx: function(dx, dy) {
+        if (this.timerId != null) {
+            window.clearTimeout(this.timerId);
+        }
+        this.timerId = window.setTimeout(
+            this._moveGriddedTiles,
+            this.tileLoadingDelay
+        );
+    },
     
     /**
      * APIMethod: setTileSize

Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer.js	2011-02-24 11:43:13 UTC (rev 11407)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Layer.js	2011-02-24 11:43:41 UTC (rev 11408)
@@ -571,6 +571,17 @@
     },
 
     /**
+     * Method: moveByPx
+     * Move the layer based on pixel vector. To be implemented by subclasses.
+     *
+     * Parameters:
+     * dx - {Number} The x coord of the displacement vector.
+     * dy - {Number} The y coord of the displacement vector.
+     */
+    moveByPx: function(dx, dy) {
+    },
+
+    /**
      * Method: setMap
      * Set the map property for the layer. This is done through an accessor
      *     so that subclasses can override this and take special action once 

Modified: sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js
===================================================================
--- sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js	2011-02-24 11:43:13 UTC (rev 11407)
+++ sandbox/ahocevar/layercontainer/lib/OpenLayers/Map.js	2011-02-24 11:43:41 UTC (rev 11408)
@@ -1687,10 +1687,15 @@
                 this.maxPx.y -= dy;
             }
             this.events.triggerEvent("move");
-            var layer;
-            for (var i=0, ii=this.layers.length; i<ii; ++i) {
+            var layer, i, len;
+            for (i=0, len=this.layers.length; i<len; ++i) {
                 layer = this.layers[i];
-                layer.visibility && layer.events.triggerEvent("move");
+                // FIXME inRange must be taken into account somehow
+                // do we need to deal differently with the base layer?
+                if (layer.visibility) {
+                    layer.moveByPx(dx, dy);
+                    layer.events.triggerEvent("move");
+                }
             }
         }
     },



More information about the Commits mailing list