If you use the map widget to show map data, always make sure to check the terms of usage and licensing conditions of the map data provider! For demonstration purposes, we make use of map data from https://tile.openstreetmap.org, see http://www.openstreetmap.org/copyright.
By default, the widget uses map data from Open Street Maps. You need to ensure this is compatible with privacy related regulations. Alternatively, you can configure a custom map provider.
The map widget adds a new form element to the form designer. It lets you show an interactive world map to the user. Uses can then select a certain type of geometry in the map: either a list of disconnected points, a line consisting of many line segments, or a polygonal area. The selected geometry is stored in a hidden textarea field and transmitted to the server when the form is submitted. When an existing form record is reopened, the map focuses on the selected geometry automatically.
Whether the user can select points, a line, or an area can be configured in the form designer. You can also to disallow selecting any kind of geometry, which can be useful if you only want to add a map to the form for illustrative purposes. Finally, you can also choose an initial location and zoom level for the map in the form designer.
If necessary, you can also show custom map data from a service provider. Supported protocols are WMTS, WMS und TMS.
Contents
The map widgets lets users select points, lines, or areas on a map. |
Properties
You can adjust several properties for the map widget to customize the map layout and to use custom map data.
Basic map configuration. You can select an area of the map to show to users and choose the geometry types that users may select. |
- Latitude and longitude - The initial position on the map that is shown when no geometry was selected yet.
- Zoom min, zoom max. - The minimum and maximum allowed zoom levels at which the user may view the map.
- Zoom initial - Initial zoom level applied when no geometry was selected yet.
- Select points / line / area - Whether users can select points, a line, or an area in the map. Multiple geometry types can be selected, the user can then choose a type to select with the buttons at the top left corner of the map. When no types are selected, the user cannot select any geometry in the map. This might be useful when you only want to include a map in your form.
- Locate button: When enabled, adds a locate button to the map. If the user click on the button, their current location is checked and shown on the map. The map is scrolled such that the user can see their position.
- Locate immediately - When enabled, and no geometry was selected, locates the user immediately when the form is opened. When a form is openend in the inbox, the automatic location feature is always disabled. We recommend that you avoid using this option, as it results in the browser asking the user to share their location as soon as they open the form.
- Custom map data - Lets you use custom map data, see the section below.
You can also customize the color of the markers in the map. |
- Points - Controls the color of the bead-shaped point marker icons in the map.
- Location - Controls the color of the marker for the user's position.
- Line - Controls the color of the line, when the geometry type is set to line.
- Area: border - Controls the color of the border of an area, when the geometry type is set to area.
- Area: fill - Controls the color of the inside of an area, when the geometry type is set to area.
Custom map data
You can also include custom map data provided by map services. The map widget currently supports the protocols WMTS, WMS, and TMS. If you use map data, make sure you check the terms of service and the licensing conditions of the map provider! The map widget offers an input field where you can enter a custom attribution text that is shown at the bottom right corner of the map widget.
WMTS and TMS
WMTS and TMS are quite similar. The only difference is that for TMS, the y coordinate is inverted with respect to WMTS.
Here we use an URL template to load map data from a WMTS map service. |
Map services that implement the WMTS or TMS protocol are easy to integrate into the map widget. You only need to enter the appropriate URL of the map service. The placeholders {x} (latitude), {y} (longitude) and {z} (zoom level) in the URL are replaced with the corresponding values when requesting map data from the map service.
WMS
Inegrating a WMS map service is a bit more difficult. See also WMS in Leaflet.
Most of the required data can be obtained from the GetCapabilities method of the WMS map service. If the base URL of the map service, for example, is https://webmap4.lroc.asu.edu/, you can access its capabilities via the URL https://webmap4.lroc.asu.edu/?request=GetCapabilities erfolgen. This URL gives you an XML file with the capabilities of the web service.
Here we integrate a map of the moon via a WMS map service. We load 2 layers, one layer with the imagery, and one layer with the names of well-know locations on the moon. |
- Link - Must be the base URL of the WMS map service.
- Version - The version of the WMS map service. The default is 1.1.1, which is supported by most services.
- Coordinates - Spatial reference system (SRS) to use when requesting map data. As long as the map service supports the SRS, the value you choose here is not important. You can find the supported SRS within the <srs> XML element of the service's capabilities descriptor.
- Layers - Layers that are loaded from the map service, separated by a comma. A common use case as shown in the illustration above is to load one layer with the image data and one layer with the labels. You can find the supported layers within the <Layer> XML elements of the service's capabilities descriptor.
- Separate layers - If disabled: The map service is responsible for combining the requested layers into the final image. This is the recommended settings, as the map service is usually better at combining the layers into an appropriate image. If disabled: The layers are loaded separately from the web service and placed on top of each other.
- Styles - Optional styles to apply, if the map service supports it.
- Format - Image format of the map data. The web service must supported the entered image format. You can find the supported formats within the <Format> XML elements of the service's capabilities descriptor.
- Capitalize parameters großschreiben - When enabled, all parameters (such as format=image/png or version=1.1.1) are capitalized when making a request to the map service. Must be enabled if the map service requires it.
Localization
You can customize the localized messages in the form by editing the I18N variables in the backend. The plugin only ships with support for German and English, this lets you support other languages as well. The I18N keys and their default values are as follows:
- mapActionLocate - Show your current position on the map
- mapActionSelectArea - Select an area on the map
- mapActionSelectLine - Select a line on the map
- mapActionSelectPoints - Select points on the map
- mapActionReset - Reset selected points
- mapActionUserPosition - You are here
- mapActionZoomIn - Zoom in
- mapActionZoomOut - Zoom out
JavaScript-API
For advanced use cases, you can interact with the map widget programmatically via JavaScript. The entry point for the API is provided by the global object $.xutil.xMapApi.
Some examples:
The entire API looks as folows. $.xutil.xMapApi is the main entry point of the map widget API, which is described by the interface IXMapApi. This interface has the following definition:
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article