Powered by Zoomin Software. For more details please contactZoomin

HERE Maps API for JavaScript - API Reference

Product category
Technology
Doc type
Version
Product lifecycle
This publication

HERE Maps API for JavaScript - API Reference: Class: Style

Table of Contents

Class: Style

H.map.render.harp.Style

Instances of this class hold style configuration for rendering provider data using HARP rendering engine.

new H.map.render.harp.Style (config)

Creates an instance of style.

Name Type Description
config string | Object

Either a URL to load the style from or an object describing the rendering style. The URL can be absolute or relative, but should end with .json extension.

Extends

Methods

addEventListener (type, handler, opt_capture, opt_scope) inherited overrides

This method adds a listener for a specific event.

Note that to prevent potential memory leaks, you must either call removeEventListener or dispose 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.

getBaseUrl ()string | undefined inherited overrides

Returns the style base URL.

Returns:
Type Description
string | undefined

getConfig ()T inherited overrides

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

getEnabledFeatures ()Array.<{feature: string, mode: (string|undefined)}> | undefined

To get the list of enabled style features. If setEnabledFeatures was called before, then this method will return features previously passed to that setter. If setEnabledFeatures wasn't called before, then the result depends on the style state:

  • if the style is loaded, then this method will extract and return a list of features enabled by default from the style configuration.
  • if the style is not loaded, then this method will return undefined.
Returns:
Type Description
Array.<{feature: string, mode: (string|undefined)}> | undefined

Returns the state of the current style.

Returns:
Type Description
H.map.render.Style.State

load ()void inherited overrides

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.

Returns:
Type Description
void

removeEventListener (type, handler, opt_capture, opt_scope) inherited overrides

This method removes a previously added listener from the EventTarget instance.

setEnabledFeatures (enabledFeatures)void

Enables style features. Style features allow to switch on and off certain map objects defined in the style configuration, for example: buildings, public transport, etc. The list of features supported by the current style configuration can be obtained by calling style.getConfig().features.

This method dispatches "change" event.

Please note that this method overrides style features enabled by default. To preserve default features, you need to pass them to this method together with features you want to enable. This example shows how to preserve currently enabled features and additionally enable "road exit labels" feature in mode "all":

The mode "none" can be used to disable the feature.

// Get the list of currently enabled features:
const enabledFeatures = style.getEnabledFeatures();
// Define feature to enable and its mode:
const featureToEnable = {feature: 'road exit labels', mode: 'all'};
// Add feature to the list of enabled features or replace its mode if it's already in the list:
const featureIndex = enabledFeatures.findIndex(el => el.feature === featureToEnable.feature);
enabledFeatures.splice(featureIndex, featureIndex === -1 ? 0 : 1, featureToEnable);
// Apply changes:
style.setEnabledFeatures(enabledFeatures);
Name Type Description
enabledFeatures Array.<{feature: string, mode: string}> | undefined

The list of style features to enable, for example:

[
  {feature: 'road exit labels', mode: 'all'},
  {feature: 'congestion zones', mode: 'all'},
  {feature: 'environmental zones', mode: 'all'}
]

If this parameter is undefined, then the list of enabled features will be taken from the style configuration. An empty array means that all style features should be disabled.

Throws:

If enabledFeatures parameter has multiple occurrences of the same feature.

Type
H.lang.InvalidArgumentError
Returns:
Type Description
void

Events

Event fired when style changes

Type:

Event fired when error occurs during style load, parsing, etc.

Type:
Was this article helpful?
TitleResults for “How to create a CRG?”Also Available inAlert