I have the following situation,

I have imported a web scene into a script. The webscene consist of two scene layers and during most of the script I am only working with one scene layer. However almost at the end of my script, whenever I want to click on an anchor element in a list in the sidebar which I have created with HTML, I would like to zoom in on an object in another scene layer.

The anchor element does contain a dataset.gebouwid and I include this information in a new Query. However now I am completely lost in which way I can use this query to query through another sceneLayer.

I have looked at the sandbox of Query SceneLayerView, however in this specific case throughout the whole script there appears only one scene Layer. So I was wondering what in case when you want to query through another scene Layer.

 for (i = 0; i < uniqueItems.length; i++) {
                                var value2 = uniqueItems[i];
                                var subtext = value2.substring(value2.length - 9, value2.length);
                                //   console.log(subtext);

                                var entry = document.createElement('li');
                                var link = document.createElement('a');
                                link.textContent = value2;
                                // link.href=value2;
                                link.href = '#';
                                link.dataset.gebouwid = subtext;
                                // console.log(subtext);
                                link.onclick = function (event) {
                                    var clickedElement = event.target;
                                    var element = clickedElement.dataset.gebouwid;

                                    var query = new Query({
                                        where: "lokaalid = '" + element + "'",
                                        returnGeometry: true,
                                        outFields: ["*"]

In the sample you mentioned the scene layer is retrieved using webScene.layers.getItemAt(0)

Assuming you are accessing the scene layer the same way in your code, you can access any other layer by increasing the index in getItemAt(index):

var sceneLayer = webScene.layers.getItemAt(1);

An alternative, more robust way of retrieving specific layers in a web scene is using its title instead of an index:

var sceneLayer = webScene.layers.find(function(layer){
  return layer.id === "[Replace with title of 2nd scene layer]";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.