Greetings, habrovchane!
Searching on Habra, I did not find detailed articles about services such as
Layar and
Locago . If many have heard about Layar or even used it, then I think about Locago, not many. These services are designed to display geographic labels on the map. In the case of Layar, these are maps from Google, and Locago uses vector maps. I can’t say where their maps come from, but at least in a map of a small city like Tambov I can navigate, and many of the main streets are not very visible and the names are displayed in Russian.
I wanted to talk a little bit about how to make layers for these services.
')
Layar is currently available for the iPhone and Android. The emphasis in this application is on augmented reality. While Locago is only a map with marks on it. Locago is focused on regular phones with java, which is what caused the use of vector maps. During operation, the application centers the map depending on the labels received from the server. Although the application can use a GPS receiver, but apparently it should be a receiver that works via Bluetooth. This feature did not work on the smartphone. It should be noted that the Locago application is paid and an ad banner pops up during operation.
Where to begin?
And so, first you need to register on the site
Layar.com and get access to the development of layers, for this you need to send a request to
http://layar.com/publishing , and in a few days you will be sent an invite. Unfortunately, neither faster nor how.
After getting the invite, go to the developer profile and click My layers -> Create a layer, then
set up our layer . In the
API endpoint URL field, you can enter an arbitrary URL, then it can be changed to a real one. In the
overage tab,
you need to select the countries that will cover your layer. And in
Filters you need to configure filters. The default filter is the display range of labels from your current location. The disadvantage is that you cannot transfer the filter interface to the application dynamically, as can be done at Locago, but you need to configure it in the developer profile on the Layar website. On the other hand, this increases to some extent the protection of your content; I will say a few words about this at the end.
Now about
Locago . Again, you need to register and nothing more is required. Then you can immediately add your layer to the site directory.
API Layar
The Layar API is a request (GetPOIs-Request) response (GetPOIs-JSON Response). As already stated above, there are several versions of the API.
2.1 | old version that supports all basic parameters |
2.2 | Added implementation of actions with audio and video |
3.0 | Added 3D objects , custom ranges (radius setting), checkboxes, search, user authorization |
3.1 | added support for paid layers |
3.5 | added Layer Stream and animation textures in 3D objects |
4.0 | added ability to interact with the layer. I did not have such a task, so I did not understand this feature in detail, you can read it here. |
Parameters in the request can be quite a lot. The category of required parameters that are transmitted with any request and are formed by the application itself includes the application identifier, API version, current location, country code and language identifier. Additional parameters include filter data, authorization information, which is produced via
OAuth .
The script should send a response in JSON format. The answer must include such parameters as the layer name, POI (point of interest) array and error code. Optional parameters include information on the presence of several pages (in the case where there are too many points that can be broken into pages), the update time of the layer, the presence of an action (link to multimedia content, informational text). It is worth noting that in Layar clients there is a limit on the display of the number of points, in Android - 90, iPhone - 100, for which the data are divided into several pages. This action lies entirely on the developer.
Now, as for information about POI, here is the name of the point, the coordinates of the point (multiplied by 1,000,000), the distance to the point and the number of the icon that we need to load in the layer profile in the
Look & feel tab. If we install API 2.1 version in the profile, then only three icons will be available to us, therefore in version 3.0 the number of icons used was not limited. When you first load a layer with an application, all icons are cached in the phone’s memory, so you don’t need to worry about the large traffic associated with swapping all the icons of a layer. The POI's advanced settings store short text information (for example, address or POI name) and a link to a photo, if needed.
Examples for creating simple layers . The manual is written intelligibly with examples in PHP, so that questions should not arise in principle.
Locago API
It's much easier with Locago. Everything is generated on the side of your server, both the filter interface and the tag information. Here, the first thing that an application should receive when accessing a layer is the main page of a layer with the .idoc extension and called an xml-based IDoc file.
Here is an example of such a document.
<? xml version ="1.0" encoding ="UTF-8" ? >
< idoc title ="Bus68" icon ="icon.png" >
<!-- Part: Layer-->
< layer >
< info > </ info >
< symbolLayer name ="Places" dataset ="locago.php.igeo" webServiceFormat ="igeo" >
< categorySymbol value ="0" symbol ="0.png" />
< categorySymbol value ="1" symbol ="1.png" />
< categorySymbol value ="2" symbol ="2.png" />
</ symbolLayer >
< tag name ="bus" />
</ layer >
<!-- Part: Page -->
< style fontSize ="12" fontStyle ="bold" alignX ="middle" > </ style >
< br />
. < br />
< checkbox value ="false" id ="bus0" label =" 1 " />
< checkbox value ="false" id ="bus1" label =" 108" />
< checkbox value ="false" id ="bus2" label =" 14" />
< br />
< style alignX ="middle" >
< button label ="" action ="layer.load({sublayer:'Places', arg:{bus0:doc.fields.bus0.value, bus1:doc.fields.bus1.value, bus2:doc.fields.bus2.value }})" />
</ style >
</ idoc >
* This source code was highlighted with Source Code Highlighter .
I think you can immediately understand what tags are responsible for what. The
dataset attribute of the
symbolLayer tag contains a page giving the application information about tags. And in the
action attribute of the
button tag, we indicate which layer to load with this
sublayer button
: 'Places' , in case there are several layers on the page, then you can assign different layers to different buttons and in
arg we prescribe what parameters we pass on request, in this case we send
checkbox values. As a result, we will have this type of page

We should give the application XML in which the tags should be listed. The XML file must have the .igeo extension at the end and is called
IGEO . Here is an example of the IGEO file:
<? xml version ="1.0" encoding ="UTF-8" ? >
< geodata >
< Marker name ="Restaurant Slussen" symbol ="i:pinorange" x ="18.071862" y ="59.322227" text ="A nice cosy restaurant.\ntel:+46555123" />
< Marker name ="Bar Gamla stan" symbol ="i:pinorange" x ="18.070829" y ="59.325035" text ="redirect:1187768.idoc" />
</ geodata >
* This source code was highlighted with Source Code Highlighter .
As you can see here two labels, each label has an attribute
name ,
symbol - this is a link to the icon or, as shown in the example, a label of a certain color can have other values, the
x ,
y coordinates of the point and the
text to which we write explanatory text. Pay attention to the
text attribute of the second label, here is a link to the idoc file, that is, you can send the user to a page with a more detailed description of the label. The
symbol attribute can be replaced by the
category attribute which will point to a specific category to which the label belongs. And categories need to be declared on the idoc main page in
categorySymbol tags, as you can see, in the first example such tags are present and icons are declared in them, which will be displayed when you assign a tag to a category.
A few words about content protection
It should be noted that when using Locago, your content is very difficult to protect, I would say it is impossible, since all pages are stored on the server and can be opened by any browser, respectively, you can generate any request. Therefore, it will not be difficult to parse the data. In Layar, this is somewhat more difficult, since we cannot see which requests are coming from the application itself (of course, the issue is controversial and it’s easy for knowledgeable people to get what they want) and therefore it is more problematic to obtain data. The question of protection will certainly arise from those who themselves manually created a database of tags.
I hope the article will be useful to someone.