Google Map API – Removing Markers
You need to keep an array of the google.maps.Marker objects to hide (or remove or run other operations on them). In the global scope: var gmarkers = []; Then push the markers on that array as you create them: var marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i].latitude, locations[i].longitude), title: locations[i].title, icon: icon, map:map }); // … Read more