Select to view content in your preferred language

swapping map.on click events for measurement tool vs info

3888
4
06-01-2015 02:25 PM
lowolhar
Deactivated User

I have a map with a clickListener that is setup initially via map.on to handle the standard infoTemplate information for layers that are turned on in an info WIndow. When I try to put the measurement tool on my page (using 3.13)  I use a .remove for the click listener when the tool opens and am able to do the measure events no problem. 

However when the measure ends and I'm not sure if this should be when the close my form with the widget or on measure-end I am not able to re add my infoTemplate  clickListener back in to show the info Window.

I've seen a couple of examples that use dojo aspect or dojo connect but I gather dojo connect and disconnect are old.  I can't seem to hit on a good way to do it or figure out the placement. Does anyone out there have a working measurement/info swap method that works? I'm thinking I may have to scrap the requested measurement functionality if its not possible.  I'm using bootstrap / jquery / 3.13 with some amount of dojo mixed in to use some of the easier esri widget items where needed. 

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Lo Wolhar,

However when the measure ends and I'm not sure if this should be when the close my form with the widget or on measure-end I am not able to re add my infoTemplate  clickListener back in to show the info Window.

Can you show us the code that you are using for this?

0 Kudos
YousefQuran
Frequent Contributor

Hi,

  I had face the same issue and the solve was simple ..
I define a public Boolean variable and change the value each time I switch measurement On/Off  to know the current click map mood ( Measurement vs. InfoWindow )


So, before show up the InfoWindow, you have to check if the mood is InfoWindow mood in a simple if statement ...
That will prevent the conflict of the click event handlers. And its works fine with us. 

Hope this help you.

Regards,
Yusuf

KenBuja
MVP Esteemed Contributor

Take a look at dojo/on and its pausable method. This allows you to pause and resume the event listeners without needing to remove them and add them back in.

0 Kudos
KellyHutchins
Esri Frequent Contributor

You can use map.setInfoWindowOnClick to enable/disable info window clicks for the map. Here's an example that disables info windows when a measure tool is activated and re-enables them when the tool is deactivated.

query(".esriMeasurement .dijitButtonNode").on("click", lang.hitch(this, function(e){
   var tool = measureWidget.getTool();
   if(tool){
    this.map.setInfoWindowOnClick(false);
   }else{
    this.map.setInfoWindowOnClick(true);
   }
}));