@mapquest/directions

0.3.3 • Public • Published

MQ-Directions

This is a JavaScript interface to the MapQuest Directions API. The route() method returns a Promise fulfilled with a GeoJSON FeatureCollection of available routes divided in traffic segments and maneuver points. It's up to you to style the results for map display with a custom style function based on the GeoJSON feature properties. The getShape() method returns a detailed route shape suitable for all zoom levels.

Example

const Directions = require('@mapquest/directions');
const directions = new Directions({key:'your-key'});

directions.route({
  locations: [
    'chicago, il',
    'lansing, mi'
  ],
  maxRoutes: 3,
  timeOverage: 99
})
.then(function(results){
    console.log('results is a GeoJSON of the available routes and maneuver points', results);

    const firstRouteId = results.properties.routeSessionIds[0];  //access routeSessionIds here
    return directions.getShape(firstRouteId)   //get the detailed route shape
})
.then(draw)

Readme

Keywords

none

Package Sidebar

Install

npm i @mapquest/directions

Weekly Downloads

5

Version

0.3.3

License

MIT

Last publish

Collaborators

  • ignigena