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
@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."
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!
Check out new user group experience and if you are a leader please create your group
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
256 | |
255 | |
81 | |
41 | |
30 |
User | Count |
---|---|
321 | |
263 | |
122 | |
64 | |
49 |