Mapping Directions from FileMaker Pro with Google Maps


Ever wish you could generate a Google Map pin map from your FileMaker database of things like:

  • a sales route
  • a customer list
  • a distribution list?

Not a complex Cluster Map of large numbers of addresses, as I have detailed in another blog post, but a simple reusable script to display small groups of locations as pins on a map. Well, so did I and I went looking for a method. I knew I had seen something like this before, but due to the vagaries of the Internet, and possibly poor search skills on my part, I couldn’t find exactly what I wanted. So I did what I usually do, I decided to build my own demo file and document it, so the next time I went looking for this technique, I would know where to look.

My goal was to make a simple modular and portable script that developers (myself included) could just paste into their solution and modify a few steps and have it up and running quickly. This demo is my attempt at this.

Credit goes to ‘Sorbsbuster‘, a prolific poster on forums.filemaker.com. His response to a query called “Multiple Pins in a Web Viewer” is the basis of this technique.

Demo File

media_1391313198146.png

Download Demo File here.

The demo file is a simple table with a batch of addresses from across Canada and the USA. This list is a very old list of companies in the computer industry that I found rummaging around on my hard drive. Some of the addresses are current, but some are not, and you will see how Google Maps handles this issue below.

Open the file, do a search on a small subset, keeping your Found Set at or below 25 addresses, and click the ‘Display Map’ button.

You can import your own data, or simply use the demo data to test the script.

Directions Pins in Google Maps

media_1391314363534.png

Note that Google will find errors in your data and display them like this: “Did you mean a different: <<Your Address Here>>?” The maps are only as good as your data, so some cleaning up may be required. Google Maps gets especially picky about Company names.

No company name specified

media_1391315070740.png

There are two variations of the $address variable in the script. Above is the ‘no company name’ version.

Company Names included in the address

media_1391315115750.png

Above is a screen shot of the script running with the $address variable set to include the Company name.

  1. Note that there are more errors, because my list is so old and many of these companies no longer exist. Google Maps highlights the errors more because I have attached an incorrect company name to the address. When the companies do still exist, the pins on the map can be clicked on to reveal more information about the company.
  2. Note that a URL for the company has been located by Google and displays in the pin popup. This information did not come from the URL string. Google matched the address and company name with existing information. There is also a Street View preview in the popup box.

The script to copy

media_1391313229592.png

Here are the steps to import this capability into your own database.

Copy the script “Google Map Directions for a Small Batch of Addresses” into your solution.

Modify Three Steps

media_1391313246582.png

Modify the three steps to customize the script to your solution:

  1. The Go to Layout step — set it to a list view of your addresses.
  2. The sort order — this the order that the addresses will be sent to Google via a URL, so order them how you would like the directions to go. Try postal or zip code.
  3. The address fields. — there are two variants of this step. One of the steps is commented out and includes a field for a label, such as the Company name.

The script is pretty straightforward, it loops through the address records and builds a calculated URL which is passed to the default web browser. There are two error capture routines: 1) no more than 25 records and 2) no more than 2,048 characters can be in the URL. These are Google limits. If you need a bigger batch of addresses mapped, I encourage you to look at the Cluster Maps demo file linked above.

Debugging Address Problems

When your addresses don’t seem to be mapping correctly in Google Maps, here is a method to debug the issue. First turn off the “Perform without dialog” in the Open URL step of the script.

Turn Off Perform without dialog

 

 

 

 

 

 

Run the script and when it stops at the Open URL dialog box, select the URL and copy it to your clipboard — Command (Mac) or Control (Windows) C.

Specify-URL-Dialog

Next, paste the URL into a text editor, such as TextMate (Mac) or Notepad (Windows). If the text editor you  have chosen displays URLs as clickable links, you should be able to see where the URL breaks and then go about adjusting either the text in the address, or adding more error correction to the script to catch this specific type of error. In the screenshot below, there is an extra space in the URL. If  this is sent to Google Maps, the results will not display correctly.Texmate-view

Summing Up

One of the benefits of using a simple technique like this is that, in addition to no messy Javascript to deal with, you are unlikely to exceed any of Googles Directions API limits (2,500 direction requests per 24 hour period) or require a Google Map API Key. More detail on the Google Directions API can be found hereThis script should run fine in either .fp7 or .fmp12 format.

I hope you find this script and technique useful in your solutions.

Related Articles

Trackbacks/Pingbacks

  1. Mapping Directions from FileMaker Pro with Google Maps | Filemaker Info - February 3, 2014

    […] See on hbase.net […]

  2. Mapping Directions from FileMaker Pro with Google Maps - EASY APPS! - February 4, 2014

    […] Read the rest of the article here. […]

  3. Multi-pin Google Maps in FileMaker Pro - FileMaker Pro Gurus - February 5, 2014

    […] YOU EVER WISH you could make a multi-pin map in FileMaker?  Douglas Alder did, and he made it […]