Skip to main content

Message Types

The postMessage API supports the following messages:

Outbound

  • ready
  • select

Inbound

  • fit
  • select
  • filter
  • show
  • create_layer
  • remove_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.

warning

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.

warning

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.

warning

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"
}
PropertyDescription
typethe 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" ]
}
PropertyDescription
typethe message type
targetthe target object specifying a type (datasource or layer) and the id
featureIdsan 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" ]
}
PropertyDescription
typethe message type
targetthe target object specifying a type (datasource or layer) and the id
featureIdsan array of the features that should be selected on the map
warning

the select message overwrites any previous selection.

warning

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" ]
}
PropertyDescription
typethe message type
targetthe target object specifying a type (datasource or layer) and the id
featureIdsan 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"
}
PropertyDescription
typethe message type
targetthe target object specifying a type (datasource or layer) and the id
featuresan array of the GeoJSON features that should be shown on the map
crsthe reference of the coordinates in the provided features GeoJson.
The CRS of the show message must match the CRS of the target layer. If omitted, HSS assumes the coordinates use the target layer's CRS.

create_layer

Creates a new layer that can later be referenced in other messages.

{
"type": "create_layer",
"layerId": "test_layer",
"crs": "EPSG:4326"
}
PropertyDescription
typethe message type
layerIdunique identifier for the layer to be created
crscoordinate 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"
}
PropertyDescription
typethe message type
layerIdID of the layer to be removed
Things to note

HxGN Smart Sites ships with an extensive list of coordinate references stored in the HxGN Smart Sites Admin database.