2017-08-05 136 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

相關問題