Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Layer/Vector/RootContainer.js @ 76

Revision 76, 4.7 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
2 * full list of contributors). Published under the Clear BSD license. 
3 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
4 * full text of the license. */
5
6/**
7 * @requires OpenLayers/Layer/Vector.js
8 */
9
10/**
11 * Class: OpenLayers.Layer.Vector.RootContainer
12 * A special layer type to combine multiple vector layers inside a single
13 *     renderer root container. This class is not supposed to be instantiated
14 *     from user space, it is a helper class for controls that require event
15 *     processing for multiple vector layers.
16 *
17 * Inherits from:
18 *  - <OpenLayers.Layer.Vector>
19 */
20OpenLayers.Layer.Vector.RootContainer = OpenLayers.Class(OpenLayers.Layer.Vector, {
21   
22    /**
23     * Property: displayInLayerSwitcher
24     * Set to false for this layer type
25     */
26    displayInLayerSwitcher: false,
27   
28    /**
29     * APIProperty: layers
30     * Layers that are attached to this container. Required config option.
31     */
32    layers: null,
33   
34    /**
35     * Constructor: OpenLayers.Layer.Vector.RootContainer
36     * Create a new root container for multiple vector layer. This constructor
37     * is not supposed to be used from user space, it is only to be used by
38     * controls that need feature selection across multiple vector layers.
39     *
40     * Parameters:
41     * name - {String} A name for the layer
42     * options - {Object} Optional object with non-default properties to set on
43     *           the layer.
44     *
45     * Required options properties:
46     * layers - {Array(<OpenLayers.Layer.Vector>)} The layers managed by this
47     *     container
48     *
49     * Returns:
50     * {<OpenLayers.Layer.Vector.RootContainer>} A new vector layer root
51     *     container
52     */
53    initialize: function(name, options) {
54        OpenLayers.Layer.Vector.prototype.initialize.apply(this, arguments);
55    },
56   
57    /**
58     * Method: display
59     */
60    display: function() {},
61   
62    /**
63     * Method: getFeatureFromEvent
64     * walk through the layers to find the feature returned by the event
65     *
66     * Parameters:
67     * evt - {Object} event object with a feature property
68     *
69     * Returns:
70     * {<OpenLayers.Feature.Vector>}
71     */
72    getFeatureFromEvent: function(evt) {
73        var layers = this.layers;
74        var feature;
75        for(var i=0; i<layers.length; i++) {
76            feature = layers[i].getFeatureFromEvent(evt);
77            if(feature) {
78                return feature;
79            }
80        }
81    },
82   
83    /**
84     * Method: setMap
85     *
86     * Parameters:
87     * map - {<OpenLayers.Map>}
88     */
89    setMap: function(map) {
90        OpenLayers.Layer.Vector.prototype.setMap.apply(this, arguments);
91        this.collectRoots();
92        map.events.register("changelayer", this, this.handleChangeLayer);
93    },
94   
95    /**
96     * Method: removeMap
97     *
98     * Parameters:
99     * map - {<OpenLayers.Map>}
100     */
101    removeMap: function(map) {
102        map.events.unregister("changelayer", this, this.handleChangeLayer);
103        this.resetRoots();
104        OpenLayers.Layer.Vector.prototype.removeMap.apply(this, arguments);
105    },
106   
107    /**
108     * Method: collectRoots
109     * Collects the root nodes of all layers this control is configured with
110     * and moveswien the nodes to this control's layer
111     */
112    collectRoots: function() {
113        var layer;
114        // walk through all map layers, because we want to keep the order
115        for(var i=0; i<this.map.layers.length; ++i) {
116            layer = this.map.layers[i];
117            if(OpenLayers.Util.indexOf(this.layers, layer) != -1) {
118                layer.renderer.moveRoot(this.renderer);
119            }
120        }
121    },
122   
123    /**
124     * Method: resetRoots
125     * Resets the root nodes back into the layers they belong to.
126     */
127    resetRoots: function() {
128        var layer;
129        for(var i=0; i<this.layers.length; ++i) {
130            layer = this.layers[i];
131            if(this.renderer && layer.renderer.getRenderLayerId() == this.id) {
132                this.renderer.moveRoot(layer.renderer);
133            }
134        }
135    },
136   
137    /**
138     * Method: handleChangeLayer
139     * Event handler for the map's changelayer event. We need to rebuild
140     * this container's layer dom if order of one of its layers changes.
141     * This handler is added with the setMap method, and removed with the
142     * removeMap method.
143     *
144     * Parameters:
145     * evt - {Object}
146     */
147    handleChangeLayer: function(evt) {
148        var layer = evt.layer;
149        if(evt.property == "order" &&
150                        OpenLayers.Util.indexOf(this.layers, layer) != -1) {
151            this.resetRoots();
152            this.collectRoots();
153        }
154    },
155
156    CLASS_NAME: "OpenLayers.Layer.Vector.RootContainer"
157});
Note: See TracBrowser for help on using the repository browser.