Error while getting route (using the json file and the Web component)


So I have been making an app to show route.
I had made a version of the app and was modifying it using checkpoints.

Until couple of days ago, the route was visible without any error popping up.

But now, there’s this new error yail-dividing error. I was using web component to get the route.

Kindly help.

We certainly do not know; you did not provide a Block image showing what you are doing.

  • You "made a version of the app and was modifying it using checkpoints"; you may have changed something in your latest checkpoint version of the app that causes the error. If you load a previous 'checkpoint' version; does that version run properly?
  • There are many ways to get a 'route'. Are you using the Navigate control HOW TO: Use the Navigate control or are you using a different method? In this case of 'Navigate', the route is provided by . There might be an error communicating with their server or the server is experiencing heavy usage. Since the route information is provided by volunteers, the route provided (coordinates) might have an error.
  • App Inventor 2 developers can provide something similar to using Navigate ; use the Map component but without the directions display or can use OpenStreetMap without the Map Component. Turn by turn map direction advice is also possible using the Google Directions api . Use it with a Google Map API key .

You might need to use a different method to find the route as described above. We don't know because you did not provide an example of your code Blocks. " there’s this new error yail-dividing error: is this a route different from one you tried before (different point to point - identical start and ending point)?

You posted several months ago ( Communication between two apps ) . Is this the same Project? Are you really attempting to derive a route or are you collecting geocoordinates and attempting to post the results of an actual trip on a Map component. In that case, most developers would call that collection of coordinates a trak or track. In that case LineString to draw a track might help. The example uses a LineString to plot a trak on the Map component.

Are you creating your own geojson from coordinates and plotting that using the WebViewer?


Hello Steve.

Yes, it is the same project (Communication between two apps) . Back then, I had employed the idea you gave using Web component (NOT navigate component). And it worked back then.

Now, there seems to be a problem. The app crashes and also shows another error (Permission).

I tried using Navigate component but the screen doesn’t show ANYTHING when I add it.

The concerned blocks are shown here:

blocks (2)

Kindly help.

Impossible to debug your two issues with the information provided Rohit. Since you alone have the hardware, only you can test and determine the issues. The following may help you.

  • I hope you saved a series of dated aia files. You need to load a Project that worked prior to “Until couple of days ago” in place of your current checkpoint. It is most likely your issue is due to changes you recently made in your app. You said you create checkpoints. I asked earlier for you to load an earlier checkpoint and tell us what happens? Did you try using a previous checkpoint? What happens?

  • Your latest issue (Runtime Error) is related to your use of the phone component; you didn’t show any Blocks. other than call TelefoneDatos1.NumeroTelefono. I have no idea what that does. Temporarily remove you phone blocks (make a copy first) and see if the phone permissions error persists.

  • Using Navigate is possibly inappropriate to your Project. Navigate is used to determine a route between two points and provide driving instructions etc. That is not what you are doing. You ‘drive’ a path or track and continuously plot points at an indeterminate interval. I cannot tell exactly what you are doing, you do not show your route Procedure Blocks. Possibly this

You re-calculate a ‘route’ at every LocationSensor1 LocationChanged event instead of just adding a point to the Map.
Plotting and revising the ‘route’ that way creates a LOT of points to plot. You may be getting into an area where the Map has issues plotting that many points and re plotting all the points frequently instead of just adding the most recent geocordinate. This could be part of your yail issue. Be aware, the routing service is run on donated servers and OSM policy discourages numerous calls to its server. Their servers are not intended for commercial projects and continuous calls to the server and usage. OSM might be degrading your use of the service because of too many calls. Instead, you might subscribe to the Google Directions api and pay for its usage. Google Directions are more robust (and accurate) compared to what is provided by the volunteers at OSM.

  • you use a LocationSensor, a Map component and the AdvancedLocationSensor extension. That combination of tools may be eliciting your yail divide issue (an erroneous point? can’t tell because you did not post your List of points). The issue may be a result of the ALS not correctly rendering a geocoordinate pair or something else. What does your route coordinate file look like?

  • you use a call Map.PanTo block AND a Map.CenterFrom String in the same LocationChanged event. The PanTo block frequently glitches in my opinion so it is better to use a Map.CenterFrom String. However, you certainly should not be using BOTH in the same event handler.

  • you use something called KIMS. It provides coordinates. Is this another GPS receiver or what. KIMS could be providing an erroneous data point eliciting the error.

Have you performed a DoIt debugging?

I would load a previously constructed aia of the Project, run it and see what happens. Hopefully the earlier version will work. You probably made a change in your recent checkpoint causing chaos. You have to discover the issue. Sorry I cannot be more specific. Something mentioned above is probably the cause of the issue.

It is highly unlikely this is an App Inventor 2 issue. The last update was made in April

Hello Steve,

App crashes.

This was to assign an identity to the user, since it is supposed to communicate with the application of the destination via Firebase (which is possible and working).

It's just the name for the marker.

OK I will remove one of them.

Thing is, I have been asked to show the route in the map component of app and to be free i.e. I have been asked not to use the Google API policy. I have been using the companion and testing the app for a long time. Maybe the the degrading part is happening.

Yes. This is it. This is the procedure.

So what should I do to just calculate route and show it on map using the string?

Kindly help.


It appears OSM silently changed the format of the route json. I don’t know why OSM made the change. Their changes require users to modify how their App Inventor apps extracts the distance and estimated time of travel from the json when they use the Web url http://router.project… method to extract the coordinates, distance and time estimate.

Change the code for

the theDuration and theMiles calculation as indicated on the attached Blocks. Modify your code appropriately and you should no longer get the yail error message. Developers need to change two blocks.

Did the code modifications work for you Rohit?

I will put a note into the tutorial showing the changes required to now parse the modified json route file when I get some time.

You only need to calculate the route once. You can move the route calculation out of the LocationChanged event and avoid continuous recalculation.


Not exactly. The earlier barrage of errors are not there. Instead, there is a simple error like this - yail-dividng again but smaller one. This repetitively pops up

The linestring doesn't appear nor does miles, duration data when I put it under ScreenInitialize event. I tried putting it under a clock component. The above error pops up after few moments but with the linestring, duration & distance data. When I zoomed in, the linestring was shifting slightly. and then after some alternate shifting due to position, the above error pops up.

EDIT: This error is also popping up successively when used under clock component.

Kindly help.


most likely repeats since you call the route Procedure within a timer. Do not do that. I would call the route calculation from a Button, once. Absolutely do not call route within the LocationChanged event.

The miles and time does appear; look at your Title bar, it just does not appear in the marker bubble. For a LineString to exist, the LineString must have two sets of coordinates; the present latitude and longitude AND the previous latitude and longitude. You call route somehow when you have only one latitude/longitude pair (probably because you use it in a timer event) , You call route before a second pair can be established. Take out the timer Block and you might have a better result.

I mentioned earlier "You only need to calculate the route once. You can move the route calculation out of the LocationChanged event and avoid continuous recalculation."

You said you 'put it under ScreenInitialize event'; I imagine by it you meant the call route Procedure. I can only guess because you are not sharing your code. If you call it in the screeninitialize, you call route before you have both an origin and a destination value; you have to have both.

You said "When I zoomed in, the linestring was shifting slightly. and then after some alternate shifting due to position,"; I expect the linestring will shift since you make calls to recenter the map.

If this were my problem, I would make a copy of the Project, then remove the timers and call the route Procedure from a Button from the copy and see what happens.

You adapted a tutorial for your purposes but did not realize the tutorial does things you should not do in YOUR app. You are also adapting a different tutorial (Algerian Pharmacy tutorial) that uses straight line distances to determine which, of a number of locations is the closest to you. You can do that but will have to significantly modify the code. Run the route Procedure to extract only the distance from several possible destination locations and place the distance to the locations. Do not plot the track each time you do that, you only need the track from the shortest distance location probably. Calculating the distances to several venues will probably post several tracks on the map if you use your existing code. You probably do not want to do that so will have to adapt the code to do what you want.

No one can test your app.

Experiment, make intermediate copies of your app so you can back out of new coding that might cause issues and you should be OK.

Oh. So your original issue was solved. :slight_smile: osmDistanceImage

1 Like

A number of the errors in your screenshots suggest you’re trying to manually parse the JSON response from the open route service. The Navigate component will parse this as a dictionary for you and then you can look up the right data inside of the data structure rather than the more ad hoc approach you’re taking, which is resulting in bad data going into your calculations and yielding the errors.

1 Like

Navigate could work for Rohit Evan @ewpatton .

The bad data he is experiencing is the result of his improper use of the route routine; he would get these errors using Navigation were he to call Navigate from a Timer event . He wrote his basic app prior to MIT introducing Navigation. His app correctly parses the . He does not call the Procedure properly at the moment. He will fix it without Navigate. A similar app works fine here. He took an example, modified it and got into trouble. :frowning: Navigate is not a panacea.

1 Like

Hello Steve,

Thank you for the response.

Oh silly me!

I made such a blunder there.

That was definitely a big error itself.

The errors are not there!

It works now with a button. It was not a smart move to get route without using a button. Putting it under clock was a poor move, as you said.

I will do as you have said.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.