cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Default fields based on current location

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 

2 REPLIES 2
Highlighted
Super User III
Super User III

@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."

Highlighted
Frequent Visitor

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!

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (13,147)