Hello,
I'm using the Directions widget in version 3.20 of the API:
Directions | API Reference | ArcGIS API for JavaScript 3.20
Is it possible to prevent the zoomToFullRoute() method from being called after the route is calculated? I would like to keep the map at its current extent instead of automatically zooming in/out to the calculated route.
Thanks,
Solved! Go to Solution.
Max,
try overriding the Directions class like this:
var NoZoomDirections = declare(Directions, {
zoomToFullRoute: function () {
console.log("overriding zoomToFullRoute");
}
});
var directionsWidget = new NoZoomDirections(/*... the usual instantiation */);
Works for me. I only get the console message, not the zoom.
If you want to have the zoomToFullRoute() functionality in some cases, you'd need to add
this.inherited(arguments);
into the new function body along with a conditional statement.
About what you and Robert Scheitlin, GISP said about when the map is automatically zoomed in or not: I've had exactly that issue and described it here: Zoom button and auto zoom in Directions widget. Maybe you could take a look at it and verify the problem.
Cheers,
Nik
Max,
I am not seeing the map zoom to the calculated route unless I click on the route directions results.
Hi Robert,
This sample shows an example:
ArcGIS API for JavaScript Sandbox
After two cities are entered, the list of steps is populated and the map zooms in to the full extent of the route. I was wondering if it is possible to show the steps and highlight the route on the map, but leave the map extent as is.
Cheers,
Max,
try overriding the Directions class like this:
var NoZoomDirections = declare(Directions, {
zoomToFullRoute: function () {
console.log("overriding zoomToFullRoute");
}
});
var directionsWidget = new NoZoomDirections(/*... the usual instantiation */);
Works for me. I only get the console message, not the zoom.
If you want to have the zoomToFullRoute() functionality in some cases, you'd need to add
this.inherited(arguments);
into the new function body along with a conditional statement.
About what you and Robert Scheitlin, GISP said about when the map is automatically zoomed in or not: I've had exactly that issue and described it here: Zoom button and auto zoom in Directions widget. Maybe you could take a look at it and verify the problem.
Cheers,
Nik
Thanks Niklas, this works for me. Hopefully the manual zoom button is added again as an option.