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 / Geo location feature
Power Apps
Answered

Geo location feature

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

 

I'm trying to create a feature in my app that detects if a user is within a particular location. The code I have works perfectly on my laptop but not on my phone. On my phone, it shows according to my code that I am "not within an approved location", when I am. What could I be doing wrong? Thanks.

 

 

UpdateContext({varPicture: Camera1.Stream});
// Constants
// Radius of the Earth in kilometers
Set(
 EarthRadius,
 6371
);
// Conversion factor from degrees to radians
Set(
 DegreesToRadians,
 Pi() / 180
);
// Specify the radius (in kilometers)
Set(
 varRadius,
 5
);
// Load the approved locations
ClearCollect(
 colApprovedLocations,
 With(
 {_GeoLocations: GeoLocations},
 Filter(
 _GeoLocations,
 User().Email in Concat(
 ApprovedPersonnel,
 Email,
 ";"
 )
 )
 )
);
// Check if the user is within the radius of any approved location
Set(
 isWithinRadius,
 CountRows(
 Filter(
 colApprovedLocations,
 EarthRadius * 2 * Asin(Sqrt(0.5 - Cos((Location.Latitude - Latitude) * DegreesToRadians) / 2 + Cos(Latitude * DegreesToRadians) * Cos(Location.Latitude * DegreesToRadians) * (1 - Cos((Location.Longitude - Longitude) * DegreesToRadians)) / 2)) <= varRadius
 )
 ) > 0
);
// Use the isWithinRadius variable to determine if the user is in an approved location
If(
 isWithinRadius,
 Notify(
 "Welcome back! You are within an approved location.",
 NotificationType.Success
 );
 Navigate(HomeScreen),
 Notify(
 "You are not within an approved location.",
 NotificationType.Error
 )
);

 

 

Categories:
I have the same question (0)
  • Verified answer
    JonDoesFlow Profile Picture
    1,304 on at

    Hey @AdaEloka 

     

    Have you checked to make sure your power app app on your phone is allowed to gain location data? 

     

    You could also add some debugging:

    // Debugging: Display current location

    Notify("Current location: " & Text(CurrentLatitude) & ", " & Text(CurrentLongitude), NotificationType.Information);

     

    Can you test on different devices?



    ---------------------------------------------------------------------------


    If I have helped you with an answer, please accept this post as a solution and thumbs up my reply. Thanks !

    Blog - JonDoesFlow
    Twitter - JonDoesFlow
    YouTube - JonDoesFlow

  • AdaEloka Profile Picture
    on at

    Hi @Jondoesflow yes the powerapp has access to location data on my phone. The debugging also didn't show any obvious issues. However, it worked well with another device. Thanks 

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard