Software tips, techniques, and news.

By Brendan McBride  Posted on  April 5th, 2016  in  Free Downloads, FileMaker

FileMaker Google Route Optimization

FileMaker Google MapsWhether you are a technician that has multiple appointments in a day, or you are a traveling salesperson, you want to minimize your time on the road. Luckily for us, Google has an API for route optimization! Let's look at how to connect your FileMaker solution with the Google Maps Directions API to take a list of locations and order them to minimize the time spent traveling.

Creating a Free Developer Account

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.

Create Google Project

You can get away without using an API key, but you will be limited to 8 locations. Once you have created the project, you will then need to enable the Google Maps Directions 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.

Googel Directions API Credentials

Once you have created your credentials, and the API Key has been created, copy it into your solution. Now you have everything you need to make requests to the Google Directions API.

Making Requests and Parsing the Response

The request to the Google Maps Directions API can be completely handled by using the native FileMaker script step "Insert from URL".

Insert from URL [ Select ; No Dialog ; TABLE::postResult ; "https://maps.googleapis.com/maps/api/directions/js... API Key]" ; Do not automatically encode URL ]

This means that it is compatible with both Desktop and iOS clients. In order to get multiple addresses sorted in the fastest route, you will need to set the flag "optimize:true".

https://maps.googleapis.com/maps/api/directions/json?origin=Indianapolis,IN&destination=Indianapolis,IN&waypoints=optimize:true|Fishers,IN|Plainfield,IN|Nobilesville,IN&key=YOUR_API_KEY

By setting the optimize flag, you are now required to enter the location of origin and destination, along with the waypoints you wish to visit in between. Details for how to set up the url request can be found on the Google Maps Directions Documentation.

Once a successful request has been made, a JSON-encoded response will be returned. You will then be able to use a plugin, a web viewer, or any JSON parser that you prefer to pull out the data that you need. Remember, if you need your solution to be mobile compatible, you can't use a plugin unless you use Perform Script on Server. The Google Directions API returns complete directions with the response, so you can get as much or as little as you want out of it. By setting the optimize flag to true, the response will also include the order in which you should visit the provided waypoint locations.

..."summary" : "I-465 W","warnings" : [],"waypoint_order" : [ 1, 2, 3, 4, 5, 6, 0, 7 ]...

In the example above, the waypoint order is what you will need to reference to order your locations. Starting with 0, you will want to rearrange your locations to so that they go from increasing order. The first waypoint put into the request will need to be the second waypoint visited. You will need to go through each location in the same order you passed to the API. Then, set each record with the number provided. When you sort the records by the corresponding waypoint, you will have the optimized route. Now, when you map the locations in this order, you will have the best route possible.

Conclusion

Save time and money optimizing your drive. Google has yet another API that us FileMaker users can easily integrate with and use. Feel free to contact us if you need further assistance or to discuss making your routes as optimized as possible with any other route optimizing APIs.

Did you know we are an authorized reseller for FileMaker Licensing?
Contact us to discuss upgrading your FileMaker software.

Download
Download the Download FileMaker Google Route Optimization File
Please complete the form below to download your FREE FileMaker file.
FileMaker Experience *
Terms of Use *
OPT-IN: I agree that I am downloading a completely free FileMaker application file with no strings attached. This file is unlocked, and I may use it for my business or organization as I see fit. Because I am downloading a free file, I agree that I should receive occasional marketing. I understand that I can OPT-OUT of these emails at anytime.
Brendan McBride thumbnail
Brendan McBride

Brendan is a certified FileMaker and web developer and is a very friendly, hard-working, and technically-astute engineer ready to solve any problem you throw at him. Brendan went to Purdue, receiving a Bachelors in Computer Science and minored in Economics.

FileMaker 18 Certified Developer
FileMaker 17 Certified Developer
FileMaker 16 Certified Developer
FileMaker 15 Certified Developer
FileMaker 14 Certified Developer
FileMaker 13 Certified Developer
FileMaker 12 Certified Developer
FileMaker 11 Certified Developer
"We were actually able to add more features than we thought would be possible within our budget. We always experienced a ‘can do’ attitude and DB Services was incredibly patient and easy to work with."
Courtney Hartman
Art Director
"The new FileMaker custom website interface is very user-friendly and easy to follow for our clients. In addition, it is much faster than the old Instant Web Publishing (IWP) interface. Thank you and all the others who have helped us out at DB Services. I am very grateful for the excellent service you provide us. Its nice to know we can call you for help if we have an issue."
Wayne Capek
President
"We needed a solution that would simplify the administration of our responsibilities under our contract with the State of Indiana. We have seen a dramatic increase across the state in the number of potential foster and adoptive parents that have begun the preparation and training process. This increase has resulted in a significant opportunity for children available for adoption. That’s a big win for everyone! And it’s all because we can refer potential parents to the proper state contacts efficiently and quickly."
Chris Morrison
Executive Director
"Thank you for all of your expertise and valuable help. I am so grateful to have found DB Services."
Linda Findlay
Owner
"Thank you for our new database system. We transitioned from a carbon copy paper based system to a digital database. The software has saved us time and money. We used to archive all our jobs in cabinets, now we can look up a job in seconds from anywhere. The software allows us to easily email estimates to our customers in pdf format. In a year there was a return on investment just from eliminating the purchasing of our carbon forms."
Todd Cartmel
Owner
"The new system allows us to create and track jobs for customers along with inventory, something we had been doing with separate word and spreadsheet files. Because it’s now so intuitive, new staff members are able to begin using the database immediately without our usual training session and ‘cheat sheets’ for getting around within the file."
Tom Andrews
President