简体   繁体   中英

how to clear google map marker cache in 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);

 })

Please try this:

const mark= OBJECT.CustomerList;
for (let i = 0; i < mark.length; i++) {
          (function(index){
              mark[index].setMap(null);
          })(i)
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM