FileMaker Location and Location Values Functions
It really is all about location, location, location. FileMaker Go makes it possible for us to collect and share longitude and latitude coordinates with the Location and Location Values functions. They’ve been around for a while but are worth a second look these days as we find more and more uses for FileMaker Go and GPS data in the workplace.
LOCATION & LOCATION VALUES
The Location and Location Values functions allow us to record the current GPS position of our devices in latitude and longitude. This function will only work in FileMaker Go. Both operations capture the same parameters:
Accuracy – how precise we want the results to be
Timeout – how long FileMaker will try to find our location (optional)
So the function, when used in a script, will look like this:
Location ( 100; 30 )
Within 30 seconds, the application will return the latitude and longitude with an accuracy of 100 meters. It will present a value that looks something like this: +42.137092, -77.048661, +38.000000
There are three values, separated by commas: latitude, longitude, and horizontal accuracy. This data is a start, but we find the LocationValues function to be a bit easier to use. Used in a script, the Location Values would look like this:
And will return something like this:
Can you spot the similarities? And can you see why this might be easier to use? Let’s break down the results first. The values are in order:
- Altitude (in meters)
- Horizontal accuracy (+/- accuracy in meters)
- Vertical accuracy (+/- accuracy in meters)
- Age of value in minutes (0.2 would represent 0.2 minutes or 12 seconds ago)
So we get a little more information from the LocationValues function. But what is more beneficial for a FileMaker developer is how the data is formatted. It’s separated by carriage returns. The separate lines allow us to extract the values we’re looking for (usually latitude and longitude) using the GetValue function. Since we like to have our code be as self-explanatory as possible, we’d probably break it out into three different variables:
And boom! We have the latitude and longitude for our current device. We can then go on to store those values in a field or use them to compare other GPS values.
LOCATION USE CASES
What are some use cases for this particular function? There are many. We could use this to get the current coordinates and then feed those coordinates into Google Maps. Most businesses have physical addresses, but we’ve worked with clients who had to go to a job site that didn’t have an address, just coordinates.
Or we might want to Location Stamp a record to capture that a person was in a particular location at a specific time in case of an audit. For example, consider a service industry that employs cleaning personnel. They could have their employees “clock in” on FileMaker Go, and the app would capture the date, time, and location so that the employer could confirm that their staff was actually onsite.
Another example would be distributed teams that work in several different areas. For example, we had a customer who had four separate locations throughout the state. Using the Location function, they could log in, and the system would automatically detect the nearest branch and set the appropriate branch location in all of the records they created that day. Thereby eliminating the need for repetitive and manual data entry.
So let’s break that down a bit. Let’s say we have two locations for a trucking company:
Location 1: Texarkana, Texas (33.431099, -94.034476)
Location 2: Atlanta, Georgia (33.749856, -84.389732)
Our employee is on the road. He has to enter his time every day, but depending on which location is physically closest, his time will get recorded to one site or the other. Here’s how we would script that.
Note: we can go and find the formula for figuring the distance between two coordinates, but we recommend using custom functions when possible. We used this distance custom function to determine how far away the sites were.
If your users are actively using FileMaker Go, you might find the Location functions helpful in your solutions. Give them a try, and let us know what you think.
Check out more FileMaker development tips and tricks like how to move data from repeating fields and how to leverage FileMaker container fields.