Mapbox GL JS标记显示/隐藏

时间:2019-04-24 09:42:20

标签: filter mapbox-gl-js markers

使用Mapbox GL JS,并按照提供的示例展示如何将标记附加到地图上

for iteration in it.combinations(list_tmp, 2):
    print(iteration)

如何在点击事件中隐藏/显示不同的标记

1 个答案:

答案 0 :(得分:0)

像这样吗?

function hide() {
    let markers = document.getElementsByClassName("marker");
    for (let i = 0; i < markers.length; i++) {
        markers[i].style.visibility = "hidden";
    }
}

function show() {
    let markers = document.getElementsByClassName("marker");
    for (let i = 0; i < markers.length; i++) {
        markers[i].style.visibility = "visible";
    }
}