@vcmap/event-control
v1.0.1
Published
> Part of the [VC Map Project](https://github.com/virtualcitySYSTEMS/map-ui)
Readme
@vcmap/event-control
Part of the VC Map Project
The Event Control plugin is intended to perform actions in reaction to events. In particular, it allows callbacks to be executed in reaction to various events.
The trigger events that can be used are as follows:
- Layer state change
- Map state change
- Module added/removed
- Planning project state change
- Window state change
Configuration
Plugin configuration is simple: the actions property is an array of actions, defined as follows:
| Property | Type | Description | Possible values |
| -------------- | ---------------------- | ------------------------------------------------------------------- | ---------------------------------------------- |
| type | String | The type of event to react to. | layer, map, module, planning, window |
| targetName | String | The name of the target (layer, planning id, ...) to react to. | any |
| onActivate | Array | Optional. Callback options to be executed on target's activation. | |
| onDeactivate | Array | Optional. Callback options to be executed on target's deactivation. | |
For more information about callbacks, see the Callback documentation.
Configuration examples
- I want to toggle the state of
layer2at the same time as that oflayer1:
"actions": [
{
"type": "layer",
"targetName": "layer1",
"onActivate": [
{
"type": "ActivateLayersCallback",
"layerNames": ["layer2"]
}
],
"onDeactivate": [
{
"type": "DeactivateLayersCallback",
"layerNames": ["layer2"]
}
]
}
]- I want the layer
planningLayerto be activated when enabling the Planning project with idplanningId:
"actions": [
{
"type": "planning",
"targetName": "planningId",
"onActivate": [
{
"type": "ActivateLayersCallback",
"layerNames": ["planningLayer"]
},
]
}
]- I want the Legend window to open when enabling the layer
layerWithLegend:
"actions": [
{
"type": "layer",
"targetName": "layerWithLegend",
"onActivate": [
{
"type": "ToggleNavbarButtonCallback",
"buttonId": "legendId",
"activeState":true
}
]
}
]- I want a module to be enabled only in 3D:
"actions": [
{
"type": "map",
"targetName": "cesiumMap",
"onActivate": [
{
"type": "AddModuleCallback",
"module": "config/3Dconfig.json"
}
],
"onDeactivate": [
{
"type": "RemoveModuleCallback",
"moduleId": "config/3Dconfig.json"
}
]
}
]- I want the map to start rotating when opening MyOwnPlugin:
"actions": [
{
"type": "window",
"targetName": "myOwnPluginWindowId",
"onActivate": [
{
"type":"StartRotationCallback"
}
]
}
]