Coder Social home page Coder Social logo

isabella232 / navigation.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/navigation.js

0.0 0.0 0.0 2.84 MB

Utility for monitoring a user location in relation to a route

Home Page: https://www.mapbox.com/navigation.js/tests/debug/#14/39.9229/-75.1351

License: ISC License

JavaScript 91.81% HTML 8.19%

navigation.js's Introduction

navigation.js

  • Install: npm install navigation.js --save
  • Test: npm test
  • Run debug map locally: npm start. Then head to http://localhost:9966

Example:

var navigation = require('navigation.js')({
    units: 'miles',
    maxReRouteDistance: 0.03,
    maxSnapToLocation: 0.01
});

// Where is the user along the route?
navigation.getCurrentStep(userLocation, mapboxDirectionRoute.routes[0].legs[0], 0);

API Usage

getCurrentStep

Given a user location and route, calculates closest step to user.

Parameters

  • user object point feature representing user location. Must be a valid GeoJSON object.
  • route object from Mapbox directions API. The Mapbox directions API returns an object with up to 2 routes on the route key. getCurrentStep expects of these routes, either the first or second.
  • userCurrentStep number along the route
  • userBearing number current user bearing. If provided, the user must be within a certain threshold of the steps exit bearing to successful complete a step.

Returns object Containing 3 keys: step, distance, snapToLocation. distance is the line distance to end of step, absoluteDistance is the users absolute distance to the end of the route snapToLocation is location along route which is closest to the user.

options

Configuration options

Parameters

  • object units - either miles or km. maxReRouteDistance - max distance the user can be from the route. maxSnapToLocation - max distance to snap user to route. completionDistance - distance away from end of step that is considered a completion. If this distance is shorter than the step distance, it will be changed to 10ft. warnUserTime - number of seconds ahead of maneuver to warn user about maneuver. shortCompletionDistance - if the step is shorter than the completionDistance, this distance will be used to calculate if the step has been completed. userBearingCompleteThreshold - Bearing threshold for the user to complete a step

Specification

For more information on how decisions are made in the library, see the specification.

navigation.js's People

Contributors

emilymdubois avatar tmcw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.