Layers
A layer can access data from a data source. You can use an ArcGIS Map as a container for layers to display geographic data in a Unity scene.
There are two groups of layers that an ArcGIS Map contains:
- Basemap layers, used for geographic context.
- Data layers, used to display geographic data within the context of the basemap.
A layer's data source can either be a data service or a data file stored locally.
Basemap Layers
You can use one or more basemap layers to provide a background of geographical context for the data layers displayed in your Unity scene.
Basemap layer types
In ArcGIS Maps SDK for Unity, basemap layers are currently limited to image tile layers. Image tile layers can use an online image tile service or a local image tile package as a data source. See Image tile layers below for more information.
Basemaps
Basemap layers are collected together in a basemap and you use the Basemap property of the ArcGIS Map to control the basemap in your scene.
ArcGIS Maps SDK for Unity provides a number of preset basemaps.
There are three ways to create a Basemap to use in your ArcGIS Map:
- Use one of the preset basemaps.
- Provide a URL to an image tile service or a local image tile package.
- Provide a URL to a web map's JSON.
Basemaps from web maps
As mentioned above, you can create a basemap from a URL that references web map JSON, typically read from an item of type Web Map
which is stored in an ArcGIS Portal. If the web map contains image tile layers, they will be used in the basemap.
Set a basemap
In the Basemap panel, you have a list of preset basemaps that you can select from. You can also set a custom basemap with a basemap service URL, image tile service URL, or from a local file package. If you don't want to set a basemap, do not select any checkbox in the Basemap panel.
The preset basemaps are the following:
To set a custom basemap:
Click on the Basemap tab to see the panel content if you are in another panel.
Select Custom Basemap option at the bottom of the list.
In the Source field, enter a service URL or a local file path.
- If you enter a basemap service URL, select Basemap from the Type drop-down list.
- If you enter a image tile layer service URL, select Image Layer for the Type.
- To use a
.tpk
or.tpkx
file package as a basemap source, click on ··· to select the local file package, then select Image Layer for the Type. - To use a private hosted image tile layer, select the matching configuration from the Authentication drop-down list. For more information about using private content, see ArcGIS identity.
Click on the ArcGISMap in the Hierarchy window.
Expand the ArcGIS Map Component, then Basemap section in the Inspector window.
Introduce the online service URL for the basemap layer service, or image tile layer service, or a local file package path in the Basemap field.
- If you introduce a basemap layer service URL select Basemap from the Type drop-down list.
- If you introduce a image tile layer service URL or a local file path, select Image Layer for the Type.
- To use a private hosted image tile layer, select the matching configuration from the Authentication drop-down list. For more information about using private content, see ArcGIS identity.
Set a basemap with ArcGISBasemap
. If you want to use a image tile layer or a local file package as the basemap, specify the layer type in the constructor.
You can find the sample code to set a Basemap with a basemap service URL in the SampleAPIMapCreator.cs file. The sample script file is in:
Assets/Samples/ArcGIS Maps SDK for Unity/1.0.0/All Samples/Scripts/APISample
Data layers
Data layers bring additional geographic data into your Unity scene to be displayed in the context of the basemap. You use the Layers property of the ArcGIS Map to control the data layers in your scene. The following types of layer are supported:
- Image tile layers
- Scene layers
- 3D Object scene layers
- Integrated mesh scene layers
In global scenes, we support data in any geographic coordinate system; for projected coordinate systems, we support Web Mercator when the spatial reference is set to WGS84.
In local scenes, we support any projected coordinate systems; for geographic coordinate systems, we support WGS84 when the spatial reference is set to CGCS 2000.
Refer to Spatial references for more information.
Image tile layers
An image tile layer is a data layer that can access and display image tile data provided by an image tile service or an image tile package.
The spatial reference of the image tile layers should match with the spatial reference of the basemap.
Image tile services
An image tile service is a data service that provides static pre-rendered image tiles to be displayed at different scales. You can learn more about image tile services in the Mapping APIs and location services guide.
Local image tile packages
Image tile layers can also access data from image tile packages stored locally.
An image tile package is a single .tpk (or .tpkx) file containing image tiles, and you can share the file as you would with any file. Compared with .tpk files, .tpkx files provide better performance on network shares and cloud store directories.
Scene layers
A scene layer is a type of data layer that is optimized for displaying large amounts of 3D data from a scene service or a local scene layer packages, as defined by the Open Geospatial Consortium's Indexed 3D Scene Layer (I3S) specification.
ArcGIS Maps SDK for Unity currently supports 3D object scene layers and integrated mesh scene layers from the I3S specification:
- 3D object scene layer: A 3D object scene layer represents objects such as buildings that are explicitly modeled in 3D. You can visualize a 3D object scene layer with textures embedded into the 3D features. A 3D object scene layer is automatically thinned to improve performance and visibility at different scale ranges. With a 3D object scene layer, you can change the rendering by filtering by attributes. See 3D attributes filtering for more details.
- Integrated mesh scene layer: An integrated mesh scene layers is generally created for citywide 3D mapping. It is often captured by drones and structure from motion mapping.
Scene layers will be reprojected to the spatial reference of the ArcGIS Map when they don't match in both global and local scenes. Therefore, you can use scene layers that are in any geographic and projected coordinate system.
Scene services
A scene service is a data service that provides I3S Scene Layer content. It is optimized for streaming large amounts of 3D data to client applications considering the client's 3D view of the data.
Local scene layer packages
Scene layers can also access data from scene layer packages (.slpk files) stored locally.
ArcGIS Maps SDK for Unity currently supports two types of .slpk files: integrated mesh scene layer package and 3D object scene layer package. SLPK files can be created by using different tools depending on the original data files.
Set data layers
- Click on the Layers tab.
- In the Add Data section, select a layer type from the Type drop-down list.
- In the Source field, introduce an online service URL. If you want to use a local file package, click on ··· and select the file.
- Introduce a name in the Name field.
- Click on the Add button.
When you click on the Add button, the layer will be listed under the Layers section.
To use a private content, select the matching configuration from the Authentication drop-down list in the Layers section. For more information about using private content, see ArcGIS identity.
- Click on the ArcGISMap game object in the Hierarchy window.
- Expand the ArcGIS Map Component, then Layers section in the Inspector window.
- Click on the + icon on the right side in the section to add a new array element.
- Set a Name and select a layer type from Type drop-down list.
- Introduce a online service URL or a local file path in the Source field.
To use a private content, select the matching configuration from the Authentication drop-down list. For more information about using private content, see ArcGIS identity.
Use ArcGISImage
, ArcGIS3DObject
or ArcGISIntegrated
according to the layer you add to the scene and register them to the ArcGISMap
. Specify the source URL or file path, layer name, opacity value (between 0.0f
and 1.0f
), visibility, and API key in the constructor.
You can find the sample code to add ArcGISImage
and ArcGIS3DObject
in the SampleAPIMapCreator.cs file. The sample script file is in:
Assets/Samples/ArcGIS Maps SDK for Unity/1.0.0/All Samples/Scripts/APISample
Layer management
You can toggle layers on and off, change layer opacity, delete and reorder layers.
You can make the following layer management operation under the Layers section.
- Change the layer order by clicking on ⋮ and select Move Up or Move Down.
- Change a layer name by clicking on the layer name or click ⋮ and select Rename.
- Delete a layer by clicking ⋮ and select Remove.
- Copy a layer URL, click ⋮ and select Copy URL.
- Change a layer visibility by clicking on the checkbox.
- Click on the triangle icon on the left to expand a layer registry and see the layer properties.
- Introduce a value between
0.0
and1.0
or use the slider to set the layer opacity. - Change the layer type by clicking on the Type drop-down list.
- Replace the layer source URL or file path.
- Select matching authentication configuration.
- Make the Scene view camera to zoom to the extent of a layer, click on ⋮ and select Zoom To.
You can make the following layer management operation under the Layers section in the Hierarchy window.
- Change the layer order by click on = next to the triangle icon and moving the item up or down.
- Click on the triangle icon on the left to expand a layer registry and see the layer properties.
- Change the layer name by introducing a new name in the Name field.
- Introduce a value between
0.0
and1.0
or use the slider to set the layer opacity. - Change the layer type by clicking on the Type drop-down list.
- Replace the layer source URL or file path.
- Select matching authentication configuration.
- Click on + icon to add more layers
- Click on the layer name then click - to delete a layer.
To remove a layer:
You can update layer's name, opacity, and visibility without needing to rebuild the map.
To change the opacity of a layer:
You can find the sample code to remove a layer and change opacity of layers in the SampleAPIMapCreator.cs file. The sample script file is in:
Assets/Samples/ArcGIS Maps SDK for Unity/1.0.0/All Samples/Scripts/APISample