[OpenLayers-Users] vector layer destroyed twice throws error

Chris Green chris.green at ibstv.co.uk
Mon Apr 12 05:16:52 EDT 2010


Hi Eric

The code I am using (slightly simplified) is below. I am not calling
getZIndex, I have been assuming that it is called somehow as part of the
layer.destroy() function. The other relevant piece of information is that if
I repeat the layer.destroy() call I get the div is null error only on even
numbers: so first time is OK, 2nd time error, 3rd time OK again, 4th time
error....etc.

  

    cityWFS = new OpenLayers.Layer.Vector("Cities", {
            styleMap: cityStyle,
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.WFS.v1_1_0({
            url:
"http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/apps/NewStart/htdocs/citie
s.map",
            featureType: "Cities",
            info_format: 'text',
            hover: true,
            maxFeatures: 100,
            filter: cityFilter,
            featureNS: "http://mapserver.gis.umn.edu/mapserver"
              })  //protocol
            });
           
     if (cityHover==null){   
         
         var cityHover = new OpenLayers.Control.SelectFeature(cityWFS, {
         hover: true,
         highlightOnly: true,
               overFeature: function(feature) {
           
          		"some code"
               },            
               
		  outFeature: function(feature) {
              }
      		"more code"
       	}); 
     
	    } 
      
       
         map.addControl(cityHover);
         cityHover.activate();
              
         map.addLayer(cityWFS);
  

 

-----Original Message-----
From: Eric Lemoine [mailto:eric.lemoine at camptocamp.com] 
Sent: 12 April 2010 09:38
To: chris.green at ibstv.co.uk
Cc: users at openlayers.org
Subject: Re: [OpenLayers-Users] vector layer destroyed twice throws error

On Mon, Apr 12, 2010 at 8:13 AM, Chris Green <chris.green at ibstv.co.uk>
wrote:
> Hello List
>
>
>
> I am using OL 2.8 and have a vector layer that is populated with features
> via WFS. In my application I  need to be able to remove and re-create the
> vector layer repeatedly, which I can perform once only  but the second
time
> I call layer.detroy() I get the error ‘this div is null’ thrown by the
> getZIndex function in Layer.js.

The error indicates that getZIndex is called on a destroyed layer. Is
it your code that calls getZIndex?

Cheers,
-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com





More information about the Users mailing list