[OpenLayers-Dev] vector layer and removeLayer

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Mon Oct 15 05:21:52 EDT 2007

Hi list,

if I do a refresh of my application in Internet Explorer 6, I get a
javascript error "invalid argument", which comes from removeLayer. This only
happens after drawing a feature in a vector layer.

It is also reproducable using the editingtoolbar.html example. Draw a
polygon, and press CTRL+F5.

I needed to add a null check in Map.js's removeLayer to make this go away:

if (layer.div) {

But after this I get length is empty or no object in Util.js's removeItem,
so apparently a null array is passed in. I also added a null check there.

Next one up, this.features.length is not an object in destroyFeatures of
Vector.js, so I added another null check. This resolved it.

But maybe as Tim said before on a similar issue, we should investigate the
root cause instead of putting in sanity checks ...

Using OL 2.5.

Best regards,

Bart van den Eijnden
OSGIS, Open Source GIS

More information about the Dev mailing list