Hello, i'm using the search and the route solving functions. The thing is, sometimes i can find a point on the map with the search function, but the same text can't be reused to mark the start/end point for the route solving function. Is there a solution for this ?
Thanks for you help
try to take the location from search tool and pass this as direction stop on direction widget
location is the geometry from search result
location = webMercatorUtils.webMercatorToGeographic(location);
var CoordsforStop = "" + location.x + "," + location.y +"";
directions.updateStop(CoordsforStop,1);
Thanks for your answer, but i don't really understand.
how can i get the location out of this :
var searchFrom = new Search({
map: map
}, "fromTxf");
thanks again for your help
You can use the select - results event in order to identify the selected item from the list
Search | API Reference | ArcGIS API for JavaScript 3.17
from the result take the item geometry and push it on location parameter.
something like that
require([
...
], function( ... )
on(s,'select-result', function(e) {
var location = e.geometry;
location = webMercatorUtils.webMercatorToGeographic(location);
var CoordsforStop = "" + location.x + "," + location.y +"";
directions.updateStop(CoordsforStop,1);
});
...
});
Thanks for your help it worked in the end !
glad to help you. if you want mark the question as correct answer.