Locago

Tutorial: Dynamic layer

Every layer on Locago can be described as layer pages and a map view. In the map view the layer can show an overlay of points, lines and/or polygons.

This tutorial will show you how to create a dynamic layer showing some places in Lund. The result for the Locago user will be the same as for the further developed static layer, but the geographical content will be loaded "on the go".

To follow this tutorial you need to understand some PHP. You can use any language running on a Web server to dynamically create your geographical data source. The use of PHP is not what makes this layer dynamic. PHP is used as a complement to the IScript language in this tutorial. The dynamic part of the layer depends instead on how Locago is loading the geographical content.

You can download all the files needed to create the tutorial layer here. You can also see them here.

The steps to create this dynamic layer are:


Start the tutorial


Step 1 - Create the IGEO file

IGEO is a XML-based file format where geographical data can be stored.

Create an IGEO file with this content:

<?php
$pizza = $_GET['pizza'];
$pub = $_GET['pub'];
$fitness = $_GET['fitness'];
 
$igeo = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$igeo .= "<geodata>\n";
 
if($pizza == 'true') {
$igeo .= "<Marker name='Pizzeria Avesta' text='Best kebab pizza in town' x='13.183161' y='55.70653'/>\n";
$igeo .= "<Marker name='Pizzeria Delphi' text='Fast and good pizza' x='13.21273' y='55.722304'/>\n";
}
 
if($pub == 'true') {
$igeo .= "<Marker name='Pub Liten' text='Nice pub, almost every Thursday from 6 pm' x='13.209395' y='55.71247'/>\n";
$igeo .= "<Marker name='Pub Vildanden' text='Largest collection of beer in town' x='13.168977' y='55.709625'/>\n";
}
 
if($fitness == 'true') {
$igeo .= "<Marker name='Gerdahallen' text='Student fitness center' x='13.201615' y='55.7089'/>\n";
$igeo .= "<Marker name='Hogevallsbadet' text='Fitness center' x='13.18344' y='55.700061'/>\n";
}
 
$igeo .= "<Marker name='Domkyrkan' text='The oldest church in Lund' x='13.194063' y='55.709635'/>\n";
$igeo .= "</geodata>\n";
 
/* headers */
header('Content-type:text/xml; charset=UTF-8');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
echo $igeo;
 
exit;
?>

Save the file as dynamic.php.igeo
Note! If you copy it, make sure there are no empty spaces in the beginning of the file.

This PHP file generates an IGEO depending on parameters sent to it through the PHP _GET method.
Hint! Create an example of the IGEO file first and check that it works before letting PHP generate it

Up Next >

Step 2 - Create the IDOC file

IDOC is also a XML-based file format where both the layer content and how the layer page will look like are described.

Create an IDOC file with this content:

<?xml version="1.0" encoding="UTF-8" ?>
<idoc title="My Dynamic Lund" icon="icon.png" >
 
<!-- Part: Layer-->
<layer>
<info>
This (example) layer dynamically shows some places in Lund.
</info>
<symbolLayer name="Places" dataset="dynamic.php.igeo" webServiceFormat="igeo" />
<coverage name="Lund" bounds="13.157 55.688 13.232 55.728" />
<tag name="Example" />
</layer>
 
<handler id="dataloaded" action="layer.viewSelection(1); app.showMap();" />
 
<!-- Part: Page -->
<style fontSize="12" fontStyle="bold" alignX="middle" >
My Dynamic Lund
</style>
<br/>
<br/>
These are some of my favorite places in Lund.
<br/>
<br/>
Choose which type of places you want to see
<br/>
<section value="false" id="pizza" title="Pizza" />
<section value="false" id="pub" title="Pub" />
<section value="false" id="fitness" title="Fitness" />
<br/>
<br/>
<section title="Show content" action="layer.load({sublayer:'Places', handler:doc.handlers.dataloaded, arg:{pizza:doc.fields.pizza.value, pub:doc.fields.pub.value, fitness:doc.fields.fitness.value}})" />
</idoc>

Save the file as dynamic_tutorial_1.idoc, or download the file from here.
Save the icon: icon.png as icon.png

The title and icon specified in the <idoc> tag is used to describe the layer to the Locago users.
The icon needs to be in .png, .gif or .jpg format and a good size is 24x24 pixels.

Part: Layer

A sublayer, such as <symbolLayer> , connects the IGEO information to the map overlay. The access to the geographical content is defined with the attribute dataset. By defining the attribute webServiceFormat the layer is loaded dynamically. The markers in the IGEO will not be stored on the Locago server, but loaded on the go. The permissive service formats are igeo, rss and kml .

The coverage tag describes where content from this layer is visible. This will help when a Locago user searches for a layer around the user's position. In a static layer this is not needed, because the bounds are calculated from the uploaded IGEO file, but for a dynamic layer it is impossible.
Hint! To make the layer accessible when searching for a layer from a position, please use the coverage tag.
See the IDOC documentation for more information.

Part: Page

The appearance of the layer page is also described in the IDOC. See the IDOC documentation to find out the appearance possibilities. Many of the tags are similar to ordinary HTML.

The action attribute of the <section> tag makes a call to load a sublayer using the IScript language. When the layer is loaded, the handler is informed and executes its action. The Locago user can view the selected objects in the map. The sublayer, "Places", is called with the argument array. The arguments are set by using doc.fields . See the IScript documentation for more information.

< Back Up Next >

Step 3 - Make the content available and publish it on Locago

Make the content available

A Web server is needed to make the content available to Locago. Place all the files in the same directory, or change the path to the files in relation to the placement of the files. A relative path is allowed.

Publish the page on Locago

To publish a page you need to be signed in. If you do not have an account you need to create one first. It is free.

The layer URL to be given on the publisher page is the path to the IDOC file.

After publishing your layer you can add it to your mobile phone from the head menu in Locago by searching for the title. You can also view the layer in the Locago Web demo by clicking the 'View' option on the publisher page.
Note! Your layer may not be visible if you browse the Locago layers by tag. Only the top ten rated layers in every tag category are visible. This may be changed in Locago in the future.

Manage published layers

When logged in, you can manage all your already published layers on the publisher page. If any content is changed, please update your layer by clicking on 'Update'.

< Back Up