Calculate a distance between two points

Hello Koders, I hope you are all doing well!

A few days ago, someone asked me :

How can we calculate a distance between two points with Kodular?

I then replied that I had made an application a year ago (with Thunkable :thunkable: , when I didn’t know Makeroid :makeroid: yet) and that I could then help him.

But I wanted to do more, I thought :

Maybe other people are wondering how to do it, so why not do a little tutorial?

That’s why, today I’ll show you How to calculate a distance between two points


In order to do this, you’ll need :

  • Your brain :brain:
  • Location_sensor component
  • Notifier component
  • Buttons
  • Text boxes
  • Labels
  • Design imagination

So let’s begin !

  1. Current location :

If your Location sensor is not working (not activated), the calculation won’t work so we need to verify it.

Capture

If the Location sensor isn’t activated, it will display this notification :

You can put your departure address by yourself, or a button will give it to you :

Capture

  1. Arrival address :

You have to put your arrival address, its no big deal juste make sure to write it correctly !

  1. The calculation system

I didn’t invented the formula, I just found it on a forum (sorry I lost the link, it was 1 year ago) and tried to reproduce it with blocks. You can try to understand it if you want :stuck_out_tongue: but it’s not necessary.

This procedure is called after a click on the button “Calculate distance”

As you can see, the arrival is an address and can’t be coordiwnates.

Let’s verify on Google Maps if I haven’t cheated !

Mmm there is a (little : 42 kilometers) difference between what Google Maps is telling me and what my app is. Why ?
Because the distance calculated with the app is linear, it doesn’t take into account all the curves, etc…
And that’s the problem with this method…

Voilà, I think that’s all !
I don’t know if this little tutorial will help you (I didn’t know how to write it).

I share you the aia of course and if you have any question, I will answer them with pleasure :slight_smile:

Calculate_distance.aia (22.4 KB)

11 Likes

Could you please not use white font? :sweat_smile:

1 Like

Sorry I was using dark theme !

1 Like

Exactly. :joy:

2 Likes

Excellent! This is exactly what I need for my application on drone delivery for my exams! Thank you very much !

Hey @Stiaen

image
I need something:

  • Either the customer uses the automatic location to find his address (I need a method that finds the address from the coordinates)
  • Either the customer enters or even his address (which must therefore be converted into coordinates)

Do you have any idea how to do that?

Thanks !

EDIT : I’ve find it, its in the location component :slight_smile:

error while downloading the aia

1 Like

same… here… aia not available to dl

1 Like

and anyway, it doesn’t work for me :confused: I get more than 9000 meters, in the reality it is 15

this calculation is wrong. i have also used this method but it calculates different than real. because with this mehtod it calculates the direct distance which such a ruler. then i started to use google matrix api

@Stiaen already told that in his first post.

sorry, i have not seen that

I’ll try it. Thanks.

1 Like

download aia failure?

1 Like

error while downloading the aia

You can just copy the blocks. A good way to learn the blocks.

1 Like

error while downloading the aia, could you please share aia file

Already answered for error in aia

This post was flagged by the community and is temporarily hidden.

sorry can send aia