The api instance returned as argument using the MapIFrameAPI.ready function.
Methods
-
addEditBar(options, callback)
-
Add a new Editbar associated with a layer
Parameters:
Name Type Description optionsObject Properties
Name Type Argument Description layerIdnumber <optional>
layer to draw in, if none create a ghost one
toolsArray.<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'
callbackfunction 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 optionsObject <optional>
Properties
Name Type Argument Description titlestring <optional>
button title
namestring <optional>
button name, default will increment a new one
iconstring <optional>
button icon (as font icon class)
callbackfunction a function that takes button name
Fires:
- event:button
-
addLayer(options, callback)
-
Insert a new layer on the map
Parameters:
Name Type Description optionsObject Properties
Name Type Argument Description positionnumber <optional>
position in the layer switcher, default on top
layerOptionsObject layer options as in .carte
callbackfunction a callback function that takes a JSONLayer
-
addLayerFeatures(options [, callback])
-
Add new features to a layer
Parameters:
Name Type Argument Description optionsObject Properties
Name Type Argument Description idnumber layer id
featuresGeoJSON | Array.<GeoJSONFeature> <optional>
features to add in the layer
clearboolean <optional>
clear the layer before add
callbackfunction <optional>
function that takes an object with the number of features readed and the total features length
-
deleteSelection( [callback])
-
Delete selected features
Parameters:
Name Type Argument Description callbackfunction <optional>
a function that takes the number of features deleted
-
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 selectedParameters:
Name Type Argument Description conditionCondition | Array.<Condition> callbackfunction <optional>
a function that takes a filterResult
-
getCenter(callback)
-
Get the center of the map
Parameters:
Name Type Description callbackfunction 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 conditionCondition | Array.<Condition> callbackfunction <optional>
a function that takes a GeoJSONFeature array
-
getLayers(callback)
-
Get all layers associated with the map
Parameters:
Name Type Description callbackfunction a callback function that takes a JSONLayer array
-
getSelection( [callback])
-
Get the current selection
Parameters:
Name Type Argument Description callbackfunction <optional>
a function that takes a GeoJSONFeature array
-
getStep(callback)
-
Get the current step (model 'etape' only)
Parameters:
Name Type Description callbackfunction a function that takes the current step index
-
getSteps(callback)
-
Get a list of steps (model 'etape' only)
Parameters:
Name Type Description callbackfunction a function that takes a list of steps
-
getTab(callback)
-
Get the current tab index
Parameters:
Name Type Description callbackfunction a function that takes the current tab
-
getTabs(callback)
-
Get the list of tabs
Parameters:
Name Type Description callbackfunction a function that takes an array of tabs
-
getZoom(callback)
-
Get map zoom level
Parameters:
Name Type Description callbackfunction a function that takes the zoom level as argument
-
layout(options)
-
Change the map layout
Parameters:
Name Type Description optionsObject Properties
Name Type Argument Description cssstring <optional>
full text css declaration
jcssstring <optional>
css declaration as an array [selector, { prop: value }]
styleURIstring <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 optionsObject | string options to set the control properties or the control id
Properties
Name Type Argument Description idstring the control id: toolbar,zoom,scaleLine,attribution,mousePosition,layerSwitcher,profil,printDlg,legend,searchBar,locate
visibleboolean <optional>
collapsedboolean <optional>
-
message( [options])
-
Display a message on the map
Parameters:
Name Type Argument Description optionsstring | Object <optional>
the message or a list of options, if none close the dialog
Properties
Name Type Argument Default Description messagestring the message
typestring <optional>
notification the message type (notification, message, alert, wait)
-
moveTo(position)
-
Move map to place
Parameters:
Name Type Description positionObject the position to move to
Properties
Name Type Description destinationArray.<number> an array of longitude, latitude
zoomnumber rotationnumber typestring the type of movement use 'flyTo' to have a fly to effect
-
on(event, listener)
-
Listen to an event
Parameters:
Name Type Description eventstring event name
listenerfunction Listens to Events:
-
popup(options)
-
Show a popup on the map
Parameters:
Name Type Description optionsObject Properties
Name Type Description positionJSONCoordinate longitude / latitude of the popup
contentstring the popup content (formated with Markdown)
-
removeLayer(layerId, callback)
-
Remove a layer from the map
Parameters:
Name Type Description layerIdnumber callbackfunction a callback function that takes a boolean
-
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 conditionCondition | Array.<Condition> callbackfunction <optional>
a function that takes the number of features selected as argument
-
setCenter(center)
-
Change map center
Parameters:
Name Type Description centerArray.<number> | centerOptions an array of [longitude, latitude and zoom (optional)] or center options
-
setLayer(options)
-
Set the layer options
Parameters:
Name Type Description optionsObject Properties
Name Type Argument Description idnumber layer id
visibleboolean <optional>
layer visibility
opacityboolean <optional>
layer opacity
displayInLayerSwitcherboolean <optional>
display the layer in the switcher
titlestring <optional>
layer title
urlstring <optional>
layer url (only for external file layer)
-
setStep(n)
-
Go to a step (model 'etape' only)
Parameters:
Name Type Description nnumber step index to goto
-
setTab(id, callback)
-
Change the current tab
Parameters:
Name Type Description idnumber | string the current tab index (or the carte public id)
callbackfunction a function that takes the current tab
-
setZoom(zoom)
-
Set map zoom level
Parameters:
Name Type Description zoomnumber the zoom level
-
un(event, listener)
-
Remove an event listener
Parameters:
Name Type Description eventstring event name
listenerfunction
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 editObject the map position
Properties
Name Type Description actionstring select, addfeature, drawend, removefeature, modifyfeature, attributes, import:start, import:end, export:start, export:end
featuresArray.<GeoJSONFeature> attributesArray.<string> list of modified attributes
layerIdnumber -
move
-
Listen to position change
Properties:
Name Type Description positionObject the map position
Properties
Name Type Description centerArray.<number> the center of the maps as an array of longitude, latitude
zoomnumber the zoom level
Listeners of This Event:
-
select
-
Listen to new selection
Properties:
Name Type Description selectionArray.<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 stepnumber current step
-
select:show
-
Listen to new feature show
Properties:
Name Type Description TheGeoJSONFeature current feature shown in a GeoJSON format