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
- Host: GitHub
- URL: https://github.com/faradayio/cm1-route
- Owner: faradayio
- Created: 2011-08-16T20:06:32.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2012-10-08T22:17:19.000Z (over 13 years ago)
- Last Synced: 2025-01-27T04:29:31.701Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 798 KB
- Stars: 1
- Watchers: 7
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
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!");
}
});