Hello;
I have to insert some td html elements in the results table of the Directions dijit (version 3.22) and I need to remove the "segment-select" event of the Direction dijit.
What I want is that when I click on any of the segments of the direction table results, the map view does not move to the selected segment in the map
I have tried to do this in the direction finish event function and in the startup function of the widget but without results.
1-
var buttonHandler = on.pausable(this._dijitDirections, "segment-select");
buttonHandler.pause();
2-
var buttonHandler = on(this._dijitDirections,'segment-select', lang.hitch(this, function (evt) {
}));
buttonHandler.remove();
3-
4-
this.own(on(this._dijitDirections, 'segment-select', lang.hitch(this, function (event) {
event.stopPropagation();//and event.target.stopPropagation()
})));
Any suggestions?
Best Regard.
Solved! Go to Solution.
Alberto,
OK that is quite a bit more complicated. You have to override the Directions dijits centerAtSegmentStart function:
Add the new require to your require array:
require([
...
"dojo/Deferred",
...
], function(
...
Deferred,
...
) {
set the dijits centerAtSegmentStart override function:
directions.startup();
directions.centerAtSegmentStart = _centerAtSegmentStart;
Here is the override function:
function _centerAtSegmentStart(a) {
var b, d = new Deferred;
if (directions.directions && directions.directions.features) {
b = Math.max(0, Math.min(directions.directions.features.length - 1, a || 0));
var e = directions.directions.features[b];
directions.highlightSegment(b, !0);
directions._showSegmentPopup(e, b);
d.resolve()
} else
d.reject(Error("No directions."));
return d.promise
}
Alberto,
You can remove the listeners this way:
directions.on('directions-finish', function(){
query('.esriRoute', this._dijitDirections.domNode).forEach(function(item){
item.outerHTML = item.outerHTML;
});
});
Thank you very much Robert.
Your code works fine , but in addition to remove the segment-select event, it also removes the segment-highlight event (Fired when you hover over a route segment in the directions display.). I need to remove only the segment-select event but not the segment-highlight .
It's possible?.
Regards.
Alberto,
OK that is quite a bit more complicated. You have to override the Directions dijits centerAtSegmentStart function:
Add the new require to your require array:
require([
...
"dojo/Deferred",
...
], function(
...
Deferred,
...
) {
set the dijits centerAtSegmentStart override function:
directions.startup();
directions.centerAtSegmentStart = _centerAtSegmentStart;
Here is the override function:
function _centerAtSegmentStart(a) {
var b, d = new Deferred;
if (directions.directions && directions.directions.features) {
b = Math.max(0, Math.min(directions.directions.features.length - 1, a || 0));
var e = directions.directions.features[b];
directions.highlightSegment(b, !0);
directions._showSegmentPopup(e, b);
d.resolve()
} else
d.reject(Error("No directions."));
return d.promise
}