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
The basemap layer service provides several vector tile and image tile basemap layers that you can use for your applications.
Vector tile basemaps are vector tile layers capable of displaying high-density geographic data as vector tile data. In addition to the default vector basemap styles, you can create custom vector basemap styles with ArcGIS Vector Tile Style Editor.
Image tile layers are pre-rendered images hosted in ArcGIS that can be displayed at different scales.
For a complete list of styles, see the Basemap layer service topic in the Mapping APIs and location services guide.
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.
The following are the source and source types to create a Basemap to use in your ArcGIS Map.
Source | Source type |
---|---|
Basemap layer | Basemap |
Web map | Basemap |
Image tile layer | Image layer |
Vector tile layer | Vector tile layer |
Basemaps from the basemap layer service (basemap styles service)
The basemap layer service provides global basemap layers in a variety of styles to use in mapping applications.
There are two ways to access basemap layers: through the basemap styles service and the tile services. You can access the basemap styles service with a URL and parameters to get the JSON definition for a specific basemap style. To see a complete list of styles, visit the Basemap layer service in the Mapping APIs and location services guide.
With ArcGIS Maps SDK for Unity, you can use the standard endpoint formatted as follows.
https://basemaps-api.arcgis.com/arcgis/rest/services/styles/{basemapStyle}?type=webmap
For information about tile services, see the image tile layers and vector tile layers sections.
Basemaps from web maps
As mentioned previously, you can create a basemap from a URL that references a web map by providing the item page URL or the JSON, typically read from an item with type Web Map
which is stored in an ArcGIS Portal.
You can load any web maps that contain image tile layers, vector tile layers, and reference layers as a basemap. It is possible to use web maps that contain other layer types but they will not be displayed in the viewport.
ArcGIS Maps SDK for Unity provides several preset basemaps from the Map Creator UI. These also use the basemap layer service with the web map format.
There are two ways to format the URL to create a basemap from a web map:
- Item page URL
- REST endpoint URL
Set a basemap
In the Basemap panel is a list of selectable, preset basemaps. You can also set a basemap from a basemap layer service, a web map, an image tile layer, a vector tile layer, or a local tile package.
If you do not want to set a basemap, click the ArcGIS Map game object in the Hierarchy window and empty the Basemap field in the Inspector window.
The preset basemaps are listed in the World Basemaps for Developers group in the ArcGIS Online. Preset basemaps do not include Human Geography Map and Human Geography Dark Map.
To set a custom basemap:
-
Click the Basemap tab.
-
Click + Add New at the bottom of the list. A pop-up window opens.
-
In the Source field, enter a service URL or a local file path.
- To use a basemap layer service or a web map, select Basemap from the Type drop-down list.
- To use an image tile layer service, select Image Layer from the Type drop-down list.
- To use a
.tpk
, or.tpkx
tile package as a basemap source, click more options ··· to select the local tile package, then select Image Layer from the Type drop-down list. - To use a vector tile layer service, select Vector Tile Layer from the Type drop-down list.
- To use a
.vtpk
file package as a basemap source, click more options ··· to select the local file package, then select Vector Tile Layer from the Type drop-down list. - To use a privately hosted web map or services, select the matching configuration from the Authentication drop-down list. For more information about using private content, see user authentication.
-
Type a Name for your basemap; this will be used to identify it in the basemap gallery.
-
Click Add to finish creating the custom basemap. The pop-up window closes.
-
Verify that the custom basemap is selected in the gallery.
To remove a custom basemap registry from the basemap gallery, click the X on the thumbnail.
-
Click 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, image tile layer service, or a local file package path in the Basemap field.
- To use a basemap layer service or a web map, select Basemap from the Type drop-down list.
- To use an image tile layer service,
.tpk
, or.tpkx
tile package, select Image Layer from the Type drop-down list. - To use a vector tile layer service or
.vtpk
tile package as a basemap source, select Vector Tile Layer from the Type drop-down list. - To use a privately hosted web map or services, select the matching configuration from the Authentication drop-down list. For more information about using private content, see user authentication.
Set a basemap with ArcGISBasemap
. If you want to use an image tile layer, vector tile layer, or a local tile package as the basemap, specify the layer type in the constructor.
You can find the sample code to set a Basemap in the ArcGISImagery
value with ArcGISBasemap
class in the SampleAPIMapCreator.cs file. The sample script file is located in:
Assets/Samples/ArcGIS Maps SDK for Unity/[version]/Sample Content/Scenes/Scripts/APISample
Refer to FAQ for troubleshooting data loading issues.
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 layers are supported:
- Image tile layers
- Vector tile layers
- Scene layers (version 1.7 or higher)
- 3D object scene layers
- Integrated mesh scene layers
- Building scene layers
To find the scene layers version, open the service JSON and look for "service
.
In global scenes, Esri 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 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 display at different scales.
You can use the following kinds of URLs for the source to add image tile services to your ArcGIS Map:
- Item page URL
- Image tile service URL
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.
Vector tile layers
A vector tile layer contains vector representations of data across a range of scales that is provided by a vector tile service or vector tile package. In contrast to image tiles, vector tiles can adapt to the resolution of the device they are displayed on and restyled for multiple uses.
The spatial reference of the vector tile layers should match the spatial reference of the basemap.
Vector tile services
A vector tile service is a type of data service that stores and provides access to vector tiles and vector tile style resources.
You can use the following kinds of URLs for the source to add vector tile services to your ArcGIS Map:
- Item page URL
- Vector tile service URL
- Vector tile style URL
You can learn more about vector tile services in the Mapping APIs and location services guide.
Local vector tile packages
A vector tile service can also package vector tiles for offline use as vector tile packages. A vector tile package (.vtpk) is a collection of vector tiles and style resources that are stored on a server. When you publish a vector tile package to ArcGIS Online or ArcGIS Enterprise, a vector tile layer is created.
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, integrated mesh scene layers, and building 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 layer is generally created for citywide 3D mapping. It is often captured by drones and structures from motion mapping.
- Building scene layer: A building scene layer is a 3D representation of a building model, which may be derived from 3D construction content, such as 3D BIM (Building Information Modeling) data. The building scene layer organizes construction data and groups content into standard engineering disciplines. Content in a building scene layer may represent a partial building, an individual building, or multiple buildings on campus.
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.
You can use the following kinds of URLs for the source to add scene services to your ArcGIS Map:
- Item page URL
- Scene service URL
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 three types of .slpk files: integrated mesh scene layer package, 3D object scene layer package, and building scene layer package. SLPK files are created by using different tools depending on the original data files.
Set data layers
- Click 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 the ··· and select the file.
- Introduce a name in the Name field.
- Click the Add button.
When you click the Add button, the layer is listed under the Layers section.
To use private content, select the matching configuration from the Authentication drop-down list in the Layers section. For more information about using private content, see user authentication.
- Click the ArcGISMap game object in the Hierarchy window.
- Expand the ArcGIS Map Component, then the Layers section in the Inspector window.
- Click the + icon on the right side of the section to add a new array element.
- Set a Name and select a layer type from Type drop-down list.
- Introduce an online service URL or a local file path in the Source field.
To use private content, select the matching configuration from the Authentication drop-down list. For more information about using private content, see user authentication.
Use ArcGISImage
, ArcGIS3DObject
, ArcGISIntegrated
, or ArcGISBuilding
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/[version]/Sample Content/Scenes/Scripts/APISample
Refer to FAQ for troubleshooting data loading issues.
Layer management
You can toggle layer visibility on and off, change layer opacity, remove and reorder layers. When you have multiple layer sources, the last item added to the collection takes precedence and is displayed topmost in the Map Creator UI.
You can make the following layer management operations under the Layers section.
- Change the layer order by clicking on ⋮ and select Move Up or Move Down. The layer at top of the layer list has the highest priority.
- 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 layer visibility by clicking on the checkbox.
- Click 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 zoom to the extent of a layer by clicking on ⋮ and selecting Zoom To.
You can make the following layer management operations under the Layers section in the Hierarchy window.
- Change the layer order by clicking on = next to the triangle icon and moving the item up or down. The layer at bottom of the layer list has the highest priority.
- Click 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 the + icon to add more layers
- Click the layer name then click - to delete a layer.
To remove a layer:
arcGISMap.Layers.Remove(arcGISMap.Layers.IndexOf(layer_4));
You can update a layer's name, opacity, and visibility without needing to rebuild the map.
To change the opacity of a layer:
layer_1.Opacity = 0.9f;
You can find the sample code to remove a layer and change the opacity of layers in the SampleAPIMapCreator.cs file. The sample script file is in:
Assets/Samples/ArcGIS Maps SDK for Unity/[version]/Sample Content/Scenes/Scripts/APISample