Locago

Locago IScript Reference Documentation

Version: 1.0 beta, Date: 2008-04-03
This document describes the Locago IScript library. The objects are available in the environment depending on where the script is executed. The environment can have the following variables:
thisThe Field object the script is executed from.
docThe Document object the script is written in.
appThe Locago Application object with several useful methods.
layerThe Layer object that is currently active if any.
mapThe Map object with methods for changing the view.

Available Types

Application

The Application object is always available in the app object and it contains a variety of useful methods.

Properties

PropertyTypeAccessDescription
locationLocationread only Access to the location object.
routeRouteread only Access to the route object.
versionStringread only The version of the applet in format:major.minor.subminor
loadedKBNumberread only The size of transferred data in this session in KB.

showMap()

Change display mode to show the map.

showLayer()

Change display mode to show the current layer page.

clearCache()

Clear the resident cache that stores pages, images and geodata. Next time an item is needed it will be loaded from the server.

call(number : String)

ParameterTypeUseDescription
numberString required The number that is called.
Makes a phone call to the specified number.
app.call("+46317790960");

browse(arg : String)

ParameterTypeUseDescription
argString required The URL that should be shown.
Opens an external browser with the specified URL.

reloadPage()

Reload the current page.

reloadPageParams(params : Object)

ParameterTypeUseDescription
paramsObject URL parameters and values.

Reload the current page with another set of parameters.

Example:
app.reloadPageParams({p1:"value"});

requireSignedIn(showSignInForm : boolean)

ParameterTypeUseDescription
showSignInFormboolean Whether or not to show the sign in form if the user is not signed in.

Aborts the script if the user is not signed in. Optionally redirects the user to the sign in form.

Document

A Document keeps the fields in a document and provides a few other methods. The current document is available in the doc variable.

Properties

PropertyTypeAccessDescription
fieldsread only Returns an object with all fields in the document. These can from this object be accessed by their id. Example to set the value of a field:doc.fields.value="hej"
handlersread only Returns an object with all handlers in the document. These can from this object be accessed by their id.

link(url : String, replace : boolean, arg? : Object)

ParameterTypeUseDescription
urlString The id of the document. This can be relative to the current document or a complete URL.
replaceboolean Set to 'true' to load the new URL in the current "window", replacing the current document. Defaults to 'false'.
argObjectdefault: URL parameters and values.

Follow a link and open the specified document.

Example:
doc.link({url:"subpage.idoc", arg:{param1:doc.field.f1.value, param2:"text"}})

back()

Change to the previously used page or map.

doFieldActions(arg : String)

ParameterTypeUseDescription
argString A string that should match the id of the fields. A * is allowed in the beginning and in the end of the string and it matches any characters.
Executes the actions of all fields which id matches the argument.

Field

A field is an element in a page that usually can be manipulated by the user. The fields are created in IDOC and can be accessed from IScript by their id. The following example changes the value of the field myField to "hello".
doc.fields.myField.value="hello"
Fields can be of various kinds. The most common is the textField that is a text box in a page. Others are buttons, images and handlers.

Properties

PropertyTypeAccessDescription
valueObject The current value of the field. The effect on changing the value depends on the type of field.
idStringread only The id of the field.

doAction()

Execute the script associated with the field.

addOption({value : String, label? : String, action? : String})

ParameterTypeUseDescription
valueString required The value of the option to add.
labelString optional The label to display for the option to add. If not specified the value is used as label.
actionString optional Action that is executed when the option is selected.
Add an option to a field. Note, not all fields support options.

removeOption(arg : String)

ParameterTypeUseDescription
argString required The value of the option to remove.
Remove an option from a field. Note, not all fields support options.

clearOptions()

Remove all options from the field. Note, not all fields support options.

inputText()

This method is intended an actions in options in textField. It changes the mode to text input. This way there can be predefined options and an option to enter text in a text field.

Layer

A Layer is some information that is displayed on the map. It consists of some sublayers that are configured individually. The current layer is available in the layer variable.

Properties

PropertyTypeAccessDescription
visibleboolean If this value is set to true the layer is displayed when it is the current layer or if this layer is alwaysVisible.
alwaysVisibleboolean If this value is set to true the layer is displayed also when it is not the current layer under the condition that visible is true.
currentNameStringread only The name of the currently selected object or "" if no object selected.
currentXread only The x-coordinate (longitude) of the currently selected object or "" if no object selected.
currentYread only The y-coordinate (latitude) of the currently selected object or "" if no object selected.
docread only Accesses the layer's front page.

set({sublayer : String, visible? : boolean, selectable? : boolean, category? : integer, included? : boolean})

ParameterTypeUseDescription
sublayerString required The name of the sublayer where a parameter should be set.
visibleboolean optional Change visibility of a sublayer to "true" or "false".
selectableboolean optional Change selectability of a sublayer to "true" or "false".
categoryinteger optional Change visibility of a category of objects in a sublayer. Note, included decides if objects with this category should be included or not. The category should be a number between 0 and 31.
includedboolean optional Change visibility of objects of a certain category that is specified with the category parameter. Note, by default are all categories visible.
Set parameters in a sublayer. You can do two things with this:
  • Make a sublayer visible or hidden.
  • Make objects with a certain category in a sublayer visible or hidden.
This example hides the sublayer myLayer:
layer.set({sublayer:'myLayer', visible:'false'})
This example hides the objects where the category attribute is 3:
layer.set({sublayer:'myLayer', category:3, included:'false'})
This example makes the sublayer myLayer visible, but not selectable:
layer.set({sublayer:'myLayer', visible:'true', selectable:'false'})

load({sublayer? : String, handler? : Field, disableDistanceSorting? : boolean, arg? : Object})

ParameterTypeUseDescription
sublayerString optional The name of the sublayer where data should be loaded. If not specified the first one is used.
handlerField optional A handler that is called when the server returns with a valid answer. No argument is supplied to the handler.
disableDistanceSortingbooleandefault:false If set to true, returned objects will not be sorted on distance to the map center.
argObject optional The parameters sent to the server. This should be a script object with named parameters. A special argument, _maxItems, can be used to limit the number of items returned. May be between 0 and 40, and defaults to 10.
This method is available for dynamic data layers and loads data from the layer's dataset URL. The data is loaded and prepared via the Locago server, which by default limits the number of items to 10, unless the _maxItems parameter is provided in the arg object.
layer.load({handler:doc.handlers.wikiresult, arg:{x:map.centerX, y:map.centerY, radius:10000, _maxItems:20}})

showCurrentObject()

Shows the map and zooms in on the currently selected object.

remove()

Removes this layer.

viewSelection(arg? : boolean)

ParameterTypeUseDescription
argbooleandefault:false Decides if all objects in the dataset should be selected or only those that are currently visible.
Selects objects in the layer, shows the map and zooms so that these are visible.

viewExtent()

Positions the map so that the complete layer extent is visible.

Map

The map handles the geographic display.

Properties

PropertyTypeAccessDescription
centerXNumber The x-value (longitude) of the center coordinate of the map.
centerYNumber The y-value (latitude) of the center coordinate of the map.
scaleNumber The approximate inverse scale of the map. This means that when the scale is 1:10000 this value is 10000.
xminNumberread only The left border of the minimal rectangle that encloses the displayed area.
yminNumberread only The lower border of the minimal rectangle that encloses the displayed area.
xmaxNumberread only The right border of the minimal rectangle that encloses the displayed area.
ymaxNumberread only The upper border of the minimal rectangle that encloses the displayed area.
animateboolean This property decides if map panning and zooming should be animated.

infoAt({x : Number, y : Number, category : String})

ParameterTypeUseDescription
xNumber Longitude for position to get info on.
yNumber Lattitude for position to get info on.
categoryString Type of information requested. Should be one of "street", "city", "region", "country". If not specified all categories are returned.
Performs a local reverse geocoding for the specified point and returns the address information that is currently loaded.