views:

74

answers:

1

I'm trying to customize the icons drawn by the GDirections object. I've got a list of lat long coordinates which I use to construct a path. However, I can't find any way of customizing (or even turning off) the markers that are automatically placed by the API.

var map;
map = new GMap2(document.getElementById("map_canvas"));
.... //get the path coordinates
var route = new GDirections(map);
route.load(path_coordinates);

Calling route.getPolyline().hide() hides the path but not the markers. Calling route.getMarker(1).isHidden() returns true and obviously hiding it doesn't change anything. Is this functionality not supported by the api? I'm using map api 2.81

+1  A: 

Try this code:

var map;
map = new GMap2(document.getElementById("map_canvas"));
.... //get the path coordinates
var route = new GDirections(map);
route.load(path_coordinates);
GEvent.addListener(route , "addoverlay", hideDirMarkers); 
function hideDirMarkers(){ 
        var numMarkers = route.getNumGeocodes() 
        for (var i = 0; i < numMarkers; i++) { 
                var marker = route.getMarker(i); 
                if (marker != null) 
                        marker.hide(); 
                else 
                        alert("Marker is null"); 
        } 
}
antyrat
Thanks for the answer. I was trying the same thing but with the `load` event.
Pavel