Capture a User-Approved Location in Power Apps
At a Glance
- Target Audience
- Power Apps makers building mobile check-in, inspection or site-visit apps
- Problem Solved
- Capture a foreground user-approved coordinate without inventing a Location control, promising accuracy or designing covert continuous tracking.
- Use Case
- Enable the Location signal on demand, freeze a user-reviewed record, save it once with error handling, stop updates and test real devices and denial paths.
Power Apps can read a device's current latitude, longitude and altitude. That is useful for a visible check-in, site visit or asset inspection.
It is not a licence to build covert employee tracking.
The safe pattern is a foreground, user-initiated capture: explain why the location is needed, let the user trigger it, show what will be saved, collect only the necessary fields and stop requesting updates when the screen no longer needs them.
Also, there is no Location control to insert. In canvas apps, Location is a Power Fx signal.
What the Location signal actually provides
Microsoft currently documents:
Location.Latitude
Location.Longitude
Location.Altitude
Using Location without a property returns a record containing those values. The device may ask for permission when the app first uses the signal. Microsoft also warns that Location is a continuous signal and can consume battery while formulas depend on it. Enable(Location) and Disable(Location) let you bound that work. Read the Power Fx signals reference.
The documented canvas-app Location signal does not expose an accuracy property. Do not label a coordinate “GPS verified” or promise metre-level precision. Its quality depends on the device, permissions and available location sources.
Design the check-in before the formula
Answer these questions with the process owner and your privacy/security team:
- What specific task needs location?
- Is one check-in enough, or is a route truly necessary?
- Must you store exact coordinates, or would a site/geofence choice be enough?
- Who may view the record?
- How long is it needed?
- What happens when permission is denied or no reliable location is available?
- Can the user see and correct the business context before submitting?
The ICO's data-minimisation guidance says personal information must be adequate, relevant and limited to what the stated purpose needs. Its storage guidance says you must be able to justify how long it is retained. Read the ICO's data-minimisation and storage-limitation principles.
This article is implementation guidance, not a legal determination. Your organisation needs its own lawful basis, notice, access and retention decisions.
Build the data source
For a simple SharePoint list called Site visits, create:
| Column | Type | Purpose |
|---|---|---|
| Title | Single line of text | Site, job or visit reference |
| Latitude | Number | Captured latitude |
| Longitude | Number | Captured longitude |
| Altitude | Number, optional | Captured altitude |
| Captured at | Date and time | Time the user captured the signal |
| Capture note | Multiple lines, optional | Reason or exception note |
SharePoint already records Created and Created By. Do not duplicate more user information unless the process needs it.
Configure list permissions so only the intended operational roles can see precise coordinates. A Power Apps screen is not a security boundary; enforce access at the data source.
If the process has complex row-level security, relational data or a large governed app estate, Dataverse may be the better store. The location formula is the same; the data and licence design is not.
Step 1: build a transparent screen
Add:
- a short notice explaining the purpose;
- a text input for site/job reference;
- a Start location button;
- labels showing the current latitude and longitude;
- a Capture this location button;
- a preview of the captured values and time;
- a Submit check-in button;
- a Stop location button or automatic stop on leaving the screen;
- an alternative route when location is unavailable.
Do not enable location silently on app launch if only one optional screen needs it. Align the request with the user's action.
Step 2: enable the signal deliberately
Set the Start location button's OnSelect property to:
Enable(Location);
Set(varLocationStarted, true)
The first access may trigger a device permission prompt. Put plain language next to the button before that happens:
Select Start location to use your device's current position for this visit record. The app will show the coordinates before you submit them.
Do not claim the permission prompt proves consent to every later organisational use. It proves only that the platform/device allowed the app to access location at that moment.
Step 3: show the live values
Set a status label's Text property to:
If(
varLocationStarted,
"Current reading: " &
Text(Location.Latitude, "[$-en-US]0.000000") &
", " &
Text(Location.Longitude, "[$-en-US]0.000000"),
"Location is off"
)
This proves the app is receiving values. It does not prove their physical accuracy.
Microsoft's mobile-sensor tutorial says to test on a capable phone or tablet because most PCs may not have the necessary sensors. See the current mobile-sensor prerequisites and examples.
Step 4: create a frozen preview
The Location signal can change. Do not let the coordinates change invisibly between the user's review and the write.
Set the Capture this location button's OnSelect property to:
Set(
varCapturedLocation,
{
Latitude: Location.Latitude,
Longitude: Location.Longitude,
Altitude: Location.Altitude,
CapturedAt: Now()
}
)
Show the captured record in a preview label:
If(
IsBlank(varCapturedLocation),
"No location captured",
Text(varCapturedLocation.Latitude, "[$-en-US]0.000000") &
", " &
Text(varCapturedLocation.Longitude, "[$-en-US]0.000000") &
" at " &
Text(varCapturedLocation.CapturedAt, DateTimeFormat.ShortDateTime)
)
Let the user recapture before submission.
Step 5: validate and save once
Set the Submit check-in button's DisplayMode to:
If(
IsBlank(Trim(txtVisitReference.Text)) ||
IsBlank(varCapturedLocation),
DisplayMode.Disabled,
DisplayMode.Edit
)
Then use one Patch in the button's OnSelect property:
IfError(
Patch(
'Site visits',
Defaults('Site visits'),
{
Title: Trim(txtVisitReference.Text),
Latitude: varCapturedLocation.Latitude,
Longitude: varCapturedLocation.Longitude,
Altitude: varCapturedLocation.Altitude,
'Captured at': varCapturedLocation.CapturedAt,
'Capture note': Trim(txtCaptureNote.Text)
}
),
Notify(
"The check-in was not saved. Your captured location is still on screen—try again or contact support.",
NotificationType.Error
),
Notify("Check-in saved", NotificationType.Success);
Disable(Location);
Set(varLocationStarted, false);
Set(varCapturedLocation, Blank());
Reset(txtVisitReference);
Reset(txtCaptureNote)
)
IfError is important. Without it, a success message or screen reset can run even when the data write failed. See Microsoft's Power Fx error-handling guidance.
The formula uses control names from this example. Replace them with the names in your app and match your list's exact column types.
Step 6: stop location updates
Set the screen's OnHidden property to:
Disable(Location);
Set(varLocationStarted, false)
Use the same formula on a visible Stop location button.
Microsoft says Location automatically turns off when no formula on the current screen depends on it. Explicit enable/disable still makes the intended boundary clearer and is easier to test.
Handle the real failure modes
Permission denied
Tell the user why location is needed, how to change device/app permissions and what alternative process exists. Do not trap them on a blank screen.
No usable sensor or browser result
Test in Power Apps mobile on the target devices. A desktop authoring preview is not proof. Offer a site selector, manual address or “unable to capture” exception when the business process permits it.
Implausible coordinate
Latitude must be between -90 and 90; longitude between -180 and 180. Those range checks catch corrupted data, not inaccurate positioning. If the process requires proof of being at a site, compare against an agreed geofence and still keep an exception path.
Duplicate submission
Disable the submit button while the write is in progress, retain the returned record ID and use a visit/job key when the process must be idempotent. A double tap should not create two visits.
Offline use
Do not claim offline reliability without designing and testing local queues, conflict handling and later synchronisation. Precise location plus offline storage creates an additional data-protection and device-loss risk.
Test matrix
Test the published app—not only Studio—with:
- an iOS device;
- an Android device;
- every supported browser/device combination;
- permission granted;
- permission denied;
- location services switched off;
- poor indoor reception;
- a slow connection during Patch;
- a user with no list permission;
- navigation away before submission;
- two rapid taps on Submit.
For each test, confirm what the user sees, what is written and whether location remains active after leaving the screen.
What this solution does not do
It does not provide background tracking, route history, guaranteed GPS accuracy, anti-spoofing or legal approval for workforce monitoring.
If the requirement is continuous fleet or worker tracking, use a platform designed and governed for that job. A canvas app's foreground Location signal is not a covert telemetry service.
Frequently asked questions
Is Location a control in Power Apps?
No. It is a Power Fx signal with documented Latitude, Longitude and Altitude properties. Reference it in formulas and enable or disable it when needed.
Can a canvas app track someone in the background?
This guide does not implement or promise background tracking. It captures a user-reviewed reading while the app is active. Use a purpose-built, governed platform for continuous tracking.
Does Location.Latitude prove an exact GPS position?
No. The documented canvas-app signal exposes coordinates but not an accuracy value. Device hardware, permissions and available location sources affect the reading.
What should happen if the user denies location permission?
Explain the purpose and provide a clear recovery or alternative process. Do not save zero coordinates or claim a successful check-in.
Should location data be kept forever?
No. Define and justify a retention period for the operational purpose, restrict access, review it and delete or anonymise data that is no longer needed.
For more practical Power Apps patterns that include permissions, errors and production testing, join the Power Apps Builders Space.
