Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8236349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:06:23+00:00 2026-06-07T19:06:23+00:00

I use GMAP3 plugin to render driving direction. And would like to add a

  • 0

I use GMAP3 plugin to render driving direction. And would like to add a clear button so it can be clear but I haven’t been able to find the right syntax in GMAP3. Here is the my js code, modified from the sample in gmap3.net. I have markers plotted already and latlng are retreived from plotted markers instead of from clicks position on the map.

function removePath() {
    $(mapID).gmap3({
        action: 'clear',
        name: 'directionRenderer'
        // tag: 'path'  // works too with tag instead of name
});

function updatePath() {
$(mapID).gmap3({
    action: 'getRoute',
    options: {
            origin: m1.getPosition(),
            destination: m2.getPosition(),
            travelMode: google.maps.DirectionsTravelMode.DRIVING
    },
    callback: function (results) {
            if (!results) return;
            $(mapID).gmap3({ 
                action: 'setDirections', 
                directions:results,

            });
    }
});
};

function updateDirection(mm) { // Directions between m1 and m2
var mmID = $(mm).prop('id');
...
if (mmID == 'clearDirection') {
...
    removePath();
    return;
};
...
if (m1 && m2) { updatePath(); };    
};

function initmap() {
    $(mapID).gmap3(
        {
        action: 'init',
        options: defaultMapOptions
        },
    // add direction renderer to configure options (else, automatically created with default options)
        {   action: 'addDirectionsRenderer',
        preserveViewport: true,
        markerOptions: { visible: false },
        options: {draggable:true},
        tag: 'path'
        },
    // add a direction panel
        {   action: 'setDirectionsPanel',
        id: 'directions'
        }
    );

};

A is in place in HTML documents as directions panel. It has a a wrapper which is hidden when the route is cleared by using jquery css property change. The wrapper div’s display property is changed back to ‘block’ whenever value is assigned to either m1 or m2.

<body> 
...
<div id="direction_container" class="shadowSE">
    ....
    <div id="directions"></div>
    ....
</div>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:06:24+00:00Added an answer on June 7, 2026 at 7:06 pm

    Its absolutely working fine.

    $map.gmap3({ action: 'clear', name: 'directionRenderer' });
    

    *Instructions-
    If you later draw the route then you must write below code otherwise directions not display.

    $map.gmap3({ action: 'addDirectionsRenderer', preserveViewport: true, 
    markerOptions: { visible: false} }, 
    { action: 'setDirectionsPanel', id: 'directions' });
    

    Thanks…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

to clear markers from google maps I use: mapContent.gmap('clear', 'markers'); But what if I
I'm trying to use the GMap.NET.WindowsForms control in my Windows forms application but I
I know with the use of gmap v3 i can give the center, and
I'd like to use jQuery with Google maps. I'm trying to replicate this example
I want to add a google map(with street view) in my site. I use
Last time I have noticed problem with google maps cluster. I use gmaps4rails plugin
We use this script to show Gmap, but I cannot for the life of
I want to use this jquery plugin in my rails3 apps http://gmap.nurtext.de/ (Google Maps
i have a city ALMA but it can be more then 5 in the
Using Gmaps.map.replaceMarkers() I can replace entire marker set. But in my application I will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.