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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Bing Maps (GetLocation...
Power Apps
Answered

Bing Maps (GetLocationByAddress and Distance)

(0) ShareShare
ReportReport
Posted on by 34

I am attempting to build a school district bus stop locator app that works the same way as a store locator app.

 

I am using instructions on this article to display the address on a Bing Map in my Power App via Image Control. This is working correctly.

 

I then have a gallery with all the bus stops. There is a column for latitude and a column for longitude. I'm using this column to calculate the distance, which I added as a new field in the gallery:

 

ACOS(Cos(Radians(90-DeviceLat))*Cos(Radians(90-ThisItem.Latitude))+Sin(Radians(90-DeviceLat))*Sin(Radians(90-ThisItem.Latitude))*Cos(Radians(DeviceLong-ThisItem.Longitude)))*6371

I don't want it to be DeviceLat or DeviceLong, but instead, use the Lat and Lon of the location entered in the text box (txtLocation).

 

I'm attempting to use this formula in a text input on a hidden page (the same one I configured to create the Bing Maps Image Control): BingMaps.GetLocationByAddress({addressline:txtLocation.Text, locality:"Houston,TX", countryRegion:"USA"}).point.coordinates.latitude

 

This is returning errors.

 

Is there a way I can create Latitude and Longitude fields from the txtLocation box so that I can accurately calculate the distance? Is there an easier way to do what I'm trying to do?

 

 

Categories:
I have the same question (0)
  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Kat_YESPrep

    I suggest you try  GetRoute function to calculate the distance .

    For example:

    Set(dist, BingMaps.GetRoute("San Francisco, CA", "Los Angeles, CA"))

    And after clicking the button you can get the distance by accessing the properties in the dist variable, for example, in the Text property of a label:

    "Distance: " & dist.travelDistance & " " & dist.distanceUnit

     

    Here's a similar issue for your reference:

    https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Calculate-distance/m-p/54895

     

     

    Best regards,

  • Kat_YESPrep Profile Picture
    34 on at

    Thanks so much! That was very helpful.

     

    Is there a way to sort by the distance value? It's not found on any table, as it's a calculated value.

     

    Is there also a way to filter my gallery based on the distance value, if that is a calculated value, and not found on a table?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 519 Most Valuable Professional

#2
11manish Profile Picture

11manish 489

#3
Haque Profile Picture

Haque 327

Last 30 days Overall leaderboard