Web Components
The Open Data Hub provides a collection of reusable Web Components for integrating real-time data into websites and applications. These components, covering domains such as tourism, weather, and mobility, are designed to be easily embedded and configured without requiring deep integration with the underlying APIs.
You can browse and use the available Web Components at https://webcomponents.opendatahub.com/. Each component includes a "Share" button that provides an embeddable code snippet for quick integration.
1. Implementing a Web Component
To use a Web Component from the Open Data Hub, follow these steps:
- Visit the Web Components library.
- Select the component you want to use.
- Click the "Share" button to copy the embed code.
- Paste the code into your HTML page.
Always place the Web Component code inside a <div> element to ensure proper rendering.
For example, to embed the day-trip-map-widget:
<meta charset="UTF-8">
<div>
<script src="https://cdn.webcomponents.opendatahub.com/dist/137e4aa4-af69-4085-90be-b58299879cb4/day_trip_map_widget.min.js"></script>
<day-trip-map-widget lang-and-locale="en-US" log-info="false"></day-trip-map-widget>
</div>
Each component accepts its own attributes, set on the HTML tag. For the day-trip-map-widget, for example:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
lang-and-locale | string | no | en-US | Sets the language and locale (e.g., de-DE, it-IT). |
log-info | string | no | false | Enables logging output when set to true. |
Refer to each component's own page in the Web Components library for its full list of attributes.
2. Character encoding and emoji support
Some Web Components, such as day-trip-map-widget, use emojis or special icons that require UTF-8 encoding to render correctly.
Without UTF-8 encoding, emojis and special characters may appear as boxes or question marks.
Ensure your HTML document includes the following in the <head> section:
<meta charset="UTF-8">
This applies to all Web Components that display weather icons, trail symbols, or other Unicode glyphs.