I've been using a feature service URL off ArcGIS Online and have a Feature Layer based on that endpoint in my JSAPI 4.2 web application.
I see that anytime I update the definition expression or create a query object it makes a network call to the service.
I wanted to minimize server calls and work with the data on the client so I created a FeatureLayer based on graphics imported from a geojson file (based on one of the examples). Then I learned that query objects off a feature layer does not support where, out fields, etc. Per documentation, only the geometry, objectIDs, and spatialreference should be defined. Similar to using a FeatureLayerView.
I'd like to do things like filtering the features, running queries to produce popups, running statistic queries, etc. on the client, and prevent the server-side call. My question then is, does the API support client-side queries? Am I using the wrong layer, should I be using a GraphicsLayer or some other layer? Or do I need to write my own methods for doing the filtering/querying on client?
Much Thanks!
You're right, it looks like where is not supported for layerView.queryFeatures.
If you want to query for attributes, one option would be something like:
function queryByAttr(lv: layerView, key: string, value: any):Array<Graphic>{
return layerView.featuresView.graphics.filter(graphic => graphic.attributes && graphic.attributes[key] === value).toArray();
}
There may be an easier way to do this, but that should work. Use layerView.loadedGraphics (instead of featuresView.graphcis) for 3D.