I want to Import Routing with OSRM in MIT App Inventor.I have the url i want to insert "https://router.project-osrm.org/route/v1/driving/22.935271,40.640063;22.948055,40.629269?overview=false&alternatives=false&steps=true" and i think i should do it with web component to call this url. This URL will calculate a driving route between two coordinates.Can anyone help me build this block so as this works?.
While asking chatgpt it says that i have to Add Components to Input Coordinates
Add two TextBox components for the user to input starting and destination coordinates (or use a LocationSensor for the device’s current location).
- Add a Button to trigger the routing process.
5. Configure Blocks to Get the Route
In the Blocks Editor, you’ll set up logic to:
-
Send a GET request to the OSRM API with the start and destination points.
-
Parse the JSON response and extract route details.
-
Display the route on a map or provide step-by-step directions.
Set the Web Component URL: -
When the button is clicked, update the
Web1.URL
property based on the coordinates entered in the TextBox components.
- Send Web Request:
- Use the Web1.Get block to send the request.
- Parse JSON Response:
- In the Web1.GotText event, you’ll receive the response. Use the
JSONTextDecode
block to parse the JSON. - Extract route steps from the JSON. The
steps
field in the response will contain a list of instructions.
- Display Directions:
- You can display the parsed directions in a Label or create a list of turn-by-turn steps.
Example Block Setup:
- On Button Click:
- Set
Web1.URL
to the OSRM API URL with user inputted coordinates. - Call
Web1.Get
.
- Set
- On Web1.GotText:
- Parse the JSON response using the
JSONTextDecode
block. - Extract the steps and display them in a Label or ListView.
- Parse the JSON response using the
Can anyone help me build this blocks ?
Thank you !