[OpenLayers-Dev] [vector-behavior] proposal for changes

Paul Spencer pspencer at dmsolutions.ca
Tue Jul 15 08:52:56 EDT 2008


Hi Eric, no particular comments on your changes, they all sound great  
to me but I am not actively using any Strategy related stuff yet so I  
am not qualified to have an opinion.  But I did want to comment on  
using class as a keyword in the strategies option - I think that class  
is a reserved word in (at least some implementations of) javascript  
and has to be quoted when used as a property name, which people aren't  
used to (at least I wasn't):

new OpenLayers.Layer.Vector({
    strategies: [{
            'class': OpenLayers.Strategy.BBOX,
            options: {ratio: 4}
        }, {
            'class': OpenLayers.Strategy.Save
    }]
});

I'm not sure what a better name would be, but if you stick with class  
be aware that some folks will run into problems.

Cheers

Paul

On 15-Jul-08, at 4:16 AM, Eric Lemoine wrote:

> Hello
>
> I'd like to bring a few changes to the vector-behavior code. Before
> making these changes, I wanted to describe them and give everyone a
> chance to speak up. Here they are:
>
> * remove update() and commit() from the strategy API. Just like
> controls and handlers, strategies are activated/deactivated through
> activate()/deactivate().
>
> * remove property 'strategy' from Layer.Vector, strategies are set in
> the 'strategies' properties (Array)
>
> * make Layer.Vector responsible for creating, destroying, activating
> and deactivating its strategies. (a) Today Layer.Vector.setMap()
> activates the strategies but never deactivates them; instead,
> Layer.Vector should override removeMap() and deactivates the
> strategies in there. (b) To make Layer.Vector responsible for creating
> and destroying the strategies, Strategy classes as opposed to Strategy
> instances must be passed to the Layer.Vector constructor, I would go
> with:
>
> new OpenLayers.Layer.Vector({
>    strategies: [{
>            class: OpenLayers.Strategy.BBOX,
>            options: {ratio: 4}
>        }, {
>            class: OpenLayers.Strategy.Save
>    }]
> });
>
> * make Layer.Vector responsible for creating and destroying its
> protocol. In the same way as above, a Protocol class as opposed to a
> Protocol instance is passed to the Layer.Vector constructor:
>
> new OpenLayers.Layer.Vector({
>    strategies: [{
>            class: OpenLayers.Strategy.BBOX,
>            options: {ratio: 4}
>        }, {
>            class: OpenLayers.Strategy.Save
>    }],
>    protocol: OpenLayers.Protocol.HTTP,
>    protocolOptions: {url: /path/to/service}
> });
>
> * remove the setLayer() method from the Strategy base class.
> Vector.Layer will do something like that:
>
> for (var i = 0; i < this.strategies.length; i++) {
>    var strategy = new this.strategies[i].class({
>        layer: this,
>        ...
>    });
> }
>
> * make Layer.Vector responsible for creating/destroying the format
> instance. Again, a format class as opposed to a format instance is
> passed to the Layer.Vector constructor.
>
> * remove the setFormat() method from the Protocol class. The format
> instance is passed at protocol creating using new
> OpenLayers.Protocol({format: format}).
>
> Thoughts?
>
> Thanks,
>
> --
> Eric
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://www.dmsolutions.ca/




More information about the Dev mailing list