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

Eric Lemoine eric.c2c at gmail.com
Mon Jul 21 11:34:00 EDT 2008


To me it makes more sense that strategies rely on the moveend *layer*
event that Pierre just committed rather than they check if the layer
is visible and in range. Strategies shouldn't know about properties
like visible and inrange, and implementing strategies should be as
easy as possible, for people not familiar with OL core to be able to
develop their own, possibly app-specific, strategies. Eric

2008/7/21, Tim Schaub <tschaub at opengeo.org>:
> Hey-
>
> I did the same for the BBOX strategy last week (only in the topp/trimet
> sandbox):
>
> http://trac.openlayers.org/changeset/7523
>
> Next week I'll work on merging whatever other changes I've made
> elsewhere to the vector-behavior sandbox.
>
> Tim
>
>
> Eric Lemoine wrote:
>> Yes, by registering a moveend listener on its layer the strategy will
>> only receive moveend events if the layer moveTo was called, i.e. if
>> the layer is visible and in range. This is making sense to me. What do
>> you guys think? Eric
>>
>> 2008/7/18, Pierre GIRAUD <bluecarto at gmail.com>:
>>> 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
>>> _______________________________________________
>>> Dev mailing list
>>> Dev at openlayers.org
>>> http://openlayers.org/mailman/listinfo/dev
>>>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
>> !DSPAM:4033,4880c4fd271554901796417!
>>
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>



More information about the Dev mailing list