/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the 2-clause BSD license. * See license.txt in the OpenLayers distribution or repository for the * full text of the license. */ /** * @requires OpenLayers/Layer/Vector.js */ /** * Class: OpenLayers.Layer.Vector.RootContainer * A special layer type to combine multiple vector layers inside a single * renderer root container. This class is not supposed to be instantiated * from user space, it is a helper class for controls that require event * processing for multiple vector layers. * * Inherits from: * - */ OpenLayers.Layer.Vector.RootContainer = OpenLayers.Class(OpenLayers.Layer.Vector, { /** * Property: displayInLayerSwitcher * Set to false for this layer type */ displayInLayerSwitcher: false, /** * APIProperty: layers * Layers that are attached to this container. Required config option. */ layers: null, /** * Constructor: OpenLayers.Layer.Vector.RootContainer * Create a new root container for multiple vector layer. This constructor * is not supposed to be used from user space, it is only to be used by * controls that need feature selection across multiple vector layers. * * Parameters: * name - {String} A name for the layer * options - {Object} Optional object with non-default properties to set on * the layer. * * Required options properties: * layers - {Array()} The layers managed by this * container * * Returns: * {} A new vector layer root * container */ /** * Method: display */ display: function() {}, /** * Method: getFeatureFromEvent * walk through the layers to find the feature returned by the event * * Parameters: * evt - {Object} event object with a feature property * * Returns: * {} */ getFeatureFromEvent: function(evt) { var layers = this.layers; var feature; for(var i=0; i} */ setMap: function(map) { OpenLayers.Layer.Vector.prototype.setMap.apply(this, arguments); this.collectRoots(); map.events.register("changelayer", this, this.handleChangeLayer); }, /** * Method: removeMap * * Parameters: * map - {} */ removeMap: function(map) { map.events.unregister("changelayer", this, this.handleChangeLayer); this.resetRoots(); OpenLayers.Layer.Vector.prototype.removeMap.apply(this, arguments); }, /** * Method: collectRoots * Collects the root nodes of all layers this control is configured with * and moveswien the nodes to this control's layer */ collectRoots: function() { var layer; // walk through all map layers, because we want to keep the order for(var i=0; i