Hi,
While implementing route and directions in my application but getting the following errors in the getRoute() functions.
Property 'solve' does not exist on type 'RouteTaskConstructor'.
Property 'route' is missing in type '{ directions: { features: any; }; }' but required in type '{ route: Graphic; }'.
Type 'number[]' is missing the following properties from type 'Color': a, b, g, r, and 7 more.
The expected type comes from property 'color' which is declared here on type 'Symbol'
Cannot assign to 'classList' because it is a read-only property.
Property 'directions' does not exist on type '{ route: Graphic; }'.
PFB the code snippet:
const getRoute = () => {
const routeParams = new RouteParameters({
stops: new FeatureSet({
features: view.graphics.toArray()
}),
returnDirections: true
});
RouteTask.solve(routeParams)
.then((data: { routeResults: { route: Graphic; }[] | { directions: { features: any; }; }[]; }) => {
data.routeResults.forEach((result: { route: Graphic; }) => {
result.route.symbol = {
type: 'simple-line',
color: [5, 150, 255],
width: 3
};
view.graphics.add(result.route);
});
if (data.routeResults.length > 0) {
const directions = document.createElement('ol');
directions.classList = 'esri-widget esri-widget--panel esri-directions__scroller';
directions.style.marginTop = '0';
directions.style.padding = '15px 15px 15px 30px';
const features = data.routeResults[0].directions.features;
features.forEach((result: { attributes: { text: string; length: number; }; }, i: any) => {
const direction = document.createElement('li');
direction.innerHTML = result.attributes.text + ' (' + result.attributes.length.toFixed(2) + ' miles)';
directions.appendChild(direction);
});
view.ui.empty('top-right');
view.ui.add(directions, 'top-right');
}
});
};