Select to view content in your preferred language

Is a bug of measurement ????? help me!

746
3
05-25-2011 06:44 PM
luoyong
New Contributor
hi: there is some thing wrong with the measurement widget, the code as felow:

i user js api of 2.3.

if (measurement != null)
{
    measurement.destroy();
}

measurement = new esri.dijit.Measurement({
                map: map
            }, dojo.byId('apDiv1'));
measurement.startup();

// measurement  is a  Global  object
// this code may be called many times , the first once it  work right , but the second.......   it does not work right

the excption is :

  tride to register widget with id == apDiv1 but that id is already gegisterdineNumber;


but before i   new  the measurement  object   a alread call its  "destroy();" , does not  the "destroy();"  work ???


or is it a bug ???  How do i do it ?

thank you.
0 Kudos
3 Replies
derekswingley1
Deactivated User
There might be a problem here, but why do you need to destroy and re-create the measurement widget over and over?
0 Kudos
luoyong
New Contributor
There might be a problem here, but why do you need to destroy and re-create the measurement widget over and over?


becuase there are tow or three  maps will show in the  map contrls,  the user click the first map icon in my appliction then the map control will show the first map, and when the user click the other map icon ,then map control  will show anthoer.

code like follows:


      if (map == null)
        {
            map = new esri.Map("Map_Panel");
            dojo.connect(map, "onLayersAddResult", AfterLayersAdd);
            dojo.connect(map, "onLayerAddResult", function(layer, err) { AfteLayerAdd(layer, err);});
        }
        else
        {
            extent = map.extent; 
              
         map.destroy();     // this is ok but measurements "destroy()" is not ok.

            map = new esri.Map("Map_Panel");
            dojo.connect(map, "onLayersAddResult", AfterLayersAdd);
            dojo.connect(map, "onLayerAddResult", function(layer, err) { AfteLayerAdd(layer, err); });
            map.extent = extent;
            //  dojo.connect(map, "onMouseDrag", onMapMouseDrag);   // Navigation.js
            //  dojo.connect(map, "onMouseDragEnd", onMapMouseDragEnd);  // Navigation.js
        }


if (measurement != null)
{
measurement.destroy();
}

measurement = new esri.dijit.Measurement({
map: map
}, dojo.byId('apDiv1'));
measurement.startup();
0 Kudos
derekswingley1
Deactivated User
I see, thanks for the additional details. I think this might be a bug.
0 Kudos