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 / Default fields based o...
Power Apps
Unanswered

Default fields based on current location

(1) ShareShare
ReportReport
Posted on by 43

Hi,

 

I have a list of physical assets in a SP list this includes columns for latitude and longitude as well as the address for this asset. I would like for my app to recognise my current location and use this to then pull the information from the SP list to populate a form based on that.

 

Basically use my current lat and long to match that in the SP list (I'm aware getting these to be exact matches won't really work so will have to be in the vicinity of).

 

Has anyone done anything similar and can suggest a way to make this work?

 

Thanks in advance 

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @KathrynHughes 
    For example, lets say you have an asset in your table like this called 'Assets Table'.

     

    Asset (text) Latitude (number) Longitude (number)
    Flamethrower 100.000100 50.000500

     

     

    Now place a gallery on your app's screen with this code in the Items property with some code like this.

    Filter('Assets Table',
     Latitude + 0.000100 >= Location.Latitude
     And Latitude - 0.000100 <= Location.Latitude
     And Longitude + 0.000100 >= Location.Longitude
     And Latitude - 0.000100 <= Location.Latitude
    )

     

    You'll want to adjust the numbers according to the range you want to find assets within.

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • tgibso2 Profile Picture
    11 on at

    Hi Kathryn,

     

    I've developed something similar. I have a SharePoint list with the location name, latitude and longitude. I import this into a collection using:

    ClearCollect(Collection1, 'SharePoint List');

     

    From there I add another action to create a second collection with an additional column that calculates the distance between the user and the site:

    ClearCollect(Collection2,
    AddColumns(Collection2,"Distance",
    Acos(Cos(Radians(90-(Value(Latitude)))) *Cos(Radians(90-(Location.Latitude))) +Sin(Radians(90-(Value(Latitude)))) *Sin(Radians(90-(Location.Latitude))) *Cos(Radians((Value(Longitude))-(Location.Longitude)))) *6371))

    Using the equation from this website.

    "Latitude" and "Longitude" are the column headings for the site locations from Collection1 (i.e. the SharePoint List).

     

    Then I can create a drop down sorted by distance:

    Distinct(SortByColumns(Collection2,"Distance"),LocationName)

     

    Hope that helps!

     

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard