AnsweredAssumed Answered

Query a FeatureLayerView With Geometry in Version 10.22

Question asked by chuckf74 on Jul 12, 2016

Is it possible to query a FeatureLayerView of a hosted feature service from AGS 10.22?  The code below is not working:

 

    view.whenLayerView(featureLayerProjects).then(function (lyrView) {

        lyrView.watch("updating", function (val) {

            if (!val) {  // wait for the layer view to finish updating

                view.on("click", function (evt) {

 

                    var circle = new Circle({

                        center: evt.mapPoint,

                        radius: 1000

                    });

 

                    console.log(circle);

 

                    var query = new Query();

                    query.geometry = circle;

                    query.spatialRelationship = "intersects";

 

                    lyrView.queryFeatures(query).then(function (results) {

                        console.log(results);  // prints the array of client-side graphics to the console

                    });

                });

            }

            else {

                console.log('something else happened');

            }

        });

    });

 

The code above comes is modified from an example I found in the documentation here: FeatureLayerView | API Reference | ArcGIS API for JavaScript 4.0

 

When I don't pass a query to the queryFeatures() function all of the features in the featureSet are returned.  When I do pass a query, I get an error in the console:  Object {name: "QueryEngine", message: "Invalid query", details: undefined} "

 

The larger problem I'm trying to solve is to click a point and get the attributes.  I though it would be possible to use the FeatureLayerView client side and not send a query to the server, but I cannot find a way to do it.  Is it because the server version is not new enough?

 

Thanks,

Chuck

Outcomes