Augmented Reality with Layar and ArcGIS Online

Let’s investigate how GIS and Augmented Reality can operate together. That is what I thought when I watched the possibilities of Layar some time ago. But only until last week, I did not find the time to look into it. But it turns out to be very fascinating to do and I am sure it will open up some new possibilities to combine the managebility of GIS with the exiting visualisations of Augmented Reality.

Background

Layar is a Dutch based company providing apps and services to overlay 3d information on the image your smartphone captures through the camera. It show you the world enriched (“augmented”) with extra information. For example: you can see the design of new buildings situated on the actual location that they are going to be built. Really cool! Layar calls these layers Geo Layers. They also provide a way to make the ads in your magazine pop out (digitally ofcourse) from the paper. Read more about that here: https://www.layar.com/augmented-reality/.

With GIS it is very simple to publish online maps and other 2D visualisations (for example this one: http://dev.citysdk.waag.org/buildings/. Since GIS is always based on a database, the visualisation changes if the data changes. And it is this last feature that is also implemented in the example below: change your data in ArcGIS Online and the Layar data is also changed.

Concepts

In the solution below I use ArcGIS Online to store my feature data (point data, in this case) and serve it as a feature service. I could also have chosen to use one of our ArcGIS for Server feature services. These feature services also expose the data in the REST protocol, using JSON notation. On the other hand, Layar also uses JSON/REST, so this is a good combination. The “only” thing I had to do is convert the ArcGIS JSON to Layar JSON. So I created a webservice to do just that.

The webservice I developed (ASP.NET/C#) deserializes the JSON from ArcGIS Online, converts the resulting point object to a POI object and serializes the hotspot object to JSON that can be processed by Layar. You’re still here? :-). The full solution in Visual Studio is available in GitHub, so no need to copy and paste everything.

These objects are the Layar objects (POIs, hotspots, etc). I’ll refer to the solution in GitHub, since (although the code is rather lengthy) it is pretty straightforward.

Step 4: Convert AGSpoint to POI

For this, I have written a function in the AGSpoint class: ConvertToPOI(). This will take the attribute of each feature in ArcGIS and use them to fill the attributes of a new collection of POIs. See this snippet:

Here, the values of the attributes ID and titel_en from the ArcGIS are put in the attributes id, title and attribution of the newly created hotspot. The x and y of the geometry of the feature are converted to the lat and lon of the hotspot.

If you came this far, you can figure this step out yourself, there are too many different options to do this. I use a Amazon EC2 Windows instance. See the result here.

Layar – revisited

Now we have to define the Layar layer. Log in to the “My Layers” section in Layar and define the new layer. Provide a name, title, description, and all other required descriptions. At the API Endpoint URL, provide the URL of your webservice (in my case: http://dev.geosolutions.nl/layarpoi/default.aspx).

That’s it! Congratulations on your first Layar/ArcGIS layer.

Testing

The Layar website provides an interface for testing your layer through the browser instead of yor smartphone. In the “My Layers” screen, press “Test”. Specify the details necessary, and press “Load POIs”. If this works fine (you should see the POIs appearing in the right section of the screen), you can go to your smartphone. Install the app ad log in to your account. You should see a menu option “Test Layers” and your new layer should be there.

This is what I see anyway:

Publishing

Now you only have to request Layar to review your service and make it available to the broader public!

5 thoughts on “Augmented Reality with Layar and ArcGIS Online”

Good work. Thank you for sharing this tutorial about ArcGIS, I learn more from it. But I still have a problem, can I use it on my .net class? Hope you can give me some suggestion. Thank you in advance.