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
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; } });
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,
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
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