<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Scene - goTo() | Sample | ArcGIS Maps SDK for JavaScript</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.1/"></script>
<arcgis-scene basemap="dark-gray-vector" ground="world-elevation" zoom="4">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle>
<arcgis-compass slot="top-left"></arcgis-compass>
<calcite-button id="default">Default flight</calcite-button>
<calcite-button id="linearSlow">Linear slow flight</calcite-button>
<calcite-button id="linearFast">Linear fast flight</calcite-button>
<calcite-button id="expoIncrease">Exponentially increasing speed flight</calcite-button>
<calcite-button id="fixedDuration">10 seconds flight</calcite-button>
<calcite-button id="bounceBerlin">Bounce to Berlin</calcite-button>
/*****************************************************************
* Get a reference to the HTML elements
*****************************************************************/
const viewElement = document.querySelector("arcgis-scene");
// Wait for the view to initialize
await viewElement.viewOnReady();
/*****************************************************************
* Add event listeners to go to a target point using animation options
*****************************************************************/
// The target point is a new camera obtained by shifting the current camera 30 degrees to the east
function shiftCamera(deg) {
const camera = viewElement.camera.clone();
camera.position.longitude += deg;
function catchAbortError(error) {
if (error.name != "AbortError") {
document.getElementById("default").addEventListener("click", () => {
// Don't set any animation options for a default camera flight
viewElement.goTo(shiftCamera(60)).catch(catchAbortError);
document.getElementById("linearSlow").addEventListener("click", () => {
// Animation options for a slow linear camera flight
document.getElementById("linearFast").addEventListener("click", () => {
// Animation options for a fast linear camera flight
document.getElementById("expoIncrease").addEventListener("click", () => {
// Animation options for a camera flight with an increasing speed
document.getElementById("fixedDuration").addEventListener("click", () => {
maxDuration: 10000, // Make sure to set maxDuration if the duration is bigger than 8000 ms
// Define your own function for the easing option
function customEasing(t) {
return 1 - Math.abs(Math.sin(-1.7 + t * 4.5 * Math.PI)) * Math.pow(0.5, t * 10);
document.getElementById("bounceBerlin").addEventListener("click", () => {