HERE 地图 UI JS - 如何将自定义按钮添加到地图 UI?

HERE Map UI JS - How to add custom buttons to the Map UI?

我试图在 HERE JS 文档中找到有关如何将自定义按钮添加到我们拥有的 HERE JS 3.0 地图的指南。UI。

该按钮将移动地图以客户当前位置为中心(我们在 HERE 功能之外提供位置并手动传递)。但是,这需要通过 HERE 地图本身上的按钮触发。但我不知道如何将按钮附加到地图(到目前为止,文档只是关于如何自定义现有的 UI 按钮或如何添加信息气泡):

https://developer.here.com/documentation/maps/dev_guide/topics/map-controls.html

这可能吗?将不胜感激!

class H.ui.UI 应该可以帮助你到达你想到达的地方,特别是方法 addControl(name, control)。使用 HERE UI 工具包可以轻松制作出您想要的 UI 元素(即按钮)。

我已经编写了以下代码来帮助您实现您正在寻找的东西(我假设)

    //#region add new UI element

    inherits = function (childCtor, parentCtor) {
        function tempCtor() { } tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; childCtor.base = function (me, methodName, var_args) {
            var args = new Array(arguments.length - 2);
            for (var i = 2; i < arguments.length; i++) {
                args[i - 2] = arguments[i];
            }
            return parentCtor.prototype[methodName].apply(me, args);
        };
    };

    var customUI = function (opt_options) {
        'use strict'; var options = opt_options || {};

        H.ui.Control.call(this);
        this.onButtonClick = this.onButtonClick.bind(this);

        // create a button element   
        this.increaseBtn_ = new H.ui.base.Button({
            'label': '<svg class="H_icon H_icon" viewBox="0 0 25 25">' +
                '<path d="M 18.5,11 H 14 V 6.5 c 0,-.8 -.7,-1.5 -1.5,-1.5 -.8,0 -1.5,.7 -1.5,1.5 V 11 H 6' +
                '.5 C 5.7,11 5,11.7 5,12.5 5,13.3 5.7,14 6.5,14 H 11 v 4.5 c 0,.8 .7,1.5 1.5,1.5 .8,0 1.5,' +
                '-.7 1.5,-1.5 V 14 h 4.5 C 19.3,14 20,13.3 20,12.5 20,11.7 19.3,11 18.5,11 z" />' +
                '</svg>',
            'onStateChange': this.onButtonClick
        });

        //add the buttons as this control's children   
        this.addChild(this.increaseBtn_);

        this.setAlignment(options['alignment'] || 'top-right');

        this.options_ = options;
    };
    inherits(customUI, H.ui.Control);

    customUI.prototype.onButtonClick = function (evt) {
        'use strict'; if (evt.currentTarget.getState() === 'down') {
            console.log('Hollla, I am the new custom UI element.');
        }
    };

    var WaliedCheetos_CustomUI = new customUI();
    ui.addControl('WaliedCheetos_CustomUI', WaliedCheetos_CustomUI);

    //#endregion