2017-08-05 102 views
0

加载后我在此贴图上设置了具有自定义图像的标记。然后点击标记我得到泡泡弹出。点击它时,我想更改标记图标。点击它时如何更改标记图标?如何在点击此处时更改标记图标地图

单击标记后显示气泡的代码,如下所示。

map.addObject(group); 

    // add 'tap' event listener, that opens info bubble, to the group 
    group.addEventListener('tap', function (evt) { 
    // event target is the marker itself, group is a parent event target 
    // for all objects that it contains 

    var bubble = new H.ui.InfoBubble(evt.target.getPosition(), { 
     // read custom data 
     content: evt.target.getData() 
    }); 


    // show info bubble 
    ui.addBubble(bubble); 
    }, false); 

回答

0

在我的应用程序中,当点击标记时,它将更改标记的原始颜色。您是否尝试过使用markerTemplate,这意味着您将标记的svg存储为字符串的变量?

var markerTemplate = '<svg xmlns="http://www.w3.org/2000/svg" width="28px" height="36px">... fill="${COLOR}"/></svg>' 

然后,您可以使用例如fill="${COLOR}"在这个字符串,并在你的EventListner新的颜色替换该占位符markerTemplate.replace('${COLOR}', 'rgba(231, 0, 0, 0.7)');

希望这有助于

+0

感谢......... – Rakesh

相关问题