Is there a way to actually to that in its current state?
Add some stops and then query the route.
The widgets stops collection property is part of the viewModel:
I know, but when deleted and added again the widget won't make a new query with the same results.
Have you actually validated that setting the stops dynamically will solve the route and display directions? I have tried this and it does not seem to be the case. Unless there is something else I need to do besides specifying viewModel stops.
Would love your input!
Chris, No I did not test this myself. It use to work in 3.x but 4.x Directions widget is still in Beta.
We are working to add support for this in a future release. I don't currently have an ETA on when this functionality will be available.
Has there been any update on this? I'd like to use all of the nifty UI/UX interactions that come with the built-in widget, but without requiring manual input of start/end stops.
Would very much appreciate an update.
Any news on this? Is it going to be included soon?
I am also looking for a 'proper' way to programmatically add stops to the directions widget.
I am successful at adding the geometries to the ViewModel, and can route successfully, however this leaves the widget in a semi-broken state, as the search inputs and the related Directions._stops && Directions._stopsToSearches properties do not get populated, so if I change one of the stops manually in the widget (like changing the start location), ALL the programmatically entered stops get removed and only the manually entered stop is present.
for now, I am hooking into the 'after render' event with dojo's aspect.after method, and manually setting the input text value and disabling the input so the user is unable to change stops, BUT this is not going to work for my customer in the long run.
I have no problem manually performing all the steps to add the 'stop' objects to keep the ViewModel and Widget in sync, but trying to look through the minified code to determine what steps I actually need to take hasn't gotten me anywhere, as it is near impossible to tell what the parameter types are, or even the correct order to do things. Is there an engineer that can help with the required steps? Thanks!
I was exactly doing that today. The only way I found to do it is to hack a little bit the widget.
When you change the stops collection in view model it has absolutely no effect on SearchWidget view model that is embedded inside Directions widget... So, basically, you have to find SearchWidget, and run a search.
Here is a simple example using a feature geometry :
You can extend it by configuring SearchWidget view model to search inside Feature layers if needed
This little hack works on 4.10->4.12
Good luck with that until that will become a feature
Thanks for the tip Tony. Have you found a way to preset more than two search widgets? I managed to trigger the add Stop button with the _handleAddStopFocus() method but the new search widget is not included in the _stopsToSearches collection so I can not add a third stop.
Retrieving data ...