Learn how to create and display a
Pan, zoom, tilt, and rotate the scene to explore.
A
In this tutorial, you will create and display a scene of the Santa Monica Mountains in California using the topographic
Prerequisites
Steps
Create a new pen
- Go to CodePen to create a new pen for your mapping application.
Add basic HTML
Define a basic HTML page.
- In CodePen > HTML, add HTML to create a basic page.
<html>
<head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>ArcGIS Maps SDK for JavaScript Tutorials: Display a scene</title>
</head>
<body>
</body>
</html>Add CSS
- In CodePen > HTML, add CSS to set the map to use the full width and height of the browser.
7 collapsed lines<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><title>ArcGIS Maps SDK for JavaScript Tutorials: Display a scene</title><style>html,body {height: 100%;margin: 0;}</style>10 collapsed lines</head><body></body></html>
Get an access token
You need an
- Go to the Create an API key tutorial and create an
API key with the followingprivilege(s) :
- Privileges
- Location services > Basemaps
- Privileges
- In CodePen, set the
apiKeyproperty on the globalesriConfigvariable to your access token.<!-- The esriConfig variable must be defined before adding the other esri libraries --><script>var esriConfig = {apiKey: "YOUR_ACCESS_TOKEN",};</script>
To learn about other ways to get an access token, go to Types of authentication.
Add the ArcGIS Maps SDK for JavaScript script tag
-
In the
<head>, add the<script>tag for the JavaScript Maps SDK.21 collapsed lines<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><title>ArcGIS Maps SDK for JavaScript Tutorials: Display a scene</title><style>html,body {height: 100%;margin: 0;}</style><script>var esriConfig = {apiKey: "YOUR_ACCESS_TOKEN",};</script><!-- Load the ArcGIS Maps SDK for JavaScript from CDN --><script type="module" src="https://js.arcgis.com/5.0/"></script>10 collapsed lines</head><body></body></html>
Create a scene
Use the Scene component to set the ground (surface) height that will be rendered on the map.
The camera-position attribute is the point from which the visible extent of the scene is determined. The camera-tilt attribute refers to the number of degrees from the surface that the camera is pointed.
- In the
<body>tag, add the<arcgis-scene>component and specify thebasemap,ground,camera-positionandcamera-tiltattributes.26 collapsed lines<html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><title>ArcGIS Maps SDK for JavaScript Tutorials: Display a scene</title><style>html,body {height: 100%;margin: 0;}</style><script>var esriConfig = {apiKey: "YOUR_ACCESS_TOKEN",};</script><!-- Load the ArcGIS Maps SDK for JavaScript from CDN --><script type="module" src="https://js.arcgis.com/5.0/"></script></head><body><arcgis-scene basemap="arcgis/topographic" ground="world-elevation" camera-position="-118.808, 33.961, 2000"camera-tilt="75"></arcgis-scene></body>3 collapsed lines</html>
Add navigation toggle and zoom components
- Inside the
<arcgis-scene>component, add the<arcgis-zoom>and<arcgis-navigation-toggle>components and specify their slot.
29 collapsed lines
<html>
<head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>ArcGIS Maps SDK for JavaScript Tutorials: Display a scene</title>
<style> html, body { height: 100%; margin: 0; } </style>
<script> var esriConfig = { apiKey: "YOUR_ACCESS_TOKEN", }; </script>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.0/"></script>
</head>
<body>
<arcgis-scene basemap="arcgis/topographic" ground="world-elevation" camera-position="-118.808, 33.961, 2000" camera-tilt="75">
<arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-navigation-toggle slot="top-left"></arcgis-navigation-toggle>
</arcgis-scene>5 collapsed lines
</body>
</html>Run the app
In CodePen, run your code to display the map.
The scene view should display the topographic
What’s next?
Learn how to use additional SDK features and ArcGIS services in these tutorials: