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

1108
2
04-26-2017 12:21 PM
EllaHaines
New Contributor III

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?

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Ella,

  The supportsQueryWithDistance was added from ArcGIS Server 10.3.1 and onward.

EllaHaines
New Contributor III

I believe it was just upgraded to 10.3.1, perhaps I should have specified that - where would I find it?

Looks like I'm wrong, it's still 10.3 only. Thanks for letting me know.

0 Kudos