cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PurpleHaze
Regular Visitor

How do I calculate mileage?

Hi. I'm quite new to using PowerApps.

I'm working on a simple app where you create records to store in a Sharepoint list.

Three of the columns in each record would be "Travelling From", "Destination" and "Mileage".

 

The former two are Location type columns and Mileage is meant to be the distance, in miles, automatically calculated between

these two locations. I enter my starting and destination locations on my PowerApp, it calculates the mileage between them

and stores it in the record with them. Once I submit the form, a new item is created with that data in the Sharepoint list.

 

The question is how do I make that calculation?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi@PurpleHaze,

Based on the issue that you mentioned, do you want to calculate the distance between two locations?

Actually, the Location column is not the most efficient choice, you can just add three Text columns in your SP list to be filled with "Travelling From", "Destination" and "Mileage".

In general, we use the Bing Map connector to locate and calculate distance. Yes, @jlindstrom provides the correct direction.

Add a Button and set the OnSelect property as below.

Set(
    Dis,
    BingMaps.GetRoute(
        TextInput1.Text,
        TextInput2.Text,
        {distanceUnit: "Mile"}
    )
)

Set the Text property of the corresponding "Mileage" control as below

Dis.travelDistance & " " & Dis.distanceUnit

002.png

Best Regards,

Qi

Best Regards,
Qi

View solution in original post

6 REPLIES 6

Use the Bing Maps connector.

You will need to go to https://docs.microsoft.com/en-us/bingmaps/getting-started/bing-maps-dev-center-help/getting-a-bing-m... and get an api key

 

Once you have that, you can use the following expression to get the mileage between two locations

 

    BingMaps.GetRoute(
        TextInput1.Text,
        TextInput2.Text,
        { distanceUnit: "Mile" }).travelDistance

 

Thanks. But are there any other map services I can use?

Not as standard connectors but you can write a custom connector to any rest based API. Does Bing Maps not recogize your location?

I hadn't tried it yet, I'm just wondering why Bing seems to be the only option when there's also Google Maps.

v-qiaqi-msft
Community Support
Community Support

Hi@PurpleHaze,

Based on the issue that you mentioned, do you want to calculate the distance between two locations?

Actually, the Location column is not the most efficient choice, you can just add three Text columns in your SP list to be filled with "Travelling From", "Destination" and "Mileage".

In general, we use the Bing Map connector to locate and calculate distance. Yes, @jlindstrom provides the correct direction.

Add a Button and set the OnSelect property as below.

Set(
    Dis,
    BingMaps.GetRoute(
        TextInput1.Text,
        TextInput2.Text,
        {distanceUnit: "Mile"}
    )
)

Set the Text property of the corresponding "Mileage" control as below

Dis.travelDistance & " " & Dis.distanceUnit

002.png

Best Regards,

Qi

Best Regards,
Qi

the connectors in Power platform are based on what those companies want to expose via Power Platform connectors. They own them. Google is a competitor to Microsoft and has a competitive app/forms product. they have recently restricted many of the existing google services connectors.

 

the bing maps connector works well.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,001)