Class: Style
- Last UpdatedMay 21, 2025
- 3 minute read
Instances of this class hold style configuration for rendering data on the map. It also provides utility methods for operating with the style.
This is a generic class and type of the style configuration is T
.
Name | Type | Description |
---|---|---|
config |
string | T |
Either a URL to load the style from, encoded style configuration as string or object describing
the style configuration. See |
opt_baseUrl |
string |
optional
The base URL to use for resolving relative URLs in the style like textures, fonts.
When URL is passed as a |
Throws:
-
if the specified base URL is invalid.
Extends
Members
-
The state of the style.
Properties:
Methods
-
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
-
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 () inherited
-
This method removes listeners from the given object. Classes that extend
EventTarget
may need to override this method in order to remove references to DOM Elements and additional listeners. -
Returns the style base URL.
Returns:
Type Description string | undefined -
To get the current style configuration as a JavaScript Object, or
null
if there was an error loading/parsing the style configuration.Note that the copy of the configuration is returned.
Returns:
Type Description T -
getState ()H.map.render.Style.State
-
Returns the state of the current style.
Returns:
Type Description H.map.render.Style.State -
Starts loading the style configuration if it was specified as a URL or parsing the style configuration if it was passed encoded string or object.
-
removeEventListener (type, handler, opt_capture, opt_scope) inherited
-
This method removes a previously added listener from the
EventTarget
instance.
Events
-
Event fired when style changes
Type:
-
Event fired when error occurs during style load, parsing, etc.
Type: