Tolerance discrepancy

4336
8
08-08-2014 03:38 PM
SteveCole
Frequent Contributor

In the app I'm developing, I'm using featureLayer.on("click",...) to control when the infoWindow content is displayed. What I've noticed is that I can click and select a feature in the layer without triggering that click event. The end result is that my infoWindow information does not appear.

To illustrate this, I have taken one of the ESRI samples and made a Fiddle of it: My Sample

In the sample (and my app in development), I am using featureLayer.on("mouse-enter",...) to change the mouse icon to a pointer to indicate to the user that the feature can be clicked. What I'm noticing is that if the mouse is close to the feature but not truly "over it", you can click and select it due to some mystical tolerance. That's fine for ESRI's sample but, in my app, that means that my infoWindow content doesn't get displayed.

What I need is consistency: if the mouse icon does not change to a pointer (i.e. the mouse is actually over the feature), then a click should NOT select the feature. How can I accomplish this? I couldn't find a reference to a tolerance with the exception of IdentifyTask.

Thanks!

Steve

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Steve,

  I believe (and I may be wrong) that the API has some internal click tolerance setup when displaying popups. That way they can handle clicking on points and lines.If there was not a tolerance than it would be real difficult to click a point. Maybe Jonathan Uihlein‌ can confirm.

SteveCole
Frequent Contributor

Thanks, Robert. That totally makes sense; it just appears that this is not user adjustable.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Correct, I have never see anything about this tolerance or how one might adjust it, but it is obviously there.

0 Kudos
JonathanUihlein
Esri Regular Contributor

Unfortunately, tolerance is not currently adjustable in this context.

However, this is a great suggestion. We'll discuss it internally and see if this feature can make the next release.

Pulaski_AreaGIS
New Contributor

Has this feature ever been implemented? We have an application we would like to restrict the tolerance in popup results.

0 Kudos
BenFousek
Occasional Contributor III

Jonathan Uihlein​ This would also be handy for increasing tolerance. I implement a lot of right click menus on features and users find that it can be hard to get the menu with polylines at certain angles.

OwenEarley
Occasional Contributor III

Just out of interest the old ArcIMS viewer had a pixelTolerance - I am fairly sure it was used for this purpose.

0 Kudos
DavidColey
Frequent Contributor

Here's what I do:

Setup a PointToExtent Function that allows you pass a pointer tolerance in as a parameter base on map extent width in map coordintates thus:

Function pointToExtent (mapMain, point, toleranceInPixel) {

    var pixelWidth = mapMain.extent.getWidth() / mapMain.width;

        var toleranceInMapCoords = toleranceInPixel * pixelWidth;

        return new Extent(point.x - toleranceInMapCoords,

                              point.y - toleranceInMapCoords,

                              point.x + toleranceInMapCoords,

                              point.y + toleranceInMapCoords,

                              mapMain.spatialReference);

          } 

then, in on-style wiring of your feature layers' query, pass the function to the geometry property of your query, along with a tolerance setting in pixels.  Keep in mind that pixel tolereances change depending on resolution and scale, so you'll have to make some adjustments.  Also, Jeff Pace employes a slightly different method that is not as resolution depenedent as what I'm showing here, so I would search his posts as well-

on(lyrName, 'click', function (event) { //mapMain

            var query = new Query();

            query.geometry = pointToExtent(mapMain, event.mapPoint, 10);

            var deferred = lyrF.selectFeatures(query, //featurelayer

              FeatureLayer.SELECTION_NEW);

            mapMain.infoWindow.setFeatures([deferred]);

            mapMain.infoWindow.show(event.mapPoint);

          });

Here, '10' is my pixel tolerance in map coords, (meters) and seems to work pretty well for line features in WebMercator