Select to view content in your preferred language

ArcGIS JS SceneView.goTo control camera rotation

263
0
10-25-2023 07:16 AM
SheikhImranJaffry
New Contributor

I'm making a SceneView for my website. I have functionality where the globe cannot be controlled by the viewer, but moves from point of interest to point of interest based how users hover over other elements in the site. This part works fine, except that the viewer is bouncing around between different points such that the rotation of the camera becomes very skewed, to the point where it's disorienting. Is there any way to lock the camera such that the top of the screen is always north, the bottom is always south, the right is always east, and the left is always west using options or other js magic? Thanks!

My Function:

 

   view.when(function () {
        // Access the DOM elements and attach event listeners
        var itemElements = document.getElementsByClassName('item');
        // Attach listener for each item
        for (var i = 0; i < itemElements.length; i++) {
          itemElements[i].addEventListener('mouseenter', function (event) {
            var lat = parseFloat(event.currentTarget.dataset.lat);
            var long = parseFloat(event.currentTarget.dataset.long);
            view
              .goTo(
                {
                  position: {
                    x: lat,
                    y: long,
                    spatialReference: {
                      wkid: 4326
                    }
                  }
                });
          });
        }
      });
    });

 

 

0 Kudos
0 Replies