OpenLayers OpenLayers

Changeset 7650

Show
Ignore:
Timestamp:
07/31/08 21:27:35 (4 months ago)
Author:
tschaub
Message:

Adding strategy and protocol base classes for better vector behavior. This just sets the common API for strategy and protocol. In general, a vector layer can have many strategies. A setLayer method gets called on each of these layers. When a layer is added to a map, any strategies on that layer get activated. When the layer is destroyed, any strategies get destroyed (this could be changed to deactivate for symmetry). A vector layer may also have a protocol. A protocol is typically constructed with a format. The layer doesn't need to know about the format. The protocol doesn't need to know about the layer. Strategies coordinate feature management for a layer. Specific strategies and protocols to follow. r=crschmidt (closes #1646)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers.js

    r7627 r7650  
    181181            "OpenLayers/Renderer/VML.js", 
    182182            "OpenLayers/Layer/Vector.js", 
     183            "OpenLayers/Strategy.js", 
     184            "OpenLayers/Protocol.js", 
    183185            "OpenLayers/Layer/PointTrack.js", 
    184186            "OpenLayers/Layer/GML.js", 
  • trunk/openlayers/lib/OpenLayers/Layer/Vector.js

    r7627 r7650  
    126126     */ 
    127127    styleMap: null, 
    128  
     128     
     129    /** 
     130     * Property: strategies 
     131     * {Array(<OpenLayers.Strategy>})} Optional list of strategies for the layer. 
     132     */ 
     133    strategies: null, 
     134     
     135    /** 
     136     * Property: protocol 
     137     * {<OpenLayers.Protocol>} Optional protocol for the layer. 
     138     */ 
     139    protocol: null, 
     140     
    129141    /** 
    130142     * Property: renderers 
     
    195207        this.features = []; 
    196208        this.selectedFeatures = []; 
     209         
     210        // Allow for custom layer behavior 
     211        if(this.strategies){ 
     212            for(var i=0, len=this.strategies.length; i<len; i++) { 
     213                this.strategies[i].setLayer(this); 
     214            } 
     215        } 
     216 
    197217    }, 
    198218 
     
    202222     */ 
    203223    destroy: function() { 
     224        if (this.stategies) { 
     225            for(var i=0, len=this.strategies.length; i<len; i++) { 
     226                this.strategies[i].destroy(); 
     227            } 
     228            this.strategies = null; 
     229        } 
     230        if (this.protocol) { 
     231            this.protocol.destroy(); 
     232            this.protocol = null; 
     233        } 
    204234        this.destroyFeatures(); 
    205235        this.features = null; 
     
    258288            this.renderer.map = this.map; 
    259289            this.renderer.setSize(this.map.getSize()); 
     290        } 
     291        if(this.strategies) { 
     292            for(var i=0, len=this.strategies.length; i<len; i++) { 
     293                this.strategies[i].activate(); 
     294            } 
    260295        } 
    261296    }, 
  • trunk/openlayers/tests/list-tests.html

    r7644 r7650  
    111111    <li>Popup/FramedCloud.html</li> 
    112112    <li>Projection.html</li> 
     113    <li>Protocol.html</li> 
    113114    <li>Renderer.html</li> 
    114115    <li>Renderer/Elements.html</li> 
     
    118119    <li>Request/XMLHttpRequest.html</li> 
    119120    <li>Rule.html</li> 
     121    <li>Strategy.html</li> 
    120122    <li>Style.html</li> 
    121123    <li>StyleMap.html</li>