Some Claris FileMaker features are easier to understand than others. Web viewers, for instance, can be a difficult concept for new users to wrap their heads around. Those who have worked with them for years take their usefulness for granted, but when you are introducing someone to Claris FileMaker it can be hard for them to understand why you would want a web browser inside your database.
When teaching classes, I remember trying to describe the usefulness of web viewers and watching students struggle to get it, then I would show them how they could be used with Google Maps. That was when the light bulb would go on. Seeing how they could feed a customer’s address into Google Maps without having to switch to a separate web browser was a perfect example of a web viewer’s potential.
Google Maps integration is still a frequently requested feature for many databases. It’s something that is easy to implement and that you can build onto to add advanced functionality. In this article, I’ll walk you through several examples of increasing complexity, and discuss which services you can access for free and which you’ll need to pay for.
What’s included with Google Maps
Google gives away a lot of things for free, but like any other business, its goal is to make money. The rule of thumb with Google Maps is that information displayed on screen is free, but information returned in a format that is easily parsable will come at a cost. For example, you can generate and display driving directions between multiple points at no charge. However, if you want to enter those same points and have Google Maps return the distance between them, formatted as JSON you’ll need to pay.
In this article, I’ll focus on free resources, and I’ll save the paid features for the next one.
To illustrate these, I’ve downloaded a list of Starbucks coffee shops and loaded them into a simple Claris FileMaker database. This file is available to download so you can try it out for yourself.
Example 1 – Basic Mapping
We’ll start with a very simple example and one that Claris FileMaker practically writes for you. If you go into Layout mode, select the web viewer tool from the toolbar, and drag out a box on your layout, you will be presented with the Web Viewer Setup dialog, and you can select Google Maps (US) from the list of pre-defined examples.
You will be presented with a list of data points you need to fill in to build the URL. Once you select the appropriate fields for Address, City, and State, hit OK, and return to Browse mode, you will see a Google Map for the address of the current record. It doesn’t get much easier than that.
I love that Claris FileMaker provides such an easy way for you to get started with Google Maps, but there are probably things you’ll want to customize to make it more useful. That’s easily done by learning a little bit about the Google Maps URL.
The Google Maps URL allows you to search, get directions, display maps, and show street view panoramas without needing to access an API.
As you read through the documentation, you may notice that the URL Claris FileMaker created for you used a different format than those shown in the examples. FileMaker added the Google Maps shortcut years ago, and the URL format has changed since then. Going forward, you should use the format specified in the current Google documentation.
It’s also more common to use ‘+’ instead of commas in the URL these days, so we should update that while we are at it.
You may also have noticed that I omitted the zip code and country when I was picking fields for the URL above. Google Maps doesn’t need those, and it’s best to leave them out so you can keep your URL as short as possible.
Taking these things into consideration, you should change the formula for calculating the web viewer URL in Example 1 from this:
"http://local.google.com/maps?" & "q=" & /*Address=*/ Starbucks::Street Address & "," & /*City=*/ Starbucks::City & "," & /*State=*/ Starbucks::State_Province
"https://www.google.com/maps/search/?api=1&query=" & /*Address=*/ Starbucks::Street Address & "+" & /*City=*/ Starbucks::City & "+" & /*State=*/ Starbucks::State_Province
Example 2 – Driving Directions
Another useful thing you can do for free with the Google Maps URL is create driving directions. Let’s say that you are at your favorite Starbucks working hard on a blog post when they run out of almond milk. Obviously, you can’t work like this and you’re going to need to go to another Starbucks to finish the post. Fortunately, your database already shows other Starbucks locations in the same zip code, so it will be easy to create a script that feeds both addresses into Google Maps and gives you driving directions.
You’ll need to construct a URL using the parameters for directions found here:
To make this easier, I’ve created a calculation field called “Map Address” that encodes the full address for me. The formula for it is:
GetAsURLEncoded ( Street Address );
GetAsURLEncoded ( City );
GetAsURLEncoded ( State_Province)
["¶" ; "+"]; ["%20"; "+" ] )
Based on what we see in Google’s documentation, the URL to display the directions between 304 South 9th Street Columbia, MO and 605 E Nifong Blvd Columbia, MO looks like this:
I created a script to build this URL and feed it into a web viewer that opens in a card window so I have more room to view it like so:
Example 3 – Driving Directions with Waypoints
As I’m sure you are aware, Google Maps isn’t limited to creating trips between points A and B. When using the Google Maps URL to get directions, you can set as many stops on your trip as you like. The number of waypoints allowed varies by the platform where the link opens, with up to three waypoints supported on mobile browsers, and a maximum of nine waypoints supported otherwise. You should also note that, as with any URL, you must keep the total length of the request to no more than 2,048 characters.
So, if you get bored and decide that you need to visit every Starbucks in a particular zip code, Google Maps can do that for you. All you need to do is specify the stops, in the order you want to visit them, as waypoints within your URL like so:
As you can see, Google Maps provides a lot of value without charging you anything at all. It’s possible that accessing Google Maps through the URL will provide everything you’ll ever need.
If you find yourself needing additional tools such as the ability to convert addresses to latitude and longitude, calculate the travel time between points, or get real-time traffic information, you can tap into those with the Google Maps API. While these tools aren’t free, they are still extremely affordable, and you only pay for what you use.
In part two of this series, I’ll show you the tools the API gives you, how to set up an account with Google, and how to generate and use an API key to access those tools.
Alan has been using FileMaker since 1993 to develop applications for companies ranging from one-man operations to Fortune 500 businesses. A skilled communicator, Alan has written blogs, magazine articles, training materials, and white papers for Claris, Inc. As an authorized FileMaker trainer and certified developer, he has helped many other developers grow their skills as well. A lifelong resident of the Midwest, he can be found in his off hours fishing and enjoying the outdoors with his wife and two children.