Reputation: 155
I have more than 400 marker on the google map, and I use the loop to set each marker to setMap(null), but there are always a few on the google map.I then set the rest of the marker in the chrome console to setMap(null), which still doesn't work.
My code is as follows
let marker = OBJECT.CustomerList;
marker.forEach( function ( value ,index ) {
OBJECT.CustomerList[index].setMap(null);
})
Upvotes: 3
Views: 1039
Reputation: 9933
Please try this:
const mark= OBJECT.CustomerList;
for (let i = 0; i < mark.length; i++) {
(function(index){
mark[index].setMap(null);
})(i)
}
Upvotes: 1