Imagine a sales rep visiting a customer in an adjacent state. Since the rep is unfamiliar with the area, it would be great to have a list of nearby customers they could visit afterwards. One of the best ways to accomplish this is to perform a radius search on the customers within your FileMaker solution, evaluating the distance between the rep and each customer's address. Let's take a look at how to build one of these yourself using Google Maps API, some custom functions, and a couple calcs.
One of the most reliable APIs used to look up geocoordinates of an address is the Google Maps API.
This straightforward API call is an HTTP GET composed of a URL with three components – the base url, an URL encoded address, and an API key.
Getting your API key is free and easy, and the first step is to create a project in the Google Developers Console if you don't already have one.
Once you have created the project, you will then need to enable the Google Geolocations API and then set up the credentials for the API. This will take you to a setup process where the API will be managed. We will be using HTTP requests, so you will want to mark that the API will be accessed via a web browser client.
Once you have created your credentials, and the API Key has been created, copy it into your solution. Next we need to enable billing for our project.
In the console, click the three horizontal bars to bring up the menu. We'll navigate to the "Billing" section.
If you haven't already, enable billing for this project. You can add a billing account or link an existing billing account through this screen. If you add a new billing account, navigate back to this screen and link the account you just created. This will enable billing for the current project.
Keep in mind that certain APIs have different billing plans. Most Google APIs allow for free usage up to a certain number of calls per month. The Geolocation API currently has a $5 per 1,000 requests price tag, with $200 free credit every month. This means your first 40,000 requests each month with this API are free, with everything over that at the $5 price tag.
You can find more pricing information on the API page in Google's API Library.
Once we make the call using the Insert from URL script step, Google returns our results in an XML format. Using a custom function we can parse out the latitude and the longitude of the address we submitted and store that information inside FileMaker.
Watch on Youtube FileMaker Radius Search
Inside FileMaker, we perform the radius search by calculating the distance between the reference address and each address. The custom function used takes the latitudes and longitudes of the two pertinent addresses and returns the distance between them as miles. Once we have the distance between the two points, the actions taken can be whatever a user wants. Beyond radius searches, this process can be applied to many different scenarios, such as which employee should make a delivery based on their current location.
A radius search helps determine the relevant locations for any radius from a certain point of relevance. It is an effective tool and can extract important data that can add value and efficiency to your FileMaker solution.
Did you know we are an authorized reseller for FileMaker Licensing?
Contact us to discuss upgrading your FileMaker software.
Nate is an amicable, smart, and conscientious FileMaker developer focused on producing high quality results for clients. He is a hard worker, always seeking ways to create efficiencies through creative solutions in his FileMaker consulting work.