Web scene - slides

This sample demonstrates how to load a WebScene and work with its slides. Slides store a snapshot of a visualization state of the scene that can be reapplied to the scene at a later time. They contain properties for viewpoint, layer visibilities, basemap and environment (as well as a title and thumbnail). This WebScene contains a few pre-made slides, and clicking on any of them will navigate the viewpoint to the corresponding natural landmark with its saved environment settings. In addition, the sample shows how to create new slides given the current view, and store them in the WebScene. Using the Daylight and Weather components (on the left), you can set up different environmental conditions when creating new slides.

The WebScene instance (assigned to viewElement.map) contains a presentation property that manages the scene's slides.

Use dark colors for code blocksCopy
1 2 3 4 5 6 <!-- Reference a webscene in the arcgis-scene component--> <arcgis-scene item-id="1c7a06421a314ac9b7d0fae22aa367fb"> <script type="module">  const viewElement = document.querySelector("arcgis-scene");  const slides = viewElement.map.presentation.slides; </script>

To create a new slide containing a snapshot of the current view, use the Slide.createFrom static method. This method returns a Promise that resolves with a new Slide instance once the slide has been successfully created. You can also add the slide to the slides collection of the scene presentation so that if the scene is published back to the portal, the newly created slide is correctly persisted as part of the WebScene.

Use dark colors for code blocksCopy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127  // Create a slide containing a snapshot of the current view and its properties  Slide.createFrom(viewElement.view).then((slide) => {  // Set the slide title using the text from the title input element  slide.title.text = document.getElementById("createSlideTitleInput").value;  // Add the slide to the slides collection of the scene presentation  slides.add(slide);  // Create an UI for the new slide using a custom function  createSlideUI(slide);  }); 

The slide properties can be used to create DOM elements to represent each viewpoint. Below is an example of a UI created using Calcite Components. Slides are displayed there in the form of a list, with each item represented by a thumbnail, title, and description using the information stored in the slides.

Use dark colors for code blocksCopy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127  // Create a new element which will contain all the slide information  const slideElement = document.createElement("calcite-list-item");  // Assign attributes of the slide to the element  slideElement.id = slide.id;  slideElement.label = slide.title.text;  slideElement.scale = "s";  slideElement.setAttribute("closable", "");  // Assign the date and time (in UTC) representing the light state to the slide description  slideElement.description = slide.environment.lighting.date.toLocaleString("en-GB", {  timeZone: "UTC",  });  // Create an element with a thumbnail using the slide's URL  slideElement.innerHTML = `<calcite-content slot="content-start">  <img alt="" src="${slide.thumbnail.url}">  </calcite-content>`;  slidesDiv.appendChild(slideElement); 

Once a new DOM element is created for each slide, you can set up a click event handler to apply the slide's settings to the view. This is done with the slide's applyTo() method, which allows the user to animate to the given slide's viewpoint and set saved properties.

Use dark colors for code blocksCopy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127  slideElement.addEventListener("calciteListItemSelect", () => {  // Applies a slide's settings to the SceneView and configure the animation  slide.applyTo(viewElement.view, {  maxDuration: 3000,  easing: "in-out-coast-cubic",  });  }); 

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.