<!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:&nbsp;<span style="color: blue;">function</span>&nbsp;()&nbsp;{
                <span style="color: blue;">if</span>&nbsp;(<span style="color: blue;">this</span>.showDetailsSelect&nbsp;!=&nbsp;<span style="color: blue;">null</span>)&nbsp;{
                        <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&nbsp;=&nbsp;<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>&nbsp;(layer&nbsp;<span style="color: blue;">instanceof</span>&nbsp;OpenLayers.Layer.Vector)&nbsp;{
                        $this&nbsp;=&nbsp;<span style="color: blue;">this</span>;
                        <span style="color: blue;">var</span>&nbsp;selectOptions&nbsp;=&nbsp;{
                                hover:&nbsp;<span style="color: blue;">true</span>,
                                toggle:&nbsp;<span style="color: blue;">true</span>,
                                highlightOnly:&nbsp;<span style="color: blue;">true</span>,
                                clickout:&nbsp;<span style="color: blue;">true</span>,
                                renderIntent:&nbsp;<span style="color: maroon;">"temporary"</span>,
                                onSelect:&nbsp;<span style="color: blue;">function</span>&nbsp;(f)&nbsp;{&nbsp;$this.showDetails(f);&nbsp;},
                                onUnselect:&nbsp;<span style="color: blue;">function</span>&nbsp;(f)&nbsp;{&nbsp;$this.hideDetails(f);&nbsp;}
                        };
                        <span style="color: blue;">if</span>&nbsp;(<span style="color: blue;">this</span>.showDetailsSelect)&nbsp;{
                                <span style="color: blue;">this</span>.deactivateDetails();
                        }
                        <span style="color: blue;">this</span>.showDetailsSelect&nbsp;=&nbsp;<span style="color: blue;">new</span>&nbsp;OpenLayers.Control.SelectFeature(
                                                layer,&nbsp;selectOptions
                                        );
                        <span style="color: blue;">this</span>.showDetailsSelect.clickSelect&nbsp;=&nbsp;<span style="color: blue;">this</span>.fixDetailsOnClick;
                        <span style="color: blue;">this</span>.showDetailsSelect.events.register(<span style="color: maroon;">"featurehighlighted"</span>,&nbsp;<span style="color: blue;">this</span>,&nbsp;<span style="color: blue;">this</span>.tooltipDetailsSelect);
                        <span style="color: blue;">this</span>.showDetailsSelect.events.register(<span style="color: maroon;">"featureunhighlighted"</span>,&nbsp;<span style="color: blue;">this</span>,&nbsp;<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>