<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Sry, worn topic before.<br>
Hi,<br>
I have a listener on "removelayer" (why there ist no
"preremovelayer" like for addlayer). When a layer is removed then
the following function is called:<br>
<pre style="font-family: Consolas; font-size: 13px; color: black; background: none repeat scroll 0% 0% white;">deactivateDetails: <span style="color: blue;">function</span> () {
                <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.showDetailsSelect != <span style="color: blue;">null</span>) {
                        <span style="color: blue;"></span><span style="color: blue;">this</span>.showDetailsSelect.unselectAll();
                        <span style="color: blue;">this</span>.showDetailsSelect.deactivate();
                        <span style="color: blue;">this</span>.map.removeControl(<span style="color: blue;">this</span>.showDetailsSelect);
                        <span style="color: blue;">this</span>.showDetailsSelect.destroy();
                        <span style="color: blue;">this</span>.showDetailsSelect = <span style="color: blue;">null</span>;
                }
        },</pre>
After this function other listeners are called at last the listner
of the handler in the showDetailsSelect control which is a
SelectFeature-control. So the function <span class="sourceRowText"
role="presentation">moveLayerToTop is called and the "this.map is
null"</span>-exception is thrown. When I remove the destroy-method
the exception isn't thrown. The question is "When you should call
destroy? Or should I ever call destroy? Or is there an error in
destory of SelectFeature?"<br>
Last but not least the initialization of the SelectFeature:<br>
<pre style="font-family: Consolas; font-size: 13px; color: black; background: none repeat scroll 0% 0% white;"><span style="color: blue;">if</span> (layer <span style="color: blue;">instanceof</span> OpenLayers.Layer.Vector) {
                        $this = <span style="color: blue;">this</span>;
                        <span style="color: blue;">var</span> selectOptions = {
                                hover: <span style="color: blue;">true</span>,
                                toggle: <span style="color: blue;">true</span>,
                                highlightOnly: <span style="color: blue;">true</span>,
                                clickout: <span style="color: blue;">true</span>,
                                renderIntent: <span style="color: maroon;">"temporary"</span>,
                                onSelect: <span style="color: blue;">function</span> (f) { $this.showDetails(f); },
                                onUnselect: <span style="color: blue;">function</span> (f) { $this.hideDetails(f); }
                        };
                        <span style="color: blue;">if</span> (<span style="color: blue;">this</span>.showDetailsSelect) {
                                <span style="color: blue;">this</span>.deactivateDetails();
                        }
                        <span style="color: blue;">this</span>.showDetailsSelect = <span style="color: blue;">new</span> OpenLayers.Control.SelectFeature(
                                                layer, selectOptions
                                        );
                        <span style="color: blue;">this</span>.showDetailsSelect.clickSelect = <span style="color: blue;">this</span>.fixDetailsOnClick;
                        <span style="color: blue;">this</span>.showDetailsSelect.events.register(<span style="color: maroon;">"featurehighlighted"</span>, <span style="color: blue;">this</span>, <span style="color: blue;">this</span>.tooltipDetailsSelect);
                        <span style="color: blue;">this</span>.showDetailsSelect.events.register(<span style="color: maroon;">"featureunhighlighted"</span>, <span style="color: blue;">this</span>, <span style="color: blue;">this</span>.tooltipDetailsUnselect);
                        <span style="color: blue;">this</span>.map.addControl(<span style="color: blue;">this</span>.showDetailsSelect);
                        <span style="color: blue;">this</span>.showDetailsSelect.activate();
                }</pre>
<br>
In advance thx for answers and comments.<br>
Slawomir<br>
</body>
</html>