pulled out most of the logic to generate the maps and directions to its own js file