[OpenLayers-Dev] [vector-behavior] strategies and inRange

Pierre GIRAUD bluecarto at gmail.com
Fri Jul 18 06:03:58 EDT 2008


Hi all,

I'm playing with the code in the vector-behavior sandbox.
I found that the strategies (at least BBOX and Grid) don't check if
the layer is in range.

We can add code as following to support that :
{{{
Index: lib/OpenLayers/Strategy/Grid.js
===================================================================
--- lib/OpenLayers/Strategy/Grid.js     (revision 7544)
+++ lib/OpenLayers/Strategy/Grid.js     (working copy)
 -276,7 +276,9 @@
     refresh: function(evt) {
         var bounds = this.layer.map.getExtent();
         var force = evt.zoomChanged || evt.force;
-        this.grid.moveTo(bounds, force);
+        if (this.layer.inRange && this.layer.visibility) {
+            this.grid.moveTo(bounds, force);
+        }
     },

     CLASS_NAME: "OpenLayers.Strategy.Grid"
}}}

But, it feels like we duplicate some code as the inRange and
visibility checks are already made at the map level.

Instead we could imagine adding a "moveend" event at the layer level.
It would be triggered only when the layer is moved itself. And the
strategies would register to this new event.

Tshaub and sbenthall, please tell me if you feel confident with this.
If so, I can commit something very quickly in the sandbox.

Regards,
Pierre



More information about the Dev mailing list