1

我使用 Mapbox 作为地图来显示公司 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,它只是将所有新的添加到地图中。

我已经创建了一个地图 obj。宽度 jQuery,$.mapbox.mapObj所以我希望它可以从我的对象中重置/删除我所有的 markerLayers,我可以在它上面添加我所有的新 markerLayers。

4

1 回答 1

2

您可以使用重置标记层

markerLayer.clearLayers()
于 2013-08-13T12:17:32.343 回答