[ka-Map-users] BUG in removeObject

Pje pjebra at gmail.com
Tue Dec 12 13:52:55 EST 2006


Hi, list. I think there is a bug in the function removeObject. It's suposed
to remove all objects if NULL is passed as parameter, but it's not doing
this. When an object is removed from this.aObjects array the length will
decrease too... thats why the function is not working. I did some changes
and now its working:

kaMap.prototype.removeObject = function( obj ) {
    _obj = obj
    for (var i=this.aObjects.length-1; i>=0; i--) {
        if (this.aObjects[i] == obj || obj == null) {
            if (!obj) {
                obj = this.aObjects[i];
            }
            if (obj.canvas) {
                obj.canvas.removeChild( obj );
                obj.canvas = null;
            }
            this.aObjects.splice(i,1);
            obj = null;

            if (_obj != null || i == 0) {
                return true;
            }
        }
    }
    return false;
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20061212/731ff884/attachment.html


More information about the ka-Map-users mailing list