-1

Many other solutions like Google Maps API v3: How to remove all markers? All involve having some kind of maps array to store the map objects for later usage.

I have a situation where there is no such array to access. I can't edit the original js that makes the maps, but I can add my own script to the page.

Is it possible to retrieve all the markers after the page loads to then remove one?

Example of how markers are currently being added by framework I have to use:

        map = new google.maps.Map(document.getElementById("map_canvas"), options);
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map, 
            position: results[0].geometry.location,
                            icon:  '/pin.png',
                            title: data['store_title']
        });
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map,marker);
        });
Chris
  • 514
  • 6
  • 22

1 Answers1

0

Directly via the API it doesn't seem to be a way to do that.

If you don't have access to the array with the markers there isn't much to be done.

Lucas M.
  • 16
  • 1