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.
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
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
There are two variations of the $address variable in the script. Above is the ‘no company name’ version.
Company Names included in the address
Above is a screen shot of the script running with the $address variable set to include the Company name.
- 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.
- 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
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
Modify the three steps to customize the script to your solution:
- The Go to Layout step — set it to a list view of your addresses.
- 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.
- 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.
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.
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.
I hope you find this script and technique useful in your solutions.
- Creating Google Cluster Maps from FileMaker
- Cluster Maps and Instant Web Publishing
- Cluster Maps Continued: Perimeter Search in FileMaker Pro 12
- Cluster Maps Update – Running URL Scripts in a Web Viewer
- Simple Static Map Overlays in FileMaker Pro
- FileMaker and Image Maps in a Web Viewer
- Paperless Archaeology – Bar Charts in Google Earth from FileMaker