# How Do I calculate total distance from a group of inputs?

Hello.

I am using @AliFarahat google maps extended plugin and hit a wall. I can’t figure out how to get a total(sum) for ‘distance and duration’. I have the each leg’s distance and duration saved in 9 different inputs but I cannot get the total distance of these 9 inputs into 1 input/text. The user can remove/change a leg which changes the total distance dynamically. How should I proceed?

Bump - Still am not able to figure this out - Any suggestion is appeciated. I’ve tried custom states, I’ve tried ‘distance value’ instead of ‘distance text’ to no avail. I truly am stumped. SOS!!

Hey There,

Can you share an example in the app editor so I can have a look?

Hi Ali,

Thanks for getting back to me. Pasted below is an example of what I am having trouble with. The goal is to calculate the total distance between each leg and have that amount (the total) display in the ‘i_total_distance’ field and also saved in the database as I will, each quarter, have to pay certain taxes on the amount of total distance travelled. I feel like the solution is something simple that’s been overlooked.

( As suggested, I’ve removed the link to the editor because my API key was visible.) I have sent you a DM @AliFarahat
Thanks again for getting back to me.

Thank you, I was thinking of deleting the key after a possible solution, but you’re right I should PM Ali.

The API key you had attached was not working, or billing was not available / attached. So i prepared an example on my own app here.

1 Like

Phenomenal - this works exactly the way I need it to. Big ups to Mr Ali and the awesome bubble community.

2 Likes

Hi Ali. Hope you’re having a great week.

I tested (on your website) the distance calculator. I had put in 5 locations and the value it gave me was the same distance as in google maps - awesome!! - but it only started calculating after the 3rd inputted location… You’re probably working on it but this is great progress! Eagerly waiting your reply!

This topic was automatically closed after 70 days. New replies are no longer allowed.