Select to view content in your preferred language

Scene Layer Query Error

237
2
07-03-2024 10:40 AM
masivFizzy
Emerging Contributor

Hello, I am constantly running into this issue:
Error querying features: {name: 'scenelayer:query-not-available', details: {…}, message: 'SceneLayer queries are not available without an associated feature layer'}

I am trying to implement the "SceneLayerView - query statistics by geometry" https://developers.arcgis.com/javascript/latest/sample-code/layers-scenelayerview-query-stats/ but r...https://www.arcgis.com/home/webscene/viewer.html?layers=07da066aa64b45a6aa0b1263d2adcfd9 . Also prov...

```

function queryByPoint(point) {
        const buffer = geometryEngine.geodesicBuffer(point, 50, "meters");
        const query = sceneLayer.createQuery();
        query.geometry = buffer;
        query.spatialRelationship = "intersects";
        query.returnGeometry = true;
        query.outFields = ["*"];

        sceneLayer.queryFeatures(query).then((results) => {
          if (results.features.length > 0) {
            console.log('Features found:', results.features);
          } else {
            console.log('No features found.');
          }
        }).catch((error) => {
          console.error('Error querying features:', error);
        });
      }

      // Add UI button for point query
      const pointButton = document.createElement("button");
      pointButton.innerText = "Query by Point";
      pointButton.className = "esri-button";
      pointButton.addEventListener("click", () => {
        sketchViewModel.create("point");
      });
      sceneView.ui.add(pointButton, "top-left");
    };
```

 

0 Kudos
2 Replies
JamesIng
Regular Contributor

Would you be able to provide the full code of your app that you're trying?

James from www.landkind.com
0 Kudos
janzagar_0
Emerging Contributor

I am having a similar error getting queries to work on my own project. Were you able to find a solution?

0 Kudos