[GIS] Using FeatureLayer as pure client side query in ArcGIS API for JavaScript

arcgis-javascript-apifeature-layer

I've created this wrapper around feature layer where I create the empty feature layer as is in the API help page :

new FeatureLayer(featureCollectionObject, options?)

providing the first parameter an object (not url) and some options as the second paramater. then I fill this feature layer with my data that I get from my service (not the esri map service btw)…

So the features are on the map (what a beauty) and then I want to query them, but it seems like this api doesn't do the client side queries with where clause… using queryFeatures or selectFeatures doesn't matter, it always ends up with

"FeatureLayer::_query – query contains one or more unsupported
parameters"

I can create my own wrapper and loop through the feature atrributes, and then set them selected based on my search criteria, but I want feature layer to do it for me, without having to send a request to a url (which doesn't exist in our case).

Simple test, now with a proper feature layer (instantiated using the url) with the SNAPSHOT mode, one would expect that query with a where clause would be performed on the client side, but no, it actually sends a request to a server (what for when I have all the data on client?)

I've reused someone else's jsfiddle here -> jsfiddle .Just click in the map to run simple query ("resolution = 3") and you can see it fails.

Can anyone shed more light into this for me please?

Best Answer

This is a limitation of a feature layer built from a featureCollection. See the help file page which says:

The feature layer, when initialized with a feature collection object... does not support queries that need to be performed on the server, e.g. queries with a where clause or non-extent based spatial queries.