Terrain anchors

Stay organized with collections Save and categorize content based on your preferences.

A Terrain anchor is a type of Geospatial anchor that allows you to place AR objects using only latitude and longitude, leveraging information from Google Maps to find the precise altitude above ground.


Make sure that you enable the Geospatial API before proceeding.

Set the plane-finding mode

The chosen plane detection mode controls the stability of placed Terrain anchors. Use ARWorldTrackingConfiguration.PlaneDetection to select how your app detects planes.

Mode Behavior Use case
horizontal | vertical ARKit detects horizontal and vertical surfaces, such as floors and walls, as planes and accurately renders AR objects placed on them. Your app needs to recognize both horizontal and vertical surfaces.
horizontal ARKit detects horizontal surfaces only. Your app needs to recognize horizontal surfaces only. Use to save computational power.
vertical ARKit detects vertical surfaces only. Your app needs to recognize vertical surfaces only. Use to save computational power.
[] (empty set literal) Plane detection is disabled. May cause the vertical positioning of the Terrain anchor to be less accurate. Your app does not need accurate plane detection.

Create a Terrain anchor

To create and place a Terrain anchor, call GARSession.createAnchorWithCoordinate:altitudeAboveTerrain:eastUpSouthQAnchor:error:.

if (garFrame.earth.trackingState == GARTrackingStateTracking) {
  NSError *error = nil;
  GARAnchor *anchor = [garSession createAnchorWithCoordinate:coordinate

Creating anchors within 0.1 degrees of the North or South Poles (90 degrees or -90 degrees) is not supported. If such an anchor is specified, createAnchorWithCoordinate:altitude:eastUpSouthQAnchor:error: will return an GARSessionErrorCodeInvalidArgument and the anchor will fail to be created.

Check the Terrain anchor state

Once created, a Terrain anchor will have a state attached to it.

State Description
GARTerrainAnchorStateTaskInProgress The Terrain anchor has just been created, and ARCore is communicating with the ARCore API on Google Cloud to determine the anchor's exact pose.
GARTerrainAnchorStateSuccess The Terrain anchor has been successfully hosted and is now trackable. You can now use it to attach content to your AR experience.
Error state An error has occurred during the resolving process.

Check GARAnchor.terrainState to check the current state of the Terrain anchor:

switch (terrainAnchor.terrainState) {
case GARTerrainAnchorStateSuccess:
    // Terrain anchor finished resolving.
case GARTerrainAnchorStateTaskInProgress:
    // ARCore is contacting the ARCore API to resolve the Terrain anchor's pose.
    // Display some waiting UI.
case GARTerrainAnchorStateErrorUnsupportedLocation:
    // The requested anchor is in a location that isn't supported by the Geospatial API.
case GARTerrainAnchorStateErrorNotAuthorized:
    // An error occurred while authorizing your app with the ARCore API. See
    // https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.TerrainAnchorState#error_not_authorized
    // for troubleshooting steps.
case GARTerrainAnchorStateErrorInternal:
    // The Terrain anchor could not be resolved due to an internal error.
case GARTerrainAnchorStateNone:
    // This Anchor isn't a Terrain anchor or it became invalid because the Geospatial Mode was
    // disabled.

What's next