Ok, so I have a google Map store locator. Input a post code, it returns stores in a radius. Got all these pretty info windows, marker icons, and can even do directions…
In a nutshell, I need to be able to HIDE (which I can do) all the markers before I calculate directions (because the directions api seems to automatically add its own markers which I have no idea how to override).
At the moment I’m using the following to HIDE the markers. This works 100%. It sets the visible value of the marker to false in the DOM tab of firebug and the marker icons disappear.
function clearMarkers() {
for (var i = 0; i < markers.length; i++) {
markers[i].setVisible(false);
}
}
Now, my issue is I cannot SHOW OR unhide the markers. This is my current function. I can still click on my listing of stores and it pops up the markers infoWindow, BUT the marker just doesn’t appear once its been hidden. Can anyone help me in unhiding the marker ICON in this restoreMarkers function?
function restoreMarkers() {
for (var i = 0; i < markers.length; i++) {
markers[i].setVisible(true);
}
markers.setMap(map);
}
Without having tried it I can think of one possible thing that could go wrong. Is it possible that the directionsrenderer places another layer on top of the map that hides all the markers? Have you tried removing it to see whether that would bring back the markers?
I have used the setVisible(true) many times without any problems, so if the directionsdisplay is not the problem I am at a loss. Any chance you could link to the homepage where the code runs so we could try it out?