Select to view content in your preferred language

Buggy behavior with Measurement widget

1333
7
Jump to solution
11-20-2018 04:10 PM
RyanKelso
Frequent Contributor

I've noticed some strange behavior with the standard Measurement widget, I wonder if others have noticed at least some of these things and they might get addressed.

Clicking the 'Clear' button while you have an active measurement (before you double-click to finish) causes some buggy behavior when you start another measurement.  It will include the final point of your previous measurement, and if you double-click to finish, it will draw all of the geometry from the previous measurement, though it does not include those distances in the measurement total.  Also while this is happening, the measurement totals are not dynamically updating as you move your cursor.

I think it should be fixed by either making the 'Clear' button do nothing until you have double-clicked to finish your measurement, or have the Clear button delete any remnant of the previous measurement.  It also wouldn't hurt to have some indication (a tooltip or message on the widget window) that you should double-click to finish your measurement, since this is not always obvious to less GIS-savvy users.

The other main issue is that there are some actions that cause the measurement geometry to become clipped and invisible while you are actively measuring.  The easiest way to see it in action is to start a measurement and continuously pan the map as you are measuring.  Sometimes continuing to click your measurements (or finishing) will cause the geometry to appear, sometimes not.  It seems like other actions will trigger this behavior but I haven't been able to isolate them.  I've noticed this in other widgets that use draw tools.  It appears to be an issue with more recent versions of the JSAPI, I can load up an old v2.1 WAB app and can't duplicate the problem.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   The fix for the clear issue is pretty simple.

In the widget.js make this change (add lines 2-4):

      clearGraphics: function(){
        if(html.hasClass(this.clearGraphicsBtn, 'jimu-state-disabled')){
          return;
        }
        this.measurement.clearResult();
        if(this.currentFeatureLayer){
          this.currentFeatureLayer.clear();
          if(this.linePicGraphicsLayer){
            this.linePicGraphicsLayer.clear();
          }
        }
        html.addClass(this.clearGraphicsBtn, 'jimu-state-disabled');
      },

As for the other issue I believe that it is an issue that is know to occur with latter versions of the JS API and Chrome 70. You can verify this by testing FireFox or IE.

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Ryan,

   The fix for the clear issue is pretty simple.

In the widget.js make this change (add lines 2-4):

      clearGraphics: function(){
        if(html.hasClass(this.clearGraphicsBtn, 'jimu-state-disabled')){
          return;
        }
        this.measurement.clearResult();
        if(this.currentFeatureLayer){
          this.currentFeatureLayer.clear();
          if(this.linePicGraphicsLayer){
            this.linePicGraphicsLayer.clear();
          }
        }
        html.addClass(this.clearGraphicsBtn, 'jimu-state-disabled');
      },

As for the other issue I believe that it is an issue that is know to occur with latter versions of the JS API and Chrome 70. You can verify this by testing FireFox or IE.

RyanKelso
Frequent Contributor

Thanks Robert that is super helpful.  I've taken that change a step further and made the 'Clear' button disappear when it is disabled.  And you're right, the clipped geometry issue doesn't look like it is there in FireFox.  For the people who are getting really frustrated by that problem I'm going to try setting them up with FireFox.  Hopefully either Esri or Google fixes the problem eventually.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Great. Don’t forget to mark this question as answered by clicking on the mark correct link on the reply that answered your question.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Ryan,

 Actually I found a simple css rule that takes care of everything (meaning the button is not clickable, so there is no need for the other code I provided) :

.jimu-btn.jimu-state-disabled {
  pointer-events: none;
}
RyanKelso
Frequent Contributor

Thanks again, Robert.  That is basically what I was after in the beginning to fix the 'clear' button.  I'm going to go ahead and mark this discussion as answered, however I think the 'real' answer to this would be for Esri to acknowledge and commit to fix these issues with their widget and API because measuring is a core feature for many GIS apps/users and these sort of issues should be ironed out.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Actually no. GeoNet is a community of people helping each other. To get it fixed in the core you need to contact ESRI and report the issue. And hopefully it will get fixed in the next release.

0 Kudos
RyanKelso
Frequent Contributor

I was thinking mostly about the clipped geometry issue as the more serious problem, which if what you said is true that it's a known issue with newer versions of the API and Chrome, I don't see the point in reporting.  They'll bother to fix it or they won't.

And you're right, GeoNet is a community of people, which includes ESRI Staff, who sometimes graciously step in and offer help as well, and I like to think they at least read some of this stuff even if they don't respond.  My experiences have made me cynical about contacting ESRI support, I avoid it unless I feel like it's my last hope.  I think anyone who encounters a problem they see as serious enough to pursue fixing, would be smart to generate as much exposure to ESRI eyeballs as possible, including opening a support case, using the Ideas site, and posting here on GeoNet.