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}