Perl interface to Google Directions API
Google has a pretty neat service for getting driving/cycling/walking directions between places, and now there’s a perl interface to it: Google::Directions (and on GitHub)
It’s Moosey and it’s juicy… I hope it helps you get from A to B with Perl a bit faster! 🙂
If anybody is top-fit with Moose::Util::TypeConstraints, I have some issues in this module which I don’t understand and would really appreciate some tips with. 🙂
And here’s some sample code:
#!/usr/bin/env perl
use strict; use warnings; use Google::Directions::Client; use Getopt::Long;
my %params; GetOptions( \%params, 'origin=s', 'destination=s', );
my $goog = Google::Directions::Client->new();
my $response = $goog->directions( %params ); my $first_leg = $response->routes->[0]->legs->[0]; printf( "That journey will take you %0.1f minutes and %0.1fkm\n", ( $first_leg->duration / 60 ), ( $first_leg->distance / 1000 ), );
# $> ./test_directions.pl --origin "Munich, Germany" --destination "Hamburg, Germany"
# That journey will take you 443.8 minutes and 778.5km
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.