openlayers/openlayers — pull request #965 by tomcollins (2013-05-01 10:52:41+00:00)
Title: SelectFeature should rebase layers before they are removed from a map

When the SelectFeature control is handling multiple layers it moves their root into a RootContainer. Later, when a layer is removed from a map using map.removeLayer, the layers features remain visible as they are not contained in the layers renderer.

I've updated SelectFeature so that it listens for the map's preremovelayer event and then resets the layers root. This results in features being removed correctly.

This relates to https://github.com/openlayers/openlayers/issues/958

The following gist demonstrates the use of removeLayer with multiple layers and SelectFeature: https://gist.github.com/tomcollins/b39caeda532f11617cd5