Map (Mapquest, Google, etc.) Directions API to PDF

301 views Asked by At

We have a delivery/dispatch system built on MS Access, which prints PDFs of delivery documents.

I would like to modernize this by offering drivers the ability to have delivery directions available in paper form with the rest of their paperwork.

  • I've looked at or tried test code with BatchGEO, Google Maps API v3, Mapquest API.

  • I've tried each of the above with TCPDF, DomPDF, wkhtmltopdf and jsPDF.

  • I've also looked at PhantomJS, Casper and others.

I'm open to free or license-based services.

Looking for a way I can send start / end addresses, get back a map w/directions, be able to add some basic info (job #, contact phone number, etc.) and turn that entire result into a PDF.

Running on Ubuntu (have access to root) but have access to windoz boxen.

If anyone has any experience in attempting something similar, looking for guidance.

Realize some services do not allow. I am open to paying for this functionality.

1

There are 1 answers

0
Grant P On

What you are talking about sounds very possible using a combination of Google Maps API services and jsPDF. Did you run into some issue that made it impossible?

Based on what it sounds like you are looking to do, you can use Google's geocoding capabilities to determine the LatLng endpoints of the desired route and then make a call to their directions service to find possible routes. This call returns an array of actual step-wise human readable directions that you may format however you would like as well as a character string which can be decoded to give you an array of Polyline points which can be drawn on the map in order to give a visual representation of the route.

Now once you have all the data, it just becomes a matter of how you would like to display in on the PDF. As far as the Google Map is concerned, it could be a little trickier but it appears a solution to getting a snapshot of the drawn on map was discovered here. As for the text, jsPDF has an HTML renderer that, while still in its early stages, should not have any issue simply displaying directions in a list format.