Google Maps in FileMaker

By Cath Kirkland, 18 July 2023

Google Travel Hero

Introduction

Wow, there are endless possibilities with Google Maps! But where do we even begin? In this demo, we'll show you just how effortless it is to find and display the travel time between any two locations using Google Maps.

Imagine this: you're using FileMaker Go, and in just a few clicks, you can instantly know your exact location and estimate the travel time to your next destination or important meeting.

Now, here's the slightly tricky part - getting your hands on a Google API key. If you don't have one don't worry we will take you through the steps of getting one. Let's get started and discover the benefits of this integration…

 

Example File

Are you ready to get started? Let's dive in!

Download the Example File

 

Setting-up A Google API Key

If you already have one of these, then you can skip this whole section! If not then read on…

You will need to set up a Google API key. This involves creating a cloud.googe.com account and using a credit card. 

In most cases usage rates fall in the free zone, mostly because Google currently gives you a $200 recurring monthly credit. Some of their rates are here:

https://developers.google.com/maps/documentation/directions/usage-and-billing

Finding the right place to set up a Google API key can be a pain and you have to enable the services you want to use. But don’t worry once you have the API key it's smooth sailing from there!

1. Go to the Google Cloud Console https://console.cloud.google.com/projectselector2

2. Select a project, or create a new one. 

3. Go to the APIs & Services > Credentials page. 

4. Create Credential, select API key and choose the following options:

  • Choose Application Restriction if any.
  • Click Restrict key.
  • From the Selected APIs dropdown. Enable the following: 
    • Directions API, Geocoding API, Geolocation API, Maps JavaScript API, Places API (you wont be able to select some of these until there is billing information added.

 To finalise your changes, click Save.

google travel 7

 

The Google APIs

When you set up your Google API key you do get the option to enable the services you want to use. If you are going to be using Google Maps integration for a multiple integrations in your FileMaker database we suggest setting up multiple keys.  In the event that you do start to get charged you then have a little more visibility as to where those charges are driven from as the charges get linked to the API key.  We didn't do this here but you know… you live and learn!

For more information on the services we use look here:

 

Directions API

Get directions between locations, for driving, cycling, transit, and walking:

https://developers.google.com/maps/documentation/directions

 

Geocoding API

Convert addresses or Place IDs to latitude/longitude coordinates and vice-versa:

https://developers.google.com/maps/documentation/geocoding

 

Geolocation API 

Uses cell phone towers to establish a gps location:

https://developers.google.com/maps/documentation/geolocation/overview

 

Maps JavaScript API 

Build dynamic, interactive, deeply customized maps, location, and geospatial experiences for your web app:

https://developers.google.com/maps/documentation/javascript

 

Places API 

Get location data for over 200 million places, and add place details, search, and autocomplete to your apps:

https://developers.google.com/maps/documentation/places/web-service

 

 

Getting Started

Download the demo file and enter your own API key.

The main block of code contains a couple of substitutes. We have inserted tags into the code to make it simple to substitute with your own data.  The minimum data you will need is the 

  • Start coordinates (longitude + latitude)
  • Destination coordinates.  
  • API key
  • Mode is optional and will default to driving if not specified

 google travel 1

Returning The Travel Time

The code also contains the name of a script which will get called when the map loads in a webviewer. The time is passed as a script parameter in seconds.

The script name in the example file is called:

[MAP: SetTravelTime] 

You can customise this to call your script by changing the name directly in the map code.

 

For Example...

In our example we demonstrate the travel time in New York City across central park. Changing the mode of transport re-calculates the optimal route and estimated travel time for the 4 modes Google allows you to select.  

Note: For each mode to work there does have to be sufficient google data to revaluate the route. For instance biking mode does not work in Christchurch, NZ due to a lack of google data.

 google travel 2

40 minutes to walk from The Metropolitan Museum of Art to Times Square. 

google travel 3

29 minutes by public transport

google travel 4 

13 mins to drive

google travel 5

But the winner was 12 minutes to bike between the two points.  

Compare some other locations in our demo file or add your own. 

 

 

What's Your Current Location?

Using FileMaker Go this is simple to work out as we can use the FileMaker Function 

LocationValues(200;10)

Where 200 represents the accepted accuracy in meters and 10 represents the maximum acceptable time in seconds since the location was last looked up. This function returns a delimited list of location information where:

1st value = latitude

2nd value = longitude 

On non-iOS devices you could use Geolocation API which uses cell phone towers to establish a gps location.

 

 

How To GPS Your Addresses

In reality to use this integration your contact addresses have to be GPS’ed.  There are two main ways to do this.

  • At the point of data entry
  • Retrospectively.

That choice will be up to you. There is code in the example file which will retrospectively loop through a bunch of addresses and use the Google Places API to code them.

Alternatively you can use a widget like Google address validator in a web viewer to enter and code addresses as you go.

google travel 6

Hope you found this interesting. Download our file and have a play.

 

 

Example File

As mentioned, we always include an example file with our articles to help you learn and explore. We spend a lot of time on these so please do check it out.

Click here to download the example file

 

 

Something to say? Post a comment...

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments

Categories(show all)

Subscribe

No Tags