Message Types
The postMessage API supports the following messages:
Outbound
readyselect
Inbound
fitselectfiltershowcreate_layerremove_layer
All inbound messages include either a top‑level layerId or a target object with a type of datasource or layer and an id.
HxGN Smart Sites resolves datasources by their public ID, and temporary layers by their layerId.
You can view or modify datasource public ID's in the HxGN Smart Sites Admin Client.
Messages are handled synchronously through a queue. If multiple messages are sent in quick succession, they will be processed one at a time in the order they were received.
It is possible for a datasource to be loaded multiple times on the map, if it exists in multiple Publications. In this case, the message only applies to the top layer.
The postMessage Api messages only interacts with features that are already loaded on the map. If the feature is not loaded in the model, you will not be able to select, fit or filter it. For this reason, the use of SLD’s with scale ranges is currently not supported.
Outgoing Messages
ready
This is an outgoing message sent by the HxGN Smart Sites Client application to notify the host application that the map has been initialized and the application is ready to receive messages. The message is sent after all layers and their data have been loaded and any automatic fitting is applied.
{
"type": "ready"
}
| Property | Description |
|---|---|
| type | the message type |
Incoming Messages
fit
This message provides a list of feature IDs to fit on the map. The provided features should be loaded on the map, an error is logged if this is not the case.
{
"type": "fit",
"target": {"type": "layer", "id": "123"},
"featureIds": [ "456" ]
}
| Property | Description |
|---|---|
| type | the message type |
| target | the target object specifying a type (datasource or layer) and the id |
| featureIds | an array of the features that should be fitted on the map |
select
This message provides a list of feature IDs to select on the map. The provided features should be loaded on the map, an error is logged if this is not the case.
{
"type": "select",
"target": {"type": "datasource", "id": "123"},
"featureIds": [ "456" ]
}
| Property | Description |
|---|---|
| type | the message type |
| target | the target object specifying a type (datasource or layer) and the id |
| featureIds | an array of the features that should be selected on the map |
the select message overwrites any previous selection.
The object property panel is only shown on single feature selection.
filter
This message provides a list of feature IDs that should be filtered. The provided features should be loaded on the map, an error is logged if this is not the case.
{
"type": "filter",
"target": {"type": "datasource", "id": "123"},
"featureIds": [ "456" ]
}
| Property | Description |
|---|---|
| type | the message type |
| target | the target object specifying a type (datasource or layer) and the id |
| featureIds | an array of the features that should be filtered on the map |
show
This message provides GeoJSON to be decoded and shown on a temporary layer.
{
"type": "show",
"target": {"type": "datasource", "id": "123"},
"features": [
{
"geometry": {"coordinates": [52, 7], "type": "Point"},
"type": "Feature"
}
],
"crs": "EPSG:7625"
}
| Property | Description |
|---|---|
| type | the message type |
| target | the target object specifying a type (datasource or layer) and the id |
| features | an array of the GeoJSON features that should be shown on the map |
| crs | the reference of the coordinates in the provided features GeoJson. |
- crs
- features
- target
- `show` message
show message must match the CRS of the target layer. If omitted, HSS assumes the coordinates use the target layer's CRS.features field contains an array of GeoJSON Feature objects. Each feature must have a type and a geometry, with coordinates expressed in the provided crs.target identifies the destination (type: datasource or layer). When targeting a datasource, its styling is used to render the features, which may be defined by an SLD.show message replaces all features from previous show messages.create_layer
Creates a new layer that can later be referenced in other messages.
{
"type": "create_layer",
"layerId": "test_layer",
"crs": "EPSG:4326"
}
| Property | Description |
|---|---|
| type | the message type |
| layerId | unique identifier for the layer to be created |
| crs | coordinate reference system used for the layer (e.g., "EPSG:4326"), defaults to WGS:84 if no CRS is provided |
{
"type": "create_layer",
"layerId": "test_layer",
"crs": "EPSG:4326"
}
remove_layer
Removes a layer created with the create_layer message.
{
"type": "remove_layer",
"layerId": "test_layer"
}
| Property | Description |
|---|---|
| type | the message type |
| layerId | ID of the layer to be removed |
HxGN Smart Sites ships with an extensive list of coordinate references stored in the HxGN Smart Sites Admin database.