I am using below code to add markers to mapbox map.
var marker = L.marker([latitude, longitude],
{
icon: L.divIcon({
html: 'myhtml',
iconSize: [40, 40]
})
});
marker.addto(map);
I have added markers using for loop using above code. Now I want to remove marker to refresh the map. Is there any was I can remove all markers and polylines from map. Or if there is any way I can reload the mapbox map.
You can use map.removeLayer(marker); to remove the marker (an ILayer object).
Also, addto(map) should be addTo ;)