You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.

Unsupported browser

You are using a browser that is not supported. JavaScript API works on the latest versions of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. Use one of these browsers and provide your feedback through GeoNet, the Esri Community.

  • {i18n.unsupportedBrowser.chrome}
  • Firefox
  • Safari
  • undefined
Loading...

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to create an animated tour of the slides in a WebScene by using the applyTo() method. applyTo() returns a promise that resolves after the slide has been applied to the view. By chaining the applyTo() method of the slides, we can play through all the slides without user input.

The chaining is done with a recursive function:

// slides  is the array of slides from the webscene
var slides = scene.presentation.slides;

function goToSlide(i) {
  var slide = slides.getItemAt(i);

  if (i < slides.length) {
    infoDiv.innerHTML = slide.title.text;
    // call the applyTo method on the current slide
    slide
      .applyTo(view, { duration: 3000 })
      // and after the slide was applied to the view wait for 8 seconds
      // and then call goToSlide for the next slide
      .then(function() {
        window.setTimeout(function() {
          goToSlide(i + 1);
        }, 8000);
      });
  }
}

// go to the first slide - this function triggers the chaining
goToSlide(1);

Sample search results

TitleSample
Loading...