gpt4 book ai didi

dictionary - 从mapbox map 中删除所有标记或重新初始化 map

转载 作者:行者123 更新时间:2023-12-02 09:45:12 24 4
gpt4 key购买 nike

我正在使用下面的代码向 Mapbox map 添加标记。

var marker = L.marker([latitude, longitude],
{
icon: L.divIcon({
html: 'myhtml',
iconSize: [40, 40]
})
});
marker.addto(map);

我使用上面的代码使用 for 循环添加了标记。现在我想删除标记以刷新 map 。我可以从 map 上删除所有标记和折线吗?或者如果有什么方法可以重新加载mapbox map 。

最佳答案

您可以使用map.removeLayer(marker);删除标记(ILayer 对象)。

此外,addto(map) 应该是 addTo ;)

关于dictionary - 从mapbox map 中删除所有标记或重新初始化 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22960139/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com