AnsweredAssumed Answered

JS 4: Query with Distance not working - where to find supportsQueryWithDistance?

Question asked by ellatrue on Apr 26, 2017
Latest reply on Apr 26, 2017 by ellatrue

So I have this code:

 

function segmentQuery(mapPoint) {
   var queryTask = new QueryTask({
      url: "https://.../MapServer/0"
   });

   var query = new Query({
      geometry: mapPoint,
      distance: 5000,
      units: "miles",
      spatialRelationship: "intersects"
   });

   queryTask.execute(query).then(function (result) {
      //take the top feature and open the segment popup
      if (result.features[0]) {
         AddSegmentPopup(result.features[0], mapPoint);
      }
      else {
         AddPointGraphic(mapPoint);
      }
   });

}

This is based on a mapPoint received from a click event. For some reason it isn't hitting anything if I click near the feature but not on it (but within 5000 miles).

 

I noticed the documentation mentions "This parameter only applies if supportsQueryWithDistance is true." However, that link doesn't seem to have any useful information that I can find about how to enable it and where. Is that the problem? Is this something I can enable when publishing a service? I couldn't find anything like that in the Sharing..Publish Service dialog in ArcMap 10.3, but maybe that's because I only have Mapping capabilities added and nothing else?

 

Or is this a much simpler problem that I'm missing somehow?

Outcomes