mapbox remove marker

Solutions on MaxInterview for mapbox remove marker by the best coders in the world

showing results for - "mapbox remove marker"
Elizabeth
30 Oct 2019
1// markers saved here
2var currentMarkers=[];
3
4// tmp marker
5var oneMarker= new mapboxgl.Marker(currentMarkerDiv)
6    .setLngLat(marker.geometry.coordinates)
7    .addTo(mapboxMap);
8
9// save tmp marker into currentMarkers
10currentMarkers.push(oneMarker);
11
12
13// remove markers 
14if (currentMarkers!==null) {
15    for (var i = currentMarkers.length - 1; i >= 0; i--) {
16      currentMarkers[i].remove();
17    }
18}