Google Maps API: GDirections with no Markers

I’ve been working with the Google Maps API quite a lot over the past couple of weeks, but one thing that has continuously thwarted me, has been how to remove the little Info Window maps from a route that has been loaded using GDirections and finally I have found the answer. When you load a GDirections object with the optional map panel in the constructor it automatically places the route and markers on the map. The work around is to not provide any arguments to the constructor, and instead load retrieve the GPolyline with the getPolyline method and the getPolyline: true option. Then in the “load” event, add it to the map and presto.


var dirs = new GDirections();
GEvent.addListener(dirs, "load", function() {
var polyline = dirs.getPolyline();
map.addOverlay(polyline);
});
dirs.loadFromWaypoints("Directions from here to there", {getPolyline: true});