A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/javascript/latest/tutorials/display-a-scene/ below:

Display a scene | Overview | ArcGIS Maps SDK for JavaScript 4.33

Learn how to create and display a scene with a basemap layer and elevation.

A scene contains layers of geographic data that are displayed in 3D. Scenes allow you to display real-world visualizations of landscapes, objects, buildings, and other 3D objects.

In this tutorial, you will create and display a scene of the Santa Monica Mountains in California using the topographic basemap layer and the world elevation layer. The scene and code will be used as the starting point for other 3D tutorials.

Note

To learn more about scenes, visit Scenes (3D) in the Mapping and location services guide. To learn more about services, visit Basemap layers.

Prerequisites ArcGIS Accounts:

You need an ArcGIS Location Platform or ArcGIS Online account.

Steps Create a new pen
  1. Go to CodePen to create a new pen for your mapping application.
Add basic HTML

Define a basic HTML page.

  1. In CodePen > HTML, add HTML to create a basic page.
Note

The <!doctype html> tag is not required in CodePen. If you are using a different editor or running the page on a local server, be sure to add this tag to the top of your HTML page.

Use dark colors for code blocks

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

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Display a scene</title>

  </head>

  <body>

  </body>

</html>
Add CSS
  1. In CodePen > HTML, add CSS to set the map to use the full width and height of the browser.

    Expand

    Use dark colors for code blocks
    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
        <style>
          html,
          body {
            height: 100%;
            margin: 0;
          }
        </style>
    
Get an access token

You need an access token with the correct privileges to access the location services used in this tutorial.

  1. Go to the Create an API key tutorial and create an API key with the following privilege(s):
  2. In CodePen, set esriConfig.apiKey to your access token.

    Use dark colors for code blocks

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    <!-- 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 references
  1. In the <head> tag, add references to the ArcGIS core library, its CSS stylesheet, and the @arcgis/map-components package.

    Expand

    Use dark colors for code blocks
    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
        <!-- Load Calcite components from CDN -->
        <script type="module" src="https://js.arcgis.com/calcite-components/3.2.1/calcite.esm.js"></script>
    
        <!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
        <link rel="stylesheet" href="https://js.arcgis.com/4.33/esri/themes/light/main.css" />
        <script src="https://js.arcgis.com/4.33/"></script>
    
        <!-- Load Map components from CDN-->
        <script type="module" src="https://js.arcgis.com/4.33/map-components/"></script>
    
Create a scene

Use the Scene component to set the basemap layer, elevation surface, and camera attributes. Scenes use the information in the elevation layer to determine the ground (surface) height that will be rendered on the map.

The camera's position, specified by 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.

  1. In the <body> tag, add the <arcgis-scene> component and specify the basemap, ground, camera-position and camera-tilt attributes.

    Expand

    Use dark colors for code blocks
    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
      <body>
    
        <arcgis-scene
          basemap="arcgis/topographic"
          ground="world-elevation"
          camera-position="-118.808, 33.961, 2000"
          camera-tilt="75">
    
        </arcgis-scene>
    
      </body>
    
Add navigation toggle and zoom components
  1. Inside the <arcgis-scene> component, add the <arcgis-zoom> and <arcgis-navigation-toggle> components and specify their position.

Expand

Use dark colors for code blocks
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
    <arcgis-scene
      basemap="arcgis/topographic"
      ground="world-elevation"
      camera-position="-118.808, 33.961, 2000"
      camera-tilt="75">

      <arcgis-zoom position="top-left"></arcgis-zoom>
      <arcgis-navigation-toggle position="top-left"></arcgis-navigation-toggle>

    </arcgis-scene>
Run the app

In CodePen, run your code to display the map.

The scene view should display the topographic basemap layer and elevation layer for an area of the Santa Monica Mountains in California.

What's next?

Learn how to use additional API features and ArcGIS services in these tutorials:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4