[OpenLayers-Dev] Layer.Vector: getStrategyByClass

Tim Schaub tschaub at opengeo.org
Mon Nov 24 13:57:46 EST 2008


Hey-

Eric Lemoine wrote:
> On Tue, Nov 18, 2008 at 9:38 AM,  <bartvde at osgis.nl> wrote:
>> Hi list,
>>
>> it would be convenient if the Vector Layer would have a getStrategyByClass
>> function or not?
> 
> Yes it would.
> 
>> On a side note, should the getBy function of Map.js not be a Util one?
> 
> In that case it'd look like:
> 
> function(obj, array, property, match) {
>     var test = (typeof match.test == "function");
>     var found = OpenLayers.Array.filter(obj[array], function(item) {
>         return item[property] == match || (test && match.test(item[property]));
>     });
>     return found;
> }
> 

Since the obj and array args are only used there in obj[array], it 
doesn't make sense to have two args.

So, this breaks down into a function that filters an array for items 
that have a matching property.

Instead of an OpenLayers.Util.getBy function, this sounds more like an 
OpenLayers.Array.getItemsByProperty function - or something.

If people prefer the less literal util name, that's fine by me.

Tim

> Given that Map.getBy is an API method it should remain. However it
> could rely on the getBy function defined in Util.js:
> 
> getBy: function(array, property, match) {
>     return OpenLayers.Util.getBy(this, array, property, match)
> },
> 
> I'm +1 on adding a  getStrategyByClass method to the Layer.Vector
> class and on adding a GetBy function to Util.js.
> 
> Thanks Bart,
> --
> Eric
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list