Query according to Spatial Relationship

472
2
Jump to solution
10-04-2019 07:38 AM
PaulMcCord
Occasional Contributor

I'd like to query content according to a spatial relationship using ArcGIS API 4.12. I've set up a test of this query as follows:

var municBoundariesURL = "https://devarcgisent.placeholdertext.lan/serverdev/rest/services/ParkFinder/MunicipalBoundaries2/MapServer/0"
var queryOptions = new Query({
    //where: "1=1",
    outFields: ["*"],
    returnGeometry: true,
    spatialRelationship: "within",
    geometry: "-83.04517899999858,42.32973669999929"
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
var queryTask = new QueryTask({
    url: municBoundariesURL
});
queryTask.execute(queryOptions).then(function(response){
    var nameResults = response.features.map(function(feature){
        feature.name = feature.attributes.NAME
        return feature;
    });
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I know this isn't set up correctly, but I played with a number of configurations and every time I got a message in the console saying: "[esri.core.Accessor] Accessor#set Invalid property value, value needs to be one of 'esri.geometry.Extent', 'esri.geometry.Multipoint', 'esri.geometry.Point', 'esri.geometry.Polyline', 'esri.geometry.Polygon', or a plain object that can autocast (having .type = 'extent', 'multipoint', 'point', 'polyline', 'polygon')"

The heart of my question boils down to lines 2-7 above. I can successfully search by field name (ie, set 'where' equal to "1=1" or any other field name), so I know the query is working when the query options are populated properly.

Can someone help me to set up the query options so that I can return just the feature that the point (specified with 'geometry') falls within? 

Thank you

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Paul,

   The error message is telling you the problem. You need to pass an actual Point class and not a string to the queries geometry property.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Paul,

   The error message is telling you the problem. You need to pass an actual Point class and not a string to the queries geometry property.

PaulMcCord
Occasional Contributor

That did it. Thank you, Robert! 

0 Kudos