OLMapControl
The OLMapControl renders an interactive OpenLayers map inside a form. It stores the current map state as JSON and can optionally generate a static image that is used in create view, PDF output and offline mode.
For the structure of the mapConfig object, see the Integrate Maps documentation.
<div
id="location_map"
data-hf-control="OLMapControl"
data-hf-options="{
label: 'Location map',
height: 320,
required: true,
mapConfig: {
provider: 'OpenLayers',
capabilities: {
url: 'https://maps.example.com/wmts?SERVICE=WMTS&REQUEST=GetCapabilities',
layers: [
{
base: 'basemap',
overlays: [],
label: 'Base map'
}
]
},
mapConfig: {
center: [15.439504, 47.070713],
zoom: 10
},
controls: {
mapNavigation: true,
geolocation: true
},
features: {
toggleLayerVisibility: true,
setMarkers: false
}
},
staticImage: {
show: true,
pdf: 'fullWidth'
}
}"
></div>
FormControl Options
mapConfig - required
ICustomMLMapConfigdefaultValue
defaultValue: { testEntry: 'testValue' }object | functionfunction() => objectdoNotCopy
doNotCopy: truebooleanheight
height: 300numberonChanged
onChanged: HFFormdefinition.Namespace.Methodfunctionfunction(value: string) => voidpersistent
persistent: 'user''user'staticImage
{ show: boolean, pdf: 'fullWidth' | 'blockWidth' }staticImage.pdf
pdf: 'fullWidth''fullWidth' | 'blockWidth'staticImage.show
show: truebooleanStatic image and offline mode
If staticImage.show is enabled, the control captures the current map view as a JPEG attachment whenever the form is saved. This attachment is used in three places:
- In create view, where the live map is replaced by the stored image.
- In PDF output, where
staticImage.pdfcontrols the image size. - In offline mode, where the stored image is shown instead of the live map.
If no static image exists and the application is offline, the control displays a placeholder instead of the map.
Stored data
The OLMapControl stores the current map center and zoom level as a JSON string:
{
"id": "location_map",
"value": "{\"center\":{\"latitude\":47.070713,\"longitude\":15.439504},\"zoom\":10,\"mapLayer\":\"basemap\"}"
}
The JSON stored in the value field has the following structure:
{
"center": {
"latitude": 47.070713,
"longitude": 15.439504
},
"zoom": 10,
"mapLayer": "basemap"
}
Static image shadow field
If staticImage.show is enabled, an additional shadow field stores the generated attachment name:
{
"id": "location_map_HFMapImage",
"value": "location_map_HFMapImage.jpg"
}