Skip to content

dbaq/angularjs-google-directions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AngularJS-Google-Directions

An angular.js wrapper around the Google Directions API (heavily inspired by AngularJS-Google-Places)

Bower

This module is available as bower package, install it with this command:

bower install angularjs-google-directions

or

bower install git://github.com/dbaq/angularjs-google-directions.git

Demo

See this plunker

Usage

  • Include the Google Maps JS library in your app
  • Add dbaq.google.directions as a dependency
  • Inject googleDirections as a dependency to your controller or other service
  • Invoke the getDirections method and pass in an origin and a destination

Example

var myApp = angular.module('myApp', ['dbaq.google.directions']);

myApp.controller('mainCtrl', function($scope, googleDirections) {
  var args = {
    origin: '37.7738571,-122.4102823',
    destination: '37.7891231,-122.4173545',
    travelMode: 'bicycling'
  }

  $scope.directions = googleDirections.getDirections(args).then(function(directions) {
    return directions;
  });
});

Further Customizations

You can override any default option below by passing that property to the getDirections method

var defaults = {
    unitSystem: null,
    durationInTraffic: false,
    waypoints: [],
    optimizeWaypoints: false,
    provideRouteAlternatives: false,
    avoidHighways: false,
    avoidTolls: false,
    travelMode: 'driving', // bicycling, transit, walking
    unitSystem: 'metric', // imperial
};

Donations

If your app is successful or if you are working for a company, please consider donating some beer money 🍺:

paypal

Keep in mind that I am maintaining this repository on my free time so thank you for considering a donation. 👍

Testing

TODO

License

MIT

About

An angular.js wrapper around the Google Directions API

Resources

License

Stars

Watchers

Forks

Packages

No packages published