How can I remove old markers from direction A to B <p>I'm using this <a href="http://jsfiddle.net/pYy4B/" rel="nofollow">example</a> 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 <code>gmarkers[j].setMap(null);</code> but not working.</p> <pre><code>for (var j=0; j&lt; gmarkers.length; j++) { if (boxes[i].contains(gmarkers[j].getPosition())) gmarkers[j].setMap(map); } </code></pre> <p><a href="http://stackoverflow.com/questions/24912796/google-api-v3-show-nearby-markers-on-customer-road">fiddle/original code from this question</a></p>