I'm using an OpenLayers.Control.SelectFeature for selections on multiple layers. However, when I add a layer using setLayer(), my selections on the other layers are lost.
Anyone know how to work around this? I would like to keep my existing selections on other layers when I add a layer to the SelectFeature control.
Here is an example: MY EXAMPLE
Update:
I'm aware that this is part of the API. But i'm looking for a work around.
/**
* APIMethod: setLayer
* Attach a new layer to the control, overriding any existing layers.
*
* Parameters:
* layers - Array of {<OpenLayers.Layer.Vector>} or a single
* {<OpenLayers.Layer.Vector>}
*/
setLayer: function(layers) {
var isActive = this.active;
this.unselectAll();
this.deactivate();
if(this.layers) {
this.layer.destroy();
this.layers = null;
}
this.initLayer(layers);
this.handlers.feature.layer = this.layer;
if (isActive) {
this.activate();
}
},