Hi
I'm working on a navigation app. I have noticed that sometimes there is a divergence between the map and Route plan. Clearly, you can see this in attached pictures, can someone shed some light why this is happening?
My QML code:
RouteTask <SPAN class="punctuation token">{</SPAN>
id<SPAN class="operator token">:</SPAN> routeTaskOnline
url<SPAN class="operator token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Froute.arcgis.com%2Farcgis%2Frest%2Fservices%2FWorld%2FRoute%2FNAServer%2FRoute_World" target="_blank">http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World</A><SPAN>"</SPAN></SPAN>
Credential <SPAN class="punctuation token">{</SPAN>
oAuthClientInfo<SPAN class="operator token">:</SPAN>oAuth
<SPAN class="punctuation token">}</SPAN>
onLoadStatusChanged<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>loadStatus <SPAN class="operator token">==</SPAN><SPAN class="operator token">=</SPAN> Enums<SPAN class="punctuation token">.</SPAN>LoadStatusLoaded<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Route task ready"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
routeTaskOnline<SPAN class="punctuation token">.</SPAN><SPAN class="token function">createDefaultParameters</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
onCreateDefaultParametersStatusChanged<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>createDefaultParametersStatus <SPAN class="operator token">==</SPAN><SPAN class="operator token">=</SPAN> Enums<SPAN class="punctuation token">.</SPAN>TaskStatusCompleted<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
routeParameters <SPAN class="operator token">=</SPAN> createDefaultParametersResult<SPAN class="punctuation token">;</SPAN>
routeParameters<SPAN class="punctuation token">.</SPAN>returnRoutes <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">true</SPAN><SPAN class="punctuation token">;</SPAN>
routeParameters<SPAN class="punctuation token">.</SPAN>returnDirections <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">true</SPAN><SPAN class="punctuation token">;</SPAN>
routeParameters<SPAN class="punctuation token">.</SPAN>directionsDistanceUnits<SPAN class="operator token">=</SPAN>Enums<SPAN class="punctuation token">.</SPAN>UnitSystemMetric<SPAN class="punctuation token">;</SPAN>
routeParameters<SPAN class="punctuation token">.</SPAN>directionsLanguage<SPAN class="operator token">=</SPAN><SPAN class="string token">"PL"</SPAN>
routeParameters<SPAN class="punctuation token">.</SPAN>travelMode<SPAN class="punctuation token">.</SPAN>outputGeometryPrecision<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN>
routeParameters<SPAN class="punctuation token">.</SPAN>outputSpatialReference <SPAN class="operator token">=</SPAN> SpatialReference<SPAN class="punctuation token">.</SPAN><SPAN class="token function">createWebMercator</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
onErrorChanged<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Route Error:"</SPAN><SPAN class="punctuation token">,</SPAN> JSON<SPAN class="punctuation token">.</SPAN><SPAN class="token function">stringify</SPAN><SPAN class="punctuation token">(</SPAN>routeTaskOnline<SPAN class="punctuation token">.</SPAN>error<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
onSolveRouteStatusChanged<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>solveRouteStatus <SPAN class="operator token">==</SPAN><SPAN class="operator token">=</SPAN> Enums<SPAN class="punctuation token">.</SPAN>TaskStatusCompleted <SPAN class="operator token">&&</SPAN> solveRouteResult<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">for</SPAN> <SPAN class="punctuation token">(</SPAN>var index <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> index <SPAN class="operator token"><</SPAN> solveRouteResult<SPAN class="punctuation token">.</SPAN>routes<SPAN class="punctuation token">.</SPAN>length<SPAN class="punctuation token">;</SPAN> index<SPAN class="operator token">++</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"add route graphics idx:"</SPAN><SPAN class="operator token">+</SPAN>index<SPAN class="punctuation token">)</SPAN>
route <SPAN class="operator token">=</SPAN> solveRouteResult<SPAN class="punctuation token">.</SPAN>routes<SPAN class="punctuation token">[</SPAN>index<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
routeGraph <SPAN class="operator token">=</SPAN> ArcGISRuntimeEnvironment<SPAN class="punctuation token">.</SPAN><SPAN class="token function">createObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Graphic"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN>geometry<SPAN class="operator token">:</SPAN> route<SPAN class="punctuation token">.</SPAN>routeGeometry<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
routeGraph<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">.</SPAN><SPAN class="token function">insertAttribute</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"route"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
graphicsOverlay<SPAN class="punctuation token">.</SPAN>graphics<SPAN class="punctuation token">.</SPAN><SPAN class="token function">append</SPAN><SPAN class="punctuation token">(</SPAN>routeGraph<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
directionListModel <SPAN class="operator token">=</SPAN> route<SPAN class="punctuation token">.</SPAN>directionManeuvers<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">else</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>solveRouteStatus <SPAN class="operator token">==</SPAN><SPAN class="operator token">=</SPAN> Enums<SPAN class="punctuation token">.</SPAN>TaskStatusErrored<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Route error"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
Component<SPAN class="punctuation token">.</SPAN>onCompleted<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN>
routeTaskOnline<SPAN class="punctuation token">.</SPAN><SPAN class="token function">load</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Pictures:



Best Regards
Marek