Select to view content in your preferred language

disable hide deactivate identify infowindow while measuring

7283
7
06-21-2012 11:05 AM
KirkWebb
New Contributor III
I am trying to disable/deactivate/hide my infowindow when I use the standard arcgis javascript api measure widget and have it show when I am not measuring with the following code:


        dojo.connect(map, 'onLayersAddResult', function (result) {

        function disablepopup() {
   map.infoWindow.hide();
   }
  ///Measurement variable
            var measurement = new esri.dijit.Measurement({map: map, onClick: disablepopup}, dojo.byId('measurementDiv'));
        
          measurement.startup();

          <!--DEACTIVATES MEASUREMENT TOOLS AFTER MEASUREMENT--> 
  dojo.connect(measurement, "onMeasureEnd", function(activeTool,geometry){
  this.setTool(activeTool, false), map.infoWindow.hide()
  });

Currently, when I double click to finish measuring the info window hides as it I want it to but up until that point it popups up like normal when I start my measurement and while I am measuring.  Does anyone have a fix for this?
I have already thought and looked into the identify listener and tying the identify to a button but in this particular situation I need it to be disabled only when measuring and do not want the user to have to click an identify button.

Thanks,
Kirk
7 Replies
HemingZhu
Occasional Contributor III
I am trying to disable/deactivate/hide my infowindow when I use the standard arcgis javascript api measure widget and have it show when I am not measuring with the following code:


        dojo.connect(map, 'onLayersAddResult', function (result) {

        function disablepopup() {
   map.infoWindow.hide();
   }
  ///Measurement variable
            var measurement = new esri.dijit.Measurement({map: map, onClick: disablepopup}, dojo.byId('measurementDiv'));
        
          measurement.startup();

          <!--DEACTIVATES MEASUREMENT TOOLS AFTER MEASUREMENT--> 
  dojo.connect(measurement, "onMeasureEnd", function(activeTool,geometry){
  this.setTool(activeTool, false), map.infoWindow.hide()
  });

Currently, when I double click to finish measuring the info window hides as it I want it to but up until that point it popups up like normal when I start my measurement and while I am measuring.  Does anyone have a fix for this?
I have already thought and looked into the identify listener and tying the identify to a button but in this particular situation I need it to be disabled only when measuring and do not want the user to have to click an identify button.

Thanks,
Kirk


Usually the identify task start with a map click event. One approach you can try is to use global variable to track the function mode. For example, only set this variable to true when you intend to do indentification. So in you click event handle, do nothing when this variable is false...
0 Kudos
LuciHawkins
Occasional Contributor III
Hi hzhu,

Can you give an example of the code?  I am new to javascript and am experiencing the same problem as Kirk.

Thanks,

Luci
0 Kudos
HemingZhu
Occasional Contributor III
Hi hzhu,

Can you give an example of the code?  I am new to javascript and am experiencing the same problem as Kirk.

Thanks,

Luci


//global variable
var functionMode ="identify";
dojo.connect(map, "onclick", function(evt){
    if (functionMode =="identify")
    {
         // do identify here
    }
    else{
        return;
    }
});
0 Kudos
KirkWebb
New Contributor III
Hi, Thanks for you respnonse.

Forgive me, I am not quite following the logic here yet.

//global variable
var functionMode ="identify";
dojo.connect(map, "onclick", function(evt){
    if (functionMode =="identify")
    {
         // do identify here
    }
    else{
        return;
    }
});

I would like to be able to identify by default from the start of the application.  Then when I use the canned ArcGIS Javascript api Measure widget i would like to disable or hide the popup functionality.  Can I use the above code to do this?  If so, please explain a little more?

I appreciate your help
Thanks,
0 Kudos
HemingZhu
Occasional Contributor III
Hi, Thanks for you respnonse.

Forgive me, I am not quite following the logic here yet.

//global variable
var functionMode ="identify";
dojo.connect(map, "onclick", function(evt){
    if (functionMode =="identify")
    {
         // do identify here
    }
    else{
        return;
    }
});

I would like to be able to identify by default from the start of the application.  Then when I use the canned ArcGIS Javascript api Measure widget i would like to disable or hide the popup functionality.  Can I use the above code to do this?  If so, please explain a little more?

I appreciate your help
Thanks,


What i am trying to say here is to set up a mechanics so that when the map' click event happens, the application knows this click event is for identification or measurement. There are a lots of ways to set up this mechanics. you just have to find the one best fit for your application.
0 Kudos
ChristopherSchreiber
Occasional Contributor II

Hello Kirk, 

This is what I was able to do. It disables highlighting and popups when the 'measure-start' event is fired and then enables them when the 'measure-end' event fires. 

        on(measurement, "measure-start", function () {
            popup.popupWindow = false;
            popup.highlight = false;
        });
        on(measurement, "measure-end", function () {
            popup.popupWindow = true;
            popup.highlight = true;
        });

I hope this helps.

Chris

DavidColey
Frequent Contributor

Hi Kirk - another way to to what Chris has done above is to set up a click event on a feature layer itself:

on(yourFeatureLayer, "click", function() {
    if (measurement.activeTool == "area" || measurement.activeTool == "distance" || measurement.activeTool == "location") {
       mapMain.setInfoWindowOnClick(false);
    } else {
       mapMain.setInfoWindowOnClick(true);
    }
});

and use the activeTool property of the measurement widget.  I might want to try Chris' method as this way you have to set up an event for each feature layer in your module.

David