Route optimization is critical for any business that needs a cost effective way to deliver goods and services to their customers. If you are looking for an easy way to integrate route planning into your own software, the fastest solution is to sign up with a route optimization API (Application Programming Interface) provider like Routific, Graphhopper or Elastic Route (new). If you are interested in building your own, read on!
Part 1: Build your Own Route Optimization API with Google Maps
Part 2: Creating a Route with the Google Maps Directions API
Part 3: Optimizing a Route with the Google Maps Directions API
Part 4: Route Optimization Web Service Basics
Part 5: Let's Build a Route Optimization Web Service
Part 6: Putting it All Together - Testing your Route Optimization API
What is Route Optimization?
The term route optimization is widely used to refer to two different, but closely related things.
NOT: Driving directions - How to get from locations A to B in the fastest way possible.
HOT: Optimal route - You need to visit locations A, B, C and D in any order, in the fastest way possible - in the example below the optimal route goes A, C, D and B. This optimization is an application of the traveling salesperson problem. With Google, travel time is the primary factor which is optimized, but other factors such as distance, number of turns and many more may be taken into account when deciding which route is the most efficient.
What we are Going To Build
We are going to build a route optimization web service on top of the Google Maps Directions API . The web service essentially works like a wrapper that allows data to be sent and received in json format making it easy to humans to read and machines to parse. We'll also build some extra features like authentication (client token security) and persistence (to retrieve your data using a job id) to give you a feel for how production web services are run.
At the end of this tutorial, you are going to be able to send the API a list of
visits to be served by your
fleet (limited to a single driver and 25 stops - for now) and get back the same list, but in route optimized order. This list can easily be displayed on a map or printed out and given to your driver.