views:

341

answers:

0

Hey Guys,

I'm trying to hide the markers which are given as part of a GDirection polyline (Specifically the start and end one) as we have custom markers which are always at that location.

This is what I have tried

var gDirections = new GDirections(googleMap);
GEvent.addListener(gDirections, "load", changeGColor);

function changeGColor(){
        var gatDirectPoly = this.getPolyline();
        gatDirectPoly.setStrokeStyle ({color: "#00FF00"});
        var firstMarker = this.getMarker(0);
        //I have tried this:
        firstMarker.hide();
        //and this (I know that GMarker doesn't list a load event, but tried anyway
        GEvent.addListener(firstMarker, "load", hideMarker);
        //neither of which work. I can't find anything in the api which shows how to do this
}

function hideMarker(){
        this.hide();
}

If I do alert(firstMarker.isHidden()); in the changeGColor function then it shows true, before I even call the hide. So what I tried next was:

  var firstMarker = this.getMarker(1);
  markerHideListener = GEvent.addListener(firstMarker, "visibilitychanged", hideMarker);

However this function never triggers. Which seems odd, because surely if the marker was hidden in changeGColor, then it has to become visible to display the marker at the appropriate place along the polyline, thus the function must be called?

Anyone know how to do what I'm after? Or what I'm doing wrong?

Thanks, Psy