Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear google map marker cache in javascript?

Tags:

javascript

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);

 })
like image 622
LiJing Avatar asked Mar 31 '26 01:03

LiJing


1 Answers

Please try this:

const mark= OBJECT.CustomerList;
for (let i = 0; i < mark.length; i++) {
          (function(index){
              mark[index].setMap(null);
          })(i)
  }
like image 84
Shubham Verma Avatar answered Apr 02 '26 03:04

Shubham Verma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!