Select to view content in your preferred language

Trying to get my layer to work in (Query features from a FeatureLayerView - 4.7)

1724
2
Jump to solution
06-13-2018 11:16 AM
WilliamMobley
Occasional Contributor

I'm trying to add my own feature layer to the query features from a feature layer. However, when I try, I get a query failed response. I'm not sure what I'm missing. 

Below are the lines that I've changed. I've attached the working code as well. 


        const view = new MapView({
            container: "sceneDiv",
            map: map,
            center: [-94.961833, 29.567433],
            zoom: 9,
            padding: {
                right: 300
            }
        });


const featureLayer = new FeatureLayer({
        url: "http://atlas.texascoastalatlas.com/arcgis/rest/services/IkeDike/InundationDamages/FeatureServer/0",
        outFields: ["*"],
        definitionExpression:"year = 'Present' AND spine = 'False' AND storm = '10' AND slr = 'False'"

    });
map.add(featureLayer);

let graphics;

view.whenLayerView(featureLayer).then(function(layerView) {
    layerView.watch("updating", function(value) {
        if (!value) { // wait for the layer view to finish updating

            // query all the features available for drawing.
            layerView.queryFeatures({
                geometry: view.extent,
                returnGeometry: true
            }).then(function(results) {

                graphics = results;

                const fragment = document.createDocumentFragment();

                results.forEach(function(result, index) {
                    console.log("results:", result)
                    const attributes = result.attributes;
                    const name = attributes.damages + "all the damage"

                    Create a list zip codes in NY
                    const li = document.createElement("li");
                    li.classList.add("panel-result");
                    li.tabIndex = 0;
                    li.setAttribute("data-result-id", index);
                    li.textContent = name;

                    fragment.appendChild(li);
                });
                // // Empty the current list
                listNode.innerHTML = "";
                listNode.appendChild(fragment);
            }).catch(function(e) {
                console.error("query failed: ", e);
            });
        }
    });
});
0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

Couple of things going on with your test app. So the FeatureLayer you are adding to the application is not WebGL enabled. Please see the known limits for WebGL FeatureLayer here. Currently, WebGL FeatureLayer support is limited to layers created from feature services hosted on ArcGIS Online. Non-hosted enterprise feature services will be supported at the ArcGIS Server 10.6.1 release.

So as a result, your FeatureLayer is loaded as SVG FeatureLayer and you are running client side query on SVG FeatureLayer. You can see the known limitations for client-side queries on SVG FeatureLayer here

In any case, your application will return results from this SVG FeatureLayer on the client if you add "spatialRelationship: intersects" to the query parameter as shown below. 

// query all the features available for drawing.
            layerView.queryFeatures({
                geometry: view.extent,
                returnGeometry: true,
                  spatialRelationship: "intersects"
            }).then(function(results) {

Hope this makes sense, 

-Undral

View solution in original post

2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Couple of things going on with your test app. So the FeatureLayer you are adding to the application is not WebGL enabled. Please see the known limits for WebGL FeatureLayer here. Currently, WebGL FeatureLayer support is limited to layers created from feature services hosted on ArcGIS Online. Non-hosted enterprise feature services will be supported at the ArcGIS Server 10.6.1 release.

So as a result, your FeatureLayer is loaded as SVG FeatureLayer and you are running client side query on SVG FeatureLayer. You can see the known limitations for client-side queries on SVG FeatureLayer here

In any case, your application will return results from this SVG FeatureLayer on the client if you add "spatialRelationship: intersects" to the query parameter as shown below. 

// query all the features available for drawing.
            layerView.queryFeatures({
                geometry: view.extent,
                returnGeometry: true,
                  spatialRelationship: "intersects"
            }).then(function(results) {

Hope this makes sense, 

-Undral

WilliamMobley
Occasional Contributor

That fixed it! Thanks.  

0 Kudos