[OpenLayers-Users] RE Map.js - control destructor problem SOLVED

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Tue Mar 12 12:52:58 PDT 2013


My measuresControl were each added 2 twice in the map




Steve.Toutant at inspq.qc.ca@lists.osgeo.org 
Envoyé par : openlayers-users-bounces at lists.osgeo.org
2013-03-12 13:51

A
openlayers-users at lists.osgeo.org
cc

Objet
[OpenLayers-Users] Map.js - control destructor problem









Using OL 2.10, This code in maps.js has a strange behavior 
for (var i = this.controls.length - 1; i>=0; --i) { 
                this.controls[i].destroy(); 
            } 

Initially length=26. There is a problem when destroying controls[24]...it 
also destroys controls[23]. 
So on the next loop, i = length = 23 and controls[23] doesn't exist 
anymore. 

Why this.controls[i].destroy() would also destroy controls[i-1]? 

In this case control[24] and control[23] are OpenLayers.Control.Measure 

I've defined 2measure controls (linear and area) 
var oMeasrPolgnCtrl = new OpenLayers.Control.Measure ( 
OpenLayers.Handler.Polygon, oMeasrPolgnCtrlOptions ); 
var oMeasrPolgnCtrl = new OpenLayers.Control.Measure ( 
OpenLayers.Handler.Polygon, oMeasrPolgnCtrlOptions ); 
I don't know what to verify anymore... 
Thans for your help, 
Steve _______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130312/a0c0af13/attachment.html>


More information about the Users mailing list