Push all the overlays in an array when created (as usual). Following code will clear both map and the array:
while(overlays[0]){
overlays.pop().setMap(null);
}
pop() method of an array removes the last element of an array, and returns that element. 'while' keeps that happening as long as there are elements in the array. When overlays[0] does not exist anymore, the mission is completed and code will proceed.
Applied in the example of the previous post.
5 comments:
thanks for your trick
Any suggestions on how to delete just one marker of many in v3 via a link in infowindow? I keep track by pushing marker into markers array, but can't seem to find the "index number" of the one I want to delete
Thanks
awesome! thanks
Thank-you sir! This saved me a lot of strenuous, tedious and downright useless coding and searching.
Thanks!!!
Post a Comment