[ka-Map-users] kaXmlOverlay.js bug

Pg pg.navone at gmail.com
Wed Jun 7 17:19:44 EDT 2006


Thanks.  The bug is definetely there, but I don't understand your fix.
I thik the correct method should be

kaXmlOverlay.prototype.removePoint = function( pid ) {

	if ( (this.removePoint.arguments.length < 1) || (pid == null) ) {
		for (var i=0; i < this.ovrObjects.length; i++) {
			if (this.ovrObjects[i] != null) {
				this.ovrObjects[i].removeFromMap();
				delete this.ovrObjects[i];
				this.ovrObjects[i] = null;
			}
                        delete this.ovrObjects[i];
			this.ovrObjects.splice(i,1); i--;
		}
		return;
	}
	
	var re = new RegExp(pid);
	for (var i=0; i < this.ovrObjects.length; i++) {
		if (this.ovrObjects[i] != null) {
			if (re.test(this.ovrObjects[i].pid)) {
				this.ovrObjects[i].removeFromMap();
				delete this.ovrObjects[i];
				this.ovrObjects[i] = null;
				this.ovrObjects.splice(i,1); i--;
			}
	 	} else {
			delete this.ovrObjects[i];
			this.ovrObjects.splice(i,1); i--;
		}
	}
}

 -Pg


2006/6/7, Justin George <justin.george at gmail.com>:
> I just spent quite a while tracking this one down.
>
> On line 558 in kaXmlOverlay.prototype.removePoint, there is a loop
> which indexes over the contents of the overlay objects array. Each
> time it removes an object. So the array must index from the length
> down to zero, rather than the opposite.
>
> Fix:
>                 for (var i=this.ovrObjects.length; i >= 0; i--) {
>
> Instead of
>
>                 for (var i=0; i < this.ovrObjects.length; i++) {
>
> Hope that helps everyone with the new overlays, they're working great for me.
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>


More information about the ka-Map-users mailing list