Based on the Google Maps JavaScript API Example: Advanced Directions with acknowledgement to Tom Anthony's tutorial Geocoding UK Postcodes with Google Map API.