Display a map (Components)

Learn how to set a basemap, elevation source, and add data layers, as well as display a specific area using the Components and the High Definition Render Pipeline from Unity.

In this tutorial, you will create a local scene in Unity that contains a basemap layer service and data layers.

Local scene UI

Prerequisites

Before starting this tutorial, you should:

  1. You need an ArcGIS Location Platform 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 install the plugin. Make sure to import the sample assets.

  4. Create a new HDRP project if you have not already done so.

If you are not familiar with Unity's components, see the Introduction to components and the Use components page for more information.

Steps

Create a new scene

  1. In the top menu, click File > New Scene and open the pop-up window.

    Create a new scene
  2. Select the Basic Outdoors (HDRP) template and click the Create button, then save the scene with a scene name.

    Select Basic Outdoors (HDRP) template

Create a map

In this tutorial, you will create a local scene and set a circular extent.

  1. Create an empty game object and rename it to ArcGISMap in the Hierarchy Window.

  2. Attach the ArcGIS Map component to the empty game object. When you create an ArcGIS Map, the HPRoot component is automatically added to address the limitations of working with 32-bit floating point precision. Please refer to the High Precision Framework for more information.

  3. In the Inspector window, click Local in the Map Type section.

  4. In the Origin Position section, you can set up the center of your GIS scene with its coordinates and a spatial reference Well-Known ID (WKID). For this tutorial, set the parameters to these values:

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

    For information regarding the spatial reference, see the spatial references page.

  5. Select the Enable Extent checkbox, expand the Extent section, and set the extent of the map to these values:

    • Longitude: -74.0
    • Latitude: 40.72
    • Shape: Circle
    • Spatial Reference WKID: 4326
    • Shape Dimensions: (Radius) 5000 meters

This is the result of the Inspector window.

ArcGISMap game object

For more information about creating an ArcGIS Map, refer to the Maps page.

Set basemap

In this tutorial, use Imagery basemap from Esri.

  1. Click the ArcGISMap game object that has ArcGIS Map component attached in the Hierarchy window.

  2. Expand the ArcGIS Map component, then expand the Basemap section in the Inspector window.

  3. Set the ArcGIS Online item page URL for the basemap service in the Basemap property.

    Use dark colors for code blocksCopy
    1
    https://www.arcgis.com/home/item.html?id=c7d2b5c334364e8fb5b73b0f4d6a779b
  4. Select the ArcGIS Basemap option from the drop-down list in the Basemap Type property.

Set the API key

The basemap service that is set in the previous section requires an API key.

  1. Go to your portal to create an API key.

  2. Click the ArcGIS Map game object in the Hierarchy window.

  3. Expand the ArcGIS Map component and find the Authentication section in the Inspector window.

  4. Set the API key in the API Key field.

    Set the API key

Another way to set up a global API key for multiple scenes in your Unity project is through the project settings. For more information about the API key, refer to the API keys section.

Set elevation

  1. Click the ArcGISMap game object that has the ArcGIS Map component attached in the Hierarchy window.

  2. Expand the ArcGIS Map component, then expand the Elevation Sources section in the Inspector window.

  3. Click the + icon to add a new array element.

  4. Enter Terrain 3D in the Name field.

  5. Set the online service URL for the elevation service in the Source field.

    Use dark colors for code blocksCopy
    1
    https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer
  6. Check the Is Enabled checkbox to create relief.

For more information about the elevation, refer to the Elevation page.

Create and set up a camera

ArcGIS Maps SDK for Unity will load higher LODs for areas closer to the view and lower LODs for the areas that are further away from the ArcGIS Camera component.

  1. Set the default Main Camera as a child of the ArcGISMap game object in the Hierarchy window.

    ArcGISMap camera object
  2. Click the Add Component button in the Inspector window.

  3. Search for ArcGIS Camera component and attach it to the camera.

  4. Follow the same step from step 2, search for ArcGIS Location component and attach it to the camera.

  5. The initial camera position will be defined by the ArcGIS Location component settings. Set the parameters for the ArcGIS Location component position to these values:

    • Longitude: -74.054921
    • Latitude: 40.691242
    • Altitude: 3000
    • Spatial Reference WKID: 4326
  6. Set the parameters for the ArcGIS Location component rotation to these values:

    • Heading: 55
    • Pitch: 58
    • Roll: 0

The result with these components attached looks like the following:

Create a camera

Rename the default Main Camera to ArcGISCamera game object. When you double-click the ArcGISCamera game object, your Scene view camera is moved to the configured position. You can also adjust the pitch, heading, and roll in Scene view by holding down the right mouse button.

At this point, you may want to disable Fog in the Sky and Fog Volume to see the basemap and data layers you will add. At the last of this tutorial, you will adjust the lighting.

Disable Fog

For information about the camera, see the Camera page.

Add data layers

You will add operational data from ArcGIS Online.

  • ArcGIS Online item: UrbanObservatory_NYC_TransitFrequency

    • Layer name: 01 - New York Transit Frequency
    • Type: ArcGIS Image Layer
    • Online service URL (source):
    Use dark colors for code blocksCopy
    1
    https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/UrbanObservatory_NYC_TransitFrequency/MapServer
    • Opacity: 0.9
  • ArcGIS Online item: New_York_Industrial

    • Layer name: 02 - New York Industrial Areas
    • Type: ArcGIS Image Layer
    • Online service URL (source):
    Use dark colors for code blocksCopy
    1
    https://tiles.arcgis.com/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/New_York_Industrial/MapServer
    • Opacity: 0.6
  • ArcGIS Online item: NewYorkCity_PopDensity

    • Layer name: 03 - New York Population Density
    • Type: ArcGIS Image Layer
    • Online service URL (source):
    Use dark colors for code blocksCopy
    1
    https://tiles.arcgis.com/tiles/4yjifSiIG17X0gW4/arcgis/rest/services/NewYorkCity_PopDensity/MapServer
    • Opacity: 1.0
  • ArcGIS Online item: New York, USA Buildings

    • Layer name: 04 - New York Buildings
    • Type: ArcGIS 3D Object Scene Layer
    • Online service URL (source):
    Use dark colors for code blocksCopy
    1
    https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_NewYork_17/SceneServer
    • Opacity: 1.0

Follow these steps to add each layer.

  1. While having the ArcGISMap game object selected in the Hierarchy Window, navigate to the Layer section from the Inspector window.

  2. Expand the Layer section, and click the + icon to add a new array element.

  3. Type the layer name in the Name field.

  4. Enter the layer's online service URL in the Source field to add it to the map.

  5. Select the appropriate layer type from the drop-down list in the Type field.

  6. Set the Opacity for the layer.

  7. Select the Is Visible checkbox.

This is the result of the Layers section.

Add data

Adjust sky and lighting

Unity provides a sky and lighting system. See the Sky and lighting page for more information. In this tutorial, you will adjust the settings for the game objects that were added by the template.

Adjust the Sun

  1. In the Hierarchy window, click the Sun game object.

  2. In the Inspector window, set the rotation for the following values in the Transform section.

    • X: 36
    • Y: 110
    • Z: 85
  3. Open the Emission section and set the Intensity value to 10000.

This is the result of the Sun game object.

Adjust the Sun

Adjust the Sky and Fog Volume

  1. Click the Sky and Fog Volume in the Hierarchy window.

  2. ArcGIS Maps SDK for Unity has a sample profile for Sky and Fog volume for HDRP. Click the icon next to the Profile name in the Inspector window Volume section.

  3. Select the Sky and Fog Settings SampleScenes Profile in the pop-up window.

    Sky and Fog Settings SampleScenes Profile

Attach a camera controller

You can use the Scene view camera to navigate around the scene in the viewport during the editor mode. To explore the scene in the play mode, you must attach a camera controller. In this tutorial, you will attach a controller from the **ArcGIS Maps SDK for Unity's **sample assets.

  1. Click the ArcGISCamera in the Hierarchy window.

  2. In the Inspector window, click the Add Component button.

  3. Search for the ArcGIS Camera Controller and attach it to the ArcGISCamera game object.

    Attach ArcGIS Camera Controller

You have successfully configured a map with the Components. Click the Play icon on the Toolbar and see your map in the Game view.

Use the WASD keys to move left/right/forward/backward. Use the left mouse button to pan around the scene, the right button to orbit and the scroll wheel to zoom in or out.

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