web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Calculate distance cov...
Power Apps
Unanswered

Calculate distance covered

(0) ShareShare
ReportReport
Posted on by 15

Currently i am able to get distance covered with user clicks start and end. It gets the current location at both points and get distance.

 

How can i calculate distance if start and end points are same? If driver starts and returns to the same point? Like distance of route? 

 

 

Categories:
I have the same question (0)
  • JayMagness Profile Picture
    1,663 on at

    Hi,

     

    You would need to add weigh points so the system knows you have traveled.

     

    You could either set up a timer and capture Lat/Long as often as you feel is needed when running.

     

    Or have the users press a button to log there travels from time to time.

     

    This way the system knows you have traveld.

  • Sdhn Profile Picture
    15 on at

    @JayMagness But if user logs travel from time to time either using a button or time, the lat and long will change and wont give proper distance covered.

     

    Maybe i am wrong? Could you pls provide an example.

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Sdhn ,

    Just adding to @JayMagness 's comments, Power Apps has not been built with this in mind - You can also use Acceleration X Y and Z and I suspect there may  be a highly complex (and probably copyrighted) schema of changes in these movements in direction (as well as changes to Latitude and Longitude) to work out if you where walking/running or answering the phone/ putting it down.

  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @Sdhn :

    As far as @JayMagness said,you can use a timer control to record the user's location at regular intervals.Then use BingMaps.GetRoute to get the distance between each checkpoint, and finally add them up.

    I've made a test for your reference:

    1\Add a button and set

    OnSelect

    Set(start,!start) /*start is my variable*/

    Text

    If(start,"Stop","Start")

    2\Add a timer control and set

    Duration

    10000 /*loop in 10s*/

    OnTimerEnd

    Collect(
     StepPoint,
     {
     thepoing:Location.Latitude&","&Location.Longitude
     }
    );/*StepPoint is my custom collection for saving checkpoints*/
    If(
     CountRows(StepPoint)>1,
     Collect(
     TheDistance, /*TheDistance is my custom collection for Calculation distance*/
     {
     Value:BingMaps.GetRoute(
     First(LastN(StepPoint,2)).thepoing,
     Last(StepPoint).thepoing
     ).travelDistance
     }
     )
    )

    Repeat

    true

    Start

    start /*start is my custom variable*/

    Visible

    false /*make this control unvisible*/

    3\Add a button(Reset)

    OnSelect

    Clear(StepPoint);Clear(TheDistance)

    Text

    "Reset"

    4\Add a label control to display the distense

    Text

    Sum(TheDistance,Value)

    When the user clicks on start, the app records the current user's position every 10 seconds and calculates the distance between the user's current position and the previous position and saves it to the set TheDistance.
    Using sum to calculate the sum of Value in TheDistance can only know how much distance the user has moved after clicking start.

    In addition,I think this link will help you a lot:

    Bing Maps (Preview) 

    Best Regards,

    Bof

     

  • Sdhn Profile Picture
    15 on at

    @v-bofeng-msft This is so helpful and exactly what I was lookin for! 

    Thank you so much! 🙂

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard