[OpenLayers-Dev] this.renderer has no properties

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Mon Feb 4 09:29:03 EST 2008


Hi list,

I occassionally run into the above js error in the function eraseFeatures of
Vector.js.

    eraseFeatures: function(features) {
        this.renderer.eraseFeatures(features);
    },

My use case is a vector layer which is displayed in a table, and only if
somebody selects a row the feature is drawn. When the layer is destroyed the
problem arises.

The fix I did was to add a check for features in destroyFeatures.

    destroyFeatures: function(features) {
        var all = (features == undefined);
        if(all) {
            features = this.features;
            this.selectedFeatures = [];
        }
        // bartvde
        if (features) {
            this.eraseFeatures(features);
            var feature;
            for(var i=features.length-1; i>=0; i--) {
                feature = features[i];
                if(!all) {
                    OpenLayers.Util.removeItem(this.selectedFeatures,
feature);
                }
                feature.destroy();
            }
        }

Should I open up a ticket? Or are there other ways to prevent this?

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl








More information about the Dev mailing list