npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

navigation.js

v1.1.1

Published

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

Downloads

45

Readme

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