The Map control allows maps from various vendors, including Google Maps and OpenStreetMap, to be integrated into X4 Web Apps. You can view geodata, find locations, and look up routes.
Creating a Map control
A Map control is created with the <Map> element. The element can only be used in the layout of a Detail Component.
Possible attributes:
In addition to the standard attributes for controls, the <Map> element can have the following attributes:
|
Attribute |
Description |
|---|---|
|
|
Defines the API key if required by the vendor. Possible values: API key To use OpenStreetMap, no API key is required. If an API key is entered when using OpenStreetMap as the map provider, the API key is ignored. If Google Maps is used as the map provider, the following APIs must be enabled:
The |
|
|
Defines the longitude on which the map should be centered when it is loaded.
Possible values: Longitude in degrees with decimal places (e.g. |
|
|
Defines the longitude on which the map should be centered when it is loaded.
Possible values: Latitude in degrees with decimal places (e.g. |
|
|
Restrict scrolling behavior in maps Possible values:
|
|
|
Defines if the satellite view of the map is activated. Possible values: The satellite view cannot be used if OpenStreetMap is used as map vendor. |
|
|
Selected index The Possible values: String binding |
|
|
Required. Specifies the map vendor. Possible values:
Note when selecting Bing as the card provider: The use of Bing Maps will no longer be possible in the future. The reason is the termination of the underlying Microsoft API (May 2024, full shutdown for Free Tier from June 2025).
|
|
|
Specifies the initial zoom level of the map. The values give an approximate indication of the meters shown on the map. Please note that there may be deviations in the scale bar, as the scale changes depending on the distance from the equator. Possible values:
|
|
|
Specifies whether the user can interact with the control.
Possible values: The |
|
|
The direction in which the elements flow. The order of the elements corresponds to their declaration. Possible values:
|
|
|
Specifies what should happen when the control is full. Possible values:
|
|
|
Defines if the control is visible.
Possible values: |
Search
To allow a web app user to search for locations in the map control, the <Search/> element is used within <Map>.
<Map>
<Search/>
</Map>
Possible attributes:
The <Search/> element can have the following attributes:
|
Attribute |
Description |
|---|---|
|
|
Defines the horizontal position of the icon relative to the coordinates searched for. Possible values:
|
|
|
Path to the graphic file to be used as an icon. The icon is used to highlight the search result. The graphics file must be located in the
Possible values: String (URI) |
|
|
Defines the vertical position of the icon relative to the coordinates searched for. Possible values:
|
Routing
To allow a web app user to calculate a route between two locations in the Map control, the <Routing/> element is used within <Map> and, if necessary, after <Search/>.
<Map ...>
<Routing/>
</Map>
Possible attributes:
The <Routing/> element can have the following attributes:
|
Attribute |
Description |
|---|---|
|
|
Defines the horizontal position of the target icon relative to the coordinates searched for. Possible values:
|
|
|
Path to the graphic file to be used as an icon for the target point. The icon marks the target point of the route. The graphics file must be located in the
Possible values: String (URI) |
|
|
Defines the vertical position of the target icon relative to the coordinates searched for. Possible values:
|
|
|
Defines the horizontal position of the start icon relative to the coordinates searched for. Possible values:
|
|
|
Path to the graphic file to be used as an icon for the starting point. The icon marks the starting point of the route. The graphics file must be located in the
Possible values: String (URI) |
|
|
Defines the vertical position of the start icon relative to the coordinates searched for. Possible values:
|
Single marker
To display a single marker in a Map control, the <SingleMarker/> element is used within <Map> and, if necessary, after <Search/> and <Routing/>.
<Map>
...
<SingleMarker/>
</Map>
Possible attributes:
The <SingleMarker/> element can have the following attributes:
|
Attribute |
Description |
|---|---|
|
|
Specifies the name of the component for internal navigation. Possible values: String (name of a component) |
|
|
Specifies the description of the marker.
Possible values: String including spaces |
|
|
Specifies the link that appears in the marker pop-up.
Possible values: String (URL) |
|
|
Specifies whether the link ( Possible values:
|
|
|
Defines the horizontal position of the icon relative to the entered coordinates. Possible values:
|
|
|
Path to the graphic file to be used as an icon for the marker. The graphic file must be located in the
Possible values: String (URI) |
|
|
Defines the vertical position of the icon relative to the entered coordinates. Possible values:
|
|
|
Index of the marker
Possible values: Any string |
|
|
Required if
Possible values: Latitude in degrees with decimal places (e.g. This attribute cannot be used at the same time as |
|
|
Required if
Possible values: Longitude in degrees with decimal places (e.g. This attribute cannot be used at the same time as |
|
|
Specifies the name of the marker.
Possible values: String of alphanumeric characters |
|
|
Specifies the text that appears in the marker's pop-up instead of an external link or component name.
Possible values: String including spaces |
|
|
Required when
Possible values: String for searching a service, such as a This attribute cannot be used at the same time as the |
Marker set
To display multiple markers in a map control, the <Markers/> element is used within <Map> and, if necessary, after <Search/> and <Routing/>.
<Map>
...
<Markers/>
</Map>
Possible attributes:
The <Markers/> element can have the following attributes:
|
Attribute |
Description |
|---|---|
|
|
Defines if markers are grouped if they are very close together on the map. Possible values:
|
|
|
Specifies the name of the component for internal navigation. Possible values: String (name of a component) |
|
|
Required. Defines which data is used for the marker set.
Possible values: Data binding expression |
|
|
Defines the description of the markers.
Possible values: Data binding expression relative to the expression in |
|
|
Specifies the link that appears in the marker pop-up.
Possible values: Data binding expression relative to the expression in |
|
|
Specifies whether the link ( Possible values:
|
|
|
Defines the horizontal position of the icon relative to the entered coordinates. Possible values:
|
|
|
Path to the graphic file to be used as an icon for the markers. The graphic file must be located in the
Possible values: String (URI) |
|
|
Defines the vertical position of the icon relative to the entered coordinates. Possible values:
|
|
|
Index of the marker set
Possible values: Any string |
|
|
Required if
Possible values: Data binding expression relative to the expression in |
|
|
Required if
Possible values: Data binding expression relative to the expression in |
|
|
Defines the name of the markers.
Possible values: Data binding expression relative to the expression in |
|
|
Defines the text that appears in the marker pop-up instead of an external link or component name.
Possible values: String including spaces |
|
|
Defines if the markers are numbered. Possible values:
|
|
|
Required when
Possible values: String for searching a service, such as a This attribute cannot be used at the same time as the |
|
|
Defines the horizontal position of the numbering relative to the given coordinates. Possible values:
Bing Maps automatically positions the numbering. Therefore, this function has no effect on Bing Maps. |
|
|
Defines the vertical position of the numbering relative to the given coordinates. Possible values:
Bing Maps automatically positions the numbering. Therefore, this function has no effect on Bing Maps. |
"Select" Action within a Map
The Select action is created with the <SelectAction/> element within <SingleMarker>, <Markers>, or <SelectedLocationMarker> and is triggered as soon as a corresponding marker has been selected.
Examples
In this example, the properties are defined and a group of markers is displayed.
Example 1 Map Control (*.wad)
<Properties>
<Property name="favorites" type="List">
<Property name="lat" type="Decimal" />
<Property name="lng" type="Decimal" />
</Property>
</Properties>
...
<Map vendor="OpenStreetMap">
<Markers longitude="#lng" data="#favorites" latitude="#lat" iconUrl="heart.png" name="Favorites" description="Places, I have visited." iconVerticalPosition="top"/>
</Map>
Example 1: Data provided by the Technical Process (*.xml)
<OkList>
<favorites>
<lat>48.94061</lat>
<lng>8.40471</lng>
</favorites>
<favorites>
<lat>49.01396</lat>
<lng>8.40445</lng>
</favorites>
</OkList>
The above example leads to the following result:
In this example, two groups of markers are displayed and search and route calculation are activated.
Example 2 Map Control
<Properties>
<Property name="favorites" type="List">
<Property name="lat" type="Decimal" />
<Property name="lng" type="Decimal" />
</Property>
<Property name="destinations" type="List">
<Property name="lat" type="Decimal" />
<Property name="lng" type="Decimal" />
</Property>
</Properties>
...
<Map vendor="OpenStreetMap">
<Search/>
<Routing destinationIconUrl="finish.png" startIconUrl="car.png" destinationIconVerticalPosition="top" destinationIconHorizontalPosition="center"/>
<Markers longitude="#lng" data="#favorites" latitude="#lat" iconUrl="heart.png" name="Favorites" description="Places, I have visited." iconVerticalPosition="top"/>
<Markers longitude="#lng" data="#destinations" latitude="#lat" iconUrl="star.png" name="Destinations" description="Places, I want to visit."/>
</Map>
Example 2: Data provided by the Technical Process (*.xml)
<OkList>
<favorites>
<lat>48.94061</lat>
<lng>8.40471</lng>
</favorites>
<favorites>
<lat>49.01396</lat>
<lng>8.40445</lng>
</favorites>
<destinations>
<lat>51.8058</lat>
<lng>10.3343</lng>
</destinations>
<destinations>
<lat>52.3807</lat>
<lng>9.7706</lng>
</destinations>
</OkList>
The above example leads to the following result:
Multiple groups of markers with different icons (OpenStreetMap)
Search function (OpenStreetMap)
Route calculation (OpenStreetMap)
Additional map providers are also available. The following example shows a map control with Google Maps.
Example 2 Map Control
<Properties>
<Property name="favorites" type="List">
<Property name="lat" type="Decimal" />
<Property name="lng" type="Decimal" />
</Property>
<Property name="destinations" type="List">
<Property name="lat" type="Decimal" />
<Property name="lng" type="Decimal" />
</Property>
</Properties>
...
<Map vendor="Google">
<Search/>
<Routing destinationIconUrl="finish.png" startIconUrl="car.png" destinationIconVerticalPosition="top" destinationIconHorizontalPosition="center"/>
<Markers longitude="#lng" data="#favorites" latitude="#lat" iconUrl="heart.png" name="Favorites" description="Places, I have visited." iconVerticalPosition="top"/>
<Markers longitude="#lng" data="#destinations" latitude="#lat" iconUrl="star.png" name="Destinations" description="Places, I want to visit."/>
</Map>
Example 2: Data provided by the Technical Process (*.xml)
<OkList>
<favorites>
<lat>48.94061</lat>
<lng>8.40471</lng>
</favorites>
<favorites>
<lat>49.01396</lat>
<lng>8.40445</lng>
</favorites>
<destinations>
<lat>51.8058</lat>
<lng>10.3343</lng>
</destinations>
<destinations>
<lat>52.3807</lat>
<lng>9.7706</lng>
</destinations>
</OkList>
The above example leads to the following result:
Setting a marker by clicking in the map
The <SelectedLocationMarker> element allows the user of a Web App to set a marker by clicking on a specific location on the map. The location marked by the user can be further processed by a Technical Process.
<Map>
...
<SelectedLocationMarker .../>
</Map>
Possible attributes:
The <SelectedLocationMarker/> element can have the following attributes:
|
Attribute |
Description |
|---|---|
|
|
Required. Longitude of the marker
Possible values: Property A property must be set as the value for the attribute. |
|
|
Required. The latitude of the marker
Possible values: Property A property must be set as the value for the attribute. |
|
|
Path to the graphic file to be used as an icon. The icon marks the selected location. The graphic file must be located in the
Possible values: String (URI) |
Using the user's location
Within the <Map> element, the <Geolocation> element can be used to query the user's location. If the <Geolocation> element is used, a button is displayed on the map. By clicking on the button, the user's location is queried and marked on the map.
Possible attributes:
|
Attribute |
Description |
|---|---|
|
|
Path to the graphic file to be used as an icon for the markers. The graphic file must be located in the
Possible values: String (URI) |
|
|
Horizontal position of the icon |
|
|
Vertical position of the icon |