trantuanvn / jquery-ui-map

Automatically exported from code.google.com/p/jquery-ui-map
0 stars 0 forks source link

Enhancement request: clear directions #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be great to see a method to clear directions once they are rendered on 
the map (in my projet I have button to switch between location markers and 
directions : going back to markers after directions still shows the route, 
which is annoying). It's a small addition to the code but it would definitely 
be useful.
I guess the code would look like:

var clearDirections = function() {
 var a = this.get('services > DirectionsRenderer');
 if (a) {
   // see below what that does
   a.setMap(null);
   a.setPanel(null);
 }
}

From the GMap API:

google.maps.DirectionsRenderer class
- setMap(map:Map)    Pass null to remove the directions from the map.
- setPanel(panel:Node)  Pass null to remove the content from the panel.

Original issue reported on code.google.com by christop...@gmail.com on 1 Sep 2011 at 11:54

GoogleCodeExporter commented 8 years ago
Until this will be accepted you can add this snippet to the extensions file. 
Then if it will be immplemented and you would update to eg. beta the syntax 
would work and you could remove that extension. The jquery.ui.map.extensions.js 
works both as a bug fixer, custom client implementations and request impl 
without changing the core code.

clearDirections: function() {
    var a = this.get('services > DirectionsRenderer');
    if (a) {
        a.setMap(null);
        a.setPanel(null);
    }
}

Original comment by johansalllarsson on 1 Sep 2011 at 12:44

GoogleCodeExporter commented 8 years ago
That works great, cheers!

Original comment by christop...@gmail.com on 1 Sep 2011 at 12:55

GoogleCodeExporter commented 8 years ago

Original comment by johansalllarsson on 20 Oct 2011 at 5:45