Definition Expression Geometry

568
2
Jump to solution
10-17-2018 08:06 AM
ShawnRoberts1
Occasional Contributor

I apologize if this is a fairly simple question, I'm still learning the JS API. 

I have a feature class that I am dynamically setting altering the definition expression based on user input in a form. Ex by type of building, or size of building. I have also set it up so the user can create a temporary graphics layer to circle an area on the map, from there I would like to include that graphics layer geometry into the definition expression. Where I am struggling is how to pass that temporary geometry into the definition expression. 


I have a function that builds the def'n expression based on the inputs and I assume in there I would need to format it to add in the temp geometry I'm just not sure how that should look.

Any advice on how best to format a definition expression to take in a geometry would be greatly appreciated. 

Thanks,

Shawn.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Sean,

  A layer definitionExpression is only for a string that represents a valid SQL statment. You can not use a geometry for a layers definition expression. The only way to possibly do this is to do a QueryTask using the geometry and use the executeForIds and then when you get that result you can build a SQL string from that to feed to the defintionExpression.

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Sean,

  A layer definitionExpression is only for a string that represents a valid SQL statment. You can not use a geometry for a layers definition expression. The only way to possibly do this is to do a QueryTask using the geometry and use the executeForIds and then when you get that result you can build a SQL string from that to feed to the defintionExpression.

0 Kudos
ShawnRoberts1
Occasional Contributor

Hi Robert, thanks for the reply. That should work, it certainty seems like the long way to query for results to send into another expression, but it should work.

Thanks for the assistance. 

0 Kudos