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: ContextItem

Table of Contents

Class: ContextItem

H.util.ContextItem

new H.util.ContextItem (opt_options)

This class represents contextual information/action.

Name Type Description
opt_options H.util.ContextItem.Options optional

An object containing the initialization properties

Example
// Enable map events such as "contextmenu"
var events = new H.mapevents.MapEvents(map);

// Show default controls as well as the Context Menu control
var ui = H.ui.UI.createDefault(map, defaultLayers, 'en-US');

// Add 'Zoom in' context menu item
map.addEventListener('contextmenu', function(e) {
  e.items.push(new H.util.ContextItem({
    label: 'Zoom in',
    callback: function() {
      map.setZoom(map.getZoom() + 1);
    }
  }));
});

Extends

Members

H.util.ContextItem.SEPARATOR H.util.ContextItem staticconstantnon-null

This constant represents the separator for the context item.

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 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.

getLabel ()string

This method retrieves the label of the context item.

Returns:
Type Description
string The label of the context item

isDisabled ()boolean

This method retrieves a value indicating whether the given context item is disabled or not.

Returns:
Type Description
boolean true if the item is disabled, false otherwise

removeEventListener (type, handler, opt_capture, opt_scope) inherited

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

setDisabled (disabled)H.util.ContextItem

This method enables/disables the context item.

Name Type Description
disabled boolean

true to disable and false to enabled the context item

Fires:
  • H.util.ContextItem#event:update
Returns:
Type Description
H.util.ContextItem An object representing the given context item

setLabel (label)H.util.ContextItem

This method sets the context item label.

Name Type Description
label string

A new label for the context item

Fires:
  • H.util.ContextItem#event:update
Returns:
Type Description
H.util.ContextItem An object representing the given context item

Type Definitions

H.util.ContextItem.Options Object

This type defines options which can be used to initialize the context item.

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