I'm using this example to add markers on my direction A to B. How can I remove "old" markers, when I add new start and end points.
I try to change gmarkers[j].setMap(null);
but not working.
for (var j=0; j< gmarkers.length; j++) {
if (boxes[i].contains(gmarkers[j].getPosition()))
gmarkers[j].setMap(map);
}