突出显示Google地图api中最后单击的按钮

highlight the last clicked button in google maps api

本文关键字:最后 单击 按钮 api 显示 Google 地图      更新时间:2023-09-26

我添加自定义div元素到我的谷歌地图使用代码从这里http://code.google.com/apis/maps/documentation/javascript/controls.html#CustomExample我有3-4个按钮,我如何突出最后点击?

添加一个classname到所有自定义按钮的控件边框,然后再添加。例如:

controlUI.className = 'button';

添加一个功能来突出显示当前自定义按钮:

function hightlightButton(oElement) {
    var aButtons = document.getElementsByClassName('button');
    for (var i = 0; i < aButtons.length; i++) {
        aButtons[i].style.backgroundColor = "white";
    }
    oElement.style.backgroundColor = "yellow";
}

在单击处理程序中添加以下行来调用新函数:

hightlightButton(this);