gpt4 book ai didi

javascript - 在 Mapbox 中重置我所有的 markerLayer

转载 作者:行者123 更新时间:2023-11-30 17:55:07 24 4
gpt4 key购买 nike

我使用 Mapbox 作为 map 来显示公司的 geoLoc,我的代码是

var markerLayer = L.mapbox.markerLayer({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [value.GeoLng, value.GeoLat]
},
properties: {
title: 'A Single Marker',
description: 'Just one of me',
}
}).addTo( $.mapbox.mapObj );

我的问题是,当我收到一个新的 json 调用并返回新位置时,我不知道如何重置/删除所有旧的 markerLayer 并且它只是将所有新的添加到 map 中。

我已经创建了一个 map 对象。 width jQuery as $.mapbox.mapObj 所以我希望它可以从我的对象中重置/删除我所有的 markerLayers 并且我可以在上面添加我所有的新 markerLayers。

最佳答案

您可以重置标记层

markerLayer.clearLayers()

关于javascript - 在 Mapbox 中重置我所有的 markerLayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18204797/

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