Computing Distance from GPS points in App Inventor

With App Inventor, you can create apps that use the LocationSensor to get the phone’s GPS coordinates. Some of my students have been writing apps to perform such public services as finding the closest pub from their current location. To compute this, they need to convert to GPS lat/long coordinates into a distance in miles.

To help them, I created these quick and dirty screencasts demonstrating how to find a formula on the web then convert it into an app inventor program:



9 Responses

  1. Dave:

    Trust that your weekend is sailing along.

    Thanks a mil, for doing the tutorial on distance calculation!!!

    To leverage what your tutorial teaches, by a factor of 5-10 (5-10 different locations), it appears that an AI user would have to:

    a) identify the long/lat of the given locations
    b) create a separate calculation block for each location
    c) have the single long/lat2 plug into each of calc block
    d) return the distance answer for each location


    The biggest challenge it seems, will be the UI: returning the various distances in a way, that is engaging to the app’s user.

    Thanks, again, for the tutorial. It was a great resource.

    In Service of THE ONENESS,
    Rafiki “The Digital Doctor” Cai

  2. how about an app that does this

    find the zip code of your current location using your web and GPS enabled mobile device
    By pghboemike

    • This is a nice example of a simple app that’s real easy to create in app inventor. In this case, you’d drag a LocationSensor.LocationChanged event into the blocks editor. This event will be triggered when you get a reading of your current location. The LocationSensor.CurrentAddress can be called within that event handler to give you your current street address. Remember to plug in LocationSensor.CurrentAddress into some label.text so the address (and zip code) will appear.

  3. Hi,

    Is there any way of integrating this into a Twitter app? I’m trying to develop a simple one using App Inventor but also would like to have the ‘Who Is Tweeting Nearby’ option available to users.

    Any help would be much appreciated.

  4. “Students have been writing apps to perform such public services as finding the closest pub from their current location.”

    Useless in the UK or Manhattan, I’m afraid… just turn around XD

  5. so hoe does it work if i am travelling along in a car? to calculate car journey do i need to keep calculating distance based on time? i.e gps coordinate every 5 seconds or something? also i would like to collect the data of my mileage and add it to my google calendar with the address’s to and from is this possible?

  6. How do you you calculate the driving distance?

  7. Hello Mr Dave
    Would it be possible that the text boxes gets filled upon first location and then at the stop of second location as well the boxes gets auto filled with the Coordinates then press for calculating?
    What I’m trying to do it that I’m working on an app for a transportation where the client will lunch the app and it will show his / her location address and when the input their destination ,they would click calculate trip for example and it will show the cost rather than the miles and time of the trip .
    Thank you

  8. This website is just gret. I’ve researched these
    stuffs a whole lot and I realised that is good written, easy
    to comprehend. I congratulate you for this article that I am going to recommend to the people around.

    I ask you to visit the page where each
    scholar or learner can calculate ratings grade point average levels.

    All good!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: