Class: UI
- Last UpdatedMay 21, 2025
- 4 minute read
This class encapsulates map UI functionality.
Name | Type | Description |
---|---|---|
map |
H.Map |
An object representing the map |
opt_options |
H.ui.UI.Options |
optional
An optional object containing the initialization parameters. |
Extends
Implements
Methods
-
H.ui.UI.createDefault (map, defaultLayers, opt_locale)H.ui.UI static
-
This function creates the default UI including the zoom control, map settings control and scalebar. The default controls are assigned the following values:
- Zoom control:
- id: 'zoom'
- alignment: 'right-middle'
- Map settings control:
- id: 'mapsettings'
- alignment: 'bottom-right'
- Scalebar:
- id: 'scalebar'
- alignment: 'bottom-right'
Returns:
Type Description H.ui.UI The UI instance configured with the default controls - Zoom control:
-
This method adds an info bubble to the UI.
Name Type Description bubble
H.ui.InfoBubble The info bubble to be added
-
This method appends a control to the UI.
Name Type Description name
string The name under which to register the control
control
H.ui.Control The control to add to the UI
-
addEventListener (type, handler, opt_capture, opt_scope) inherited
-
This method adds a listener for a specific event.
Note that to prevent potential memory leaks, you must either call
removeEventListener
ordispose
on the given object when you no longer need it. -
addOnDisposeCallback (callback, opt_scope) inherited
-
This method adds a callback which is triggered when the
EventTarget
object is being disposed.Name Type Description callback
function The callback function.
opt_scope
Object optional An optional scope for the callback function
-
This method is used to capture the element view.
-
dispatchEvent (evt) inherited
-
This method dispatches an event on the
EventTarget
object.Name Type Description evt
H.util.Event | string An object representing the event or a string with the event name
-
dispose () overrides
-
This method disposes of the given UI object, including currently open info bubbles and controls attached to the UI.
-
getBubbles ()Array.<!H.ui.InfoBubble>
-
This method retrieves a list of info bubble objects which are currently attached to the UI.
Returns:
Type Description Array.<!H.ui.InfoBubble> A list object containing the retrieved info bubbles -
getControl (name)H.ui.Control | undefined
-
This method retrieves a UI control which was previously registered with the provided name.
Name Type Description name
string The name under which the control was registered
Returns:
Type Description H.ui.Control | undefined The retrieved control object or undefined
if the control does not exist. -
This method retrieves the root element of the user interface.
Returns:
Type Description Element | undefined The root element of the user interface or undefined after the UI was disposed. -
getMap ()H.Map
-
This method retrieves the map instance to which the UI was added.
Returns:
Type Description H.Map An object representing the map instance -
getUnitSystem ()H.ui.UnitSystem
-
This method retrieves the current distance measurement system for the given UI instance.
Returns:
Type Description H.ui.UnitSystem The identifier of the distance measurement system currently in use -
This method removes a previously added info bubble from the UI.
Name Type Description bubble
H.ui.InfoBubble The info bubble to be removed
-
removeControl (name)H.ui.Control | undefined
-
This method removes a previously registered control from the UI object.
Name Type Description name
string The name under which the control was previously registered
Returns:
Type Description H.ui.Control | undefined An object representing the removed control or undefined if not found -
removeEventListener (type, handler, opt_capture, opt_scope) inherited
-
This method removes a previously added listener from the
EventTarget
instance. -
Sets the "direction" CSS property on UI DOM element for the correct rendering of the languages written from right to left (like Hebrew or Arabic).
Name Type Description opt_direction
string optional The "direction" to use. When value is not specified, we detect it automatically from the inherited CSS property of the map container.
-
This method sets the distance measurement system for the given UI object.
Name Type Description unitSystem
H.ui.UnitSystem The distance measurement system to use
-
This method toggles distance measurement system between
H.ui.UnitSystem.METRIC
andH.ui.UnitSystem.IMPERIAL
.
Type Definitions
-
Optional parameters to be passed to the UI constructor.
Properties: