Select to view content in your preferred language

FeatureLayer Click Tolerance

2210
1
04-07-2014 10:49 AM
BrianRassier
Deactivated User
Hello -

I have various JS FeatureLayers on my map, and I want to hook in some logic when a feature/graphic is clicked.  This works fine using the "click" event, however, mobile devices have difficulty selecting certain features/graphics.  We have some point/line symbols that are fairly small, making it difficult to tap with a mobile device.

Is there a simple way to buffer these taps when hooking into the FeatureLayer click event?  Or possibly a tolerance setting that I didn't see, similar to the Identify task?  This seems like it has to be a common problem when moving to touch-based devices, so I don't want to reinvent something.

Thanks!
0 Kudos
1 Reply
williamcarr
Frequent Contributor
This has given me some luck.
   function pointToExtent(map, point, toleranceInPixel) {
       var pixelWidth = map.extent.getWidth() / map.width;
       var toleraceInMapCoords = toleranceInPixel * pixelWidth;
       return new esri.geometry.Extent( point.x - toleraceInMapCoords,
                    point.y - toleraceInMapCoords,
                    point.x + toleraceInMapCoords,
                    point.y + toleraceInMapCoords,
                    map.spatialReference );                           
      }


"onClick"

dojo.connect(map,"onClick",function(evt){
          var query = new esri.tasks.Query();
          query.geometry = pointToExtent(map,evt.mapPoint,10);
0 Kudos