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});

35 thoughts on “Google Maps API: GDirections with no Markers

  1. great solution. i’ve been having the same problem. however, i had always managed to fix it with the following actions: control + f5 . presto.

  2. Hey Good answer. An annotated code fragment or a link would be useful as your long paragraph is hard to decipher

  3. Something like this:

    var gDir;
    var map;
    function load() {
    if (google.maps.BrowserIsCompatible()) {
    gDir = new GDirections();
    gDir.loadFromWaypoints(mywaypoints, {getPolyline: true});
    GEvent.addListener(gDir, “load”, onGDirectionsLoad);

    //also init map
    }
    }
    function onGDirectionsLoad(){
    map.addOverlay(gDir.getPolyline());
    }

  4. How do you also add the directions? (as well as the polyline)

    I want to use your method because I don’t want any markers to be displayed.

    Thanks.

  5. Thanks for this Michael, saved me loads of time.

    Jonny,

    Try this

    var gDir=new GDirections(null, document.getElementById(“directions”));

    passing null still means no Markers, but passing the id of your directions container element
    will populate teh directions text in there. Hope that helps someone else do what I needed to do.

  6. Awesome solution I have been trying to get rid of the Marker but could not & was finding alternative soluntion & this works excellent

  7. Ι’m really inspired along with your writing skills as well as with the structure in your blog. Is this a paid subject or did you modify it your self? Anyway stay up the nice quality writing, it is uncommon to look a great weblog like this one these days..

  8. I found your blog website on google and verify a few of your early posts. Proceed to keep up the superb operate. I just further up your RSS feed to my MSN Information Reader. Looking for forward to studying extra from you in a while!…

  9. Pingback: Autoapprove List

  10. Wonderful work! That is the tyρe of information that are meant to be shared across the net.
    Disgrace on the search engines forг no longer positioning tis
    publiѕh upper! Come on over and seeк advice from my site .
    Thank you =)

  11. I know this if off topic but I’m looking into starting my own weblog and was curious what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet smart so I’m not 100% positive. Any recommendations or advice would be greatly appreciated. Kudos

  12. Very good blog you have here but I was curious if you knew of any forums that cover the same topics discussed in this article? I’d really like to be a part of community where I can get comments from other experienced people that share the same interest. If you have any suggestions, please let me know. Kudos!

  13. If you head to Megaton, youu can find the church foor
    the Kids of the Atom, spiritual people who worship the undetonated nucler bomb which Megaton is
    built around. There is a priest who shall be near
    the bomb or of theiir constructing. Speak to him and he’ll ask foor
    donations.

  14. i’ve two hues within the vintage quite short world of warcraft goldAqua together with Fuschia Pink coloured i adore that daylight with the different shades pretty feminine and stylish personally. we reccommend common quick to any individual, you possibly can create them jeans and additionally short, they search genuine very good along with toned washed shorts :) internet marketing going to get virtually all brilliant colorations inside the bailey button model.individuals are actually hottt!

  15. I simply want to tell you that I’m new to blogs and really savored you’re web site. Most likely I’m planning to bookmark your site . You absolutely come with awesome well written articles. Thanks for revealing your web-site.

  16. Among Mary Frances’s array ” nike air max 90 white leather women” of lovely handbags is “The Bombshell,” an evening bag that is a style all its own. It includes a strap around the wrist that allows you to move your hands and a freer range of motion while still ” nike air max 90 white leather women” maintaining the classic elegance of the evening bag. The bag’s beaded design incorporates seed beads, rhinestones, and dangling beads in Brown and beige tones which ” nike air max 90 white leather women” create a stunning and elegant formal look.This year, she took home the stars and stripes, winning the Junior National Championship Time Trial with a fantastic ride. She then went on to win the bronze medal in the time trial at the Junior World Championships.After reviewing the menu, I would guess ” nike air max 90 white leather women” that it was the mushroom demi glace, though OG thought he detected a touch of sweetness that his sauce didn’t have.

  17. http://www.abccleaning.ie The initial consultation provides you with the opportunity of figuring out your comfort level with the surgeon. You must be able to communicate well with your surgeon so that he/she has a clear idea of your requirements. This in turn has an impact on the results achieved. A surgeon working with excellent awareness of patient requirements can provide better aesthetic results. After determining the procedures best suited for you, the surgeon will show you before and after photographs of previous patients who have undergone plastic surgery procedures. This will help in understanding more about the results you can expect. Cost estimates of the procedure will also be given to you.www.abccleaning.ie
    the north face black friday

  18. Venue sense of comfort and rapid response favorably to any pair of shoes the whole palm zoom technology) outsole of the shoe using artificial rubber compressed into the crystal rubber, the whole bottom of the transparent color, abnormal beautiful, shoes with a reticular fibers , making the whole greatly reduce the weight of shoes.
    chanel black pumps

  19. Hey There. I found your blog the use of msn. That is a really well written article. I will be sure to bookmark it and return to read extra of your helpful information. Thank you for the post. I’ll certainly return.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>