---
title: Getting Started with ARCore Geospatial API &amp; Unity
tags:  #madewithunity #ar_fukuoka #arcore #geospatialapi  
author: [Takashi Yoshinaga](https://convert.docswell.com/user/Tks_Yoshinaga)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/PJR6Q3YR79.jpg?width=480
description: Getting Started with ARCore Geospatial API &amp; Unity by Takashi Yoshinaga
published: June 06, 22
canonical: https://convert.docswell.com/s/Tks_Yoshinaga/5664V5-geospatial-api-en
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/PJR6Q3YR79.jpg)

Getting Started with
ARCore Geospatial API


# Page. 2

![Page Image](https://bcdn.docswell.com/page/PEXM54GY7X.jpg)

Goal of This Tutorial
Low Accuracy!
Display Tracking Results
Tracking accuracy check
High Accuracy!
CG display at specified
latitude and longitude


# Page. 3

![Page Image](https://bcdn.docswell.com/page/3EKG6Z44JD.jpg)

Download Sample Data
https://github.com/TakashiYoshinaga/ARFukuoka/raw/main/GeospatialAPI_20220604/Smples.zip


# Page. 4

![Page Image](https://bcdn.docswell.com/page/L73N6DLD75.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 5

![Page Image](https://bcdn.docswell.com/page/87DWVPN2JG.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 6

![Page Image](https://bcdn.docswell.com/page/VJP9VN5LE8.jpg)

Launch Unity Hub
Unity Hub


# Page. 7

![Page Image](https://bcdn.docswell.com/page/2EVMZKP6EQ.jpg)

Project Creation (1/6)
①Projects
②New Project


# Page. 8

![Page Image](https://bcdn.docswell.com/page/57GG4QP27L.jpg)

Project Creation (2/6)
Open Editor Version


# Page. 9

![Page Image](https://bcdn.docswell.com/page/4EQXGK297P.jpg)

Project Creation (3/6)
2020.3.xxf1
This document assumes 2020.3.x for explanation.


# Page. 10

![Page Image](https://bcdn.docswell.com/page/KJ465PPR71.jpg)

Project Creation (4/6)
①3D
②Project name
③ Storage location


# Page. 11

![Page Image](https://bcdn.docswell.com/page/LE1VW99V7G.jpg)

Project Creation (5/6)
Create project


# Page. 12

![Page Image](https://bcdn.docswell.com/page/GEWL6QQ372.jpg)

Project Creation (6/6)
When the Unity Editor appears, you are ready to go!


# Page. 13

![Page Image](https://bcdn.docswell.com/page/47ZMYWWGE3.jpg)

Build Settings for Android/iOS (1/4)
File


# Page. 14

![Page Image](https://bcdn.docswell.com/page/YJ6NDGGQJV.jpg)

Build Settings for Android/iOS (2/4)
Build Settings


# Page. 15

![Page Image](https://bcdn.docswell.com/page/GJ553VV2J4.jpg)

Build Settings for Android/iOS (3/4)
①Select Android or iOS
②Switch Platform


# Page. 16

![Page Image](https://bcdn.docswell.com/page/9E2NZ3317R.jpg)

Build Settings for Android/iOS (4/4)
Player Settings


# Page. 17

![Page Image](https://bcdn.docswell.com/page/D7YPR1147M.jpg)

Build Settings for Android
For Android


# Page. 18

![Page Image](https://bcdn.docswell.com/page/VEN5D226J8.jpg)

Build Settings for Android (1/3)
①Other Settings
②Click Vulkan
③ Delete


# Page. 19

![Page Image](https://bcdn.docswell.com/page/Y79YG11RE3.jpg)

Build Settings for Android (2/3)
①Identification
②Minimum API Level
③ Select Android 7.0 ʻNougatʼ
API Level 24


# Page. 20

![Page Image](https://bcdn.docswell.com/page/G786V44GJD.jpg)

Build Settings for Android (3/3)
①Configuration
②Scripting Backend
③Select IL2CPP
④Select ARM64


# Page. 21

![Page Image](https://bcdn.docswell.com/page/L7L9566XER.jpg)

Build Settings for iOS
For iOS


# Page. 22

![Page Image](https://bcdn.docswell.com/page/4EMZ35537W.jpg)

Build Settings for iOS
①Configuraton
② Set [Required for AR] for each Usage Description


# Page. 23

![Page Image](https://bcdn.docswell.com/page/PER6Q33RJ9.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 24

![Page Image](https://bcdn.docswell.com/page/P7XM544YJX.jpg)

Prepare to download packages (1/3)
Window


# Page. 25

![Page Image](https://bcdn.docswell.com/page/37KG6ZZ4ED.jpg)

Prepare to download packages (2/3)
Package Manager


# Page. 26

![Page Image](https://bcdn.docswell.com/page/LJ3N6DDDJ5.jpg)

Prepare to download packages (3/3)
Select Unity Registry from Packages


# Page. 27

![Page Image](https://bcdn.docswell.com/page/8JDWVPP2EG.jpg)

Installation of AR Foundation (1/2)
Search AR


# Page. 28

![Page Image](https://bcdn.docswell.com/page/VEP9VNNL78.jpg)

Installation of AR Foundation (2/2)
①ARFoundation
② Install


# Page. 29

![Page Image](https://bcdn.docswell.com/page/27VMZKK67Q.jpg)

Install ARCore or ARKit
①Android: ARCore XR Plugin
iOS: ARKit XR Plugin
② Install


# Page. 30

![Page Image](https://bcdn.docswell.com/page/5JGG4QQ2JL.jpg)

Installing ARCore Extensions (1/3)
Click +
[Note]
ARFoundation and ARCore/ARKit are only tools to realize AR.
The ARCore Extensions is necessary to use Geospatial API, which is
the main topic of this article.


# Page. 31

![Page Image](https://bcdn.docswell.com/page/47QXGKK9JP.jpg)

Installing ARCore Extensions (2/3)
Add package from git URL


# Page. 32

![Page Image](https://bcdn.docswell.com/page/KE465PKRJ1.jpg)

Installing ARCore Extensions (3/3)
Search below
https://github.com/google-ar/arcore-unity-extensions.git


# Page. 33

![Page Image](https://bcdn.docswell.com/page/L71VW9XVJG.jpg)

Note
If the PC you are using is not configured for GitHub connection, an error will occur.


# Page. 34

![Page Image](https://bcdn.docswell.com/page/G7WL6QN3J2.jpg)

Installation of ARCore Extensions (supplement)
Access the ARCore Extensions repository
https://github.com/google-ar/arcore-unity-extensions.git
Click Releases


# Page. 35

![Page Image](https://bcdn.docswell.com/page/4JZMYW3G73.jpg)

Installation of ARCore Extensions (supplement)
v.1.35.0
Scroll down a little


# Page. 36

![Page Image](https://bcdn.docswell.com/page/YE6NDGXQEV.jpg)

Installation of ARCore Extensions (supplement)
Assets
Download arcore-unity-extensions-1.35.0.tgz


# Page. 37

![Page Image](https://bcdn.docswell.com/page/GE553VX2E4.jpg)

Installation of ARCore Extensions (supplement)
Move arcore-unity-extensions-1.35.0.tgz to the
Packages folder in the folder of the project you have
just created for this tutorial.


# Page. 38

![Page Image](https://bcdn.docswell.com/page/972NZ3X1JR.jpg)

Installation of ARCore Extensions (supplement)
Add package from git tarball


# Page. 39

![Page Image](https://bcdn.docswell.com/page/DJYPR184JM.jpg)

Installation of ARCore Extensions (supplement)
Select arcore-unity-extentions


# Page. 40

![Page Image](https://bcdn.docswell.com/page/V7N5D2Q6E8.jpg)

End of supplementary information


# Page. 41

![Page Image](https://bcdn.docswell.com/page/YJ9YG1DR73.jpg)

Confirmation of installation results
Select In Project from Packages


# Page. 42

![Page Image](https://bcdn.docswell.com/page/GJ86V43GED.jpg)

Confirmation of installation results
You can find ARCore Extensions


# Page. 43

![Page Image](https://bcdn.docswell.com/page/LJL956VX7R.jpg)

Get a sample of GeospatialAPI
①ARCore Extensions
②Samples
③ Import Geospatial Sample


# Page. 44

![Page Image](https://bcdn.docswell.com/page/47MZ35G3JW.jpg)

Note
Might have errors in environments that do not have the iOS build option installed.


# Page. 45

![Page Image](https://bcdn.docswell.com/page/P7R6Q3ZRE9.jpg)

Resolving iOS-related errors (Supplemental)
You may get a red text error.


# Page. 46

![Page Image](https://bcdn.docswell.com/page/PJXM549YEX.jpg)

Resolving iOS-related errors (Supplemental)
Samples
-&gt; ARCore Extensions
-&gt;1.35.0
-&gt;GeospatialSample
-&gt;Scripts


# Page. 47

![Page Image](https://bcdn.docswell.com/page/3JKG6ZP47D.jpg)

Resolving iOS-related errors (Supplemental)
Delete Editor


# Page. 48

![Page Image](https://bcdn.docswell.com/page/LE3N6DXDE5.jpg)

Resolving iOS-related errors (Supplemental)
Console
If the error disappears after clicking Clear, OK.


# Page. 49

![Page Image](https://bcdn.docswell.com/page/8EDWVP227G.jpg)

Resolving iOS-related errors (Supplemental)
Display Project tab


# Page. 50

![Page Image](https://bcdn.docswell.com/page/V7P9VN1LJ8.jpg)

End of supplementary information


# Page. 51

![Page Image](https://bcdn.docswell.com/page/2JVMZKY6JQ.jpg)

Installation of ARCore Extensions is complete!
Close Package Manager


# Page. 52

![Page Image](https://bcdn.docswell.com/page/5EGG4Q92EL.jpg)

Next, configure the tools you have
installed so far for use in this project.


# Page. 53

![Page Image](https://bcdn.docswell.com/page/4JQXGKW9EP.jpg)

ARCore or ARKit Usage Settings (1/4)
① Edit
② Project Settings


# Page. 54

![Page Image](https://bcdn.docswell.com/page/K7465P1RE1.jpg)

ARCore or ARKit Usage Settings (2/4)
XR Plug-in Management


# Page. 55

![Page Image](https://bcdn.docswell.com/page/LJ1VW9GVEG.jpg)

ARCore or ARKit Usage Settings (3/4)
For Android
Turn on ARCore


# Page. 56

![Page Image](https://bcdn.docswell.com/page/GJWL6QK3E2.jpg)

ARCore or ARKit Usage Settings (4/4)
For iOS
Turn on ARKit


# Page. 57

![Page Image](https://bcdn.docswell.com/page/4EZMYWZGJ3.jpg)

ARCore Extensions Usage Settings (1/6)
ARCore Extensions


# Page. 58

![Page Image](https://bcdn.docswell.com/page/Y76NDGZQ7V.jpg)

ARCore Extensions Usage Settings (2/6)
[For iOS]
Check the iOS Support Enabled checkbox


# Page. 59

![Page Image](https://bcdn.docswell.com/page/G7553VW274.jpg)

ARCore Extensions Usage Settings (3/6)
Notice the item drop-down for Android or iOS


# Page. 60

![Page Image](https://bcdn.docswell.com/page/9J2NZ3Q1ER.jpg)

ARCore Extensions Usage Settings (4/6)
Select APIKey from the drop-down menu


# Page. 61

![Page Image](https://bcdn.docswell.com/page/DEYPR1W4EM.jpg)

ARCore Extensions Usage Settings (5/6)
API Key input pre-created in Google Cloud
※ See [Set up a Google Cloud Project] of the
official website for how to create an API Key.[Link]


# Page. 62

![Page Image](https://bcdn.docswell.com/page/VJN5D29678.jpg)

ARCore Extensions Usage Settings (6/6)
Turn on Geospatial


# Page. 63

![Page Image](https://bcdn.docswell.com/page/YE9YG12RJ3.jpg)

ARCore Extensions usage setup completed!
Close Project Settings


# Page. 64

![Page Image](https://bcdn.docswell.com/page/GE86V45G7D.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 65

![Page Image](https://bcdn.docswell.com/page/LEL956YXJR.jpg)

Creating a scene (1/4)
File


# Page. 66

![Page Image](https://bcdn.docswell.com/page/4JMZ35N3EW.jpg)

Creating a scene (2/4)
Save As...


# Page. 67

![Page Image](https://bcdn.docswell.com/page/PJR6Q3DR79.jpg)

Creating a scene (3/4)
Sample
Save


# Page. 68

![Page Image](https://bcdn.docswell.com/page/PEXM541Y7X.jpg)

Creating a scene (4/4)
Assets
Sample should be added


# Page. 69

![Page Image](https://bcdn.docswell.com/page/3EKG6Z24JD.jpg)

First, set up ARFoundation
to realize AR experience in this scene
(*GeospatialAPI will appear a little later)


# Page. 70

![Page Image](https://bcdn.docswell.com/page/L73N6D4D75.jpg)

Setting up AR Foundation (1/7)
Delete MainCamera


# Page. 71

![Page Image](https://bcdn.docswell.com/page/87DWVPQ2JG.jpg)

Setting up AR Foundation (2/7)
Right-click on a blank space in
Hierarchy with nothing selected.


# Page. 72

![Page Image](https://bcdn.docswell.com/page/VJP9VNLLE8.jpg)

Setting up AR Foundation (3/7)
①XR
②AR Session Origin


# Page. 73

![Page Image](https://bcdn.docswell.com/page/2EVMZKQ6EQ.jpg)

Setting up AR Foundation (4/7)
AR Session Origin should appear


# Page. 74

![Page Image](https://bcdn.docswell.com/page/57GG4QW27L.jpg)

Setting up AR Foundation (5/7)
Right-click on a blank space in
Hierarchy with nothing selected.


# Page. 75

![Page Image](https://bcdn.docswell.com/page/4EQXGK397P.jpg)

Setting up AR Foundation (6/7)
①XR
②AR Session


# Page. 76

![Page Image](https://bcdn.docswell.com/page/KJ465PNR71.jpg)

Setting up AR Foundation (7/7)
AR Session should appear


# Page. 77

![Page Image](https://bcdn.docswell.com/page/LE1VW95V7G.jpg)

Prepare to use Anchor, which ties an object
to be displayed in AR to a specific location.
The ability to align when looking there again even if the tracking is lost.
Even if the CG placed at the specified latitude and longitude is lost, it will come back!


# Page. 78

![Page Image](https://bcdn.docswell.com/page/GEWL6Q5372.jpg)

Setting up AR Anchor Manager (1/3)
①AR SessionOrigin
②Add Component


# Page. 79

![Page Image](https://bcdn.docswell.com/page/47ZMYWNGE3.jpg)

Setting up AR Anchor Manager (2/3)
①Search AR
②AR Anchor Manager


# Page. 80

![Page Image](https://bcdn.docswell.com/page/YJ6NDG8QJV.jpg)

Setting up AR Anchor Manager (3/3)
ARAnchorManager should be added


# Page. 81

![Page Image](https://bcdn.docswell.com/page/GJ553V92J4.jpg)

Enable the results of position and direction
estimation by Geospatial API to be used in this scene


# Page. 82

![Page Image](https://bcdn.docswell.com/page/LE3N6DY1E5.jpg)

Setting up AR Earth Manager (1/3)
①AR SessionOrigin
②Add Component


# Page. 83

![Page Image](https://bcdn.docswell.com/page/8EDWVP5K7G.jpg)

Setting up AR Earth Manager (2/3)
①Search AR Earth
②AR Earth Manager


# Page. 84

![Page Image](https://bcdn.docswell.com/page/V7P9VNG3J8.jpg)

Setting up AR Earth Manager (3/3)
AREarthManager should be added


# Page. 85

![Page Image](https://bcdn.docswell.com/page/2JVMZK6NJQ.jpg)

Using the Geospatial API also requires
permission to access location information, etc.
But…
You don&#039;t want to write the Permission-related details, do you?


# Page. 86

![Page Image](https://bcdn.docswell.com/page/5EGG4QN5EL.jpg)

Take advantage of official scripts for easy setup!


# Page. 87

![Page Image](https://bcdn.docswell.com/page/4JQXGKQLEP.jpg)

Adding a object to set up permission (1/2)
Right-click on a blank space in
Hierarchy with nothing selected.


# Page. 88

![Page Image](https://bcdn.docswell.com/page/K7465PN5E1.jpg)

Adding a object to set up permission (2/2)
②AR Extensions
①XR


# Page. 89

![Page Image](https://bcdn.docswell.com/page/LJ1VW952EG.jpg)

Permission-related script settings (1/9)
ARCore Extensions
In this area, you can pass the following
script that is running in this scene and it
will do the Permission-related settings.
・ARSession
・ARSessionOrigin
・ARCameraManager
・ARCoreExtensionConfiguration


# Page. 90

![Page Image](https://bcdn.docswell.com/page/GJWL6Q52E2.jpg)

Permission-related script settings (2/9)
of Sessoin


# Page. 91

![Page Image](https://bcdn.docswell.com/page/4EZMYWN4J3.jpg)

Permission-related script settings (3/9)
Scene
AR Session
[Explanation]
The ARSession script is
attached to the AR Session
object in this scene (in the
Hierarchy)


# Page. 92

![Page Image](https://bcdn.docswell.com/page/Y76NDG8G7V.jpg)

Permission-related script settings (4/9)
of SessoinOrigin


# Page. 93

![Page Image](https://bcdn.docswell.com/page/G7553V9X74.jpg)

Permission-related script settings (5/9)
Scene
AR Session Origin


# Page. 94

![Page Image](https://bcdn.docswell.com/page/9J2NZ32QER.jpg)

Permission-related script settings (6/9)
of CameraManager


# Page. 95

![Page Image](https://bcdn.docswell.com/page/DEYPR1YYEM.jpg)

Permission-related script settings (7/9)
Scene
AR Camera


# Page. 96

![Page Image](https://bcdn.docswell.com/page/VJN5D2PR78.jpg)

Permission-related script settings (8/9)
of ARCoreExtensionsConfig


# Page. 97

![Page Image](https://bcdn.docswell.com/page/YE9YG13ZJ3.jpg)

Permission-related script settings (9/9)
Scene
GeospatialConfig


# Page. 98

![Page Image](https://bcdn.docswell.com/page/GE86V4LY7D.jpg)

Permission setup completed!
Allocation completed
(CameraConfigFilter is not required)


# Page. 99

![Page Image](https://bcdn.docswell.com/page/LEL956L9JR.jpg)

現状確認
AR Earth Manager
It is possible to obtain
the terminal support
status, the success or
failure of Geospatial API
initialization, and the
results of position and
orientation estimation.
Permission setting is
done by Extensions.
However, it is available
only when tracking by
GeospatialAPI has
started.
Start tracking by script!


# Page. 100

![Page Image](https://bcdn.docswell.com/page/4JMZ35MVEW.jpg)

Aside: Official Sample
There is a scene in the official sample to learn
the steps from initialization to Geospatial API utilization.


# Page. 101

![Page Image](https://bcdn.docswell.com/page/PJR6Q3VW79.jpg)

Aside: Official Sample
Samples
-&gt;ARCore Extensions
-&gt;1.35.0
-&gt;Geospatial Sample


# Page. 102

![Page Image](https://bcdn.docswell.com/page/PEXM54ZV7X.jpg)

Aside: Official Sample
Scripts
GeospatialController


# Page. 103

![Page Image](https://bcdn.docswell.com/page/3EKG6Z85JD.jpg)

Aside: Official Sample
The GeospatialController script contains code for initialization,
position acquisition, and saving and reproducing object placement.
However, both initialization and data utilization are
described together, making it difficult to reuse for other purposes


# Page. 104

![Page Image](https://bcdn.docswell.com/page/L73N6D2175.jpg)

I have prepared a script that isolates only
the initialization code to start tracking.
Aside from the details, let’s use it now!


# Page. 105

![Page Image](https://bcdn.docswell.com/page/87DWVPZKJG.jpg)

Importing sample assets (1/3)
①Samples Folder
②Double click AR_Fukuoka.unitypackage


# Page. 106

![Page Image](https://bcdn.docswell.com/page/VJP9VND3E8.jpg)

Importing sample assets (2/3)
Import


# Page. 107

![Page Image](https://bcdn.docswell.com/page/2EVMZK1NEQ.jpg)

Importing sample assets (3/3)
AR_Fukuoka should be added


# Page. 108

![Page Image](https://bcdn.docswell.com/page/57GG4Q257L.jpg)

Creating an object to start tracking (1/3)
Right-click on a blank space in
Hierarchy with nothing selected.


# Page. 109

![Page Image](https://bcdn.docswell.com/page/4EQXGKPL7P.jpg)

Creating an object to start tracking (2/3)
CreateEmpty


# Page. 110

![Page Image](https://bcdn.docswell.com/page/KJ465PY571.jpg)

Creating an object to start tracking (3/3)
①GameObject
②Change name to VPS_Demo


# Page. 111

![Page Image](https://bcdn.docswell.com/page/LE1VW9627G.jpg)

Add tracking start script (1/7)
①Assets
-&gt; AR_Fukuoka
-&gt;Scripts
②See VpsInitializer (Do not click it)


# Page. 112

![Page Image](https://bcdn.docswell.com/page/GEWL6QW272.jpg)

Add tracking start script (2/7)
VPS Demo
Drag &amp; drop VpsInitializer
into Inspector of VPS_Demo


# Page. 113

![Page Image](https://bcdn.docswell.com/page/47ZMYW54E3.jpg)

Add tracking start script (3/7)
VPS Visualizer should be added


# Page. 114

![Page Image](https://bcdn.docswell.com/page/YJ6NDG9GJV.jpg)

Add tracking start script (4/7)
of EarthManager


# Page. 115

![Page Image](https://bcdn.docswell.com/page/GJ553VNXJ4.jpg)

Add tracking start script (5/7)
Scene
AR Session Origin


# Page. 116

![Page Image](https://bcdn.docswell.com/page/9E2NZ35Q7R.jpg)

Add tracking start script (6/7)
of ARCoreExtensions


# Page. 117

![Page Image](https://bcdn.docswell.com/page/D7YPR1KY7M.jpg)

Add tracking start script (7/7)
Scene
AR Core Extensions


# Page. 118

![Page Image](https://bcdn.docswell.com/page/VEN5D2RRJ8.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 119

![Page Image](https://bcdn.docswell.com/page/Y79YG1MZE3.jpg)

Added tracking results display script (1/4)
①Assets
-&gt; AR_Fukuoka
-&gt;Scripts
②See SampleScript (Do not click it)


# Page. 120

![Page Image](https://bcdn.docswell.com/page/G786V41YJD.jpg)

Added tracking results display script (2/4)
VPS_Demo


# Page. 121

![Page Image](https://bcdn.docswell.com/page/L7L956Q9ER.jpg)

Added tracking results display script (3/4)
Drag &amp; Drop SampleScript
into Inspector of VPS_Demo


# Page. 122

![Page Image](https://bcdn.docswell.com/page/4EMZ351V7W.jpg)

Added tracking results display script (4/4)
SampleScript should be added
Double click to open script file


# Page. 123

![Page Image](https://bcdn.docswell.com/page/PER6Q3LWJ9.jpg)

Script to display tracking results (1/4)
Add a description in advance to
the empty script generated by
Unity to use the following functions
・ ARCoreExtensions
・ ARFoundation


# Page. 124

![Page Image](https://bcdn.docswell.com/page/P7XM54WVJX.jpg)

Script to display tracking results (2/4)
public class SampleScript : MonoBehaviour
{
//Tracking information using GeospatialAPI
public AREarthManager EarthManager;
//GeospatialAPI and ARCore initialization and results
public VpsInitializer Initializer;
//UI for displaying results
public Text OutputText;
void Start()
{
}
void Update()
{
}
}
01.txt


# Page. 125

![Page Image](https://bcdn.docswell.com/page/37KG6ZV5ED.jpg)

Script to display tracking results (3/4)
void Update()
{
string status = &quot;&quot;;
//If initialization fails or you do not want to track, do nothing and return
if ( ! Initializer.IsReady ||
EarthManager.EarthTrackingState != TrackingState.Tracking)
{
return;
}
//Get tracking results
GeospatialPose pose = EarthManager.CameraGeospatialPose;
//Show results
ShowTrackingInfo(status, pose);
}
void ShowTrackingInfo(string status, GeospatialPose pose)
{
//Displays lat, lng, alt and their precision
}
02.txt


# Page. 126

![Page Image](https://bcdn.docswell.com/page/LJ3N6DM1J5.jpg)

Script to display tracking results (4/4)
void ShowTrackingInfo(string status, GeospatialPose pose)
{
OutputText.text = string.Format(
&quot;Latitude/Longitude: {0}°, {1}°¥n&quot; +
&quot;Horizontal Accuracy: {2}m¥n&quot; +
&quot;Altitude: {3}m¥n&quot; +
&quot;Vertical Accuracy: {4}m¥n&quot; +
&quot;Heading: {5}°¥n&quot; +
&quot;Heading Accuracy: {6} °¥n&quot; +
&quot;{7} ¥n&quot;
,
pose.Latitude.ToString(&quot;F6&quot;), //{0}
pose.Longitude.ToString(&quot;F6&quot;), //{1}
pose.HorizontalAccuracy.ToString(&quot;F6&quot;), //{2}
pose.Altitude.ToString(&quot;F2&quot;), //{3}
pose.VerticalAccuracy.ToString(&quot;F2&quot;), //{4}
pose.EunRotation.ToString(&quot;F1&quot;), //{5}
pose.OrientationYawAccuracy.ToString(&quot;F1&quot;), //{6}
status //{7}
);
}
03.txt


# Page. 127

![Page Image](https://bcdn.docswell.com/page/8JDWVP6KEG.jpg)

Ctrl/Command + S to save script


# Page. 128

![Page Image](https://bcdn.docswell.com/page/VEP9VNY378.jpg)

Mapping scripts to variables (1/4)
VPS Demo
of ARCoreExtensions


# Page. 129

![Page Image](https://bcdn.docswell.com/page/27VMZKGN7Q.jpg)

Mapping scripts to variables (2/4)
Scene
AR Session Origin


# Page. 130

![Page Image](https://bcdn.docswell.com/page/5JGG4Q85JL.jpg)

Mapping scripts to variables (3/4)
Initializer


# Page. 131

![Page Image](https://bcdn.docswell.com/page/47QXGK9LJP.jpg)

Mapping scripts to variables (4/4)
Scene
VPS_Demo


# Page. 132

![Page Image](https://bcdn.docswell.com/page/KE465PX5J1.jpg)

Add UI for display (1/3)
①Assets
-&gt; AR_Fukuoka
②See Canvas


# Page. 133

![Page Image](https://bcdn.docswell.com/page/L71VW9N2JG.jpg)

Add UI for display (2/3)
Drag &amp; Drop Canvas
into Hierarchy


# Page. 134

![Page Image](https://bcdn.docswell.com/page/G7WL6Q42J2.jpg)

Add UI for display (3/3)
Open Canvas
Confirm that TrackingMonitorText


# Page. 135

![Page Image](https://bcdn.docswell.com/page/4JZMYW2473.jpg)

Mapping scripts to variables (1/2)
Click VPS Demo
of OutputText


# Page. 136

![Page Image](https://bcdn.docswell.com/page/YE6NDGVGEV.jpg)

Mapping scripts to variables (2/2)
Scene
TrackingMonitorText


# Page. 137

![Page Image](https://bcdn.docswell.com/page/GE553VDXE4.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 138

![Page Image](https://bcdn.docswell.com/page/972NZ38QJR.jpg)

For Android


# Page. 139

![Page Image](https://bcdn.docswell.com/page/DJYPR16YJM.jpg)

実機インストール for Android
Connect ARCore device and PC with USB cable


# Page. 140

![Page Image](https://bcdn.docswell.com/page/V7N5D2ZRE8.jpg)

Install for Android
File


# Page. 141

![Page Image](https://bcdn.docswell.com/page/YJ9YG1ZZ73.jpg)

Install for Android
Build And Run


# Page. 142

![Page Image](https://bcdn.docswell.com/page/GJ86V3YYED.jpg)

Install for Android
Name(e.g. test)
Save


# Page. 143

![Page Image](https://bcdn.docswell.com/page/LJL95V497R.jpg)

For iOS


# Page. 144

![Page Image](https://bcdn.docswell.com/page/47MZ3GKVJW.jpg)

Install for iOS
File


# Page. 145

![Page Image](https://bcdn.docswell.com/page/P7R6QZXWE9.jpg)

Install for iOS
Build Settings...


# Page. 146

![Page Image](https://bcdn.docswell.com/page/PJXM596VEX.jpg)

Install for iOS
Build


# Page. 147

![Page Image](https://bcdn.docswell.com/page/3JKG6P157D.jpg)

Install for iOS
Create new folder


# Page. 148

![Page Image](https://bcdn.docswell.com/page/LE3N6XQ1E5.jpg)

実機インストール for iOS
Set folder name
(e.g. build)
Create


# Page. 149

![Page Image](https://bcdn.docswell.com/page/8EDWV29K7G.jpg)

Install for iOS
Choose


# Page. 150

![Page Image](https://bcdn.docswell.com/page/V7P9V1Z3J8.jpg)

Install for iOS
Open build folder


# Page. 151

![Page Image](https://bcdn.docswell.com/page/2JVMZYWNJQ.jpg)

Install for iOS
Unity-iPhone.xcworkspaceを開く


# Page. 152

![Page Image](https://bcdn.docswell.com/page/5EGG49D5EL.jpg)

Install for iOS
Unity-iPhone
Setting &amp; Capabilities


# Page. 153

![Page Image](https://bcdn.docswell.com/page/4JQXGW1LEP.jpg)

Install for iOS
Automatically manage signing
Select your team


# Page. 154

![Page Image](https://bcdn.docswell.com/page/K7465KR5E1.jpg)

Install for iOS
Connect iOS device and PC with USB cable


# Page. 155

![Page Image](https://bcdn.docswell.com/page/LJ1VWXQ2EG.jpg)

Install for iOS
Select a device


# Page. 156

![Page Image](https://bcdn.docswell.com/page/GJWL6NM2E2.jpg)

Install for iOS
Click


# Page. 157

![Page Image](https://bcdn.docswell.com/page/4EZMY3Q4J3.jpg)

Android and iOS


# Page. 158

![Page Image](https://bcdn.docswell.com/page/Y76NDX6G7V.jpg)

Result


# Page. 159

![Page Image](https://bcdn.docswell.com/page/G7553X6X74.jpg)

Tutorial Procedure
p Creating a Unity Project
p Installing AR Foundation and ARCore Extensions
p Setting up a scene using the Geospatial API and
ARCore/ARKit
p Getting and displaying tracking information via
Geospatial API
p Application installation on smartphone
p Display objects at specified latitude and longitude


# Page. 160

![Page Image](https://bcdn.docswell.com/page/9J2NZXMQER.jpg)

Development Policies
pSpecify latitude, longitude, and height in advance and
display objects at those locations
• Check position and orientation accuracy every frame
• Make objects appear when position and orientation are
more accurate.
Lat・Lng
Matching
AR


# Page. 161

![Page Image](https://bcdn.docswell.com/page/DEYPR8XYEM.jpg)

Development Policies
pSpecify latitude, longitude, and height in advance and
display objects at those locations
• Check position and orientation accuracy every frame
• Make objects appear when position and orientation are
more accurate.
Lat・Lng
Matching
AR


# Page. 162

![Page Image](https://bcdn.docswell.com/page/VJN5DQ1R78.jpg)

Discrimination of tracking accuracy (1/3)
public class SampleScript : MonoBehaviour
{
//Tracking information using GeospatialAPI
public AREarthManager EarthManager;
//GeospatialAPI and ARCore initialization and results
public VpsInitializer Initializer;
//UI for displaying results
public Text OutputText;
//Allowable accuracy of azimuth
public double HeadingThreshold = 25;
//Allowable accuracy of horizontal position
public double HorizontalThreshold = 20;
}
void Start(){ }
void Update(){
/*略*/
}
04.txt


# Page. 163

![Page Image](https://bcdn.docswell.com/page/YE9YGD5ZJ3.jpg)

Discrimination of tracking accuracy (2/3)
void Update()
{
string status = &quot;&quot;;
// If initialization fails or tracking is not done, do nothing and return
if ( ! Initializer.IsReady ||
EarthManager.EarthTrackingState != TrackingState.Tracking)
{
return;
}
// Get tracking results
GeospatialPose pose = EarthManager.CameraGeospatialPose;
// Describe here the behavior according to tracking accuracy
}
//Show result
ShowTrackingInfo(status, pose);


# Page. 164

![Page Image](https://bcdn.docswell.com/page/GE86V36Y7D.jpg)

Discrimination of tracking accuracy (3/3)
// Get tracking results
GeospatialPose pose = EarthManager.CameraGeospatialPose;
// Tracking accuracy is worse than the threshold (larger value)
if (pose.OrientationYawAccuracy &gt; HeadingThreshold ||
pose.HorizontalAccuracy &gt; HorizontalThreshold)
{
status = &quot;Low Tracking accuracy &quot;;
}
else //許容誤差以内の場合
{
status = &quot;High Tracking Accuracy &quot;;
}
//結果を表⽰
ShowTrackingInfo(status, pose);
05.txt


# Page. 165

![Page Image](https://bcdn.docswell.com/page/LEL95V99JR.jpg)

Result
Accuracy is displayed as good or bad.


# Page. 166

![Page Image](https://bcdn.docswell.com/page/4JMZ3GZVEW.jpg)

Development Policies
pSpecify latitude, longitude, and height in advance and
display objects at those locations
• Check position and orientation accuracy every frame
• Make objects appear when position and orientation are
more accurate.
Lat・Lng
Matching
AR


# Page. 167

![Page Image](https://bcdn.docswell.com/page/PJR6QZ6W79.jpg)

指定した位置にオブジェクトを出現 (1/3)
public class SampleScript : MonoBehaviour
{
public AREarthManager EarthManager; //GeospatialAPIを⽤いたトラッキング情報
public VpsInitializer Initializer; //GeospatialAPIとARCoreの初期化と結果
public Text OutputText; //結果表⽰⽤のUI
public double HeadingThreshold = 25; //位置・⽅位の許容精度
public double HorizontalThreshold = 20;
public double Latitude; // Latitude to place the object
public double Longitude; // Longitude to place the object
public double Altitude; // Height to place the object
public double Heading; // Object orientation (North=0°)
public GameObject ContentPrefab; // Original data of display object
GameObject displayObject; // Actual object to be displayed
public ARAnchorManager AnchorManager; // Used to create anchors
}
void Start(){ }
void Update(){/*略*/ }
06.txt


# Page. 168

![Page Image](https://bcdn.docswell.com/page/PEXM59MV7X.jpg)

指定した位置にオブジェクトを出現 (2/3)
// Get tracking results
GeospatialPose pose = EarthManager.CameraGeospatialPose;
if (pose.HeadingAccuracy &gt; HeadingThreshold ||
pose.HorizontalAccuracy &gt; HorizontalThreshold)
{
status = &quot;Low Tracking accuracy &quot;;
}
else
{
status = &quot;High Tracking accuracy &quot;;
if (displayObject == null)
{
}
}
//結果を表⽰
ShowTrackingInfo(status, pose);
07.txt


# Page. 169

![Page Image](https://bcdn.docswell.com/page/3EKG6PG5JD.jpg)

指定した位置にオブジェクトを出現 (3/3)
if (displayObject == null)
{
// Height of the phone - 1.5m to be approximately the height of the ground
Altitude = pose.Altitude - 1.5f;
// Angle correction (because the Anchor generation function assumes South=0)
Quaternion quaternion = Quaternion.AngleAxis(180f - (float)Heading, Vector3.up);
// Create anchors at specified position and orientation.
ARGeospatialAnchor anchor
= AnchorManager.AddAnchor(Latitude, Longitude, Altitude, quaternion);
}
//If you want to use the height of the terrain (Terrain) provided
//by the API instead of Altitude, use the following
/*ARGeospatialAnchor anchor
= AnchorManager.ResolveAnchorOnTerrain(Latitude, Longitude, 0, quaternion);*/
// Materialize the object if the anchor is correctly created
if (anchor != null)
{
08.txt
displayObject = Instantiate(ContentPrefab, anchor.transform);
}


# Page. 170

![Page Image](https://bcdn.docswell.com/page/L73N6XN175.jpg)

Development Policies
pSpecify latitude, longitude, and height in advance and
display objects at those locations
• Check position and orientation accuracy every frame
• Make objects appear when position and orientation are
more accurate.
Lat・Lng
Matching
AR


# Page. 171

![Page Image](https://bcdn.docswell.com/page/87DWV2WKJG.jpg)

Specify latitude and longitude
VPS Demo
Specify latitude and longitude


# Page. 172

![Page Image](https://bcdn.docswell.com/page/VJP9V193E8.jpg)

Open Google Map


# Page. 173

![Page Image](https://bcdn.docswell.com/page/2EVMZYMNEQ.jpg)

Specify latitude and longitude (1/5)
Right-click on the location where
you want to place the object.


# Page. 174

![Page Image](https://bcdn.docswell.com/page/57GG49G57L.jpg)

Specify latitude and longitude (2/5)
Click on latitude and longitude
to copy to clipboard


# Page. 175

![Page Image](https://bcdn.docswell.com/page/4EQXGWXL7P.jpg)

Specify latitude and longitude (3/5)
Pasete Latitude and Longitude


# Page. 176

![Page Image](https://bcdn.docswell.com/page/KJ465K6571.jpg)

Specify latitude and longitude (4/5)
Altitude is not necessary this time
because it is written in a script.


# Page. 177

![Page Image](https://bcdn.docswell.com/page/LE1VWXV27G.jpg)

Specify latitude and longitude (5/5)
Heading is set to 0 (=northward)


# Page. 178

![Page Image](https://bcdn.docswell.com/page/GEWL6NL272.jpg)

Registering Display Objects (1/2)
①Assets
-&gt; AR_Fukuoka
-&gt;Content
② Find ARPrefab (Do not click it)


# Page. 179

![Page Image](https://bcdn.docswell.com/page/47ZMY3M4E3.jpg)

Registering Display Objects (2/2)
VPS Demo
AR PrefabをContentPrefab
にドラッグ&amp;ドロップ


# Page. 180

![Page Image](https://bcdn.docswell.com/page/YJ6NDXNGJV.jpg)

Registering AnchorManager (1/2)
of AnchorManager


# Page. 181

![Page Image](https://bcdn.docswell.com/page/GJ553X5XJ4.jpg)

Registering AnchorManager (2/2)
Scene
AR Session Origin


# Page. 182

![Page Image](https://bcdn.docswell.com/page/LE3N6XN4E5.jpg)

Result
Object appears at specified position


# Page. 183

![Page Image](https://bcdn.docswell.com/page/8EDWV2W57G.jpg)

Completed!


# Page. 184

![Page Image](https://bcdn.docswell.com/page/V7P9V19DJ8.jpg)

ARCore Geospatial API official page
For more information on the API, check out the official
page!https://developers.google.com/ar/develop/geospatial


# Page. 185

![Page Image](https://bcdn.docswell.com/page/2JVMZYMGJQ.jpg)

Sample Project for This Tutorial
https://github.com/TakashiYoshinaga/
GeospatialAPI-Unity-StarterKit


# Page. 186

![Page Image](https://bcdn.docswell.com/page/5EGG49XDEL.jpg)

Follow Me
• Twitter: @Tks_Yoshinaga
• LinkedIn: https://www.linkedin.com/in/tks-yoshinaga/


