An open API service indexing awesome lists of open source software.

https://github.com/faradayio/cm1-route

Routing/footprint engine extracted from HootRoot
https://github.com/faradayio/cm1-route

Last synced: 11 months ago
JSON representation

Routing/footprint engine extracted from HootRoot

Awesome Lists containing this project

README

          

# Installation

Copy cm1-route.js into your JavaScript assets directory.

In your HTML:

# Usage

`Cm1Route` provides four functions for calculating routes (one for each mode). Each function takes a single parameter that is an object containing options, `success`, `failure`, and `loading`. Each option is a callback (or anonymous function) that is run when certain events occur. When routing is successfully finished, the callback is given an instance of a `Route` which provides a `totalDistance` property and a `draw` function that will draw the route on a map contained within the specified element. While the calculation is being performed, the optional loading callback is run that will allow you to display a loading status message. The failure callback is called when there is a problem obtaining a route. A parameter containing an error message is passed in.


var route = new Cm1Route('Chicago, IL', 'New York, NY');
route.routeAutomobile({
success: function(route) {
alert('Total distance: ' + route.totalDistance);
route.draw('#mapelement');
},
failure: function(error) {
alert('Failed because ' + error);
},
loading: function() {
alert("I'm working on it!");
}
});