api 

api

The api instance returned as argument using the MapIFrameAPI.ready function.

Methods


<static> deleteSelection( [callback])

Delete selected features

Parameters:
Name Type Argument Description
callback function <optional>

a function that takes the number of features deleted


addEditBar(options, callback)

Add a new Editbar associated with a layer

Parameters:
Name Type Description
options Object
Properties
Name Type Argument Description
layerId number <optional>

layer to draw in, if none create a ghost one

tools Array.<string> <optional>

a list of tools to add, if none get tools ['Select','DrawPoint','DrawLine','DrawPolygon','DrawRegular','Transform','Attributes','Delete','Export','Import'] but not 'DrawHole','Split','Offset'

callback function

a callback function with the layer to draw in or an error code

Fires:
  • event:edit

addEditButton( [options], callback)

Add a new nexw button in the Editbar

Parameters:
Name Type Argument Description
options Object <optional>
Properties
Name Type Argument Description
title string <optional>

button title

name string <optional>

button name, default will increment a new one

icon string <optional>

button icon (as font icon class)

callback function

a function that takes button name

Fires:
  • event:button

addLayerFeatures(options [, callback])

Add new features to a layer

Parameters:
Name Type Argument Description
options Object
Properties
Name Type Argument Description
id number

layer id

features GeoJSON | Array.<GeoJSONFeature> <optional>

features to add in the layer

clear boolean <optional>

clear the layer before add

callback function <optional>

function that takes an object with the number of features readed and the total features length


filterFeatures(condition [, callback])

Filter feature on condition: hide features that don't match the condition.
The layer to search in is the layer of the first condition (other are ignored)
useCase and matchAll options are set in the first condition (other are ignored)
If attr option is missing all features will be selected

Parameters:
Name Type Argument Description
condition Condition | Array.<Condition>
callback function <optional>

a function that takes a filterResult


getCenter(callback)

Get the center of the map

Parameters:
Name Type Description
callback function

a function that takes the center of the maps as an array of longitude, latitude


getFeatures(condition [, callback])

Search features using conditions

Parameters:
Name Type Argument Description
condition Condition | Array.<Condition>
callback function <optional>

a function that takes a GeoJSONFeature array


getLayers(callback)

Get all layers associated with the map

Parameters:
Name Type Description
callback function

a callback function that takes a JSONLayer array


getSelection( [callback])

Get the current selection

Parameters:
Name Type Argument Description
callback function <optional>

a function that takes a GeoJSONFeature array


getStep(callback)

Get the current step (model 'etape' only)

Parameters:
Name Type Description
callback function

a function that takes the current step index


getSteps(callback)

Get a list of steps (model 'etape' only)

Parameters:
Name Type Description
callback function

a function that takes a list of steps


getTab(callback)

Get the current tab index

Parameters:
Name Type Description
callback function

a function that takes the current tab


getTabs(callback)

Get the list of tabs

Parameters:
Name Type Description
callback function

a function that takes an array of tabs


getZoom(callback)

Get map zoom level

Parameters:
Name Type Description
callback function

a function that takes the zoom level as argument


layout(options)

Change the map layout

Parameters:
Name Type Description
options Object
Properties
Name Type Argument Description
css string <optional>

full text css declaration

jcss string <optional>

css declaration as an array [selector, { prop: value }]

styleURI string <optional>

url to a css file

Example
api.layout({ css: '.ol-control button { background-color: red!important; font-size: 2em; }' });
api.layout({ jcss: ['button',  { "background-color": "red!important", "font-size": "2em" } ]});
api.layout({ styleURI: 'http://server.fr/style.css' });

mapControl(options)

Get map control properties (visible, collapsed)

Parameters:
Name Type Description
options Object | string

options to set the control properties or the control id

Properties
Name Type Argument Description
id string

the control id: toolbar,zoom,scaleLine,attribution,mousePosition,layerSwitcher,profil,printDlg,legend,searchBar,locate

visible boolean <optional>
collapsed boolean <optional>

message( [options])

Display a message on the map

Parameters:
Name Type Argument Description
options string | Object <optional>

the message or a list of options, if none close the dialog

Properties
Name Type Argument Default Description
message string

the message

type string <optional>
notification

the message type (notification, message, alert, wait)


moveTo(position)

Move map to place

Parameters:
Name Type Description
position Object

the position to move to

Properties
Name Type Description
center Array.<number>

an array of longitude, latitude

zoom number
rotation number
type string

the type of movement use 'flyTo' to have a fly to effect


on(event, listener)

Listen to an event

Parameters:
Name Type Description
event string

event name

listener function
Listens to Events:

Show a popup on the map

Parameters:
Name Type Description
options Object
Properties
Name Type Description
position JSONCoordinate

longitude / latitude of the popup

content string

the popup content (formated with Markdown)


selectFeatures(condition [, callback])

Select features matching conditions
The layer to search in is the layer of the first condition (other are ignored)
useCase and matchAll options are set in the first condition (other are ignored)

Parameters:
Name Type Argument Description
condition Condition | Array.<Condition>
callback function <optional>

a function that takes the number of features selected as argument


setCenter(center)

Change map center

Parameters:
Name Type Description
center Array.<number> | centerOptions

an array of [longitude, latitude and zoom (optional)] or center options


setLayer(options)

Set the layer options

Parameters:
Name Type Description
options Object
Properties
Name Type Argument Description
id number

layer id

visible boolean <optional>

layer visibility

opacity boolean <optional>

layer opacity

displayInLayerSwitcher boolean <optional>

display the layer in the switcher

title string <optional>

layer title


setStep(n)

Go to a step (model 'etape' only)

Parameters:
Name Type Description
n number

step index to goto


setTab(id, callback)

Change the current tab

Parameters:
Name Type Description
id number | string

the current tab index (or the carte public id)

callback function

a function that takes the current tab


setZoom(zoom)

Set map zoom level

Parameters:
Name Type Description
zoom number

the zoom level


un(event, listener)

Remove an event listener

Parameters:
Name Type Description
event string

event name

listener function

Events


button

Event when a user button is clicked in the edit bar


edit

Event when a feature are changed with the edit bar

Properties:
Name Type Description
edit Object

the map position

Properties
Name Type Description
action string

select, addfeature, drawend, removefeature, modifyfeature, attributes, import:start, import:end, export:start, export:end

features Array.<GeoJSONFeature>
attributes Array.<string>

list of modified attributes

layerId number

move

Listen to position change

Properties:
Name Type Description
position Object

the map position

Properties
Name Type Description
center Array.<number>

the center of the maps as an array of longitude, latitude

zoom number

the zoom level

Listeners of This Event:

select

Listen to new selection

Properties:
Name Type Description
selection Array.<GeoJSONFeature>

an array of features in a GeoJSON format

Listeners of This Event:

step

Listen to step change (model 'etape' only)

Properties:
Name Type Description
step number

current step