Dear Robert Scheitlin, GISP,
I'm developing Query/Filter custom widget forWAB (Develper Edtion) 2.17, Launchpad Theme, on 3D Scenes (ArcGIS API for javascript 4.16).
How to set the 3D scene to zoom to the extent of the features array returned from a query on a feature layer? It could be array of points, lines or polygons. And how do I "play" with the zoom level?
I have not succeeded to find clear documentation/code example about how to do it.
Solved! Go to Solution.
Dear Robert, thank you! You really saved my day!
I'll appreciate it if you please tell me why in my next code, though I try to search by extent, points that were outside of map extent are indeed not included in the results array, but are NOT hidden from the scene? I want to show on screen only points that were in the scene extent when I ran the query...
I'm attaching screenshot of my code.
Michael,
Because you are setting the layer definition query to the where clause (which is correct but does not take into account the geometry extent). If you want the layers defintion query to take both the where clause and geometry into account then you have to do something completely different. a layers definition query can not use geometries so you will have do get the Object IDs of all the query results and use that for the layers definition query (i.e. "ObjectId IN(" + oidArray.join(',') + ")". So you eith have to do another query for ids.
or
you need to loop through the results and make an array of ObjectIds from the results.
Dear Robert, I appreciate your expertize and thank you very much for your most valueable help!
I want to validate that I my understanding is correct:
In order to hide on scene all features that do not appear in the results due to geometry,
I have no other way but to use layer definition expression,
and since layer definitionexpression does not respond to geometry conditions,
I have to bypass this drawback by giving the defintion expression a query which uses ObjectIds.
Am I correct?
Correct.
Dear Robert - Excellent! It works! Thank you!
but in the queried feature layer table, the field name of the ObjectID is not "objectid" but, in my case - "fid".
I checked and the 3rd option works well for me. Am I doing it right or is there a simpler way?
All stuff you can find in the documentation.
Dear Robert, you're awesome! Thank you!