Help with navigation trhough Google Maps

A few months ago there was a Petrol shortage in the UK and I tried to design an app that would help people to find out those stations with petrol supplies. The idea behind this app is to share this information so people in need of petrol can fill their tanks without the hassle of visiting different stations until they find one with enough petrol supply.
A user who has found petrol sends the station’s longitude and latitude to a Google Spreadsheet. When a person is looking for petrol she/he retrieves the station’s information and then it is displayed in a ListView. When a user selects their favorite choice Google Maps displays the route to follow.
I have been able to get this behavior though my logic is always using the set of coordinates of the last station data in the Google Spreadsheet for all the elements in the ListView, so no matter what station is selected the route to follow is always the one corresponding to the last station. I have tried several solutions but so far none has helped me to solve this problem.
Could someone please be so kind to suggest a possible solution to this issue?
Here are my blocks and mu .aia file
iNeedPetrol.aia (21.4 KB)

Welcome back Alberto to your discussion in this post App Inventor Capabilities(Is it possible to make an app to find out if gas stations are open and have gas using App Iinventor?) - #18 by Alberto_rojas_lefort

I shared some code with you in September that 'requests' a Google route to the selected coordinates of the data in the ListView. That doesn't work?

I'll look at your aia when I get a chance.

1 Like

Serious issues that result probably from timing issues and complex code.

This code in the ListView uses your first four locations and

works:

Your code does not render the correct latitude/longitude in the &daddr= destination in the ActivityStarter Data uri in your Blocks. This code does.


Your ListView contains this stuff:

Do It Result: ["Posted on: 10:50:34

WAITING TIME
1 Hours 0 Minutes

Latitude: 28.68049
Longitude: -105.1324

Station located at:
Sample

Petrol Brand: ESSO"]

TAKE ME THERE

", "Posted on: 10:50:34

WAITING TIME
0 Hours 5 Minutes

Latitude: 28.73881395
Longitude: -106.1438568

Station located at:
Test

Petrol Brand: SHELL"]

TAKE ME THERE

", "Posted on: 10:50:34

WAITING TIME
0 Hours 5 Minutes

Latitude: 28.698467813621956,
Longitude: -106.036393

Station located at:
Test

Petrol Brand: SHELL"]

TAKE ME THERE

", "Posted on: 10:50:34

WAITING TIME
0 Hours 5 Minutes

Latitude: 28.62044127
Longitude: -106.0089309

Station located at:
Test

Petrol Brand: SHELL"]

and fails and crashes the app when exiting the route information.

Sorry, I could not find your issue.

1 Like

@SteveJG Thank you very much for your response as well for your support. This particular app is probably outdated as far as its utilization. I want to finish it since I think the purpose of it can be suited to another app that can help people in distress such as refugees or people escaping from violence or war to find food, water and medical aid. I have reached a standstill since my programming knowledge is limited but hopefully I will be able to finish it and adapt it to serve different goals. I looked at the code you sent and I couldn't use it in my app. I will try to look for a different approach to solve the ListView coordinates problem. :slight_smile:

Sorry my previous guesses did not solve your problems.

There is no ListView coordinates problem in my view. The problem is what you place in the ListView and how you handle it. These Blocks and timing issues are probably the reason your code cannot find a route;

Another issue may involve the number of decimal places you download from your spreadsheet. I had minor issues coding this new example until I limited the coordinates to five decimal places.

For whatever is worth, I attach this example and aia:


LViewRoute.aia (5.0 KB)

The ListView directs to the correct destination by clicking on the coordinates. The app also displays a Map of all the locations. Touch a red marker and the popup will display some basic information. Make a longer touch on a Marker and the app will display a route to that Marker using Google.

Perhaps there is something here that will help with you Project or your future Projects or another developer.

Good luck Alberto.

1 Like

The problem is probably solved Alberto.

needpetrolFixed

iNeedPetrol_FIXED.aia (25.2 KB)

  • I rewrote a lot of code
  • added code to ameliorate issues with your spreadsheet data (particularly see your third entry).
  • I did not delete any existing code; simply replaced the code that was not working.
  • added a new ListView and a few additional/replacement global variables
  • added a new I NEED PETROL start Button
  • used the latest ListView formatting.

Does this now work? For me, clicking on any ListView item takes you to the proper destination.

The problems were many, mostly in how you formatted your ListView. You still have inconsistent formatting in your spreadsheet that causes minor issues.

You can modify the ListView format quite easily by looking at how i used the tool.

Have fun. I only provided code for Petrol; you will need some similar code for Diesel. Hope this helps @Alberto_rojas_lefort

Thank you very much Steve, I will work on the Diesel code, once everything thing is set up I will try to adapt the app so it can be used for people in distress to help them find, food, water or shelter particularly during these rough times. :slight_smile:

2 Likes

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