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 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 install the plugin. Make sure to import the sample assets.

  4. Create a new HDRP project.

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 on File > New Scene and open the pop-up window.

    Create a new scene

  2. Select Basic Outdoors (HDRP) template and click on 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 will be 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 on Local in the Map Type section.

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

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

    For the 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 = 5000;

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

  1. Click on 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 online service URL for the basemap service in the Basemap property.

    Use dark colors for code blocksCopy
     
    1
    https://ibasemaps-api.arcgis.com/arcgis/rest/services/World_Imagery/MapServer
  4. Select the Image Layer option from the drop-down list in the Basemap Type property.

Set the API key

In this tutorial, you will use a basemap service which requires an API key.

  1. Go to your developer dashboard to get your API key.

  2. Click on 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

For more information about the API key, refer to the API keys section.

Set elevation

  1. Click on 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 section in the Inspector window.

  3. Set the online service URL for the elevation service in the Elevation property.

    Use dark colors for code blocksCopy
     
    1
    https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer

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

Create and set up a camera

ArcGIS Maps SDK for Unity will load better LODs for areas closer to the view and lower LODs for the areas that are further away with 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 on 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;

This is the result of the with these components attached.

Create a camera

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

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 the information about 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 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 on the Sun game object.

  2. In the Inspector window, set the rotation to the following values in 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 on 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 on 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

During the editor time, you have the Scene view camera to navigate around in the viewport when the Editor mode is enabled. For the play mode, you must attach a camera controller to explore your scene. In this tutorial, you will attach a controller from the ArcGIS Maps SDK for Unity's sample assets.

  1. Click on the ArcGISCamera in the the Hierarchy window.

  2. In the Inspector window, click on 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.