Display a map (C++ API)

Learn how to set a basemap, elevation source, data layers by using the C++ API.

In this tutorial, you will create a C++ class to set up an ArcGIS Map with a circular extent in the Local scene. Using the C++ class, you can easily switch between the Global and Local scene by modifying one line of code.

Local C++ API result

Prerequisites

Before starting this tutorial, you should:

  1. Have an ArcGIS Developer account or ArcGIS Online account and an API key to access ArcGIS services. If you don't have an account, sign up for free.

  2. Ensure your development environment meets the system requirements.

  3. Follow Install and setup steps, and create a new project, and select the C++ API as your scene setting option.

Steps

Create a new level

  1. Click on File on the Menu Bar and select New Level.

  2. Select Empty Level in the popup window.

    New Level

  3. Click Window in the menu bar and select World Settings.

    Open World Wettings

  4. Open Advanced under World and check Enable Large Worlds.

    Enable Large Worlds

Initialize the C++ API

  1. To create these scripts in your project, you need to go to the content folder. Click Tools > New C++ Class.

  2. This will show the Choose Parent Class wizard. You want your script to attach to an Actor. Select All Classes and click on ArcGIS Actor under Actor, then click Next. ArcGIS Actor includes ArcGIS Maps SDK Subsystem Listener that allows you to use the editor mode.

    Choose Parent Class

  3. Give a name to the Actor and set where you like to place the Actor script. It can be set in the host project or in a different module. The Public/Private button will define whether this class will be public or private. Also, you can define the path where the file will be. After you fill out the parameters click Create Class.

    Name new Actor

  4. After Unreal Engine compiles the project, Visual Studio will automatically open the .h and the .cpp files.

Add Actors and set Origin Position

ArcGIS Map Actor will place your GIS content in Unreal Engine space, and you can enable/disable the editor mode and Mesh Colliders. In this tutorial, you will configure where your GIS content is to be placed at 0, 0, 0 of the game engine space.

You can find the ArcGIS Map Actor here:

Plugins\ArcGIS Maps SDK for Unreal Engine C++ Classes\ArcGISMapsSDK\Public\ArcGISMapsSDK\Actors

  1. Drag the ArcGIS Map Actor into the level.

    ArcGISMap Actor

  2. Configure the Origin Position with a WKID for the values. In this tutorial, you are setting up the following Origin Position values for New York City.

    • Longitude: -74
    • Latitude: 40
    • Spatial Reference WKID: 4326
    • Altitude: 0

    This is the result of the ArcGIS Map Actor.

    ArcGISMap Actor Result

  3. Locate the Map Creator Actor in the Content Drawer. Drag and drop the Actor you created into the level.

    Add MapCreator

Set up the project

Before working on the .h and the .cpp files, we will first set up the project.

  1. Navigate to your MapCreator.cpp file folder. Create a PCH file with the .h suffix as follows:

    Use dark colors for code blocksCopy
              
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    #pragma once
    
    #include <assert.h>
    #include <atomic>
    #include <functional>
    #include <memory>
    
    #include "CoreMinimal.h"
    
    #include "ArcGISMapsSDK/API/Unreal/ArcGISDictionary.h"
  2. Open your_project_file.Build.cs file under the directory your_project > Source > your_project.

  3. Add this line of code after PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; that points to your PCH file.

    Use dark colors for code blocksCopy
     
    1
    PrivatePCHHeaderFile = "Private/your_PCH_file.h";
  4. In PublicDependencyModuleNames.AddRange, add two modules as follows:

    Use dark colors for code blocksCopy
     
    1
    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "ArcGISMapsSDK","ArcGISSamples"});

Create header file

  1. When you create an ArcGIS Actor, you already have the necessary includes in the header file. Make sure you have ArcGISMapsSDK/Actors/ArcGISActor.h

  2. Set the default values for the Actor's properties and set it to public. Make sure to replace YOUR_API_KEY text with your API key by going to your developer dashboard to get your API key.

    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
    public:
    	ASampleAPIMapCreator();
    	FString APIKey = "YOUR_API_KEY";
    
  3. Create the method that will execute your code. In our example, we named it CreateArcGISMap() and set it to private.

    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
    	void CreateArcGISMap();
    
  4. For the editor mode, it's necessary to react to changes during the editor time. Add subsystem listener for the ArcGIS Map Component Actor which is connected to the subsystem.

    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
    	// IArcGISMapsSDKSubsystemListener
    	void OnArcGISMapComponentChanged(UArcGISMapComponent* InMapComponent) override;
    

This is the complete source code for our header file:

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
#pragma once

#include "CoreMinimal.h"

#include "ArcGISMapsSDK/Actors/ArcGISActor.h"
#include "SampleAPIMapCreator.generated.h"

// The declaration of our Actor class
UCLASS()
class ARCGISSAMPLES_API ASampleAPIMapCreator : public AArcGISActor
{
	GENERATED_BODY()

public:
	ASampleAPIMapCreator();
	FString APIKey = "YOUR_API_KEY";

	// IArcGISMapsSDKSubsystemListener
	void OnArcGISMapComponentChanged(UArcGISMapComponent* InMapComponent) override;

	void CreateArcGISMap();
};

Include headers and create Renderer Component

  1. First, include all necessary headers.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    #include "SampleAPIMapCreator.h"
    
    #include "Engine/World.h"
    #include "Kismet/GameplayStatics.h"
    
    #include "ArcGISMapsSDK/API/GameEngine/Elevation/Base/ArcGISElevationSource.h"
    #include "ArcGISMapsSDK/API/GameEngine/Layers/Base/ArcGISLayer.h"
    #include "ArcGISMapsSDK/API/GameEngine/View/ArcGISView.h"
    #include "ArcGISMapsSDK/API/GameEngine/View/State/ArcGISElevationSourceViewState.h"
    #include "ArcGISMapsSDK/API/GameEngine/View/State/ArcGISLayerViewState.h"
    #include "ArcGISMapsSDK/API/GameEngine/View/State/ArcGISViewState.h"
    #include "ArcGISMapsSDK/API/GameEngine/View/State/ArcGISViewStateMessage.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Elevation/ArcGISImageElevationSource.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Extent/ArcGISExtentCircle.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Geometry/ArcGISSpatialReference.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Layers/ArcGIS3DObjectSceneLayer.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Layers/ArcGISImageLayer.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Layers/Base/ArcGISLayerCollection.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Map/ArcGISBasemap.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Map/ArcGISMap.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Map/ArcGISMapElevation.h"
    #include "ArcGISMapsSDK/BlueprintNodes/GameEngine/Map/ArcGISMapType.h"
    
    #include "ArcGISSamples/Public/ArcGISPawn.h"
    
  2. In the constructor, change PrimaryActorTick.bCanEverTick to false to improve performance.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    ASampleAPIMapCreator::ASampleAPIMapCreator()
    {
    	PrimaryActorTick.bCanEverTick = false;
    }
    
  3. Call the method CreateArcGISMap() for the ArcGIS Subsystem Listener.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    void ASampleAPIMapCreator::OnArcGISMapComponentChanged(UArcGISMapComponent* InMapComponent)
    {
    	AArcGISActor::OnArcGISMapComponentChanged(InMapComponent);
    
    	if (MapComponent)
    	{
    		CreateArcGISMap();
    	}
    }
    

Create ArcGIS Map and set layers

ArcGIS Map is a container of your GIS content. First, create this container as a function to begin adding your content.

  1. Create your CreateArcGISMap() function.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    void ASampleAPIMapCreator::CreateArcGISMap()
    {
    }
  2. Set the view mode by using ArcGISMapType enum and create ArcGIS Map. You will set up a map extent in the Set map extent section.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Create the map document
    	auto mapType = EArcGISMapType::Local;
    	auto arcGISMap = UArcGISMap::CreateArcGISMapWithMapType(mapType);
    
  3. Create a basemap with an image tile layer using the ArcGISImagery of ArcGISBasemapStyle class which requires the API key.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Add a basemap
    	auto basemapType = EArcGISBasemapStyle::ArcGISImagery;
    	auto arcGISBasemap = UArcGISBasemap::CreateArcGISBasemapWithBasemapStyle(basemapType, APIKey);
    
    	// Set the basemap
    	arcGISMap->SetBasemap(arcGISBasemap);
    
  4. Set and create your map elevation with ArcGISElevationSource.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Set the elevation
    	auto elevationSource = UArcGISImageElevationSource::CreateArcGISImageElevationSourceWithName(
    		"https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer", "Elevation", "");
    	auto mapElevation = UArcGISMapElevation::CreateArcGISMapElevationWithElevationSource(elevationSource);
    	arcGISMap->SetElevation(mapElevation);
    

    In this tutorial, you'll use Terrain3D as the elevation source. You can find more elevation layers in ArcGIS Online.

  5. Add the following three image tile layers and one 3D object scene layer with their name.

    Add image tile layers and the 3D object scene layer to the ArcGIS Map by using ArcGISImageLayer and ArcGIS3DObjectSceneLayer, respectively.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Create layers
    	auto layer_1 = UArcGISImageLayer::CreateArcGISImageLayerWithProperties(
    		"https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/UrbanObservatory_NYC_TransitFrequency/MapServer",
    		"NYTransitFrequencyTiles", 1.0f, true, "");
    	arcGISMap->GetLayers()->Add(layer_1);
    
    	auto layer_2 = UArcGISImageLayer::CreateArcGISImageLayerWithProperties(
    		"https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/New_York_Industrial/MapServer", "NYIndustrialTiles", 1.0f, true,
    		"");
    	arcGISMap->GetLayers()->Add(layer_2);
    
    	auto layer_3 = UArcGISImageLayer::CreateArcGISImageLayerWithProperties(
    		"https://tiles.arcgis.com/tiles/4yjifSiIG17X0gW4/arcgis/rest/services/NewYorkCity_PopDensity/MapServer", "NYPopDensityTiles", 1.0f, true,
    		"");
    	arcGISMap->GetLayers()->Add(layer_3);
    
    	auto buildingLayer = UArcGIS3DObjectSceneLayer::CreateArcGIS3DObjectSceneLayerWithProperties(
    		"https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_NewYork_17/SceneServer", "NYScene", 1.0f, true, "");
    	arcGISMap->GetLayers()->Add(buildingLayer);
    

Set map extent

To configure an extent, it is required to provide the center point position together with the shape and dimensions. ArcGISPoint class allows you to define a position of a map with GIS coordinates and its spatial reference. You can use ArcGISPoint to specify the extent center. Use ArcGISExtentCircle to configure an extent with the following parameter values and set it for the map.

  • Latitude: 40.691242
  • Longitude: -74.054921
  • Altitude: 3000 Meters
  • Radius: 10000 Meters
  • Spatial Reference: WGS 84 (WKID 4326)

The if statement will check the maptype and the extent can be set only for local. Refer step 2 in the Create ArcGIS Map and set layers section.

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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	// Create extent
	if (mapType == EArcGISMapType::Local)
	{
		// Set this to true to enable an extent on the map component
		MapComponent->SetIsExtentEnabled(true);

		auto sr = UArcGISSpatialReference::WGS84();
		auto extentCenter = UArcGISPoint::CreateArcGISPointWithXYZSpatialReference(-74.054921, 40.691242, 3000, sr);
		auto extent = UArcGISExtentCircle::CreateArcGISExtentCircle(extentCenter, 10000);
		arcGISMap->SetClippingArea(extent);
	}

For other extent options, refer to the map extent page.

Set initial camera position

The ArcGIS Camera Component controls the data that is loaded into your scene. The ArcGIS Location Component is responsible for the position and the angle of the camera. Unreal Engine's Default Pawn is a kind of Actors that can be controlled by players or AI with some additional Components and functionality. To explore ArcGIS Map with a camera, you can set your camera controller together with the ArcGIS Camera Component and the ArcGIS Location Component to a Default Pawn.

In this tutorial, you will set the initial camera position with C++ script by using ArcGIS Pawn which is a sample Pawn that has a sample camera controller code together with the ArcGIS Camera Component and the ArcGIS Location Component.

  1. The position of the ArcGIS Pawn is defined by the ArcGIS Location Component. To populate the position values of the ArcGIS Location Component, access the Component that is attached to the Actor.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Set the initial Pawn location. This can be removed to set the AArcGISPawn`s location using the details panel
    	AArcGISPawn* arcGISPawn = Cast<AArcGISPawn>(UGameplayStatics::GetActorOfClass(GetWorld(), AArcGISPawn::StaticClass()));
    	auto PawnLocationComponent = Cast<UArcGISLocationComponent>(arcGISPawn->GetComponentByClass(UArcGISLocationComponent::StaticClass()));
    
  2. Specify the position values with ArcGISPoint. In this tutorial, you set the following values for the camera position.

    • Longitude: -74.054921
    • Latitude: 40.691242
    • Altitude: 3000 Meters
    • Spatial Reference: WGS 84 (WKID 4326)
    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	auto Position = UArcGISPoint::CreateArcGISPointWithXYZSpatialReference(-74.054921, 40.691242, 3000, UArcGISSpatialReference::WGS84());
    	PawnLocationComponent->SetPosition(Position);
    
  3. Set the rotation of the camera with the following values.

    • Heading: 65
    • Pitch: 0
    • Roll: 68
    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	auto Rotation = UArcGISRotation::CreateArcGISRotation(65, 0, 68);
    	PawnLocationComponent->SetRotation(Rotation);
    

Set ArcGIS Map

  1. Set the value for the ArcGISViewOptions. If it's set to true you can change the layer's visibility during the runtime.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Create the view options config struct
    	FArcGISViewOptions viewOptions{true};
    
  2. ArcGIS Map Component communicates with ArcGISView to handle what and how the ArcGIS Map to be rendered. Set the viewOptions and arcGISMap to the MapComponent.

    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    	// Set the map and view options
    	MapComponent->GetView()->SetViewOptions(viewOptions);
    	MapComponent->SetMap(arcGISMap);
    

You have created the C++ source code for an API scene. Build and compile the project and Unreal Engine will be automatically opened.

Set up the sky and the light

  1. From the quick add menu on the toolbar, select Lights > Directional Light and drag it into the level to create a Directional Light. For more information about Directional Lights, see Lights.

    Directional Light

  2. Select the Directional Light in the Outliner, and open the Transform section in the Details panel.

  3. Reset the Location and Set the Rotation to:

    • X: 0
    • Y: -28
    • Z: -28
  4. Set the Mobility to Movable.

    Directional Light Transform

  5. In the Light section, change the Intensity Value to 3.1416.

  6. In the Cascaded Shadow Maps section, change the Dynamic Shadow Distance MovableLight to 2000000.

  7. In the Atmosphere and Cloud section, enable Atmosphere Sun Light.

  8. In the Actor > Spawn Collision Handling Method section, select Always Spawn, Ignore Collisions.

    Directional Light Actor

  9. From the quick add menu on the toolbar, select Lights > Sky Light and drag it into the level to create a Sky Light. For more information about Sky Light, see Lights.

  10. In the Transform section, reset the Location and set the Mobility to Movable.

  11. In the Light section, enable Real Time Capture.

    SkyLight

  12. From the quick add menu on the toolbar, select Visual Effects > Sky Atmosphere and drag it into the level to create a Sky. For more information about Sky Atmosphere, see Fog Effects.

  13. In the Planet section, change the Ground Radius to 6378.137207.

When the light starts loading in the Viewport, you can see the render result in the editor Viewport. Double click on the ArcGIS Pawn in the Outliner panel to snap the editor camera to the camera position.

Use the WASD keys while holding the right mouse button mouse to move around, or hold the left mouse button to pan during the editor mode.

Click the Play icon on the Tool bar, and Use the WASD keys to move around, hold the right mouse button mouse to look around or hold the left mouse button to pan.

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