User Tools

Site Tools

A Simple Layer

…and by simple I mean about as simple as it can get:

echo '{
    "layer": "layer-name",
    "hotspots": [
    "errorCode": 0,
    "errorString": "ok"

The Layar mobile app uses the following sequence:

  1. The user chooses which layer they want to use.
  2. The app contacts to Layar, who provide details about the layer (author, description, etc.) and the URL of your server.
  3. When the layer actually loads, the app sends some parameters to your server (phone's GPS location, radius of their search, etc.).
  4. Your server returns a list of things to be displayed (hotspots), and hopefully confirmation that everything went OK.

The code at the top of the page does that last step; but with an empty list of hotspots (the locations where there'll be some AR).

Creating the Layer

The first thing that you need to do is decide on a unique name for your layer. Once you've got one, you can setup the server side.

  1. Copy and paste the code above into a text editor, change the text: layer-name to the name you've chosen, and save the file with a php extension.
  2. Upload the file to your server.
  3. Check the URL to your file by visiting it in a web browser. You should only see the text that is inside the single quote marks.

With the file in place, you can now setup the Layar side.

  1. If you haven't done so already, you'll need to register for an account with Layar.
  2. Once you've logged in, click on the My Layers button in the top-right.
  3. Click on the Create a new layer! button.
  4. In the panel that pops-up enter the name that you chose, title, and description. The API endpoint is the URL to your file, and you want the 3D and 2D objects in 3D space option. If the name that you want is already taken, then you'll need to come up with another one. Just remember that the name in the PHP file has to match the one in Layar's listing.
  5. Click the button to Create layer.
layarmmo-layer.txt · Last modified: 2012/11/20 15:27 by matthewleach