I am leveraging Google Maps V3 javascript api within Ext Js 5.0.0 framework in order to display directions on a map. Everything works fine and directions are rendered and cleared perfectly except for one test case, steps described below:
Step 1.Get Directions from address 1 to address 2 (works fine and displayed on map)
Step 2.Get Directions from address 3 to address 4, 5 to 6...(n-1) to n (works fine and all sets of directions are seen on map)
Step 3. Run directionsDisplay.setMap(null) to clear all sets of directions off the map.
For this case I observe that only (n-1)->n directions are cleared off the map and the rest of the previously searched directions remain. Is there a way to clear the map completely of all directions.
Code for my clearing function is below.
resetDirections: function(){
var me = this;
Ext.getCmp('mapWidgetFrom').reset();
Ext.getCmp('mapWidgetTo').reset();
me.dirDsp.setMap(null);
me.dirDsp.setPanel(null);
document.getElementById('textDirections').style.display='none';
},
As I indicated in my comment, you are only keeping a reference to one of the
DirectionRenderer
objects. If you want to remove all the routes, you need to keep references to all of them and call setMap(null) on each one.One way:
proof or concept fiddle
code snippet: